Skip to content

Commit 6826938

Browse files
committed
Make python 3.9 compatible
1 parent df0f87c commit 6826938

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tool_parse/integrations/langchain.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ class ExtendedStructuredTool(BaseTool):
5050
"""The unique name of the tool that clearly communicates its purpose."""
5151
description: t.Optional[str] = None
5252
"""Used to tell the model how/when/why to use the tool."""
53-
func: type[ts.TypedDict | ts.NamedTuple | ts.PydanticModel] | ts.AsyncFunction | ts.Function
53+
func: t.Union[
54+
type[t.Union[ts.TypedDict, ts.NamedTuple, ts.PydanticModel]], ts.AsyncFunction, ts.Function
55+
]
5456
"""
5557
The object to run when the tool is called.
5658
`func` is used as attribute name because it used widely in other components in langchain.
@@ -82,9 +84,11 @@ def validate_name_and_description(self):
8284
@classmethod
8385
def from_objects(
8486
cls,
85-
*__objs: type[ts.TypedDict | ts.NamedTuple | ts.PydanticModel]
86-
| ts.AsyncFunction
87-
| ts.Function,
87+
*__objs: t.Union[
88+
type[t.Union[ts.TypedDict, ts.NamedTuple, ts.PydanticModel]],
89+
ts.AsyncFunction,
90+
ts.Function,
91+
],
8892
schema_spec: t.Literal["base", "claude"] = "base",
8993
**kwargs: t.Any,
9094
):
@@ -374,7 +378,7 @@ def patch_chat_model(__model: type[ChatModel]) -> type[ChatModel]:
374378
"""
375379

376380

377-
def patch_chat_model(__model: ChatModel | type[ChatModel]):
381+
def patch_chat_model(__model: t.Union[ChatModel, type[ChatModel]]):
378382
class PatchedModel(BaseChatModel):
379383
def bind_tools(
380384
self,

0 commit comments

Comments
 (0)