Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CustomFileWriteTool fails with validation error #39

Open
meetmatt opened this issue Nov 29, 2024 · 1 comment
Open

CustomFileWriteTool fails with validation error #39

meetmatt opened this issue Nov 29, 2024 · 1 comment

Comments

@meetmatt
Copy link

meetmatt commented Nov 29, 2024

Hey @strnad, great tool!
I'm trying to use CustomFileWriteTool with an Agent that is expected to create files.

When I run the crew I receive an error (sorry for the docker container name in the logs):

crewai-studio  | Traceback (most recent call last):
crewai-studio  |   File "/CrewAI-Studio/app/pg_crew_run.py", line 113, in control_buttons
crewai-studio  |     crew = selected_crew.get_crewai_crew(full_output=True)
crewai-studio  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
crewai-studio  |   File "/CrewAI-Studio/app/my_crew.py", line 40, in get_crewai_crew
crewai-studio  |     crewai_agents = [agent.get_crewai_agent() for agent in self.agents]
crewai-studio  |                      ^^^^^^^^^^^^^^^^^^^^^^^^
crewai-studio  |   File "/CrewAI-Studio/app/my_agent.py", line 37, in get_crewai_agent
crewai-studio  |     tools = [tool.create_tool() for tool in self.tools]
crewai-studio  |              ^^^^^^^^^^^^^^^^^^
crewai-studio  |   File "/CrewAI-Studio/app/my_tools.py", line 314, in create_tool
crewai-studio  |     return CustomFileWriteTool(
crewai-studio  |            ^^^^^^^^^^^^^^^^^^^^
crewai-studio  |   File "/CrewAI-Studio/app/custom_tools.py", line 26, in __init__
crewai-studio  |     super().__init__(**kwargs)
crewai-studio  |   File "/usr/local/lib/python3.12/site-packages/pydantic/main.py", line 214, in __init__
crewai-studio  |     validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
crewai-studio  |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
crewai-studio  | pydantic_core._pydantic_core.ValidationError: 1 validation error for CustomFileWriteTool
crewai-studio  | args_schema
crewai-studio  |   Input should be a subclass of BaseModel [type=is_subclass_of, input_value=<class 'custom_tools.Cust...leWriteToolInputSchema'>, input_type=ModelMetaclass]
crewai-studio  |     For further information visit https://errors.pydantic.dev/2.10/v/is_subclass_of

Here's how I attempt to use it.
Crew:

...
Tasks:
1. You are building a new product FooBar. It allows user Foo to do Bar. You should use CustomFileWriteTool to save files.
Agent: Business Analyst
Tools: CustomFileWriteTool

Agent:

Role: Business Analyst
Backstory: You are guru in translating business objectives into actionable strategies.
Goal: Create detailed feature files with use-case scenarios in Gherkin format.
...
Tools: ['CustomFileWriteTool (/CrewAI-Studio/data)']

Is it even intended to be used that way? Thanks for your tool again!

@meetmatt
Copy link
Author

I was able to guess-fix it by changing the import of BaseModel from pydantic.v1 to pydantic (v2):

app/custom_tools.py

from pydantic import BaseModel
from pydantic.v1 import Field,root_validator, ValidationError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant