refac: remove comments
This commit is contained in:
parent
81bc9845cd
commit
4aa242f9b1
5 changed files with 6 additions and 96 deletions
|
|
@ -42,27 +42,6 @@ def get_all():
|
||||||
for prompt in list_endpoints.list_prompts()
|
for prompt in list_endpoints.list_prompts()
|
||||||
},
|
},
|
||||||
"llms": {llm: signature.get_llm(llm) for llm in list_endpoints.list_llms()},
|
"llms": {llm: signature.get_llm(llm) for llm in list_endpoints.list_llms()},
|
||||||
# "utilities": {
|
|
||||||
# "template": {
|
|
||||||
# # utility: templates.utility(utility) for utility in list.list_utilities()
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
# "memories": {
|
|
||||||
# memory: signature.get_memory(memory)
|
|
||||||
# for memory in list_endpoints.list_memories()
|
|
||||||
# },
|
|
||||||
# "document_loaders": {
|
|
||||||
# "template": {
|
|
||||||
# # memory: templates.document_loader(memory)
|
|
||||||
# # for memory in list.list_document_loaders()
|
|
||||||
# }
|
|
||||||
# },
|
|
||||||
# "vectorstores": {"template": {}},
|
|
||||||
# "docstores": {"template": {}},
|
|
||||||
# "tools": {
|
|
||||||
# tool: {"template": signature.tool(tool), **values}
|
|
||||||
# for tool, values in tools.items()
|
|
||||||
# },
|
|
||||||
"tools": {
|
"tools": {
|
||||||
tool: signature.get_tool(tool) for tool in list_endpoints.list_tools()
|
tool: signature.get_tool(tool) for tool in list_endpoints.list_tools()
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,6 @@ def read_items():
|
||||||
"agents",
|
"agents",
|
||||||
"prompts",
|
"prompts",
|
||||||
"llms",
|
"llms",
|
||||||
# "utilities",
|
|
||||||
# "memories",
|
|
||||||
# "document_loaders",
|
|
||||||
# "vectorstores",
|
|
||||||
# "docstores",
|
|
||||||
"tools",
|
"tools",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -83,30 +78,6 @@ def list_memories():
|
||||||
return [memory.__name__ for memory in memories.type_to_cls_dict.values()]
|
return [memory.__name__ for memory in memories.type_to_cls_dict.values()]
|
||||||
|
|
||||||
|
|
||||||
# @router.get("/utilities")
|
|
||||||
# def list_utilities():
|
|
||||||
# """List all utility types"""
|
|
||||||
# return list(utilities.__all__)
|
|
||||||
|
|
||||||
|
|
||||||
# @router.get("/document_loaders")
|
|
||||||
# def list_document_loaders():
|
|
||||||
# """List all document loader types"""
|
|
||||||
# return list(document_loaders.__all__)
|
|
||||||
|
|
||||||
|
|
||||||
# @router.get("/vectorstores")
|
|
||||||
# def list_vectorstores():
|
|
||||||
# """List all vector store types"""
|
|
||||||
# return list(vectorstores.__all__)
|
|
||||||
|
|
||||||
|
|
||||||
# @router.get("/docstores")
|
|
||||||
# def list_docstores():
|
|
||||||
# """List all document store types"""
|
|
||||||
# return list(docstore.__all__)
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/tools")
|
@router.get("/tools")
|
||||||
def list_tools():
|
def list_tools():
|
||||||
"""List all load tools"""
|
"""List all load tools"""
|
||||||
|
|
@ -119,8 +90,3 @@ def list_tools():
|
||||||
tools.append(tool_params["name"])
|
tools.append(tool_params["name"])
|
||||||
|
|
||||||
return tools
|
return tools
|
||||||
|
|
||||||
# return [
|
|
||||||
# util.get_tool_params(util.get_tools_dict(tool))["name"]
|
|
||||||
# for tool in get_all_tool_names()
|
|
||||||
# ]
|
|
||||||
|
|
|
||||||
|
|
@ -62,18 +62,6 @@ def get_llm(name: str):
|
||||||
raise HTTPException(status_code=404, detail="LLM not found") from exc
|
raise HTTPException(status_code=404, detail="LLM not found") from exc
|
||||||
|
|
||||||
|
|
||||||
# @router.get("/utility")
|
|
||||||
# def utility(name: str):
|
|
||||||
# # Raise error if name is not in utilities
|
|
||||||
# if name not in utilities.__all__:
|
|
||||||
# raise Exception(f"Prompt {name} not found.")
|
|
||||||
# _class = getattr(utilities, name)
|
|
||||||
# return {
|
|
||||||
# name: {name: value for (name, value) in value.__repr_args__() if name != "name"}
|
|
||||||
# for name, value in _class.__fields__.items()
|
|
||||||
# }
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/memory")
|
@router.get("/memory")
|
||||||
def get_memory(name: str):
|
def get_memory(name: str):
|
||||||
"""Get the signature of a memory."""
|
"""Get the signature of a memory."""
|
||||||
|
|
@ -83,18 +71,6 @@ def get_memory(name: str):
|
||||||
raise HTTPException(status_code=404, detail="Memory not found") from exc
|
raise HTTPException(status_code=404, detail="Memory not found") from exc
|
||||||
|
|
||||||
|
|
||||||
# @router.get("/document_loader")
|
|
||||||
# def document_loader(name: str):
|
|
||||||
# # Raise error if name is not in document_loader
|
|
||||||
# if name not in document_loaders.__all__:
|
|
||||||
# raise Exception(f"Prompt {name} not found.")
|
|
||||||
# _class = getattr(document_loaders, name)
|
|
||||||
# return {
|
|
||||||
# name: {name: value for (name, value) in value.__repr_args__() if name != "name"}
|
|
||||||
# for name, value in _class.__fields__.items()
|
|
||||||
# }
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/tool")
|
@router.get("/tool")
|
||||||
def get_tool(name: str):
|
def get_tool(name: str):
|
||||||
"""Get the signature of a tool."""
|
"""Get the signature of a tool."""
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ from langchain.agents.mrkl import prompt
|
||||||
|
|
||||||
|
|
||||||
def get_custom_prompts():
|
def get_custom_prompts():
|
||||||
|
"""Get custom prompts."""
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"ZeroShotPrompt": {
|
"ZeroShotPrompt": {
|
||||||
"template": {
|
"template": {
|
||||||
|
|
|
||||||
|
|
@ -52,21 +52,15 @@ def build_json(root, nodes, edges):
|
||||||
for key, value in final_dict.items():
|
for key, value in final_dict.items():
|
||||||
if key == "_type":
|
if key == "_type":
|
||||||
continue
|
continue
|
||||||
# elif key == "prompt":
|
|
||||||
# pass
|
|
||||||
|
|
||||||
module_type = value["type"]
|
module_type = value["type"]
|
||||||
# if module_type == "Tool":
|
|
||||||
# pass
|
|
||||||
# if module_type in ["str", "bool", "int", "float", "Any"] or value["value"]:
|
|
||||||
# value = value["value"]
|
|
||||||
if "value" in value and value["value"] is not None:
|
if "value" in value and value["value"] is not None:
|
||||||
value = value["value"]
|
value = value["value"]
|
||||||
elif "dict" in module_type:
|
elif "dict" in module_type:
|
||||||
value = {}
|
value = {}
|
||||||
else:
|
else:
|
||||||
# if value['list']:
|
|
||||||
# print(key)
|
|
||||||
children = []
|
children = []
|
||||||
for c in local_nodes:
|
for c in local_nodes:
|
||||||
module_types = [c["data"]["type"]]
|
module_types = [c["data"]["type"]]
|
||||||
|
|
@ -74,19 +68,12 @@ def build_json(root, nodes, edges):
|
||||||
module_types += c["data"]["node"]["base_classes"]
|
module_types += c["data"]["node"]["base_classes"]
|
||||||
if module_type in module_types:
|
if module_type in module_types:
|
||||||
children.append(c)
|
children.append(c)
|
||||||
# children = [
|
|
||||||
# c
|
|
||||||
# for c in local_nodes
|
|
||||||
# if module_type
|
|
||||||
# in [c["data"]["type"]] + c["data"]["node"]["base_classes"]
|
|
||||||
# ]
|
|
||||||
# else:
|
|
||||||
# children = next((c for c in local_nodes if type in [c['data']['type']] + c['data']['node']['base_classes']), None)
|
|
||||||
if value["required"] and not children:
|
if value["required"] and not children:
|
||||||
raise ValueError(f"No child with type {module_type} found")
|
raise ValueError(f"No child with type {module_type} found")
|
||||||
values = [
|
values = [
|
||||||
build_json(child, nodes, edges) for child in children
|
build_json(child, nodes, edges) for child in children
|
||||||
] # if children else None
|
]
|
||||||
value = list(values) if value["list"] else next(iter(values), None)
|
value = list(values) if value["list"] else next(iter(values), None)
|
||||||
final_dict[key] = value
|
final_dict[key] = value
|
||||||
return final_dict
|
return final_dict
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue