CAMEL 新增了多智能体协作 Workforce 模块!
CAMEL 新增了多智能体协作 Workforce 模块!
CAMEL 新增了多智能体协作 Workforce 模块! CAMEL 新增了多智能体协作 Workforce 模块! Modified November 12, 2024 为何选Workforce? 🤔可能你会问:“Multi Agent Workforce和传统Workflow工作流有什么区别?” 答案在于Multi Agent系统的动态问题解决能力。 与静态工作流不同,Workforce 可以实时适应。当你将一个复杂任务分配给一组 Agents时,即使任务的某个部分失败,Workforce 也会自动分解问题,重新启动新的 Agent,并持续迭代,直到任务完全解决。 🔄这种灵活性使Multi Agent系统在大规模解决复杂问题时成为一个改变游戏规则的工具。🚀 ⬇️详情也可以在 官网的Doc 中查看! https://docs.camel ai.org/ key modules/workforce.html 🤩 以下是最令人期待的 案例 环节 🤩 Google Colab 的链接也可以查看和复制:https://shorturl.asia/gKxMH • 安装 首先,您需要安装包含所有依赖项的 CAMEL: Code block Plain Text %pip install "camel ai[all]==0.2.6" %pip install nest asyncio • 设置 API 密钥 Code block Plain Text import os from getpass import getpass os.environ["OPENAI API KEY"] = getpass("Enter your OpenAI API key: ") Ref: https://developers.google.com/custom search/v1/overview os.environ["GOOGLE API KEY"] = getpass("Enter your Google Search API key: ") Ref: https://cse.google.com/cse/all os.environ["SEARCH ENGINE ID"] = getpass("Enter your Google Search Engine ID: ") Ref: https://openweathermap.org os.environ["OPENWEATHERMAP API KEY"] = getpass("Enter your OpenWeatherMap API key: ") 代码输出: Enter your OpenAI API key: ·········· Enter your Google Search API key: ·········· Enter your Google Search Engine ID: ·········· Enter your OpenWeatherMap API key: ·········· • 导入依赖项并设置 AsyncIO Code block Plain Text from camel.agents.chat agent import ChatAgent from camel.configs.openai config import ChatGPTConfig from camel.messages.base import BaseMessage from camel.models import ModelFactory from camel.tasks.task import Task from camel.toolkits import ( WEATHER FUNCS, GoogleMapsToolkit, OpenAIFunction, SearchToolkit, ) from camel.types import ModelPlatformType, ModelType from camel.societies import Workforce import nest asyncio nest asyncio.apply() • 创建工作 agent Code block Plain Text search toolkit = SearchToolkit() search tools = [ OpenAIFunction(search toolkit.search google), OpenAIFunction(search toolkit.search duckduckgo), ] Set up web searching agent search agent model = ModelFactory.create( model platform=ModelPlatformType.OPENAI, model type=ModelType.GPT 4O, model config dict=ChatGPTConfig().as dict(), ) search agent = ChatAgent( system message=BaseMessage.make assistant message( role name="Web searching agent", content="You can search online for information", ), model=search agent model, tools=[ search tools, WEATHER FUNCS], ) Set up tour guide agent tour guide agent model = ModelFactory.create( model platform=ModelPlatformType.OPENAI, model type=ModelType.GPT 4O, model config dict=ChatGPTConfig().as dict(), ) tour guide agent = ChatAgent( BaseMessage.make assistant message( role name="Tour guide", content="You are a tour guide", ), model=tour guide agent model, tools=GoogleMapsToolkit().get tools(), ) Set up traveler agent traveler agent = ChatAgent( BaseMessage.make assistant message( role name="Traveler", content="You can ask questions about your travel plans", ), model=ModelFactory.create( model platform=ModelPlatformType.OPENAI, model type=ModelType.GPT 4O, model config dict=ChatGPTConfig().as dict(), ), ) • 创建工作队伍并添加agent Code block Plain Text workforce = Workforce('A travel group') workforce.add single agent worker( "A tour guide", worker=tour guide agent, ).add single agent worker( "A traveler", worker=traveler agent ).add single agent worker( "An agent who can do online searches", worker=search agent ) 代码输出: Workforce 135004461820576 (A travel group) • 创建任务并分配给工作队伍 • • • • • • • • • • Code block Plain Text specify the task to be solved human task = Task( content=( "Plan a one week trip to Paris, considering some historical places" " to visit and weather conditions." ), id='0', ) task = workforce.process task(human task) 为何选Workforce? 🤔可能你会问:“Multi Agent Workforce和传统Workflow工作流有什么区别?” 答案在于Multi Agent系统的动态问题解决能力。 与静态工作流不同,Workforce 可以实时适应。当你将一个复杂任务分配给一组 Agents时,即使任务的某个部分失败,Workforce 也会自动分解问题,重新启动新的 Agent,并持续迭代,直到任务完全解决。 🔄这种灵活性使Multi Agent系统在大规模解决复杂问题时成为一个改变游戏规则的工具。🚀 ⬇️详情也可以在 官网的Doc 中查看! https://docs.camel ai.org/ key modules/workforce.html 🤩 以下是最令人期待的 案例 环节 🤩 Google Colab 的链接也可以查看和复制:https://shorturl.asia/gKxMH • 安装 首先,您需要安装包含所有依赖项的 CAMEL: • 设置 API 密钥 代码输出: Enter your OpenAI API key: ·········· Enter your Google Search API key: ·········· Enter your Google Search Engine ID: ·········· Enter your OpenWeatherMap API key: ·········· • 导入依赖项并设置 AsyncIO • 创建工作 agent • 创建工作队伍并添加agent 代码输出: Workforce 135004461820576 (A travel group) • 创建任务并分配给工作队伍 • • • • • • • • • • Reply from Worker node 135004442253472 (An agent who can do online searches): 1. Eiffel Tower 2. Notre Dame Cathedral 3. The Louvre Museum 4. Arc de Triomphe 5. Palace of Versailles 6. Sainte Chapelle 7. Panthéon 8. Les Invalides 9. Place de la Concorde 10. Sacré Cœur Basilica 11. Conciergerie 12. Palais Garnier 13. Pont Neuf 14. Château de Vincennes 15. Musée d'Orsay 16. Hôtel de Ville 17. La Sorbonne 18. Saint Germain des Prés 19. Cluny Museum 20. Grand Palais 21. Petit Palais 22. Tuileries Garden 23. Place des Vosges 24. La Madeleine 25. Saint Sulpice 26. Palais Royal ====== Worker node 135004442253472 (An agent who can do online searches) get task 0.1: Check the weather conditions for the week of the trip. ====== Reply from Worker node 135004442253472 (An agent who can do online searches): Weather in Paris, FR: 17.02°Celsius, feels like 16.29°Celsius. Max temp: 18.28°Celsius, Min temp: 15.88°Celsius. Wind: 4.12 meters sec at 250 degrees. Visibility: 10000 meters. Sunrise at 1727761823, Sunset at 1727803787. ====== Worker node 135004442253472 (An agent who can do online searches) get task 0.2: Plan the itinerary based on the historical places and weather conditions. ====== Reply from Worker node 135004442253472 (An agent who can do online searches): Day 1: Morning: Eiffel Tower Afternoon: Notre Dame Cathedral Evening: The Louvre Museum Day 2: Morning: Arc de Triomphe Afternoon: Palace of Versailles Evening: Sainte Chapelle Day 3: Morning: Panthéon Afternoon: Les Invalides Evening: Place de la Concorde Day 4: Morning: Sacré Cœur Basilica Afternoon: Conciergerie Evening: Palais Garnier Day 5: Morning: Pont Neuf Afternoon: Château de Vincennes Evening: Musée d'Orsay Day 6: Morning: Hôtel de Ville Afternoon: La Sorbonne Evening: Saint Germain des Prés Day 7: Morning: Cluny Museum Afternoon: Grand Palais and Petit Palais Evening: Tuileries Garden Day 8: Morning: Place des Vosges Afternoon: La Madeleine Evening: Saint Sulpice and Palais Royal Weather conditions are mild with temperatures ranging from 15.88°C to 18.28°C, so all activities are feasible. ====== Worker node 135004456387200 (A tour guide) get task 0.3: Provide detailed descriptions and addresses of the selected historical places. ====== Reply from Worker node 135004456387200 (A tour guide): Here are the detailed descriptions and addresses of the selected historical places in Paris: 1. Eiffel Tower Address: Avenue Gustave Eiffel, 75007 Paris, France Description: An iconic symbol of France, the Eiffel Tower is a wrought iron lattice tower on the Champ de Mars, named after the engineer Gustave Eiffel. 2. Notre Dame Cathedral Address: Notre Dame Cathedral, Paris, France Description: A medieval Catholic cathedral on the Île de la Cité, Notre Dame is renowned for its French Gothic architecture and historical significance. 3. The Louvre Museum Address: The Louvre Museum, Paris, France Description: The world's largest art museum and a historic monument in Paris, it is home to thousands of works of art, including the Mona Lisa. 4. Arc de Triomphe Address: Arc de Triomphe, Paris, France Description: One of the most famous monuments in Paris, it stands at the western end of the Champs Élysées and honors those who fought and died for France. 5. Palace of Versailles Address: Palace of Versailles, 78000 Versailles, France Description: A former royal residence, the Palace of Versailles is known for its opulent architecture, gardens, and the Hall of Mirrors. 6. Sainte Chapelle Address: Boulevard du Palais, 75001 Paris, France Description: A royal chapel in the Gothic style, located within the medieval Palais de la Cité, it is famous for its stunning stained glass windows. 7. Panthéon Address: Panthéon, Paris, France Description: Originally built as a church, the Panthéon now functions as a mausoleum containing the remains of distinguished French citizens. 8. Les Invalides Address: 75007 Paris, France Description: A complex of buildings containing museums and monuments, all relating to the military history of France, and the burial site of Napoleon Bonaparte. 9. Place de la Concorde Address: 75008 Paris, France Description: The largest square in Paris, it is known for its historical significance and its central location between the Champs Élysées and the Tuileries Garden. 10. Sacré Cœur Basilica Address: Rue du Chevalier de la Barre, 75018 Paris, France Description: A Roman Catholic church and minor basilica, dedicated to the Sacred Heart of Jesus, located at the summit of the butte Montmartre. 11. Conciergerie Address: Boulevard du Palais, 75001 Paris, France Description: A former royal palace and prison, now a museum, located on the Île de la Cité. 12. Palais Garnier Address: Place de l'Opéra, 75009 Paris, France Description: A 1,979 seat opera house, which was the primary home of the Paris Opera and its associated Paris Opera Ballet until 1989. 13. Pont Neuf Address: 75001 Paris, France Description: The oldest standing bridge across the river Seine in Paris. 14. Château de Vincennes Address: Avenue de Paris, 94300 Vincennes, France Description: A historic castle that served as a royal residence, it is one of the best preserved medieval castles in Europe. 15. Musée d'Orsay Address: 75007 Paris, France Description: A museum housed in a former railway station, it holds mainly French art dating from 1848 to 1914, including paintings, sculptures, and photography. 16. Hôtel de Ville Address: 4e Arrondissement, 75004 Paris, France Description: The building housing the city's local administration, it has been the headquarters of the municipality of Paris since 1357. 17. La Sorbonne Address: Quartier de la Sorbonne, 75005 Paris, France Description: A historic building in the Latin Quarter, it is the seat of the former University of Paris. 18. Saint Germain des Prés Address: 75006 Paris, France Description: One of the four administrative quarters of the 6th arrondissement of Paris, known for its cafés and intellectual history. 19. Cluny Museum Address: Rue du Sommerard, 75005 Paris, France Description: Officially known as the Musée de Cluny, it is a museum of medieval artifacts located in the Latin Quarter. 20. Grand Palais Address: 75008 Paris, France Description: A large historic site, exhibition hall, and museum complex located at the Champs Élysées. 21. Petit Palais Address: Avenue Winston Churchill, 75008 Paris, France Description: An art museum in Paris, it houses the City of Paris Museum of Fine Arts. 22. Tuileries Garden Address: 75001 Paris, France Description: A public garden located between the Louvre Museum and the Place de la Concorde. 23. Place des Vosges Address: Paris, France Description: The oldest planned square in Paris, located in the Marais district. 24. La Madeleine Address: Place de la Madeleine, 75008 Paris, France Description: A Roman Catholic church designed in its present form as a temple to the glory of Napoleon's army. 25. Saint Sulpice Address: Rue Palatine, 75006 Paris, France Description: A Roman Catholic church in Paris, known for its gnomon and for being the second largest church in the city. 26. Palais Royal Address: 75001 Paris, France Description: A former royal palace located in the 1st arrondissement of Paris, it now serves as the seat of the Ministry of Culture and the Constitutional Council. ====== • 获取任务的结果 • 代码输出: Final Result of Original task: Final Plan for a One Week Trip to Paris: Overview: Duration: 7 days Weather: Mild temperatures ranging from 15.88°C to 18.28°C, making all activities feasible. Itinerary: