While following the OpenAIPydanticProgram tutorial here, I've ran into KeyError('description') errors.
After some extra investigation, it turns out that the problem is in the to_openai_tool method:
def to_openai_tool(pydantic_class: Type[BaseModel]) -> Dict[str, Any]:
"""Convert pydantic class to OpenAI tool."""
schema = pydantic_class.schema()
function = {
"name": schema["title"],
"description": schema["description"],
"parameters": pydantic_class.schema(),
}
return {"type": "function", "function": function}
The Pydantic schema that's passed down from OpenAIPydanticProgram's from_defaults method doesn't contain the description property and current documentation doesn't describe how to pass it. I've also noticed that the type for BaseModel is Pydantic's v1 and not the latest Pydantic, so maybe the issue is located there?
Version
0.9.15.post2
Steps to Reproduce
Try the demo provided in the documentation. You should run into the same problem.
Bug Description
While following the OpenAIPydanticProgram tutorial here, I've ran into
KeyError('description')
errors. After some extra investigation, it turns out that the problem is in theto_openai_tool
method:The Pydantic schema that's passed down from
OpenAIPydanticProgram
'sfrom_defaults
method doesn't contain thedescription
property and current documentation doesn't describe how to pass it. I've also noticed that the type forBaseModel
is Pydantic's v1 and not the latest Pydantic, so maybe the issue is located there?Version
0.9.15.post2
Steps to Reproduce
Try the demo provided in the documentation. You should run into the same problem.
Relevant Logs/Tracbacks
No response