diff --git a/playground/structs/agent_with_tools.py b/playground/structs/agent_with_tools.py index e816fb99..99e50b5c 100644 --- a/playground/structs/agent_with_tools.py +++ b/playground/structs/agent_with_tools.py @@ -23,7 +23,7 @@ load_dotenv() # Define a tool @tool -def search_api(query: str): +def search_api(query: str, description: str): """Search the web for the query Args: @@ -35,6 +35,25 @@ def search_api(query: str): return f"Search results for {query}" +@tool +def weather_api(query: str,): + """_summary_ + + Args: + query (str): _description_ + """ + print(f"Getting the weather for {query}") + + +@tool +def rapid_api(query: str): + """_summary_ + + Args: + query (str): _description_ + """ + print(f"Getting the weather for {query}") + # Get the API key from the environment api_key = os.environ.get("OPENAI_API_KEY") diff --git a/swarms/prompts/tools.py b/swarms/prompts/tools.py index a27706e3..5c2d89c8 100644 --- a/swarms/prompts/tools.py +++ b/swarms/prompts/tools.py @@ -12,36 +12,40 @@ This will enable you to leave the autonomous loop. DYNAMICAL_TOOL_USAGE = """ You have access to the following tools: Output a JSON object with the following structure to use the tools + commands: { "tools": { - tool1: "tool_name", + tool1: "search_api", "params": { - "tool1": "inputs", - "tool1": "inputs" + "query": "What is the weather in New York?", + "description": "Get the weather in New York" } - "tool2: "tool_name", + "tool2: "weather_api", "params": { - "tool1": "inputs", - "tool1": "inputs" + "query": "What is the weather in Silicon Valley", } - "tool3: "tool_name", + "tool3: "rapid_api", "params": { - "tool1": "inputs", - "tool1": "inputs" + "query": "Use the rapid api to get the weather in Silicon Valley", } } } --------------TOOLS--------------------------- -{tools} """ + + + + + + +########### FEW SHOT EXAMPLES ################ SCENARIOS = """ commands: { "tools": { - tool1: "tool_name", + tool1: "function", "params": { - "tool1": "inputs", + "input": "inputs", "tool1": "inputs" } "tool2: "tool_name",