|
|
@ -58,7 +58,7 @@ index = faiss.IndexFlatL2(embedding_size)
|
|
|
|
vectorstore = FAISS(embeddings_model.embed_query, index, InMemoryDocstore({}), {})
|
|
|
|
vectorstore = FAISS(embeddings_model.embed_query, index, InMemoryDocstore({}), {})
|
|
|
|
|
|
|
|
|
|
|
|
# ---------- Worker Node ----------
|
|
|
|
# ---------- Worker Node ----------
|
|
|
|
@tool("workerAgent", return_direct=True)
|
|
|
|
@tool("WorkerAgent", return_direct=True)
|
|
|
|
class WorkerNode:
|
|
|
|
class WorkerNode:
|
|
|
|
def __init__(self, llm, tools, vectorstore):
|
|
|
|
def __init__(self, llm, tools, vectorstore):
|
|
|
|
self.llm = llm
|
|
|
|
self.llm = llm
|
|
|
@ -82,6 +82,7 @@ class WorkerNode:
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self.agent.run([f"{tree_of_thoughts_prompt} {prompt}"])
|
|
|
|
self.agent.run([f"{tree_of_thoughts_prompt} {prompt}"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
worker_node = WorkerNode(llm=llm, tools=tools, vectorstore=vectorstore)
|
|
|
|
worker_node = WorkerNode(llm=llm, tools=tools, vectorstore=vectorstore)
|
|
|
|
|
|
|
|
|
|
|
|
# ---------- Boss Node ----------
|
|
|
|
# ---------- Boss Node ----------
|
|
|
@ -143,11 +144,7 @@ tool_names = [tool.name for tool in tools]
|
|
|
|
agent = ZeroShotAgent(llm_chain=llm_chain, allowed_tools=tool_names)
|
|
|
|
agent = ZeroShotAgent(llm_chain=llm_chain, allowed_tools=tool_names)
|
|
|
|
agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=True)
|
|
|
|
agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=True)
|
|
|
|
|
|
|
|
|
|
|
|
# boss_node = BossNode(llm=llm, vectorstore=vectorstore, task_execution_chain=agent_executor, verbose=True, max_iterations=5)
|
|
|
|
boss_node = BossNode(llm=llm, vectorstore=vectorstore, task_execution_chain=agent_executor, verbose=True, max_iterations=5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Swarms:
|
|
|
|
class Swarms:
|
|
|
|