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

Handle enum in choice #1279

Merged
merged 4 commits into from
Dec 8, 2024
Merged

Handle enum in choice #1279

merged 4 commits into from
Dec 8, 2024

Conversation

g-prz
Copy link
Contributor

@g-prz g-prz commented Nov 22, 2024

This PR aims at solving #1218 (requires #1277 to be merged)

Quick fix to solve #1275

@g-prz g-prz force-pushed the handle-enum-in-choice branch 4 times, most recently from 559b2d6 to 2a0aa9b Compare November 28, 2024 11:12
Comment on lines +27 to +28
if isinstance(choices, type(Enum)):
generator.format_sequence = lambda x: pyjson.loads(x)
Copy link
Contributor Author

@g-prz g-prz Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @rlouf 🙋‍♂️
I have a design related question: in case we pass an enum to choice, are we expecting to return an instance of that enum or only its value? If the latter we are fine, if the former we need to reconstruct the enum in here
Thx 🙏

Copy link
Member

@rlouf rlouf Nov 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean but returning the instance, but we definitely just want the value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are good for review then

@g-prz g-prz force-pushed the handle-enum-in-choice branch from 6137dae to 8090ad1 Compare November 29, 2024 08:48
@g-prz g-prz marked this pull request as ready for review November 29, 2024 09:11
@rlouf
Copy link
Member

rlouf commented Dec 8, 2024

Thank you for contributing!

@rlouf rlouf merged commit e4f96fb into dottxt-ai:main Dec 8, 2024
6 checks passed
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