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

Unpack input recursively, to ensure that sub-types that are expected … #174

Merged
merged 2 commits into from
Nov 6, 2023

Conversation

nfcampos
Copy link
Collaborator

@nfcampos nfcampos commented Nov 6, 2023

…to remain as BaseModel do

This fixes input types such as

class AgentInput(BaseModel):
    messages: Sequence[AnyMessage] = Field(..., extra={"widget": {"type": "chat"}})

@nfcampos nfcampos requested a review from eyurtsev November 6, 2023 10:31
@cla-bot cla-bot bot added the cla-signed label Nov 6, 2023
@@ -120,7 +120,10 @@ def _unpack_input(validated_model: BaseModel) -> Any:
# it was created by the server as part of validation and isn't expected
# to be accepted by the runnables as input as a pydantic model,
# instead we need to convert it into a corresponding python dict.
return model.dict()
return {
fieldname: _unpack_input(getattr(model, fieldname))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Awesome looks good, I'll update the comment and can release

@eyurtsev eyurtsev merged commit cfafce1 into main Nov 6, 2023
6 checks passed
@eyurtsev eyurtsev deleted the nc/unpack-input-recurse branch November 6, 2023 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants