worker node tool langchain setup

main
Kye 2 years ago
parent 2a197705d7
commit 2b7d620d22

@ -1,21 +1,13 @@
from swarms.tools.agent_tools import * from swarms.tools.agent_tools import *
from langchain.tools import BaseTool from langchain.tools import BaseTool, tool
from typing import Optional, Type from typing import Optional, Type
from langchain.callbacks.manager import ( from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun, AsyncCallbackManagerForToolRun,
CallbackManagerForToolRun, CallbackManagerForToolRun,
) )
from langchain.tools import tool
class WorkerNode(BaseTool):
# ---------- Worker Node ----------
from pydantic import Field
#
@tool
class WorkerNode():
"""Useful for when you need to spawn an autonomous agent instance as a worker to accomplish complex tasks, it can search the internet or spawn child multi-modality models to process and generate images and text or audio and so on """ """Useful for when you need to spawn an autonomous agent instance as a worker to accomplish complex tasks, it can search the internet or spawn child multi-modality models to process and generate images and text or audio and so on """
# name = "WorkerNode"
# description = "Useful for when you need to spawn an autonomous agent instance as a worker to accomplish complex tasks, it can search the internet or spawn child multi-modality models to process and generate images and text or audio and so on."
def __init__(self, llm, tools, vectorstore): def __init__(self, llm, tools, vectorstore):
super().__init__() super().__init__()
@ -34,6 +26,10 @@ class WorkerNode():
) )
self.agent.chain.verbose = True self.agent.chain.verbose = True
@tool(
name="Worker AutoBot Agent",
description="Useful for when you need to spawn an autonomous agent instance as a worker to accomplish complex tasks, it can search the internet or spawn child multi-modality models to process and generate images and text or audio and so on",
)
def _run( def _run(
self, prompt: str, run_manager: Optional[CallbackManagerForToolRun] = None self, prompt: str, run_manager: Optional[CallbackManagerForToolRun] = None
) -> str: ) -> str:

Loading…
Cancel
Save