Hi, I am trying to use with_structured_output
. To define a schema, the docs demonstrate a basic dict {“foo”:”bar"}
which generalizes as {“field name”: “field description”}
.
And usage will be:
# Define schema
schema = {"foo": "bar"}
# Bind schema to model
model_with_structure = model.with_structured_output(schema)
# Invoke the model to produce structured output that matches the schema
structured_output = model_with_structure.invoke(user_input)
Doc : Structured outputs | 🦜️🔗 LangChain
However with such an approach I get an error “{‘concepts’: ‘The list of concepts as strings’} - Functions must be passed in as Dict, pydantic.BaseModel, or Callable. If they’re a dict they must either be in OpenAI function format or valid JSON schema with top-level ‘title’ and ‘description’ keys.”
And the remainder of the same documention seems to imply that instead, the schema may need to be set as a tool.
It seems that instead, I should rely on the more complex Open AI format described in the guide : How to return structured data from a model | 🦜️🔗 LangChain
To sum it up, I couldn’t really make sense of the structured outputs documentation, with the simplest approach of just using a dict.