wandb / weave

Weave is a toolkit for developing AI-powered applications, built by Weights & Biases.
https://wandb.me/weave
Apache License 2.0
727 stars 68 forks source link

Support OpenAI structured output #3013

Open madroidmaq opened 3 days ago

madroidmaq commented 3 days ago

In the structured output API, OpenAI provides a parse function that can directly receive an entity class, as shown below:

response = client.beta.chat.completions.parse(
            model="gpt-4o-2024-08-06",
            messages=[
                {"role": "system", "content": SYSTEM_PROMPT},
                {"role": "user", "content": content}
            ],
            response_format=FoodNameScore,
            temperature=0
        )

But the current writing will not be automatically recorded like the client.chat.completions.create() function, and it is hoped that the automatic recording feature of the client.beta.chat.completions.parse() function can be supported.

jwlee64 commented 23 hours ago

Hi @madroidmaq, I can make a note, and raise this to the team tomorrow.

andrewtruong commented 10 hours ago

Hey @madroidmaq , this should be resolved with the latest release. Can you try weave==0.51.22 and see if it works for you?