autogen icon indicating copy to clipboard operation
autogen copied to clipboard

add support for structured output

Open lordlinus opened this issue 4 months ago • 1 comments

Why are these changes needed?

GPT-4o-2024-08-06 supports structured output with new beta API and this PR will use that API as part of extra_args to return the structured output format. remove stream option since it is not supported

Example usage:

    class StructuredOutputPlan(BaseModel):
        initial_goal: str
        steps: List[str]
    result = await self.model_client.create(
        message,
        extra_create_args={"response_format": StructuredOutputPlan},
    )

Related issue number

Resolves #3644

Checks

  • [x] I've included any doc changes needed for https://microsoft.github.io/autogen/. See https://microsoft.github.io/autogen/docs/Contribute#documentation to build and test documentation locally.
  • [x] I've added tests (if relevant) corresponding to the changes introduced in this PR.
  • [x] I've made sure all auto checks have passed.

lordlinus avatar Oct 04 '24 09:10 lordlinus