PydanticOutputParser failing with gpt-4o - works with gpt-4-turbo #21635
Replies: 3 comments 6 replies
-
To address the validation error with the PydanticOutputParser when using gpt-4o, it's crucial to ensure the output from gpt-4o matches the expected schema of your Pydantic model. The error indicates a mismatch between the expected and actual output structures.
Ensure the output from gpt-4o is correctly formatted to match your Pydantic model's schema. This might involve adjusting the model or the output data structure before parsing. For more detailed guidance, refer to the LangChain documentation on PydanticOutputParser.
|
Beta Was this translation helpful? Give feedback.
-
I had the same issues using |
Beta Was this translation helpful? Give feedback.
-
Anyone found the fix yet? |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
Using gpt-4-turbo I get the correct response:
https://smith.langchain.com/public/e8a3576d-4262-48fe-b025-bf4a98848c9b/r
Using gpt-4o I get a validation error:
OutputParserException('Failed to parse SuggestiveQuestions from completion {"properties": {"questions": {"title": "Questions", "description": "List of suggestive questions a potential buyer might ask a real estate broker.", "type": "array", "items": {"type": "string"}}}, "required": ["questions"]}. Got: 1 validation error for SuggestiveQuestions\nquestions\n field required (type=value_error.missing)')
Same code, different models.
System Info
langchain_version: "0.1.16"
library: "langsmith"
platform: "macOS-14.4.1-arm64-arm-64bit"
py_implementation: "CPython"
runtime: "python"
runtime_version: "3.11.8"
sdk: "langsmith-py"
sdk_version: "0.1.52"
langchain==0.1.16
langchain-community==0.0.36
langchain-core==0.1.48
langchain-openai==0.1.3
langchain-text-splitters==0.0.1
langchainhub==0.1.15
Beta Was this translation helpful? Give feedback.
All reactions