main
Kye 2 years ago
parent 4a72039af5
commit beac3a4a90

@ -58,20 +58,17 @@ query_website_tool = WebpageQATool(qa_chain=load_qa_with_sources_chain(llm))
web_search = DuckDuckGoSearchRun() web_search = DuckDuckGoSearchRun()
tools = { tools = [
'web_search': web_search, Tool(name='web_search', func=web_search.run, description='Runs a web search'),
'write_file_tool': WriteFileTool(root_dir="./data"), Tool(name='write_file_tool', func=WriteFileTool(root_dir="./data").run, description='Writes a file'),
'read_file_tool': ReadFileTool(root_dir="./data"), Tool(name='read_file_tool', func=ReadFileTool(root_dir="./data").run, description='Reads a file'),
'process_csv': process_csv, Tool(name='process_csv', func=process_csv.run, description='Processes a CSV file'),
# 'multimodal_agent_tool': multimodal_agent_tool, Tool(name='query_website_tool', func=query_website_tool.run, description='Queries a website'),
'query_website_tool': query_website_tool, Tool(name='terminal', func=Terminal.run, description='Operates a terminal'),
'terminal': Terminal, Tool(name='code_writer', func=CodeWriter.run, description='Writes code'),
'code_writer': CodeWriter, Tool(name='code_editor', func=CodeEditor.run, description='Edits code'),
'code_editor': CodeEditor, # Add any additional tools here...
# 'math_tool': math_tool ]
# HumanInputRun(), # Activate if you want the permit asking for help from the human
}
############## Vectorstore ############## Vectorstore
embeddings_model = OpenAIEmbeddings() embeddings_model = OpenAIEmbeddings()
@ -98,7 +95,7 @@ worker_agent.chain.verbose = True
class WorkerNode: class WorkerNode:
def __init__(self, llm, tools, vectorstore): def __init__(self, llm, tools, vectorstore):
self.llm = llm self.llm = llm
self.tools = tools # Add this line here self.tools = tools
self.vectorstore = vectorstore self.vectorstore = vectorstore
@ -107,7 +104,7 @@ class WorkerNode:
self.agent = AutoGPT.from_llm_and_tools( self.agent = AutoGPT.from_llm_and_tools(
ai_name=ai_name, ai_name=ai_name,
ai_role=ai_role, ai_role=ai_role,
tools=self.tools, # Change this line to use self.tools tools=tools,
llm=self.llm, llm=self.llm,
memory=self.vectorstore.as_retriever(search_kwargs=search_kwargs), memory=self.vectorstore.as_retriever(search_kwargs=search_kwargs),
human_in_the_loop=human_in_the_loop, human_in_the_loop=human_in_the_loop,
@ -122,6 +119,7 @@ class WorkerNode:
self.agent.run([f"{tree_of_thoughts_prompt} {prompt}"]) self.agent.run([f"{tree_of_thoughts_prompt} {prompt}"])
#inti worker node with llm #inti worker node with llm
worker_node = WorkerNode(llm=llm, tools=tools, vectorstore=vectorstore) worker_node = WorkerNode(llm=llm, tools=tools, vectorstore=vectorstore)
@ -222,20 +220,25 @@ class Swarms:
def initialize_tools(self, llm): def initialize_tools(self, llm):
web_search = DuckDuckGoSearchRun() web_search = DuckDuckGoSearchRun()
tools = { # tools = [web_search, WriteFileTool(root_dir="./data"), ReadFileTool(root_dir="./data"), process_csv,
'web_search': web_search, # # multimodal_agent_tool,
'write_file_tool': WriteFileTool(root_dir="./data"), # WebpageQATool(qa_chain=load_qa_with_sources_chain(llm)),
'read_file_tool': ReadFileTool(root_dir="./data"), # Terminal, CodeWriter, CodeEditor,
'process_csv': process_csv, # # math_tool
# 'multimodal_agent_tool': multimodal_agent_tool, # ]
'query_website_tool': WebpageQATool(qa_chain=load_qa_with_sources_chain(llm)), tools = [
'terminal': Terminal, Tool(name='web_search', func=web_search.run, description='Runs a web search'),
'code_writer': CodeWriter, Tool(name='write_file_tool', func=WriteFileTool(root_dir="./data").run, description='Writes a file'),
'code_editor': CodeEditor, Tool(name='read_file_tool', func=ReadFileTool(root_dir="./data").run, description='Reads a file'),
# 'math_tool': math_tool Tool(name='process_csv', func=process_csv.run, description='Processes a CSV file'),
} Tool(name='query_website_tool', func=query_website_tool.run, description='Queries a website'),
Tool(name='terminal', func=Terminal.run, description='Operates a terminal'),
Tool(name='code_writer', func=CodeWriter.run, description='Writes code'),
Tool(name='code_editor', func=CodeEditor.run, description='Edits code'),
# Add any additional tools here...
]
return tools return tools
def initialize_vectorstore(self): def initialize_vectorstore(self):
embeddings_model = OpenAIEmbeddings() embeddings_model = OpenAIEmbeddings()
embedding_size = 1536 embedding_size = 1536

Loading…
Cancel
Save