[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"metadata-\u002Fdata-science-blog\u002Fcoding-tutorial\u002Fhow-to-build-your-own-ai-agent":3,"opportunityTypes":4,"blogArticle":5},{},true,{"_id":6,"slug":7,"title":8,"robots":9,"publishingDate":10,"blogCategory":11,"domain":15,"company":19,"contact":19,"featuredImage":20,"intro":21,"content":22,"blogTags":23,"author":24,"createdAt":34,"updatedAt":35,"__v":36},"67855afbd41908a4f2757459","how-to-build-your-own-ai-agent","How to build Your own AI Agent","index\u002Ffollow","2025-01-13T17:36:08.691Z",{"_id":12,"slug":13,"title":14},"5ee74c240559717ed1c481c3","coding-tutorial","Coding Tutorial",{"_id":16,"slug":17,"title":18},"5f7c21782175a07c208127a3","data-analytics-and-ai","Data Analytics & AI",null,"https:\u002F\u002Faigents-files.s3.eu-west-1.amazonaws.com\u002Fproduction\u002F1736789789768_how_to_build_your_own_ai_Agent_1.jpg","Use the power of advanced technology to automate and streamline your tasks. AI agents are the current trend in artificial intelligence research and application for a good reason. This article will be a good introduction for those who want to upskill themselves in the AI agent field. ","\u003Cp>\u003Cspan style=\"font-weight: 400;\">AI is everywhere. Whenever we go into social media or have conversations with our family members, AI topics will make their way into another.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">But why have AI topics become so hot these days? It&rsquo;s because of the potential to automatically perform tasks that usually take time but can be done quickly with AI.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Since the launch of the ChatGPT product, the possibility of a Large Language Model (LLM) application for people's works has become a highlight. This becomes even more apparent with the introduction of stronger reasoning models, where the model can &ldquo;think&rdquo; better than the previous iteration.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">The topic of AI Agents has gained momentum as models have improved their reasoning abilities. While the concept of agents existed long before LLMs became popular, it&rsquo;s only recently that they&rsquo;ve surged in popularity&mdash;thanks to their ability to perceive their environment and take actions to achieve specific goals.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">As Agents become essential in the technology and business world, we will explore what Agents are and how to build your own in this article.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Ch1>\u003Cstrong>What is an AI Agent?\u003C\u002Fstrong>\u003C\u002Fh1>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Before we proceed with the technical tutorial, let&rsquo;s first understand what an AI agent is.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">As stated previously, an agent can perceive anything in its environment and act on that environment to achieve the goal. Conceptually, the agent is an entity that can make decisions independently given its situation. The image below shows how agents work at a high level.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cimg src=\"https:\u002F\u002Faigents-co.imgix.net\u002Fproduction\u002F1736788461109_how_to_build_your_own_ai_Agent_2.jpg?w=600&amp;auto=format,compress\" alt=\"\" \u002F>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Imagine a human as the agent. A human can perceive external stimuli from the environment through its sensors (eye, ear, etc.) and act on the environment using its actuators (hand, feet, etc.). To process and act upon all the information, the agent will require a core that can make decisions (brain).\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">The concept of agent above is formalized in computer science as software or systems that can act autonomously to achieve goals predating the idea of AI Agents, in which we use Artificial Intelligence as the Agent core. The earliest example of AI Agents is \u003C\u002Fspan>\u003Ca href=\"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FELIZA\">\u003Cspan style=\"font-weight: 400;\">ELIZA\u003C\u002Fspan>\u003C\u002Fa>\u003Cspan style=\"font-weight: 400;\">, a conversational program that uses pattern matching to simulate human-like dialogue.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">As technology evolves, so do AI agents. In a \u003C\u002Fspan>\u003Ca href=\"https:\u002F\u002Fwww.kaggle.com\u002Fwhitepaper-agents\">\u003Cspan style=\"font-weight: 400;\">recent publication, the Google team\u003C\u002Fspan>\u003C\u002Fa>\u003Cspan style=\"font-weight: 400;\"> introduced a clear definition of AI Agents and outlined their key components. The team defines AI Agents in this document as &ldquo;Autonomous systems that can observe the environment, reason about their goals, and take action using external tools.&rdquo;\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">This means that the Agent is a system capable of reasoning about its actions based on input.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">AI Agents core doesn&rsquo;t run by itself but relies on cognitive architecture. It&rsquo;s an architecture comprised of three components, including:\u003C\u002Fspan>\u003C\u002Fp>\n\u003Col>\n\u003Cli style=\"font-weight: 400;\" aria-level=\"1\">\u003Cspan style=\"font-weight: 400;\">Model: The language model (LM) is the central decision-making engine.\u003C\u002Fspan>\u003C\u002Fli>\n\u003Cli style=\"font-weight: 400;\" aria-level=\"1\">\u003Cspan style=\"font-weight: 400;\">Tools: Allowing the model to interact with the external systems.\u003C\u002Fspan>\u003C\u002Fli>\n\u003Cli style=\"font-weight: 400;\" aria-level=\"1\">\u003Cspan style=\"font-weight: 400;\">Orchestration: Governs how the agents accept information and are responsible for maintaining memory, state, reasoning, and planning.\u003C\u002Fspan>\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">If we illustrate the architecture, it will look like the image below.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cimg src=\"https:\u002F\u002Faigents-co.imgix.net\u002Fproduction\u002F1736788475793_how_to_build_your_own_ai_Agent_3.jpg?w=600&amp;auto=format,compress\" alt=\"\" \u002F>\u003Cbr \u002F>\u003Cbr \u002F>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Each component complements how the AI Agents work, but not every component necessarily needs to be present. For example, AI Agents can still perform without access to the tools.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">That is a quick introduction to AI Agents. Let&rsquo;s move on to the central part of the article, which is developing your own AI Agent.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Ch1>\u003Cstrong>Develop AI Agent with CrewAI\u003C\u002Fstrong>\u003C\u002Fh1>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Several AI Agent development frameworks have already been released&mdash;some have been around for a few years, while others are still in the experimental stage. However, I believe it&rsquo;s not about which framework you use but how you leverage it to solve the problem.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">For the tutorial on developing your own AI Agent, we will use the \u003C\u002Fspan>\u003Ca href=\"https:\u002F\u002Fdocs.crewai.com\u002Fintroduction\">\u003Cspan style=\"font-weight: 400;\">CrewAI\u003C\u002Fspan>\u003C\u002Fa>\u003Cspan style=\"font-weight: 400;\"> framework, as it&rsquo;s the most popular library and has an easy-to-use API.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">To start with the tutorial, we will install all the libraries we require for the tutorial. You can use the following code to do it.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\">pip install crewai crewai-tools langchain langchain-community duckduckgo-search arxiv\u003C\u002Fspan>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Once the libraries are installed, we can begin building the agent.&nbsp;\u003C\u002Fspan>\u003C\u002Fp>\n\u003Ch2>\u003Cstrong>Develop Individual Agent\u003C\u002Fstrong>\u003C\u002Fh2>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Let&rsquo;s create an individual agent using CrewAI that is designed to perform a specific task.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">First, we need to decide which LLM to use. Since CrewAI integrates multiple LLM providers through \u003C\u002Fspan>\u003Ca href=\"https:\u002F\u002Fgithub.com\u002FBerriAI\u002Flitellm\">\u003Cspan style=\"font-weight: 400;\">LiteLLM\u003C\u002Fspan>\u003C\u002Fa>\u003Cspan style=\"font-weight: 400;\">, any model supported by LiteLLM can be used as the agent&rsquo;s core model. We will use the \u003C\u002Fspan>\u003Ca href=\"https:\u002F\u002Fai.google.dev\u002Fgemini-api\u002Fdocs\u002Fmodels\u002Fgemini#gemini-1.5-flash\">\u003Cspan style=\"font-weight: 400;\">Gemini-1.5-Flash\u003C\u002Fspan>\u003C\u002Fa>\u003Cspan style=\"font-weight: 400;\"> model for our tutorial, so remember to acquire the API Key from \u003C\u002Fspan>\u003Ca href=\"https:\u002F\u002Faistudio.google.com\u002F?model=gemini-1.5-flash\">\u003Cspan style=\"font-weight: 400;\">Google AI Studio\u003C\u002Fspan>\u003C\u002Fa>\u003Cspan style=\"font-weight: 400;\">.&nbsp;\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Let&rsquo;s start by initiating the model using the following code.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\">from\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> crewai \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">import\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> Agent, LLM\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">llm = LLM(model=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">'gemini\u002Fgemini-1.5-flash'\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;api_key=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">'GEMINI-API-KEY'\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> )\u003C\u002Fspan>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Next, we will start to set up the agent. In this example, we will have an agent that can assist us in learning a new language. To do that, we will use the following code.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\">language_tutor_agent = Agent(\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;role=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Language Tutor\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;goal=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"To assist users in learning a new language by providing practice exercises.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;backstory=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"A former language teacher with experience in helping students achieve \u003Cbr \u002F>fluency in various languages.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;verbose=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">True\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;llm=llm\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">)\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">With CrewAI, we only need to describe the agents using the given hyperparameters (role, goal, and backstory). Give as many details as possible so the agent can work as expected.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Then, we must create and assign an agent a task, essentially the specific action the agent needs to perform. In CrewAI, agents can be assigned multiple tasks. We will create a task where the agent needs to provide a language practice plan based on the user's proficiency\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\">from\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> crewai \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">import\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> Task\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">language_practice_task = Task(\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;description=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Provide language {language} practice plan exercises based on the \u003Cbr \u002F>user's proficiency level: {proficiency}, \u003Cbr \u002F>including vocabulary, grammar, and conversation practice.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;expected_output=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"A set of tailored language exercises with detailed explanations\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;agent=language_tutor_agent\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">)\u003C\u002Fspan>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">In the code above, we provide two placeholders for user input in the task description, which are &ldquo;{language}&rdquo; and &ldquo;{proficiency}.&rdquo; We can assign the name as anything we want, but ensure we understand it. We also assign the task to the agent.&nbsp;\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">The agent and task are ready to kick off. We must wrap them in a group with the CrewAI Crew object. As we only testing out one individual agent, we will not see any collaboration between agents for now. To start the process, we only need to execute the following code:\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\">from\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> crewai \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">import\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> Crew, Process\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">crew = Crew(agents=[language_tutor_agent], \u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">tasks=[language_practice_task],&nbsp; \u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">verbose=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">True\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;process=Process.sequential)\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">output = crew.kickoff(inputs={\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"language\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">: \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Indonesian\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">, \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"proficiency\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">: \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Beginner\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">})\u003C\u002Fspan>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">The result can vary because we are not limiting the token output or setting the exact output structure detail in the task. Here is a screenshot example from my side where the Agent provides a learning plan output.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\">print\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">(output.raw)\u003Cbr \u002F>\u003Cimg src=\"https:\u002F\u002Faigents-co.imgix.net\u002Fproduction\u002F1736793387088_how_to_build_your_own_ai_Agent_4%20%281%29.jpg?w=600&amp;auto=format,compress\" alt=\"\" \u002F>\u003Cbr \u002F>\u003C\u002Fspan>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Congratulation! You just run an AI Agent. However, the one we execute does not truly show the Agent's strength and is not that different from a regular LLM call.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Ch2>\u003Cstrong>Develop Agent with Tool\u003C\u002Fstrong>\u003C\u002Fh2>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Let&rsquo;s add another key component of the Agent: the Tool. As discussed earlier, a Tool enables the Agent to interact with external systems and acquire real-time information, enhancing its capabilities beyond its standard LLM.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">For example, let&rsquo;s give the agent access to a Web Search tool. To achieve this, we can use a tool provided by LangChain. The search process can be executed using the code below:\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\">from\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> langchain_community.tools \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">import\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> DuckDuckGoSearchRun\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">search = DuckDuckGoSearchRun()\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">search.invoke(\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Who is elected president of United States in 2024?\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">)\u003C\u002Fspan>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">CrewAI doesn&rsquo;t accept tools directly from LangChain, so we need to wrap the tool within a CrewAI tool, as shown in the code below.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\">from\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> pydantic \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">import\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> BaseModel\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">from\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> crewai.tools.structured_tool \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">import\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> CrewStructuredTool\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">from\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> langchain_community.tools \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">import\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> DuckDuckGoSearchRun\u003Cbr \u002F>\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">class\u003C\u002Fspan> \u003Cspan style=\"font-weight: 400;\">DuckDuckGoSearchInput\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">(\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">BaseModel\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">):\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;query: \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">str\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">def\u003C\u002Fspan> \u003Cspan style=\"font-weight: 400;\">duckduckgo_search_wrapper\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">(*\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">args\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">, **\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">kwargs\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">):\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;query = kwargs[\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"query\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">]\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;search = DuckDuckGoSearchRun()\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;result = search.invoke(query)\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">return\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> result\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">def\u003C\u002Fspan> \u003Cspan style=\"font-weight: 400;\">create_duckduckgo_search_tool\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">():\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">return\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> CrewStructuredTool.from_function(\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"duckduckgo_search_tool\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;description=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Searches the web using DuckDuckGo and returns \u003Cbr \u002F>relevant information for a given query.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;args_schema=DuckDuckGoSearchInput,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;func=duckduckgo_search_wrapper\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;)\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">SearchTool = create_duckduckgo_search_tool()\u003C\u002Fspan>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Then, we can assign it to the Agent by giving them access to a specific tool we just created.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\">language_tutor_agent = Agent(\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;role=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Language Tutor\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;goal=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"To assist users in learning a new language by providing practice exercises.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;backstory=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"A former language teacher with experience in helping students achieve \u003Cbr \u002F>fluency in various languages.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;verbose=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">True\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;llm=llm,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;tools=[SearchTool],\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">)\u003C\u002Fspan>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">The agent now has access to the Web Search Tool. However, we need to tweak the previous task as we don&rsquo;t explicitly tell them to search the internet. For that reason, let&rsquo;s add another placeholder, &ldquo;{internet},&rdquo; as a way for the user to ask the agent to search the internet or not.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\">from\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> crewai \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">import\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> Task\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">language_practice_task = Task(\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;description=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Provide language {language} practice plan exercises based on the \u003Cbr \u002F>user's proficiency level: {proficiency}, \u003Cbr \u002F>including vocabulary, grammar, and conversation practice. \u003Cbr \u002F>Find the reference on internet: {internet}\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;expected_output=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"A set of tailored language exercises with detailed explanations\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;agent=language_tutor_agent\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">)\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">We ask the agent to run once more with the following code.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\">crew.kickoff(inputs={\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"language\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">: \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Indonesian\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">, \u003Cbr \u002F>\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"proficiency\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">: \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Beginner\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">, \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"internet\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">:\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Yes\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">})\u003C\u002Fspan>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">\u003Cimg src=\"https:\u002F\u002Faigents-co.imgix.net\u002Fproduction\u002F1736788665685_how_to_build_your_own_ai_Agent_5.jpg?w=600&amp;auto=format,compress\" alt=\"\" width=\"600\" height=\"149\" \u002F>\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Going through the output process, the model can access the Internet via a tool and perform a search using a query they thought would be helpful in composing the learning plan.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">That&rsquo;s how you let the Agent access information using a Tool. You can create as many tools as you want, and the Agent will decide whether to use them based on the input information provided to them (provided the LLM model can reason properly).\u003C\u002Fspan>\u003C\u002Fp>\n\u003Ch2>\u003Cstrong>Develop Multi-Agent System\u003C\u002Fstrong>\u003C\u002Fh2>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">The agent is powerful, but their capability will become obsolete the more tasks they need to handle alone. That&rsquo;s why a multi-agent system exists where several agents work collaboratively.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">A multi-agent system expands the possibilities of what AI Agents can achieve by developing several specialized individual agents and orchestrating them within an environment where they can collaborate.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">When discussing Multi-Agent systems, it&rsquo;s not about a single structure that works for every system and use case. Instead, we can consider many architectural approaches when building the system.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Two of the most common architectures are either the Network or Supervisor.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cimg src=\"https:\u002F\u002Faigents-co.imgix.net\u002Fproduction\u002F1736788673961_how_to_build_your_own_ai_Agent_6.jpg?w=600&amp;auto=format,compress\" alt=\"\" \u002F>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Network architecture is the Multi-Agent system in which agents can communicate with each other and decide which other agent to call. In contrast, supervisor architecture uses a single supervisor agent to decide which agent should act next.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">There are still many architectures you can choose and even create your own. For example, I want to develop a system where a language planning agent gathers information from a web search agent and a research paper agent before creating the plan to enhance the quality of the output.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cimg src=\"https:\u002F\u002Faigents-co.imgix.net\u002Fproduction\u002F1736788681687_how_to_build_your_own_ai_Agent_7.jpg?w=600&amp;auto=format,compress\" alt=\"\" \u002F>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">We must set up the agents, tasks, and tools to develop the abovementioned multi-agent system. Let&rsquo;s start with the research tool, where we&rsquo;ll use Arxiv paper search to facilitate the process of finding relevant research papers\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\">from\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> langchain_community.tools \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">import\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> ArxivQueryRun\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">class\u003C\u002Fspan> \u003Cspan style=\"font-weight: 400;\">ArxivInput\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">(\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">BaseModel\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">):\u003Cbr \u002F>\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">    query: \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">str\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">def\u003C\u002Fspan> \u003Cspan style=\"font-weight: 400;\">arxiv_search_wrapper\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">(*\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">args\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">, **\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">kwargs\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">):\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;query = kwargs[\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"query\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">]\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;arxiv_tool = ArxivQueryRun()\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;result = arxiv_tool.invoke(query)\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">return\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> result\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">def\u003C\u002Fspan> \u003Cspan style=\"font-weight: 400;\">create_arxiv_tool\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">():\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">return\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\"> CrewStructuredTool.from_function(\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"arxiv_paper_tool\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;description=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Finds academic papers on Arxiv based on the user's query.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;args_schema=ArxivInput,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;func=arxiv_search_wrapper\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;)\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">arxiv_tool = create_arxiv_tool()\u003C\u002Fspan>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Then, we will initiate the web agent and research agent with the following code.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\">web_agent = Agent(\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;role=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Web Agent\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;goal=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"To gather general information from the web using a search engine regarding.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;backstory=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"A curious researcher with expertise in finding \u003Cbr \u002F>accurate information from various web sources.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;verbose=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">True\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;llm=llm,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;tools = [search_tool]\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">)\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">web_task = Task(\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;description=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Perform a web search using DuckDuckGo to find the most relevant and \u003Cbr \u002F>up-to-date information for language {language} studying for {proficiency} proficiency.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;expected_output=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"A summary of web search results, including key facts and references.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;agent=web_agent,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;async_execution=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">True\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">)\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">research_agent = Agent(\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;role=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Research Agent\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;goal=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"To assist users in finding relevant academic papers\u003Cbr \u002F> and summarizing research insights.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;backstory=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"A former academic researcher passionate about \u003Cbr \u002F>spreading knowledge from scientific literature.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;verbose=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">True\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;llm=llm,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;tool = [arxiv_tool]\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">)\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">research_task = Task(\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;description=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Search for relevant academic papers on Arxiv based on \u003Cbr \u002F>language {language} studying for {proficiency} proficiency.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;expected_output=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"A list of academic papers with summaries of their key contributions.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;agent=research_agent,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;async_execution=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">True\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">)\u003C\u002Fspan>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">We assign the appropriate tools to each agent tool. As in our previous example, each task is designed to allow user input. Additionally, we allow asynchronous execution for both agents so they don&rsquo;t need to wait for each other to perform their tasks.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Lastly, we initiate the language tutor agent with the following code.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\">language_tutor_agent = Agent(\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;role=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Language Tutor\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;goal=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"To assist users in learning a new language by \u003Cbr \u002F>providing practice exercises and corrections.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;backstory=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"A former language teacher with experience \u003Cbr \u002F>in helping students achieve fluency in various languages.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;verbose=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">True\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;llm=llm\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">)\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">language_practice_task = Task(\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;description=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Provide language {language} practice plan exercises based on the \u003Cbr \u002F>user's proficiency level: {proficiency}, including vocabulary, grammar, and conversation practice.\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;expected_output=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"A set of tailored language exercises with detailed explanations\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;agent=language_tutor_agent,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;context = [web_task, research_task]\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">)\u003C\u002Fspan>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">The difference now is that the language practice task requires finishing both web and research tasks before starting this agent.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">With everything in place, we will execute our multi-agent system to produce a language learning plan.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\">crew = Crew(\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;agents=[\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;web_agent,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;research_agent,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;language_tutor_agent,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;],\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;tasks=[\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;web_task,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;research_task,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;language_practice_task,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;],\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;verbose=\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">True\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;process=Process.sequential\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">)\u003C\u002Fspan>\u003Cbr \u002F>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">output = crew.kickoff(inputs={\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"language\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">: \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Indonesian\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">, \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"proficiency\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">: \u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">\"Beginner\"\u003C\u002Fspan>\u003Cspan style=\"font-weight: 400;\">})\u003Cbr \u002F>\u003Cimg src=\"https:\u002F\u002Faigents-co.imgix.net\u002Fproduction\u002F1736788690983_how_to_build_your_own_ai_Agent_8.jpg?w=600&amp;auto=format,compress\" alt=\"\" \u002F>\u003Cbr \u002F>\u003C\u002Fspan>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">The result is a learning plan with enhanced web and research paper resources output. You can tweak the context to make the agent network intertwine even more.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">Lastly, we process all the examples above sequentially, meaning the system moves from one agent to another, with the final agent deciding when to stop. This behavior is achieved by setting the Process.sequential parameter.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">If you want a supervisor who decides which agents to act and when to stop, we can change the Crew process parameters and add the manager agent who supervises everything.\u003C\u002Fspan>\u003C\u002Fp>\n\u003Cpre>\u003Cspan style=\"font-weight: 400;\"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;process=Process.hierarchical,\u003C\u002Fspan>\u003Cbr \u002F>\u003Cspan style=\"font-weight: 400;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;manager_llm = manager_llm\u003C\u002Fspan>\u003C\u002Fpre>\n\u003Cp>\u003Cspan style=\"font-weight: 400;\">That&rsquo;s all you need to understand about creating your own AI Agent. We still haven&rsquo;t touched upon many topics, such as the reasoning process, memory, and many more. But let&rsquo;s keep that for a much more in-depth article.\u003C\u002Fspan>\u003C\u002Fp>",[],{"_id":25,"profile":26},"6779437b5181522a3ec1c371",{"_id":27,"email":28,"firstName":29,"github":30,"lastName":31,"linkedin":32,"twitter":33},"6779438d9ba3aba6cf1c8b82","cornelliusyudhawijaya@gmail.com","Cornellius","https:\u002F\u002Fgithub.com\u002FCornelliusYW","Wijaya","https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fcornellius-yudha-wijaya\u002F","https:\u002F\u002Fx.com\u002FCornelliusYW","2025-01-13T18:27:07.052Z","2025-01-14T05:55:18.971Z",0]