#CrewAI:Agent unable to Access search model

I’ve built a search internet tool with EXA and although the API key seems to work , my agent indicates that he can’t use it.

Any help would be appreciated as I am beginner when it comes to coding.

Here are the codes that I’ve used for the search tools and the agents using crewAI.

Thank you in advance for your help :

import os
from exa_py import Exa
from langchain.agents import tool
from dotenv import load_dotenv
load_dotenv()

class ExasearchToolSet():
def _exa(self):
return Exa(api_key=os.environ.get(‘EXA_API_KEY’))
@tool
def search(self,query:str):
“””Useful to search the internet about a a given topic and return relevant results”””
return self._exa().search(f”{query}”,
use_autoprompt=True,num_results=3)
@tool
def find_similar(self,url: str):
“””Search for websites similar to url.
the url passed in should be a URL returned from ‘search'”””
return self._exa().find_similar(url,num_results=3)
@tool
def get_contents(self,ids: str):
“””gets content from website.
the ids should be passed as a list,a list of ids returned from ‘search'”””
ids=eval(ids)
contents=str(self._exa().get_contents(ids))
contents=contents.split(“URL:”)
contents=[content[:1000] for content in contents]
return “nn”.join(contents)

class TravelAgents:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>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"""I am an Expert in travel planning and logistics,
I have decades experiences making travel itineraries,
I easily identify good deals,
My purpose is to help the user to profit from a marvelous trip at a low cost"""),
goal=dedent(f"""Create a 7-days travel itinerary with detailed per-day plans,
Include budget , packing suggestions and safety tips"""),
tools=[ExasearchToolSet.search,ExasearchToolSet.get_contents,ExasearchToolSet.find_similar,perform_calculation],
allow_delegation=True,
verbose=True,llm=self.OpenAIGPT35,
)
def city_selection_expert(self):
return Agent(
role="City selection expert",
backstory=dedent(f"""I am a city selection expert,
I have traveled across the world and gained decades of experience.
I am able to suggest the ideal destination based on the user's interests,
weather preferences and budget"""),
goal=dedent(f"""Select the best cities based on weather, price and user's interests"""),
tools=[ExasearchToolSet.search,ExasearchToolSet.get_contents,ExasearchToolSet.find_similar,perform_calculation]
,
allow_delegation=True,
verbose=True,
llm=self.OpenAIGPT35,
)
def local_tour_guide(self):
return Agent(
role="Local tour guide",
backstory=dedent(f""" I am the best when it comes to provide the best insights about a city and
suggest to the user the best activities based on their personal interest
"""),
goal=dedent(f"""Give the best insights about the selected city
"""),
tools=[ExasearchToolSet.search,ExasearchToolSet.get_contents,ExasearchToolSet.find_similar,perform_calculation]
,
allow_delegation=False,
verbose=True,
llm=self.OpenAIGPT35,
)
</code>
<code>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"""I am an Expert in travel planning and logistics, I have decades experiences making travel itineraries, I easily identify good deals, My purpose is to help the user to profit from a marvelous trip at a low cost"""), goal=dedent(f"""Create a 7-days travel itinerary with detailed per-day plans, Include budget , packing suggestions and safety tips"""), tools=[ExasearchToolSet.search,ExasearchToolSet.get_contents,ExasearchToolSet.find_similar,perform_calculation], allow_delegation=True, verbose=True,llm=self.OpenAIGPT35, ) def city_selection_expert(self): return Agent( role="City selection expert", backstory=dedent(f"""I am a city selection expert, I have traveled across the world and gained decades of experience. I am able to suggest the ideal destination based on the user's interests, weather preferences and budget"""), goal=dedent(f"""Select the best cities based on weather, price and user's interests"""), tools=[ExasearchToolSet.search,ExasearchToolSet.get_contents,ExasearchToolSet.find_similar,perform_calculation] , allow_delegation=True, verbose=True, llm=self.OpenAIGPT35, ) def local_tour_guide(self): return Agent( role="Local tour guide", backstory=dedent(f""" I am the best when it comes to provide the best insights about a city and suggest to the user the best activities based on their personal interest """), goal=dedent(f"""Give the best insights about the selected city """), tools=[ExasearchToolSet.search,ExasearchToolSet.get_contents,ExasearchToolSet.find_similar,perform_calculation] , allow_delegation=False, verbose=True, llm=self.OpenAIGPT35, ) </code>
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"""I am an Expert in travel planning and logistics, 
                        I have decades experiences making travel itineraries,
                        I easily identify good deals,
                        My purpose is to help the user to profit from a marvelous trip at a low cost"""),
        goal=dedent(f"""Create a 7-days travel itinerary with detailed per-day plans,
                        Include budget , packing suggestions and safety tips"""),
        tools=[ExasearchToolSet.search,ExasearchToolSet.get_contents,ExasearchToolSet.find_similar,perform_calculation],
        allow_delegation=True,
        verbose=True,llm=self.OpenAIGPT35,
        )
    

def city_selection_expert(self):
    return Agent(
        role="City selection expert",
        backstory=dedent(f"""I am a city selection expert,
                        I have traveled across the world and gained decades of experience.
                        I am able to suggest the ideal destination based on the user's interests, 
                        weather preferences and budget"""),
        goal=dedent(f"""Select the best cities based on weather, price and user's interests"""),
        tools=[ExasearchToolSet.search,ExasearchToolSet.get_contents,ExasearchToolSet.find_similar,perform_calculation]
               ,
        allow_delegation=True,
        verbose=True,
        llm=self.OpenAIGPT35,
    )
def local_tour_guide(self):
    return Agent(
        role="Local tour guide",
        backstory=dedent(f""" I am the best when it comes to provide the best insights about a city and 
                        suggest to the user the best activities based on their personal interest 
                         """),
        goal=dedent(f"""Give the best insights about the selected city
                    """),
        tools=[ExasearchToolSet.search,ExasearchToolSet.get_contents,ExasearchToolSet.find_similar,perform_calculation]
               ,
        allow_delegation=False,
        verbose=True,
        llm=self.OpenAIGPT35,
    )

I have tested the API keys, Tried playing with prompt. I don’t understand why the agent can’t have Access to the search tool

New contributor

DAVID is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật