Skip to content

core: Fix issue 31035 alias fields in base tool langchain core #31112

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

Merged
merged 11 commits into from
May 12, 2025

Conversation

CtrlMj
Copy link
Contributor

@CtrlMj CtrlMj commented May 4, 2025

Description: The 'inspect' package in python skips over the aliases set in the schema of a pydantic model. This is a workound to include the aliases from the original input.
issue: #31035

Cc: @ccurme @eyurtsev

Copy link

vercel bot commented May 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview May 11, 2025 3:01pm

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. langchain Related to the langchain package 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels May 4, 2025
@ccurme ccurme requested a review from sydney-runkle May 11, 2025 15:15
@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label May 11, 2025
# Gather pydantic field objects (v2: model_fields / v1: __fields__)
fields = getattr(cls, "model_fields", {}) or getattr(cls, "__fields__", {})
alias_map = {field.alias: name for name, field in fields.items() if field.alias}

annotations: dict[str, type] = {}
for name, param in inspect.signature(cls).parameters.items():
Copy link
Collaborator

Choose a reason for hiding this comment

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

For pydantic models, why not just look in model_fields directly? Why go through all of the signature / special casing logic?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like a fine bandaid until we drop v1 support

@ccurme ccurme changed the title Fix issue 31035 alias fields in base tool langchain core core: Fix issue 31035 alias fields in base tool langchain core May 12, 2025
@ccurme ccurme merged commit 1e56c66 into langchain-ai:master May 12, 2025
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature langchain Related to the langchain package lgtm PR looks good. Use to confirm that a PR is ready for merging. size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants