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

[Feature Request] Please support Structured Output for OpenAI models #3926

Open
noahlatzel opened this issue Jan 17, 2025 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@noahlatzel
Copy link

noahlatzel commented Jan 17, 2025

Please support the new "response_format" parameter type in OpenAI. The dropbox in the UI can be extended with a "json_schema"
option. The json_schema itself could then be described in a new file / within flow.dag.yaml. A small button could be added to the UI that appears when "json_schema" is selected and opens a small editor to define the response_format. Similar to how it is already done in "Azure AI Foundry Chat Playground"

Additional context
https://platform.openai.com/docs/guides/structured-outputs

from openai import OpenAI

client = OpenAI()

class CalendarEvent(BaseModel):
    name: str
    date: str
    participants: list[str]

completion = client.beta.chat.completions.parse(
    model="gpt-4o-2024-08-06",
    messages=[
        {"role": "system", "content": "Extract the event information."},
        {"role": "user", "content": "Alice and Bob are going to a science fair on Friday."},
    ],
    response_format=CalendarEvent,
)

event = completion.choices[0].message.parsed
@noahlatzel noahlatzel added the enhancement New feature or request label Jan 17, 2025
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

1 participant