langchain icon indicating copy to clipboard operation
langchain copied to clipboard

DOC: Update documentation for ChatCohere class to include `response_format` parameter

Open ryanchase-cohere opened this issue 1 year ago • 3 comments

URL

https://python.langchain.com/v0.2/api_reference/cohere/chat_models/langchain_cohere.chat_models.ChatCohere.html#langchain_cohere.chat_models.ChatCohere.model

Checklist

  • [X] I added a very descriptive title to this issue.
  • [X] I included a link to the documentation page I am referring to (if applicable).

Issue with current documentation:

The documentation for the ChatCohere class is missing the response_format parameter.

The response_format parameter appears to be a valid parameter when using the ChatCohere class. Example usage:

!pip install langchain_cohere
from langchain_cohere.chat_models import ChatCohere

llm = ChatCohere(cohere_api_key=COHERE_API_KEY, model="command-r-plus")
res = llm.invoke("John is five years old", response_format={
            "type": "json_object",
            "schema": {
                "title": "Person",
                "description": "Identifies the age and name of a person",
                "type": "object",
                "properties": {
                    "name": { "type": "string", "description": "Name of the person" },
                    "age": { "type": "number", "description": "Age of the person" },
                },
                "required": [
                    "name",
                    "age",
                ],
            }
        }
)

Idea or request for content:

No response

ryanchase-cohere avatar Sep 16 '24 21:09 ryanchase-cohere

langchain is just a wrapper in this case. response_format is passed in via kwargs and then propagated to the appropriate calling function, in this case BaseCohere.chat - this has dozens of other kwargs (https://github.com/cohere-ai/cohere-python/blob/main/src/cohere/base_client.py#L706). So this is documented in the cohere docs, e.g. https://docs.cohere.com/v1/docs/structured-outputs-json.

tibor-reiss avatar Sep 22 '24 11:09 tibor-reiss

what else is required so that Json mode is supported by the ChatCohere wrapper such that it would be reflected in this table https://python.langchain.com/v0.2/docs/integrations/chat/#featured-providers ?

ryanchase-cohere avatar Sep 24 '24 07:09 ryanchase-cohere

Hi, @ryanchase-cohere. I'm Dosu, and I'm helping the LangChain team manage their backlog. I'm marking this issue as stale.

Issue Summary

  • The issue highlights missing documentation for the response_format parameter in the ChatCohere class.
  • @tibor-reiss mentioned that response_format is handled via kwargs and is documented in the Cohere documentation.
  • You inquired about supporting JSON mode in the ChatCohere wrapper and its reflection in the LangChain documentation.

Next Steps

  • Please confirm if this issue is still relevant to the latest version of the LangChain repository. If so, feel free to comment to keep the discussion open.
  • If there is no further activity, this issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

dosubot[bot] avatar Dec 24 '24 16:12 dosubot[bot]