Tools on LangChain
Cohere supports various integrations with LangChain, a large language model (LLM) framework which allows you to quickly create applications based on Cohere’s models. This doc will guide you through how to leverage Cohere tools with LangChain.
Prerequisites
Running Cohere tools with LangChain doesn’t require many prerequisites, consult the top-level document for more information.
Multi-Step Tool Use
Multi-step is enabled by default. Here’s an example of using it to put together a simple agent:
Single-Step Tool Use
In order to utilize single-step mode, you have to set force_single_step=False
. Here’s an example of using it to answer a few questions:
SQL Agent
LangChain’s SQL Agent abstraction provides a flexible way of interacting with SQL Databases. This can be accessed via the create_sql_agent
constructor.
CSV Agent
LangChain’s CSV Agent abstraction enables building agents that can interact with CSV files. This can be accessed via the create_csv_agent
constructor.
Streaming for Tool Calling
When tools are called in a streaming context, message chunks will be populated with tool call chunk objects in a list via the .tool_call_chunks
attribute.
LangGraph Agents
LangGraph is a stateful, orchestration framework that brings added control to agent workflows.
To use LangGraph with Cohere, you need to install the LangGraph package. To install it, run pip install langgraph
.
Basic Chatbot
This simple chatbot example will illustrate the core concepts of building with LangGraph.
Enhancing the Chatbot with Tools
To handle queries our chatbot can’t answer “from memory”, we’ll integrate a web search tool. Our bot can use this tool to find relevant information and provide better responses.