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

**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

---------

Co-authored-by: Chester Curme <chester.curme@gmail.com>
This commit is contained in:
CtrlMj
2025-05-12 11:04:13 -04:00
committed by GitHub
parent 92af7b0933
commit 1e56c66f86
2 changed files with 16 additions and 5 deletions

View File

@@ -2146,6 +2146,15 @@ def test__get_all_basemodel_annotations_v1() -> None:
assert actual == expected
def test_get_all_basemodel_annotations_aliases() -> None:
class CalculatorInput(BaseModel):
a: int = Field(description="first number", alias="A")
b: int = Field(description="second number")
actual = get_all_basemodel_annotations(CalculatorInput)
assert actual == {"a": int, "b": int}
def test_tool_annotations_preserved() -> None:
"""Test that annotations are preserved when creating a tool."""