guidance-ai / guidance

A guidance language for controlling large language models.
MIT License
19.19k stars 1.05k forks source link

Support for OpenAI structured output #1010

Open sternj opened 2 months ago

sternj commented 2 months ago

OpenAI now allows for structured output, as mentioned in #720 . With the support for Pydantic schemas in #699 and #724 , it's feasible that a passthrough could be added, I'd be inclined to put it where the schema is being generated (I'm unsure if openai will work with JSON rather than a Pydantic schema) or in _gen_json.

sternj commented 2 months ago

I think it could also be incorporated as a context block

Harsha-Nori commented 2 months ago

Hey @sternj, I think this is a great suggestion. On top of OpenAI, it looks like Google and Cohere also have JSON schema support. We're planning on revisiting all of our remote model classes in the near future, and I think extending their APIs to support this would be a great feature. Hope we can continue a brainstorm and discussion here as we work towards this in our backlog!

@nking-1 as FYI who has been thinking about similar ideas