Skip to content

Commit

Permalink
Make python 3.9 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
synacktraa committed Sep 22, 2024
1 parent df0f87c commit 6826938
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tool_parse/integrations/langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ class ExtendedStructuredTool(BaseTool):
"""The unique name of the tool that clearly communicates its purpose."""
description: t.Optional[str] = None
"""Used to tell the model how/when/why to use the tool."""
func: type[ts.TypedDict | ts.NamedTuple | ts.PydanticModel] | ts.AsyncFunction | ts.Function
func: t.Union[
type[t.Union[ts.TypedDict, ts.NamedTuple, ts.PydanticModel]], ts.AsyncFunction, ts.Function
]
"""
The object to run when the tool is called.
`func` is used as attribute name because it used widely in other components in langchain.
Expand Down Expand Up @@ -82,9 +84,11 @@ def validate_name_and_description(self):
@classmethod
def from_objects(
cls,
*__objs: type[ts.TypedDict | ts.NamedTuple | ts.PydanticModel]
| ts.AsyncFunction
| ts.Function,
*__objs: t.Union[
type[t.Union[ts.TypedDict, ts.NamedTuple, ts.PydanticModel]],
ts.AsyncFunction,
ts.Function,
],
schema_spec: t.Literal["base", "claude"] = "base",
**kwargs: t.Any,
):
Expand Down Expand Up @@ -374,7 +378,7 @@ def patch_chat_model(__model: type[ChatModel]) -> type[ChatModel]:
"""


def patch_chat_model(__model: ChatModel | type[ChatModel]):
def patch_chat_model(__model: t.Union[ChatModel, type[ChatModel]]):
class PatchedModel(BaseChatModel):
def bind_tools(
self,
Expand Down

0 comments on commit 6826938

Please sign in to comment.