작성
·
119
0
안녕하세요! 열심히 수강중입니다.
다름이 아니고 멀티에이전트를 만드는 과정에서
분명히 체인이 잘 작동하는데
그라디오에서만 에러가 나고 있어요.
또한 처리 속도도 20초가 넘어가서
제가 어떤 부분을 실수하고 있는지 강사님의 조언이 필요합니다.
아래는 에러 화면과 코드입니다.
import os
from dotenv import load_dotenv
load_dotenv()
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
TAVILY_API_KEY = os.getenv('TAVILY_API_KEY')
from crewai import Agent, Task, Crew, Process
from langchain_openai import ChatOpenAI
from langchain_community.tools.tavily_search import TavilySearchResults
from crewai_tools import WebsiteSearchTool
import gradio as gr
# LLM
llm = ChatOpenAI(model='gpt-3.5-turbo', temperature=0, api_key=OPENAI_API_KEY)
# Instantiate tools
search_tool = TavilySearchResults(api_key=TAVILY_API_KEY)
web_rag_tool = WebsiteSearchTool()
def test_crew(topic):
researcher = Agent(
role='Market Research Analyst',
goal=f'Provide up-to-date market analysis of AI video editing tool. Focus on the topic: {topic}',
backstory='An expert analyst with a keen eye for AI video editing market trends.',
tools=[search_tool, web_rag_tool],
allow_delegation=False,
verbose=True,
llm=llm,
max_iter=3,
max_rpm=10,
function_calling="ALWAYS"
)
reporter = Agent(
role='Content Writer',
goal=f'Analyze AI video editing market data to extract actionable insights and business decision in developing AI video editing products. Focus on the topic: {topic}',
backstory='A skilled writer with a passion for technology.',
allow_delegation=False,
llm=llm
)
# Define tasks
research = Task(
description=f'Explore the internet to pinpoint emerging trends and potential AI video editing tool development opportunities. Focus on the topic: {topic}',
expected_output='A summary of the top 3 key insights in developing competitive AI video editing tool. Make sure to add reference Webpages. Also name trending services',
agent=researcher
)
report = Task(
description=f'Analyze AI video editing market data to extract actionable insights and business decision in developing AI video editing products based on the research of the previous agent. Plus name the current trending services.',
expected_output=f'A 4-paragraph reports formatted in markdown with engaging, informative, and accessible content, avoiding complex jargon. Make sure to add reference Webpages and compile a concise report in Korean Hangul. Focus on the topic: {topic}',
agent=reporter
)
# Assemble a crew with planning enabled
my_crew = Crew(
agents=[researcher, reporter],
tasks=[research, report],
process=Process.sequential
)
# Execute tasks
result = my_crew.kickoff()
return result
def process_query(message, history):
topic = "비디오 편집 트렌드" # 사용자 메시지 또는 컨텍스트에 따라 주제 정의
return test_crew(topic)
if __name__ == '__main__':
app = gr.ChatInterface(
fn=process_query,
title="AI 비디오 트랜드 봇",
description="AI 비디오 편집 도구 트렌드를 파악하여 투자 인사이트를 제공합니다."
)
app.launch()
답변 1
0
안녕하세요, 인프런 AI 인턴입니다.
님께서 제공하신 코드와 에러 화면을 기반으로 문제를 분석해 보았습니다만, 인프런에서 제공하는 정보와는 관련이 없는 질문이네요.
에러 메시지와 처리 속도 문제는 코드 내부의 로직, 외부 API 호출, 또는 gradio 라이브러리의 사용 방법에 대한 이해에서 발생할 수 있습니다. 이러한 문제를 해결하기 위해선 다음의 접근 방법이 도움이 될 수 있습니다:
OPENAI_API_KEY
와 TAVILY_API_KEY
가 정확하게 설정되었는지, 해당 API 서비스들의 호출 제한을 초과하지 않았는지 확인하세요.ChatInterface
및 관련 함수들을 올바르게 사용하고 있는지 점검하세요.제가 직접적인 해결책을 제공해드리기 어려운 점 양해 부탁드립니다. 더 구체적인 도움이 필요하시면, 관련 기술 커뮤니티나 gradio 관련 포럼을 통해 도움을 요청해보시는 것을 추천드립니다.