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

feat: Alpaca pydantic class for easy conversion, validation, and structured output generation #1202

Merged
merged 10 commits into from
Dec 2, 2024

Conversation

CaelumF
Copy link
Collaborator

@CaelumF CaelumF commented Nov 21, 2024

Description

Adds an alpaca pydantic class that allows for conversion to/from the Alpaca inference/training textual representation, and through pydantic, to/from json representations.

The expected way to generate this is however through structured output, though the other methods are useful for inference, training, and combining existing items from other sources.

Motivation and Context

Possibly closes #1184, though it doesn't provide a discoverable way to do this unless people are already familiar with Pydantic. Potentially a 1-liner function can be added to BaseMessage that shows how the message string can be easily converted, or maybe we do not need this to be particularly discoverable through the code APIs, if a larger theme of relying on pydantic classes for conversion is established as a recognisable pattern.

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)
  • Example (update in the folder of example)

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the CONTRIBUTION guide. (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly. (required for a bug fix or a new feature)
  • I have updated the documentation accordingly.

Signed-off-by: Caelum Forder <caelum119@gmail.com>
Signed-off-by: Caelum Forder <caelum119@gmail.com>
Signed-off-by: Caelum Forder <caelum119@gmail.com>
Copy link
Member

@Wendong-Fan Wendong-Fan left a comment

Choose a reason for hiding this comment

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

Thanks @CaelumF , could you help resolve the conflict with master branch?

camel/messages/conversion/alpaca.py Outdated Show resolved Hide resolved
CaelumF and others added 3 commits December 2, 2024 14:23
Co-authored-by: Wendong-Fan <133094783+Wendong-Fan@users.noreply.github.com>
@Wendong-Fan Wendong-Fan marked this pull request as ready for review December 2, 2024 14:40
@Wendong-Fan Wendong-Fan changed the title Alpaca pydantic class for easy conversion, validation, and structured output generation feat: Alpaca pydantic class for easy conversion, validation, and structured output generation Dec 2, 2024
@Wendong-Fan Wendong-Fan merged commit 3dd959a into master Dec 2, 2024
6 checks passed
@Wendong-Fan Wendong-Fan deleted the alpaca_conversion_temp branch December 2, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

[Feature Request] Convert BaseMessage to alpaca format
2 participants