"\t\t\t# process=Process.hierarchical, # In case you wanna use that instead https://docs.crewai.com/how-to/Hierarchical/\n",
"\t\t)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[1m\u001b[95m# Agent:\u001b[00m \u001b[1m\u001b[92mRetrieve relevant information to answer the user query: Who is elon musk?\u001b[00m\n",
"\u001b[95m## Task:\u001b[00m \u001b[92mRetrieve the most relevant information from the available sources for the user query: Who is elon musk?\n",
"\u001b[00m\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/akshaypachaar/miniconda3/envs/env_crewai/lib/python3.10/site-packages/crewai/tools/tool_usage.py:162: PydanticDeprecatedSince20: The `schema` method is deprecated; use `model_json_schema` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.10/migration/\n",
" acceptable_args = tool.args_schema.schema()[\"properties\"].keys() # type: ignore # Item \"None\" of \"type[BaseModel] | None\" has no attribute \"schema\"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\u001b[1m\u001b[95m# Agent:\u001b[00m \u001b[1m\u001b[92mRetrieve relevant information to answer the user query: Who is elon musk?\u001b[00m\n",
"\u001b[95m## Thought:\u001b[00m \u001b[92mI will first search for relevant information in the available documents about Elon Musk.\u001b[00m\n",
"\u001b[95m## Using tool:\u001b[00m \u001b[92mDocumentSearchTool\u001b[00m\n",
"chocolates left = total chocolates - chocolates eaten\n",
"result = chocolates left\n",
"return result\n",
"\n",
"\u001b[00m\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/akshaypachaar/miniconda3/envs/env_crewai/lib/python3.10/site-packages/crewai/tools/tool_usage.py:162: PydanticDeprecatedSince20: The `schema` method is deprecated; use `model_json_schema` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.10/migration/\n",
" acceptable_args = tool.args_schema.schema()[\"properties\"].keys() # type: ignore # Item \"None\" of \"type[BaseModel] | None\" has no attribute \"schema\"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\u001b[1m\u001b[95m# Agent:\u001b[00m \u001b[1m\u001b[92mRetrieve relevant information to answer the user query: Who is elon musk?\u001b[00m\n",
"\u001b[95m## Thought:\u001b[00m \u001b[92mThought: The search in the document did not yield relevant information regarding Elon Musk. I will now conduct a web search to find the information.\u001b[00m\n",
"\u001b[95m## Using tool:\u001b[00m \u001b[92mSearch the internet\u001b[00m\n",
"Snippet: In 2017, SpaceX made further history by re-flying both a Falcon 9 rocket and Dragon spacecraft for the first time. By pioneering the development of reusable ...\n",
"Snippet: Elon is Technoking of Tesla and has served as our Chief Executive Officer since October 2008 and as a member of the Board since April 2004.\n",
"Snippet: Real Time Net Worth · Elon Musk cofounded seven companies, including electric car maker Tesla, rocket producer SpaceX and artificial intelligence startup xAI.\n",
"---\n",
"Title: Elon Musk changes his name to Kekius Maximus on X - BBC\n",
"Snippet: The world's richest man sparks speculation after changing his name and using a picture of Pepe the Frog.\n",
"---\n",
"Title: Elon Musk | Tesla\n",
"Link: https://www.tesla.com/elon-musk\n",
"Snippet: As the co-founder and CEO of Tesla, Elon leads all product design, engineering and global manufacturing of the company's electric vehicles, battery products ...\n",
"Snippet: Elon Musk is the CEO of electric-vehicle maker Tesla, whose board he joined in 2004. During his two decades there, the company has grown to be the global ...\n",
"Snippet: Elon Musk, the South African-born entrepreneur widely known as the founder of SpaceX and Tesla, is renowned for his advances in electric vehicles and space ...\n",
"---\n",
"Title: How did Elon Musk become the most powerful man in Washington?\n",
"Snippet: Elon Musk, the world's richest man, is also the most powerful man in Washington right now. The panel discusses how this came to be and if ...\n",
"---\n",
"\n",
"\n",
"\n",
"You ONLY have access to the following tools, and should NEVER make up tools that are not listed here:\n",
"\n",
"Tool Name: DocumentSearchTool\n",
"Tool Arguments: {'query': {'description': 'Query to search the document.', 'type': 'str'}}\n",
"Tool Description: Search the document for the given query.\n",
"Tool Name: Search the internet\n",
"Tool Arguments: {'search_query': {'description': 'Mandatory search query you want to use to search the internet', 'type': 'str'}}\n",
"Tool Description: A tool that can be used to search the internet with a search_query.\n",
"\n",
"Use the following format:\n",
"\n",
"Thought: you should always think about what to do\n",
"Action: the action to take, only one name of [DocumentSearchTool, Search the internet], just the name, exactly as it's written.\n",
"Action Input: the input to the action, just a simple python dictionary, enclosed in curly braces, using \" to wrap keys and values.\n",
"Observation: the result of the action\n",
"\n",
"Once all necessary information is gathered:\n",
"\n",
"Thought: I now know the final answer\n",
"Final Answer: the final answer to the original input question\n",
"\u001b[00m\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/akshaypachaar/miniconda3/envs/env_crewai/lib/python3.10/site-packages/crewai/tools/tool_usage.py:162: PydanticDeprecatedSince20: The `schema` method is deprecated; use `model_json_schema` instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.10/migration/\n",
" acceptable_args = tool.args_schema.schema()[\"properties\"].keys() # type: ignore # Item \"None\" of \"type[BaseModel] | None\" has no attribute \"schema\"\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\u001b[1m\u001b[95m# Agent:\u001b[00m \u001b[1m\u001b[92mRetrieve relevant information to answer the user query: Who is elon musk?\u001b[00m\n",
"\u001b[95m## Thought:\u001b[00m \u001b[92mThought: I have found multiple relevant sources from the web about Elon Musk. I will now extract the complete content from the best source.\u001b[00m\n",
"\u001b[95m## Using tool:\u001b[00m \u001b[92mSearch the internet\u001b[00m\n",
"Snippet: Elon Reeve Musk is a businessman known for his key roles in the space company SpaceX and the automotive company Tesla, Inc. He is also known for his ...\n",
"---\n",
"Title: Elon Musk: Biography, Entrepreneur, SpaceX and Tesla Founder\n",
"Snippet: Elon Reeve Musk was born on June 28, 1971, in Pretoria, South Africa. His mother, Maye Musk, is a Canadian model and the oldest woman to star in ...\n",
"Snippet: The #1 New York Times bestseller from the author of Steve Jobs--this is the astonishingly intimate story of the most fascinating and controversial innovator of our era--a rule-breaking visionary who helped to lead the world into the era of electric vehicles, private space exploration, and artificial intelligence.\n",
"---\n",
"Title: Elon Musk | Book by Walter Isaacson | Official Publisher Page\n",
"Snippet: The #1 New York Times bestseller from the author of Steve Jobs--this is the astonishingly intimate story of the most fascinating and controversial innovator of our era--a rule-breaking visionary who helped to lead the world into the era of electric vehicles, private space exploration, and artificial intelligence.\n",
"Snippet: South African-born American entrepreneur who cofounded the electronic-payment firm PayPal and formed SpaceX, maker of launch vehicles and spacecraft.\n",
"---\n",
"Title: Book Review: 'Elon Musk,' by Walter Isaacson - The New York Times\n",
"Snippet: Walter Isaacson's biography of the billionaire entrepreneur depicts a mercurial “man-child” with grandiose ambitions and an ego to match.\n",
"---\n",
"Title: Who is Elon Musk and what is his net worth? - BBC\n",
"Snippet: Born in Pretoria, South Africa, Mr Musk showed his talents for entrepreneurship early, going door-to-door with his brother selling homemade ...\n",
"---\n",
"Title: Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future\n",
"Snippet: In the spirit of Steve Jobs and Moneyball, Elon Musk is both an illuminating and authorized look at the extraordinary life of one of Silicon Valley's most exciting, unpredictable, and ambitious entrepreneurs--a real-life Tony Stark--and a fascinating exploration of the renewal of American invention and its new ``makers.''\n",
"Snippet: Elon Musk: the name synonymous with Tesla, SpaceX, and audacious dreams of colonizing Mars. But what's the man behind the ambition?\n",
"---\n",
"\u001b[00m\n",
"\n",
"\n",
"\u001b[1m\u001b[95m# Agent:\u001b[00m \u001b[1m\u001b[92mRetrieve relevant information to answer the user query: Who is elon musk?\u001b[00m\n",
"\u001b[95m## Final Answer:\u001b[00m \u001b[92m\n",
"**Elon Reeve Musk** (born June 28, 1971) is a South African-born American entrepreneur and business magnate. He is the founder, CEO, and chief engineer of SpaceX; early investor, CEO, and product architect of Tesla, Inc.; founder of The Boring Company; co-founder of Neuralink; and co-founder and initial co-chairman of OpenAI. Musk is known for his ambitious vision for the future, including the colonization of Mars and the advent of sustainable energy. \n",
"\n",
"Born in Pretoria, South Africa, Musk showed an early interest in computing and technology. He taught himself computer programming at a young age and created a video game, which he sold at the age of 12. After moving to the U.S. to study at the University of Pennsylvania, Musk dropped out to pursue his entrepreneurial ambitions, co-founding Zip2, X.com, which later became PayPal, and then aiming to revolutionize transportation with his work on electric vehicles through Tesla.\n",
"\n",
"Musk established SpaceX in 2002 to reduce space transportation costs and enable the colonization of Mars. He made significant advancements with the Falcon rocket series and the Dragon spacecraft. With Tesla, Musk aims to accelerate the world's transition to sustainable energy, to help combat climate change.\n",
"\n",
"Musk has been recognized for his contributions and endeavors in the technology industry and has been listed among the most powerful and influential people in the world.\n",
"\n",
"For a more detailed exploration of his life, contributions, and impact, you can read further on his [Wikipedia page](https://en.wikipedia.org/wiki/Elon_Musk).\u001b[00m\n",
"\n",
"\n",
"\u001b[1m\u001b[95m# Agent:\u001b[00m \u001b[1m\u001b[92mResponse synthesizer agent for the user query: Who is elon musk?\u001b[00m\n",
"\u001b[95m## Task:\u001b[00m \u001b[92mSynthesize the final response for the user query: Who is elon musk?\n",
"\u001b[00m\n",
"\n",
"\n",
"\u001b[1m\u001b[95m# Agent:\u001b[00m \u001b[1m\u001b[92mResponse synthesizer agent for the user query: Who is elon musk?\u001b[00m\n",
"\u001b[95m## Final Answer:\u001b[00m \u001b[92m\n",
"**Elon Reeve Musk** (born June 28, 1971) is a South African-born American entrepreneur and business magnate, renowned for his groundbreaking contributions in various technology sectors. He is the founder, CEO, and chief engineer of SpaceX; an early investor, CEO, and product architect of Tesla, Inc.; the founder of The Boring Company; and a co-founder of Neuralink and OpenAI. Musk is celebrated for his ambitious vision for the future, which includes plans for the colonization of Mars and the promotion of sustainable energy.\n",
"\n",
"Born in Pretoria, South Africa, Musk displayed a keen interest in computing from a young age, teaching himself programming and creating a video game that he sold by the age of 12. He moved to the United States to study at the University of Pennsylvania but left before completing his degree to pursue entrepreneurial ventures, co-founding Zip2 and later X.com, which evolved into PayPal. His ambitions continued with Tesla, where he aims to revolutionize transportation through electric vehicles and combat climate change.\n",
"\n",
"Musk started SpaceX in 2002 with the goal of reducing space transportation costs and enabling the colonization of Mars, achieving significant milestones with the Falcon rocket series and the Dragon spacecraft. Recognized globally, Musk has been cited as one of the most powerful and influential people in the world due to his innovative works and contributions to technology. For further details about his life and impact, refer to his [Wikipedia page](https://en.wikipedia.org/wiki/Elon_Musk).\u001b[00m\n",
"\n",
"\n",
"**Elon Reeve Musk** (born June 28, 1971) is a South African-born American entrepreneur and business magnate, renowned for his groundbreaking contributions in various technology sectors. He is the founder, CEO, and chief engineer of SpaceX; an early investor, CEO, and product architect of Tesla, Inc.; the founder of The Boring Company; and a co-founder of Neuralink and OpenAI. Musk is celebrated for his ambitious vision for the future, which includes plans for the colonization of Mars and the promotion of sustainable energy.\n",
"\n",
"Born in Pretoria, South Africa, Musk displayed a keen interest in computing from a young age, teaching himself programming and creating a video game that he sold by the age of 12. He moved to the United States to study at the University of Pennsylvania but left before completing his degree to pursue entrepreneurial ventures, co-founding Zip2 and later X.com, which evolved into PayPal. His ambitions continued with Tesla, where he aims to revolutionize transportation through electric vehicles and combat climate change.\n",
"\n",
"Musk started SpaceX in 2002 with the goal of reducing space transportation costs and enabling the colonization of Mars, achieving significant milestones with the Falcon rocket series and the Dragon spacecraft. Recognized globally, Musk has been cited as one of the most powerful and influential people in the world due to his innovative works and contributions to technology. For further details about his life and impact, refer to his [Wikipedia page](https://en.wikipedia.org/wiki/Elon_Musk).\n"
]
}
],
"source": [
"result = crew.kickoff(inputs={\"query\": \"Who is elon musk?\"})\n",
# Understand the user query: {query}, and route it to the most appropriate knowledge base
# goal: >
# Route user queries to the most appropriate knowledge base
# backstory: >
# You are a user query routing agent. You are knowln for your ability to carefully understand user queries and route them to the most appropriate knowledge base.
retriever_agent:
role:>
Retrieve relevant information to answer the user query: {query}
goal:>
Retrieve the most relevant information from the available sources for the user query: {query}, always try to use the pdf search tool first. If you are not able to retrieve the information from the pdf search tool then try to use the web search tool.
backstory:>
You're a meticulous analyst with a keen eye for detail. You're known for
your ability understand the user query: {query} and retrieve knowlege from the most suitable knowledge base.
response_synthesizer_agent:
role:>
Response synthesizer agent for the user query: {query}
goal:>
Synthesize the retrieved information into a concise and coherent response based on the user query: {query}. If you are not ble to retrieve the information then respond with "I'm sorry, I couldn't find the information you're looking for."
backstory:>
You're a skilled communicator with a knack for turning complex information into clear and concise responses.
# Understand the user query: {query}, and route it to the most appropriate knowledge base
# expected_output: >
# The most appropriate knowledge base to route the user query to, the answer should be either 'pdf_search' or 'pdf_search'
# agent: routing_agent
retrieval_task:
description:>
Retrieve the most relevant information from the available sources for the user query: {query}
expected_output:>
The most relevant information in form of text as retrieved from the sources.
agent:retriever_agent
response_task:
description:>
Synthesize the final response for the user query: {query}
expected_output:>
A concise and coherent response based on the retrieved infromation from the right source for the user query: {query}. If you are not ble to retrieve the information then respond with "I'm sorry, I couldn't find the information you're looking for."
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.