Here are three highlights from Elon Musk's biography: 1. Elon Musk was born in Pretoria, South Africa, to model Maye and businessman and engineer Errol Musk. He briefly attended the University of Pretoria before immigrating to Canada. 2. Musk founded X.com in 1999, which later became PayPal, SpaceX in 2002, and Tesla. He is widely known for his work with electric vehicles and space exploration. 3. Elon Musk is a creative genius known for his tenacious resilience. Despite his extraordinary success, he remains human enough to allow others to see him at his most vulnerable.
# Define Search Agent search_agent = Agent( role='Search Agent', goal="Search for the latest news about the topic {topic}", backstory="You are an expert at searching for information on the internet and always keep up with the latest news.", memory = True, verbose = True, callbacks=[MyCustomHandler("SearchAgent")], tools = [SearchTools.search_internet] )
# Define Download Agent download_agent = Agent( role='Download Agent', goal="Download and summarize the main content from the list of URL", backstory="You are an expert at downloading and summarizing content from articles on the internet.", memory=True, verbose=True, callbacks=[MyCustomHandler("DownloadAgent")], tools = [BrowserTools.using_newspaper4k_scrape_and_summarize_website] )
# Define Newsletter Agent newsletter_agent = Agent( role='Newsletter Agent', goal='Create a newsletter aggregating news from a list of article summaries', backstory='You are an expert at aggregating news and creating engaging and easy-to-read newsletters.', callbacks=[MyCustomHandler("NewsletterAgent")], memory=True, verbose=True, tools = [NewsletterTools.create_newsletter] )
# search_task: search for topic via internet search_task = Task( description=( "Search and return a list of URLs related to the topic: {topic}." ), expected_output='List of URLs.', agent=search_agent, )
# download_task: download the content from each received URL download_task = Task( description=( "Download content from each URL in the list and summarize the main content of each URL" ), expected_output='A summary of the main content of URL', agent=download_agent, context = [search_task] )
# create_newsletter_task: aggregating the summary results from download_task create_newsletter_task = Task( description=( "Create a newsletter from a list of article summaries and the URL list" ), expected_output='A newsletter aggregating articles including a title and brief description.', context = [search_task, download_task], agent=newsletter_agent, )
# Handle responses from CrewAI and show it on streamlit chat_message classMyCustomHandler(BaseCallbackHandler): def__init__(self, agent_name: str) -> None: self.agent_name = agent_name
for msg in st.session_state.messages: if msg["role"] in avatars.keys(): st.chat_message(msg["role"], avatar=avatars[msg["role"]]).write(msg["content"]) else: st.chat_message(msg["role"]).write(msg["content"])
if prompt := st.chat_input(): st.session_state.messages.append({"role": "user", "content": prompt}) st.chat_message("user").write(prompt)
market_data_task = Task( description=""" Collect market data from crypto exchanges, including prices, trading volumes, and technical indicators. """, expected_output="A dataset containing prices, trading volumes, and technical indicators from exchanges.", agent=market_data_collector )
分析加密新闻
1 2 3 4 5 6 7 8 9 10
from crewai import Task
news_analysis_task = Task( description=""" Summarize news articles, press releases, and market analyses related to crypto. """, expected_output="A report summarizing the latest news, press releases, and market analyses related to crypto.", agent=news_analyzer
)
进行技术分析
1 2 3 4 5 6 7 8 9
from crewai import Task
technical_analysis_task = Task( description=""" Analyze price charts and technical indicators to predict market trends. """, expected_output="A technical analysis report including price charts and market trend predictions.", agent=technical_analyst )
评估市场情绪
1 2 3 4 5 6 7 8 9
from crewai import Task
sentiment_analysis_task = Task( description=""" Analyze market sentiment through social media and forums to gauge investor sentiment. """, expected_output="A report analyzing market sentiment from social media and forums.", agent=sentiment_analyst )
制定投资策略:
1 2 3 4 5 6 7 8 9 10
from crewai import Task
investment_strategy_task = Task( description=""" Combine analyses from other agents to provide comprehensive investment recommendations. """, expected_output="A comprehensive investment strategy report combining technical analysis, news analysis, and sentiment analysis.", agent=investment_strategist, context=[market_data_task, news_analysis_task, technical_analysis_task, sentiment_analysis_task] )
团队
1 2 3 4 5 6 7 8 9 10 11
from crewai import Crew
# Create a Crew with the agents and tasks crypto_analytics_crew = Crew( agents=[market_data_collector, news_analyzer, technical_analyst, sentiment_analyst, investment_strategist], tasks=[market_data_task, news_analysis_task, technical_analysis_task, sentiment_analysis_task, investment_strategy_task] )
# Kick off the Crew with specific input information result = crypto_analytics_crew.kickoff(inputs={"input": "Bitcoin"}) print(result)