Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date for adding response_format from cohere api #684

Open
PanicButtonPressed opened this issue Jul 29, 2024 · 2 comments
Open

Date for adding response_format from cohere api #684

PanicButtonPressed opened this issue Jul 29, 2024 · 2 comments

Comments

@PanicButtonPressed
Copy link

Hello,

noticed that the parameter response_format for the cohere api (release 5.6.1 of cohere python sdk) is not supported yet. Is there a known date yet when it will be supported?

@adizohar
Copy link
Member

Hi, Can you please share more info, example code ?

@PanicButtonPressed
Copy link
Author

Sure, according to https://docs.cohere.com/changelog/force-json-object-response-format a parameter response_format can be set in the chat api to generate outputs as JSON objects. The parameter is still experimental.

Example from their docs:

import cohere
co = cohere.Client(api_key="<YOUR API KEY>")

response = co.chat(
  model="command-r", #or command-r-plus
  message="Generate a JSON that represents a person, with name and age",
  response_format={
        "type": "json_object",
        "schema": {
            "type": "object",
            "required": ["name", "age"],
            "properties": {
                "name": { "type": "string" },
                "age": { "type": "integer" }
            }
        }
    }
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants