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 implementation uses the Chat API - see https://docs.cohere.com/reference/chat
To use this you'll need to a Cohere API key - either pass it to cohere_api_key
parameter or set the COHERE_API_KEY environment variable.
API keys are available on https://cohere.com - it's free to sign up and trial API keys work with this implementation.
Converts observations into a 'document' dict
Get the role of the message.
Get the request for the Cohere chat API.
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.