Skip to content

Allow proper union types inside of structured outputs#513

Open
jamosaur wants to merge 1 commit intoneuron-core:3.xfrom
jamosaur:structured-union-types
Open

Allow proper union types inside of structured outputs#513
jamosaur wants to merge 1 commit intoneuron-core:3.xfrom
jamosaur:structured-union-types

Conversation

@jamosaur
Copy link
Copy Markdown
Contributor

Allows union types to be used with structured output.

Deserializing also checks the data type and tries to cast it to the correct type if it is defined on the structured output class. Behaviour falls back to what was originally there (attempting to cast each type in order).

@ilvalerione
Copy link
Copy Markdown
Contributor

Can you provide code examples of the feature it's intended to add?

@ilvalerione
Copy link
Copy Markdown
Contributor

@jamosaur I would like to better understand this PR. Can you provide more context and examples?

@jamosaur
Copy link
Copy Markdown
Contributor Author

jamosaur commented Apr 1, 2026

@ilvalerione my use case for this was having something coming back from the agent that could have been float, int or null depending on some factors.

I just added support for everything rather than only my use case here. Happy for it to not be merged if it's not the direction you'd like to go of course 😄

@ilvalerione
Copy link
Copy Markdown
Contributor

Can you provide a code example about before and after this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants