Open mirco-gnuva opened 5 days ago
Hey there, @mirco-gnuva! I'm here to help you with any bugs, questions, or contributions you have. Let's squash those bugs together!
The issue you're encountering with the Structured Output component seems to be related to the handling of the 'content' field. In Langflow, the 'content' field is subject to a custom serialization process, which might be causing the unexpected behavior you're seeing when using Schema B. The BaseContent
class includes a serialize_model
method that attempts to serialize the model using jsonable_encoder
with custom encoders. If an exception occurs, it falls back to a default serialization method [1].
This custom handling could be affecting how the 'content' field is processed, leading to the error where a string is returned instead of a Pydantic BaseModel
. To resolve this, you might consider checking if there are any specific transformations or custom encodings applied to the 'content' field that could be interfering with its expected behavior in the Structured Output component.
To continue talking to Dosu, mention @dosu.
Bug Description
Hello!
Langflow version: langflowai/langflow-nightly:v1.1.0.dev4 (Docker)
I designed a flow that uses:
I'm facing the following strange behaviour:
Schema A
with that schema all works as expected
Schema B
The following Error is raised: Error building Component Structured Output: Output should be a Pydantic BaseModel, got <class 'str'> <the string that with the A schema is the 'article' key value>
Conclusion
I suspect that under the hood the completion.choices[0].content.content is returned (in other words, the 'content' attribute of the resulting Pydantic object) instead of the resulting Pydantic object itself.
Reproduction
Expected behavior
Who can help?
No response
Operating System
Docker
Langflow Version
1.1.0.dev4
Python Version
None
Screenshot
No response
Flow File
No response