kyegomez / swarms

The Enterprise-Grade Production-Ready Multi-Agent Orchestration Framework Join our Community: https://discord.com/servers/agora-999382051935506503
https://docs.swarms.world
GNU Affero General Public License v3.0
1.79k stars 245 forks source link

[BUG] pug with BaseTool init #605

Open lometheus opened 1 month ago

lometheus commented 1 month ago

when i try example with this https://docs.swarms.world/en/latest/swarms/tools/build_tool/#integrate-tools-into-agent

i get this error:

Traceback (most recent call last):
  File "/Users/fenyi/codesy/swarm-test/test.py", line 109, in <module>
    agent1 = Agent(
             ^^^^^^
  File "/Users/fenyi/codesy/swarm-test/.venv/lib/python3.12/site-packages/swarms/structs/agent.py", line 407, in __init__
    self.tool_struct = BaseTool(
                       ^^^^^^^^^
  File "/Users/fenyi/codesy/swarm-test/.venv/lib/python3.12/site-packages/pydantic/main.py", line 194, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for BaseTool
base_models
  Input should be a valid list [type=list_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.8/v/list_type
Sentry is attempting to send 2 pending events

bug from here image

actually list_base_models does not have default value, image

you can ealisy find this question with this code `from swarms import Agent from swarms.prompts.tools import tool_sop_prompt

from swarm_models import OpenAIChat from swarms_memory import ChromaDB import subprocess import os from swarms.tools.base_tool import BaseTool

def terminal( code: str, ): """ Run code in the terminal.

Args:
    code (str): The code to run in the terminal.

Returns:
    str: The output of the code.
"""
out = subprocess.run(
    code, shell=True, capture_output=True, text=True
).stdout
return str(out)

BaseTool( tools=[terminal], base_models=None, tool_system_prompt=tool_sop_prompt(), )`

Upvote & Fund

Fund with Polar

lometheus commented 1 month ago

i believe give list_base_models a default value in class Agent can relsove this question

peytontolbert commented 1 month ago

submitted pull request to fix this issue