mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-24 03:52:10 +00:00
core[patch]: Correct type casting of annotations in _infer_arg_descriptions (#31181)
- **Description:** - In _infer_arg_descriptions, the annotations dictionary contains string representations of types instead of actual typing objects. This causes _is_annotated_type to fail, preventing the correct description from being generated. - This is a simple fix using the get_type_hints method, which resolves the annotations properly and is supported across all Python versions. - **Issue:** #31051 --------- Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
This commit is contained in:
committed by
GitHub
parent
dea43436ea
commit
ae3551c96b
@@ -2711,3 +2711,24 @@ def test_tool_invoke_does_not_mutate_inputs() -> None:
|
||||
"id": "call_0_82c17db8-95df-452f-a4c2-03f809022134",
|
||||
"type": "tool_call",
|
||||
}
|
||||
|
||||
|
||||
def test_tool_args_schema_with_annotated_type() -> None:
|
||||
@tool
|
||||
def test_tool(
|
||||
query_fragments: Annotated[
|
||||
list[str],
|
||||
"A list of query fragments",
|
||||
],
|
||||
) -> list[str]:
|
||||
"""Search the Internet and retrieve relevant result items."""
|
||||
return []
|
||||
|
||||
assert test_tool.args == {
|
||||
"query_fragments": {
|
||||
"description": "A list of query fragments",
|
||||
"items": {"type": "string"},
|
||||
"title": "Query Fragments",
|
||||
"type": "array",
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user