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

Allow passing of response_format to Assistant constructor #957

Merged
merged 2 commits into from
Jul 28, 2024

Conversation

andehr
Copy link
Contributor

@andehr andehr commented Jul 23, 2024

Fixes #956

As the proposed example usage in that issue, this PR enables this kind of usage:

Assistant(instructions=some_instructions, response_format=JsonObjectAssistantResponseFormat())

or this:

Assistant(instructions=some_instructions, response_format=AssistantResponseFormat(type="json_object"))

Be sure that your instructions include a careful description of the JSON schema that you expect the LLM to generate. And note that the API means it when it says "json_object". In other words, this doesn't constrain the response to any JSON, it specifically ensures the model will return a single JSON object. So if you, for example, want a JSON array, the array will have to be a property in a wrapper object.

Here's the relevant Open AI endpoint doc: https://platform.openai.com/docs/api-reference/assistants

Copy link
Collaborator

@zzstoatzz zzstoatzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! thank you

@zzstoatzz zzstoatzz merged commit 7af639f into PrefectHQ:main Jul 28, 2024
14 checks passed
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

Successfully merging this pull request may close these issues.

Support Assistant-level response_format parameter
2 participants