Closed rgallardone closed 1 month ago
This example could be fixed by changing
from pydantic import BaseModel, Field
to
from langchain_core.pydantic_v1 import BaseModel, Field
This issue #16564 seems related
Thanks!!! This solved it. Dumb mistake on my side. Much appreciated!
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
No response
Description
I'm trying to get a structured output using a chain with
ChatOpenAI
. I reproduced the behavior with this very simple scenario:I expected the result to be a list of jokes, but it didn't work, even for this very simple prompt. If I change the code a little bit like this:
I get the following output:
Obviously, the model knows how to solve such a simple task, but it doesn't seem to be using the structure correctly when it has a list of strings as the attribute.
I tried the same behavior with more complex structured outputs, and the same happened.
System Info
langchain==0.2.1 langchain-community==0.2.1 langchain-core==0.2.3 langchain-experimental==0.0.59 langchain-openai==0.1.8 langchain-text-splitters==0.2.0
platform: linux python version: 3.10.10