Im working on my crewAI task. I have been trying to run my main.py in my anaconda prompt, below error keeps popping up , who can assist me please , thank you

Traceback (most recent call last):
  File "C:\Users\chide\LLM_AWS\CreweAI\starter_template\main.py", line 97, in <module>
    result = trip_crew.run()
  File "C:\Users\chide\LLM_AWS\CreweAI\starter_template\main.py", line 36, in run
    expert_travel_agent = agents.expert_travel_agent()
  File "C:\Users\chide\LLM_AWS\CreweAI\starter_template\agents.py", line 98, in expert_travel_agent
    return Agent(
  File "C:\Users\chide\anaconda3\envs\GenAI\lib\site-packages\pydantic\main.py", line 171, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 2 validation errors for Agent
tools.0
  Input should be a valid dictionary or instance of BaseTool [type=model_type, input_value=StructuredTool(name='sear... at 0x000001E688744160>), input_type=StructuredTool]
    For further information visit https://errors.pydantic.dev/2.6/v/model_type
tools.1
  Input should be a valid dictionary or instance of BaseTool [type=model_type, input_value=StructuredTool(name='Make... at 0x000001E6887441F0>), input_type=StructuredTool]
    For further information visit https://errors.pydantic.dev/2.6/v/model_type

below is the code snippet

from crewai import Agent

from textwrap import dedent

from langchain_openai import ChatOpenAI

from tools.search_tools import SearchTools

from tools.calculator_tools import CalculatorTools
class TravelAgents:
    def __init__(self):
        self.OpenAIGPT35 = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0.7)   
    def expert_travel_agent(self):
        return Agent(
            role="Expert Travel Agent",
            backstory=dedent(f"""Expert in Travel Planning and Logistics.
                             I have decades of experience making travel itineraries"""),
            goal=dedent(f"""create a 7-day travel itinerary with detailed per-day plans,
                        including budgets, packing suggestions, and safety trips."""),
            tools=[SearchTools().search_internet, CalculatorTools().calculate],
            allow_delegation=False,
            verbose=True,
            llm=self.OpenAIGPT35,
        )

    def city_selection_expert(self):
        return Agent(
            role="City Selection Agent",
            backstory=dedent(f"""Expert at analysing travel data to pick ideal cities for your travel
                             plans"""),
            goal=dedent(f"""Select the best cities bases on the weather,season,prices,and traveler interests"""),
            tools=[SearchTools().search_internet],
            allow_delegation=False,
            verbose=True,
            llm=self.OpenAIGPT35,
        )

    def local_tour_guide(self):
        return Agent(
            role="Local Tour Guide",
            backstory=dedent(f"""Knowledgable local guide with extensive information
                             about the city,its attraction and customs"""),
            goal=dedent(f"""Provide the BEST insights about the selected city"""),
            tools=[SearchTools().search_internet],
            allow_delegation=False,
            verbose=True,
            llm=self.OpenAIGPT35,
        )

Welcome to the community.. When setting up I recommend getting a simple setup working first.

Video here https://www.youtube.com/watch?v=-kSOTtYzgEw

This will help.. then look at Tools - CrewAI when you develop custom tools

Thank you , but im still running into the same error. I still need a help as reagrds to my code snippet below . i dont know if im passing my tools arguments correctly

from crewai import Agent
from textwrap import dedent
from langchain_openai import ChatOpenAI
from tools.search_tools import SearchTools
from tools.calculator_tools import CalculatorTools
class TravelAgents:
    def __init__(self):
        self.OpenAIGPT35 = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0.7)
        # self.OpenAIGPT4 = ChatOpenAI(model_name="gpt-4", temperature=0.7)
        # self.Ollama = Ollama(model="openhermes")

    def expert_travel_agent(self):
        return Agent(
            role="Expert Travel Agent",
            backstory=dedent(f"""Expert in Travel Planning and Logistics.
                             I have decades of experience making travel itineraries"""),
            goal=dedent(f"""create a 7-day travel itinerary with detailed per-day plans,
                        including budgets, packing suggestions, and safety trips."""),
            tools=[SearchTools().search_internet, CalculatorTools().calculate],
            allow_delegation=False,
            verbose=True,
            llm=self.OpenAIGPT35,
        )

    def city_selection_expert(self):
        return Agent(
            role="City Selection Agent",
            backstory=dedent(f"""Expert at analysing travel data to pick ideal cities for your travel
                             plans"""),
            goal=dedent(f"""Select the best cities bases on the weather,season,prices,and traveler interests"""),
            tools=[SearchTools().search_internet],
            allow_delegation=False,
            verbose=True,
            llm=self.OpenAIGPT35,
        )

    def local_tour_guide(self):
        return Agent(
            role="Local Tour Guide",
            backstory=dedent(f"""Knowledgable local guide with extensive information
                             about the city,its attraction and customs"""),
            goal=dedent(f"""Provide the BEST insights about the selected city"""),
            tools=[SearchTools().search_internet],
            allow_delegation=False,
            verbose=True,
            llm=self.OpenAIGPT35,
        )

It looks like you’re getting an error from your custom tools. you should follow this guide when creating your custom tools.

also, you don’t need the langchain model class here anymore. use the LLM class we provide to mitigate any issues that might come up later and also easier for us to debug for you.

Alright , i will just do that . Thank you

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.