### Installing Required Python Packages Source: https://github.com/elifsalihoglu/crewai_multiagent/blob/main/multi_agent.ipynb Installs the necessary libraries (crewai, crewai_tools, langchain_community) using pip. This is a prerequisite step for running the subsequent code. ```python !pip install crewai==0.28.8 crewai_tools==0.1.6 langchain_community==0.0.29 ``` -------------------------------- ### Importing Libraries and Setting OpenAI API Key Source: https://github.com/elifsalihoglu/crewai_multiagent/blob/main/multi_agent.ipynb Imports necessary Python libraries (warnings, crewai, crewai_tools, langchain_community, openai, os) and sets the OpenAI API key environment variable. Warnings are filtered to ignore them. ```python import warnings warnings.filterwarnings('ignore') from crewai import Agent, Task, Crew import openai as openai import os os.environ["OPENAI_API_KEY"] = "" ``` -------------------------------- ### Defining Agents, Tasks, Crew, and Running the Process Matching Workflow Source: https://github.com/elifsalihoglu/crewai_multiagent/blob/main/multi_agent.ipynb Defines two CrewAI agents (Support Representative and Quality Assurance Specialist) with specific roles and goals. It then defines two tasks (Inquiry Resolution and Quality Assurance Review) with descriptions, expected output formats (including a specific JSON structure), and assigned agents/tools. A Crew is initialized with these agents and tasks. Example inputs are defined, including a user inquiry and simulated process data. Finally, the crew is executed with the defined inputs, and the result is printed. ```python from crewai_tools import SerperDevTool docs_scrape_tool = SerperDevTool() support_agent = Agent( role="Process Matching Support Representative", goal="Provide the most accurate and complete information on processes matching the user’s input", backstory=( "You are tasked with " "matching user inputs with relevant processes stored in ProcessDatabase. " "Your responsibility is to ensure the retrieved information is formatted as required and " "contains only the fields specified. Make no assumptions and offer thorough assistance." ), allow_delegation=False, verbose=True ) support_quality_assurance_agent = Agent( role="Process Matching Quality Assurance Specialist", goal="Ensure the highest quality of support in process matching by verifying " "accuracy and completeness of the provided information", backstory=( "As a Quality Assurance Specialist " "you are responsible for verifying the accuracy and completeness of responses " "provided by the support representative in matching processes from the ProcessDatabase. " "Check that the response strictly follows the format and contains the exact fields " "as instructed, with no assumptions or additional context." ), verbose=True ) inquiry_resolution = Task( description=( "The user has reached out with an important request:\n" "{inquiry}\n\n" "Use all available resources to provide the best possible support." ), expected_output=( r"""[ {{ "process_id": "", "process_name": "", "applicable_dates": ["", ""], "contact": {{ "name": "", "email": "", "phone": "" }}, "steps": [ {{"step_number": , "description": ""}}, ... ] }} ] Only return the list of JSON objects with no additional context, explanation, or extra information.""" ), tools=[docs_scrape_tool], agent=support_agent, ) quality_assurance_review = Task( description=( "Review the response prepared by the Process Matching Support Representative. " "Ensure the response strictly follows the required JSON format and excludes any extra context." ), expected_output=( "A finalized, polished response that matches the exact JSON format required, " "ready to be sent to the user. " "Output is not including definition and embedding. " "Output is including all the required fields such as process details, contact, and steps." ), agent=support_quality_assurance_agent, ) crew = Crew( agents=[support_agent, support_quality_assurance_agent], tasks=[inquiry_resolution, quality_assurance_review], verbose=True, memory=True ) inputs = { "inquiry": "I'm, John Doe, planning a business trip from 15.08.2024 till 20.08.2024. Provide appropriate process from the platform.", "vdb": [ { "process_id": "12345", "process_name": "Business Trip Approval", "applicable_dates": ["2024-08-01", "2024-08-31"], "contact": { "name": "Jane Smith", "email": "jane.smith@example.com", "phone": "+1234567890" }, "steps": [ {"step_number": 1, "description": "Submit travel request form."}, {"step_number": 2, "description": "Manager approval."}, {"step_number": 3, "description": "Book travel arrangements."} ] }, { "process_id": "67890", "process_name": "Holiday Request", "applicable_dates": ["2024-06-01", "2024-06-30"], "contact": { "name": "Emily Johnson", "email": "emily.johnson@example.com", "phone": "+0987654321" }, "steps": [ {"step_number": 1, "description": "Fill out holiday request form."}, {"step_number": 2, "description": "Supervisor approval."}, {"step_number": 3, "description": "Confirmation from HR."} ] } ] } result = crew.kickoff(inputs=inputs) print(result) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.