mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-23 19:39:58 +00:00
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:
@@ -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."""
|
||||
|
||||
|
Reference in New Issue
Block a user