langchain-cohere: 0.2.4#

chains#

Functions

chains.summarize.summarize_chain.create_summarize_prompt([...])

Create prompt for this agent. :param system_message: Message to use as the system message that will be the first in the prompt. :param extra_prompt_messages: Prompt messages that will be placed between the system message and the new human input.

chains.summarize.summarize_chain.load_summarize_chain(llm)

chat_models#

Classes

chat_models.ChatCohere

Implements the BaseChatModel (and BaseLanguageModel) interface with Cohere's large language models.

Functions

chat_models.get_cohere_chat_request(messages, *)

Get the request for the Cohere chat API.

chat_models.get_role(message)

Get the role of the message.

common#

Classes

common.CohereCitation(start, end, text, ...)

Cohere has fine-grained citations that specify the exact part of text.

csv_agent#

Functions

csv_agent.agent.count_words_in_file(file_path)

csv_agent.agent.create_csv_agent(llm, path)

Create csv agent with the specified language model.

csv_agent.agent.create_prompt([...])

Create prompt for this agent.

csv_agent.tools.get_file_peek_tool()

csv_agent.tools.get_file_read_tool()

csv_agent.tools.get_python_tool()

Returns a tool that will execute python code and return the output.

embeddings#

Classes

embeddings.CohereEmbeddings

Implements the Embeddings interface with Cohere's text representation language models.

llms#

Classes

llms.BaseCohere

Base class for Cohere models.

llms.Cohere

Cohere large language models.

Functions

llms.acompletion_with_retry(llm, **kwargs)

Use tenacity to retry the completion call.

llms.completion_with_retry(llm, **kwargs)

Use tenacity to retry the completion call.

llms.enforce_stop_tokens(text, stop)

Cut off the text as soon as any stop words occur.

rag_retrievers#

Classes

rag_retrievers.CohereRagRetriever

Cohere Chat API with RAG.

react_multi_hop#

Classes

react_multi_hop.parsing.CohereToolsReactAgentOutputParser

Parses a message into agent actions/finish.

Functions

react_multi_hop.agent.create_cohere_react_agent(...)

Create an agent that enables multiple tools to be used in sequence to complete a task.

react_multi_hop.parsing.parse_actions(generation)

Parse action selections from model output.

react_multi_hop.parsing.parse_answer_with_prefixes(...)

parses string into key-value pairs,

react_multi_hop.parsing.parse_citations(...)

Parses a grounded_generation (from parse_actions) and documents (from convert_to_documents) into a (generation, CohereCitation list) tuple.

react_multi_hop.parsing.parse_jsonified_tool_use_generation(...)

Parses model-generated jsonified actions.

react_multi_hop.prompt.convert_to_documents(...)

Converts observations into a 'document' dict

react_multi_hop.prompt.create_directly_answer_tool()

directly_answer is a special tool that's always presented to the model as an available tool.

react_multi_hop.prompt.multi_hop_prompt(...)

The returned function produces a BasePromptTemplate suitable for multi-hop.

react_multi_hop.prompt.render_intermediate_steps(...)

Renders an agent's intermediate steps into prompt content.

react_multi_hop.prompt.render_messages(messages)

Renders one or more BaseMessage implementations into prompt content.

react_multi_hop.prompt.render_observations(...)

Renders the 'output' part of an Agent's intermediate step into prompt content.

react_multi_hop.prompt.render_role(message)

Renders the role of a message into prompt content.

react_multi_hop.prompt.render_structured_preamble([...])

Renders the structured preamble part of the prompt content.

react_multi_hop.prompt.render_tool([tool, ...])

Renders a tool into prompt content. Either a BaseTool instance, or, a JSON

rerank#

Classes

rerank.CohereRerank

Document compressor that uses Cohere Rerank API.

sql_agent#

Functions

sql_agent.agent.create_sql_agent(llm[, ...])

Construct a SQL agent from an LLM and toolkit or database.