core[patch]: tool import fix (#25419)

This commit is contained in:
Bagatur 2024-08-14 15:54:13 -07:00 committed by GitHub
parent df632b8cde
commit 2494cecabf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 0 deletions

View File

@ -45,12 +45,14 @@ from langchain_core.tools.convert import (
convert_runnable_to_tool as convert_runnable_to_tool,
)
from langchain_core.tools.convert import tool as tool
from langchain_core.tools.render import ToolsRenderer as ToolsRenderer
from langchain_core.tools.render import (
render_text_description as render_text_description,
)
from langchain_core.tools.render import (
render_text_description_and_args as render_text_description_and_args,
)
from langchain_core.tools.retriever import RetrieverInput as RetrieverInput
from langchain_core.tools.retriever import (
create_retriever_tool as create_retriever_tool,
)

View File

@ -25,6 +25,7 @@ import pytest
from pydantic import BaseModel as BaseModelProper # pydantic: ignore
from typing_extensions import Annotated, TypedDict, TypeVar
from langchain_core import tools
from langchain_core.callbacks import (
AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun,
@ -1904,3 +1905,26 @@ def test_tool_args_schema_pydantic_v2_with_metadata() -> None:
assert foo.invoke({"x": [0] * 10})
with pytest.raises(ValidationErrorV2):
foo.invoke({"x": [0] * 9})
def test_imports() -> None:
expected_all = [
"FILTERED_ARGS",
"SchemaAnnotationError",
"create_schema_from_function",
"ToolException",
"BaseTool",
"Tool",
"StructuredTool",
"tool",
"RetrieverInput",
"create_retriever_tool",
"ToolsRenderer",
"render_text_description",
"render_text_description_and_args",
"BaseToolkit",
"convert_runnable_to_tool",
"InjectedToolArg",
]
for module_name in expected_all:
assert hasattr(tools, module_name) and getattr(tools, module_name) is not None