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

Round trip Message serialization/deserialization #336

Closed
alex-dixon opened this issue Oct 25, 2024 · 3 comments
Closed

Round trip Message serialization/deserialization #336

alex-dixon opened this issue Oct 25, 2024 · 3 comments

Comments

@alex-dixon
Copy link
Contributor

alex-dixon commented Oct 25, 2024

From Merlin von Trott via Discord:

I am struggeling with loading the massage object back from json. What am i doing wrong ?

    original_message = ell.Message(role='assistant', content='Hello, this is a test message.', tool_result=None)
    message_json = json.dumps(original_message.model_dump_json())
    message_data = json.loads(message_json)
    loaded_message = ell.Message.model_validate(message_data)

ell-ai==0.0.14
pydantic==2.9.2
pydantic_core._pydantic_core.ValidationError: 1 validation error for Message
Input should be a valid dictionary or instance of Message [type=model_type, input_value='{"role":"assistant","con...l,"tool_result":null}]}', input_type=str]
For further information visit https://errors.pydantic.dev/2.9/v/model_type

Not sure what’s going on here exactly. Maybe we need a custom pedantic serialize/deserialize/validate hook?

@Merlinvt
Copy link

Opened a Pull request #337

@Merlinvt
Copy link

Sorry, I tried to open the pull request with the issue ...

@MadcowD
Copy link
Owner

MadcowD commented Oct 29, 2024

fuck i hate our serialization code its in 3 differnet places.

@MadcowD MadcowD closed this as completed Oct 29, 2024
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

No branches or pull requests

3 participants