Cache de-serialization does not work on ChatOpenAI with structured output, Pydantic classes and json_schema #29003
Labels
🤖:bug
Related to a bug, vulnerability, unexpected error with an existing feature
investigate
Flagged for investigation.
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Description
When using the specific configuration in the example, for ChatOpenAI structured output, caches won't work properly.
The problem appears only with Pydantic classes and
"json_schema"
. For example, there is no problem when usingTypedDict
as schema, or when using"function_calling"
as method.I have also tested Redis and Elasticsearch cache integrations. The issue is the same, LangChain is not able to restore the serialized output from the cache. I am aware of the limits of load methods, the problem however is in the dumping phase, where a Pydantic object is handled by this code. It cannot be properly serialized.
System Info
System Information
Package Information
Optional packages not installed
Other Dependencies
The text was updated successfully, but these errors were encountered: