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

Improve Structured Outputs Support: Add refusal field to Chat Completion Object #249

Open
nezhyborets opened this issue Jan 28, 2025 · 0 comments

Comments

@nezhyborets
Copy link
Collaborator

nezhyborets commented Jan 28, 2025

Is your feature request related to a problem? Please describe.
Structured Outputs have been implemented thanks to @andgordio. With Structured Outputs they've added additional field for when model is unable to generate response in a specified format: refusal, see Refusals in Structured Outputs Guide. For more info.

The field appears in both streamable and regular chat completion objects:

  1. Chat Completion Object - choices.message.refusal API reference
  2. Chat Completion Chunk Object - choices.delta.refusal API Reference

Describe the solution you'd like
Simply add the field to our structures that represent choices.message and choices.delta. It might require refactoring though. Currently we use ChatCompletionMessageParam to both create chat completion and parse Chat Completion Object in a response. But looking at the API reference, it seems that request body and response format are different and so different Swift structured may be used for clearer distinction. Also, the separation into different types makes sense for a request, but not so much for response: API Reference does not specify such distinction, and I don't think we should either.

Describe alternatives you've considered
An alternative would be to continue using ChatCompletionMessageParam to decode Chat Completion Object, it may be faster to implement this way.

Additional context
Add any other context or screenshots about the feature request here.

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

1 participant