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

make chat completion json_response any #643

Open
yang-wei opened this issue Jan 25, 2024 · 1 comment
Open

make chat completion json_response any #643

yang-wei opened this issue Jan 25, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@yang-wei
Copy link

Is your feature request related to a problem? Please describe.

Many OpenAI alternatives (such as anyscale) currently support response_format.schema in ChatCompletion request. The syntax looks like

    response_format={
        "type": "json_object", 
        "schema": Result.schema_json()
    },

under the hood, the library that supports this validates the response and re-prompt the LLM if it doesn't follow the schema response. I understand that this library only implements what OpenAI support that's why my request is to use any for response_format type rather than ChatCompletionResponseFormat

Describe the solution you'd like
use any for ResponseFormat type instead of ChatCompletionResponseFormat which follows openAI spec (which is object)

https://github.com/sashabaranov/go-openai/blob/eff8dc1118ea82a1b50ee316608e24d83df74d6b/chat.go#L196C20-L196C48

Additional context
Happy to send a PR if this is something @sashabaranov think it makes sense

@yang-wei yang-wei added the enhancement New feature or request label Jan 25, 2024
@yang-wei yang-wei changed the title make chat completion json_response any any make chat completion json_response any Jan 25, 2024
@comzine
Copy link

comzine commented Apr 21, 2024

This is not needed due to the new JSON mode:
https://platform.openai.com/docs/guides/text-generation/json-mode
But this JSON mode should be supported here 😊

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

No branches or pull requests

2 participants