강의

멘토링

커뮤니티

Cộng đồng Hỏi & Đáp của Inflearn

Hình ảnh hồ sơ của awww
awww

câu hỏi đã được viết

Học Python Chatbot & RAG qua Dự án - Sử dụng LangChain, Gradio

creawai Agent 선언 부분 오류 문의

Viết

·

138

0

section 5 의 코드 중 crewai 의 Agent 선언에서 오류 발생합니다.

search_tool = TavilySearchResults()

researcher = Agent(
        role="Market Researcher",
        goal=f"Uncover emerging trends and investment opportunities in the cryptocurrency market in 2024. Focus on the topic: {topic}.",
        backstory="Identify groundbreaking trends and actionable insights.",
        verbose=True,
        tools=[search_tool], -> 이 부분 오류 발생
        allow_delegation=False,
        llm=llm,
        max_iter=3,
        max_rpm=10,
    )


pydantic_core._pydantic_core.ValidationError: 1 validation error for Agent
tools
  Value error, Invalid tool type: <class 'langchain_community.tools.tavily_search.tool.TavilySearchResults'>. Tool must be an instance of BaseTool or an object with 'name', 'func', and 'description' attributes. [type=value_error, input_value=[TavilySearchResults(api_...cretStr('**********')))], input_type=list]
    For further information visit https://errors.pydantic.dev/2.10/v/value_error

crewai 및 langchain 버전은 아래와 같습니다.


crewai 0.86.0

crewai-tools 0.17.0

langchain 0.3.10

langchain-community 0.3.10

챗봇gradiochatgptllmlangchainragopenai-api

Câu trả lời 1

1

pdstudio님의 프로필 이미지
pdstudio
Người chia sẻ kiến thức

안녕하세요. 판다스 스튜디오입니다.

교재의 실습코드는 수업자료에 설명드린 바와 같이, 아래의 환경에서 테스트했고 정상 실행되고 있습니다.
python = "^3.11, <3.13"

python-dotenv = "1.0.1"

langchain = "0.3.3"

langchain-openai = "0.2.2"

langchain-community = "0.3.2"

gradio = "5.0.2"

crewai = "0.76.9"

crewai-tools = "0.13.4"

tavily-python = "0.5.0"

duckduckgo-search = "6.3.3"

현재 사용하고 계시는 crewai, langchain 버전에서는 코드 변경이 있어서 오류가 발생하고 있습니다.
도구를 정의하는 부분을 아래와 같이 BasetTool 클래스로 래핑해주시면 정상적으로 실행됩니다.

from langchain.tools import Tool
from langchain_community.tools.tavily_search import TavilySearchResults

# Tool 인스턴스 생성
search_tool = Tool(
    name="Tavily Search",
    func=TavilySearchResults().run,
    description="Search the internet for current information on cryptocurrencies and market trends"
)

실행해보시고 계속 오류가 발생하면 다시 말씀해주세요.

감사합니다.

AWWW님의 프로필 이미지
AWWW
Người đặt câu hỏi

안녕하세요! 답변 감사합니다.

해달 클래스로 래핑하니 기존 오류는 발생하지 않는데 다른 오류 발생합니다.

아마도 제가 llm 을 openai 를 쓰지 않고 gemini 로 사용해서 그런것 같아요ㅠ

ERROR:root:Failed to get supported params: argument of type 'NoneType' is not iterable
Provider List: https://docs.litellm.ai/docs/providers

강의 코드 대신 아래 코드로 llm 선언해서 사용 중이거든요

from langchain_google_genai import ChatGoogleGenerativeAI

llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash", temperature=0)

이 부분은 좀 더 찾아봐야겠네요 ㅠㅠ

pdstudio님의 프로필 이미지
pdstudio
Người chia sẻ kiến thức

안녕하세요. 답글 감사드립니다.

gemini api의 tool calling 부분에서 이슈가 있을 것 같습니다.

이 부분을 저도 한번 확인해보겠습니다.

감사합니다.

Hình ảnh hồ sơ của awww
awww

câu hỏi đã được viết

Đặt câu hỏi