-
Notifications
You must be signed in to change notification settings - Fork 17.4k
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
core: Fix issue 31035 alias fields in base tool langchain core #31112
Conversation
because the `inspect` method is used to collect annotations for fields we need this mapping since this method returns aliases of the fields and not the original field name
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
# 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(): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
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