Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nfcampos committed Sep 29, 2023
1 parent 7f589eb commit e35ea56
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions libs/langchain/langchain/tools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,23 +771,25 @@ def search_api(query: str) -> str:
def _make_with_name(tool_name: str) -> Callable:
def _make_tool(dec_func: Union[Callable, Runnable]) -> BaseTool:
if isinstance(dec_func, Runnable):
if dec_func.input_schema.schema().get("type") != "object":
runnable = dec_func

if runnable.input_schema.schema().get("type") != "object":
raise ValueError("Runnable must have an object schema.")

async def ainvoke_wrapper(
callbacks: Optional[Callbacks] = None, **kwargs: Any
) -> Any:
return await dec_func.ainvoke(kwargs, {"callbacks": callbacks})
return await runnable.ainvoke(kwargs, {"callbacks": callbacks})

def invoke_wrapper(
callbacks: Optional[Callbacks] = None, **kwargs: Any
) -> Any:
return dec_func.invoke(kwargs, {"callbacks": callbacks})
return runnable.invoke(kwargs, {"callbacks": callbacks})

coroutine = ainvoke_wrapper
func = invoke_wrapper
schema = dec_func.input_schema
description = repr(dec_func)
schema: Optional[Type[BaseModel]] = runnable.input_schema
description = repr(runnable)
elif inspect.iscoroutinefunction(dec_func):
coroutine = dec_func
func = None
Expand Down

0 comments on commit e35ea56

Please sign in to comment.