refac: small fixes
This commit is contained in:
parent
a4d50541ec
commit
0e5078b5f5
2 changed files with 6 additions and 3 deletions
|
|
@ -1,3 +1,4 @@
|
|||
from typing import Any, Dict
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from langchain import agents, chains, llms, prompts
|
||||
from langchain.agents.load_tools import (
|
||||
|
|
@ -131,11 +132,13 @@ def get_tool(name: str):
|
|||
elif tool_type in _EXTRA_OPTIONAL_TOOLS:
|
||||
_, extra_keys = _EXTRA_OPTIONAL_TOOLS[tool_type]
|
||||
params = extra_keys
|
||||
else:
|
||||
params = []
|
||||
|
||||
template = {
|
||||
param: (type_dict[param] if param == "llm" else type_dict["str"])
|
||||
for param in params
|
||||
}
|
||||
} # type: Dict[str, Any]
|
||||
template["_type"] = tool_type
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -113,8 +113,8 @@ def get_default_factory(module: str, function: str):
|
|||
pattern = r"<function (\w+)>"
|
||||
|
||||
if match := re.search(pattern, function):
|
||||
module = importlib.import_module(module)
|
||||
return getattr(module, match[1])()
|
||||
imported_module = importlib.import_module(module)
|
||||
return getattr(imported_module, match[1])()
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue