This page contains reference documentation for Cohere. See the docs for conceptual guides, tutorials, and examples on using Cohere modules.
Implements the Embeddings interface with Cohere's text representation language
models.
Find out more about us at https://cohere.com and https://huggingface.co/CohereForAI
This implementation uses
Base class for Cohere models.
Implements the BaseChatModel (and BaseLanguageModel) interface with Cohere's
large language models.
Find out more about us at https://cohere.com and https://huggingface.co/CohereForAI
This imple
Document compressor that uses Cohere Rerank API.
Parses a message into agent actions/finish.
Cohere has fine-grained citations that specify the exact part of text.
.. deprecated:: 0.6.0
Only used by the deprecated create_cohere_react_agent.
More info at https://docs.cohere.com/docs/
Cohere large language models.
.. deprecated:: 0.6.0
Use :class:~langchain_cohere.ChatCohere instead.
To use, you should have the cohere python package installed, and the
environment variable
Cohere Chat API with RAG.
.. deprecated:: 0.6.0
Use a standard retriever with :class:~langchain_cohere.ChatCohere
tool calling instead.
Cut off the text as soon as any stop words occur.
Use tenacity to retry the completion call.
Use tenacity to retry the completion call.
Get the role of the message.
Get the role of the message (V2). Args: message: The message. Returns: The role of the message. Raises: ValueError: If the message is of an unknown type.
Get the request for the Cohere chat API (V2). Args: messages: The messages. **kwargs: The keyword arguments. Returns: The request for the Cohere chat API.
Renders the structured preamble part of the prompt content.
Renders a tool into prompt content. Either a BaseTool instance, or, a JSON
schema must be provided.
Renders the 'output' part of an Agent's intermediate step into prompt content.
Converts observations into a 'document' dict
Renders an agent's intermediate steps into prompt content.
The returned function produces a BasePromptTemplate suitable for multi-hop.
directly_answer is a special tool that's always presented to the model as an
available tool. The model only ever invokes this whilst answering and no
AgentAction is produced, so it only needs to b
Renders the role of a message into prompt content.
Renders one or more BaseMessage implementations into prompt content.
Parses model-generated jsonified actions.
Expects input of the form
"{tool_use_prefix}: ```json
[{list of jsonified objects}]```"
outputs parsed list of jsonified objects.
Parses string into key-value pairs, according to patterns supplied in prefixes.
Also strips.
If inputs are:
completion = "
o: sam
bye then: paul.",
prefixes =
Parse action selections from model output.
Parses a grounded_generation (from parse_actions) and documents (from
convert_to_documents) into a (generation, CohereCitation list) tuple.
Get the request for the Cohere V1 chat API.
.. deprecated:: 0.6.0 V1 API request builder. Will be removed in 1.0.0.
Create an agent that enables multiple tools to be used in sequence.
.. deprecated:: 0.6.0
Use langgraph.prebuilt.create_react_agent with
:class:~langchain_cohere.ChatCohere instead.