재미있는 AI를 발견해서 Getting Started 를 따라해 보았습니다.
crewAI - Platform for Multi AI Agents Systems
윈도우10에서 wsl2 로 Ubuntu 를 설치 한후에, 테스트를 했습니다.
Ubuntu 22.04
python 3.12.4
따라한 예제
Assembling and Activating Your CrewAI Team - crewAI
예제를 그대로 따라하면 일단
BrowserbaseTool, ExaSearchTool 가 없다고 오류가 납니다.
수정중인건지 아님 못찾는건지 확인은 안되었으니,
어쨌든 이름을 모두 바꿔 줍니다.
BrowserbaseTool -> BrowserbaseLoadTool
ExaSearchTool -> EXASearchTool
그리고, 예제에서는 openai, serperapi 만 가입해서 키를 쓰면 된다고 하는거 같은데, 아닙니다 -_-;
browserbase 라는 사이트와 exa 라는 사이트도 가입해서 api key 를 받아야 하고, 키를 모두 선언해야
정상적으로 동작 합니다.
Serper - The World's Fastest and Cheapest Google Search API
Browserbase: Headless browsers for AI agents & applications
모두가입해서, key를 획득후, 샘플소스의 최상단에 써주면 됩니다.
import os
os.environ["SERPER_API_KEY"] = "key" # serper.dev API key
os.environ["OPENAI_API_KEY"] = "key"
os.environ["BROWSERBASE_API_KEY"]="key"
os.environ["BROWSERBASE_PROJECT_ID"] ="id"
os.environ["EXA_API_KEY"] = "key"
from crewai import Agent
from crewai_tools import SerperDevTool, BrowserbaseLoadTool, EXASearchTool
search_tool = SerperDevTool()
browser_tool = BrowserbaseLoadTool()
exa_search_tool = EXASearchTool()
# Creating a senior researcher agent with memory and verbose mode
researcher = Agent(
role='Senior Researcher',
goal='Uncover groundbreaking technologies in {topic}',
verbose=True,
memory=True,
backstory=(
"Driven by curiosity, you're at the forefront of"
"innovation, eager to explore and share knowledge that could change"
"the world."
),
tools=[search_tool, browser_tool],
)
# Creating a writer agent with custom tools and delegation capability
writer = Agent(
role='Writer',
goal='Narrate compelling tech stories about {topic}',
verbose=True,
memory=True,
backstory=(
"With a flair for simplifying complex topics, you craft"
"engaging narratives that captivate and educate, bringing new"
"discoveries to light in an accessible manner."
),
tools=[exa_search_tool],
allow_delegation=False
)
# Setting a specific manager agent
manager = Agent(
role='Manager',
goal='Ensure the smooth operation and coordination of the team',
verbose=True,
backstory=(
"As a seasoned project manager, you excel in organizing"
"tasks, managing timelines, and ensuring the team stays on track."
)
)
from crewai import Task
# Research task
research_task = Task(
description=(
"Identify the next big trend in {topic}."
"Focus on identifying pros and cons and the overall narrative."
"Your final report should clearly articulate the key points,"
"its market opportunities, and potential risks."
),
expected_output='A comprehensive 3 paragraphs long report on the latest AI trends.',
tools=[search_tool],
agent=researcher,
callback="research_callback", # Example of task callback
human_input=True
)
# Writing task with language model configuration
write_task = Task(
description=(
"Compose an insightful article on {topic}."
"Focus on the latest trends and how it's impacting the industry."
"This article should be easy to understand, engaging, and positive."
"Write in Korean"
),
expected_output='A 4 paragraph article on {topic} advancements formatted as markdown.',
tools=[exa_search_tool],
agent=writer,
output_file='new-blog-post.md', # Example of output customization
)
from crewai import Crew, Process
# Forming the tech-focused crew with some enhanced configurations
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, write_task],
process=Process.sequential, # Optional: Sequential task execution is default
memory=True,
cache=True,
max_rpm=100,
manager_agent=manager
)
if __name__ == "__main__":
# Starting the task execution process with enhanced feedback
result = crew.kickoff(inputs={'topic': 'AI in healthcare'})
print(result)
그리고 실행하면 자기-_-들끼리 이야기를 하다가, 결과가 나옵니다.
Finished chain 이후를 보면 됩니다.