Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structured Output component wrong 'content' #4788

Open
mirco-gnuva opened this issue Nov 22, 2024 · 1 comment
Open

Structured Output component wrong 'content' #4788

mirco-gnuva opened this issue Nov 22, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mirco-gnuva
Copy link

Bug Description

Hello!

Langflow version: langflowai/langflow-nightly:v1.1.0.dev4 (Docker)

I designed a flow that uses:

  • OpenAI component with gpt-4o-mini
  • Structured Output component

I'm facing the following strange behaviour:

Schema A

Name Description Type Multiple
title text False
article text False

with that schema all works as expected

Schema B

Name Description Type Multiple
title text False
content text False

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

Screenshot 2024-11-22 at 17 49 11
Screenshot 2024-11-22 at 17 50 05

Expected behavior

The Structured Output component runs successfully with the following schema:

Name Description Type Multiple
title text False
article text False

Who can help?

No response

Operating System

Docker

Langflow Version

1.1.0.dev4

Python Version

None

Screenshot

No response

Flow File

No response

@mirco-gnuva mirco-gnuva added the bug Something isn't working label Nov 22, 2024
Copy link

dosubot bot commented Nov 22, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant