OpenAI 发布 Swarm:用于构建、编排和部署多智能体系统的实验性 AI 框架

在快速发展的人工智能世界中,开发人员面临的一个紧迫挑战是协调复杂的多智能体系统。这些系统涉及多个 AI 智能体协同工作,通常在协调、控制和可扩展性方面存在重大困难。当前的解决方案往往很繁重,需要大量资源分配,这使部署和测试变得复杂。


AI 模型就像 CPU;Agent就是程序:这里有一个很好的类比:你可以将人工智能模型(如 GPT)视为CPU它本身非常强大,但如果没有程序(或代理)在其上运行,CPU 就无法解决特定问题。在这个类比中,代理就像程序一样,旨在利用模型的功能来执行目标任务。
例如,一个模型可能能够回答任何类型的问题,但如果您希望它同时处理客户服务和技术支持,则需要将这些角色分解为专门的代理。这使系统能够有效地分配工作,确保每个任务都由最适合该工作的代理来处理。



OpenAI 推出了Swarm Framework,作为简化多智能体编排固有复杂性的解决方案。Swarm 是一个实验性框架,专注于使智能体协调、执行和测试既轻量又高度可控。目标是让开发人员能够以直接高效的方式管理多个 AI 智能体之间的交互。这个框架已经开发了几个月,OpenAI 现在很高兴将其公开分享,希望它能被 AI 社区接受,成为构建高级 AI 系统的实用工具。

https://aiquanzi.oss-cn-chengdu.aliyuncs.com/files_user40/article/eb8cb57b62222a3cf2b1501f2f7d02b8.png


">

Swarm 的优势在于它的两个基本抽象:agents和handoffs(交接)。Swarm 中的代理是可用于完成任务的特定指令和工具的组合。在其流程的任何阶段,代理都可以将对话或任务“交接”给另一个代理,从而使编排变得无缝和模块化。这种抽象不仅可以实现不同代理之间的复杂交互,还可以确保整体协调始终处于严格控制之下。通过利用这些元素,Swarm 能够保持协调和执行过程的轻量级,使其成为一个高度可测试的框架。此外,Swarm 建立在 ChatCompletions 之上,它提供了一个强大而多功能的基础,使开发人员能够创建和部署多代理系统而无需不必要的开销。


Swarm 框架之所以重要有几个原因。首先,它提供了一种简化的方式来管理代理通信并在代理之间动态转移职责。这在不同 AI 代理专门从事不同任务的场景中至关重要,需要一种有组织且高效的交接机制。Swarm 的轻量级方法意味着开发人员可以轻松地迭代、测试和改进多代理配置,而不会被复杂的基础设施要求所困扰。此外,Swarm 的高度可控性意味着它是希望确保 AI 代理编排可靠性和效率的研究人员和开发人员的理想选择。通过保持简单、可控和高效,Swarm 代表着向让更广泛的开发者社区更容易使用高级 AI 系统迈出了重要一步。


总之,OpenAI 的 Swarm 框架旨在通过专注于简单性和可控性来克服多智能体系统编排中的重大挑战。通过提供基于智能体交互和任务交接的轻量级基础设施,Swarm 不仅使多智能体编排成为可能,而且适用于广泛的用例。随着多智能体系统继续在 AI 研究和应用中发挥关键作用,像 Swarm 这样的工具将降低障碍、提高可访问性,并最终实现更强大、更通用的 AI 解决方案的开发。无论是出于研究、产品开发还是教育目的,Swarm 都提供了一个激动人心的机会,可以以高效、精简的方式探索协调的多智能体 AI 的可能性。


安装

pip install git+ssh://git@github.com/openai/swarm.git


或者

pip install git+https://github.com/openai/swarm.git


用法

from swarm import Swarm, Agent
client = Swarm()
def transfer_to_agent_b():
return agent_b
agent_a = Agent(
name="Agent A",
instructions="You are a helpful agent.",
functions=[transfer_to_agent_b],
)
agent_b = Agent(
name="Agent B",
instructions="Only speak in Haikus.",
)
response = client.run(
agent=agent_a,
messages=[{"role": "user", "content": "I want to talk to agent B."}],
)
print(response.messages[-1]["content"])



在这个场景中,代理 A开始对话,但意识到用户需要它无法提供的东西。它将对话转交给代理 B,后者用俳句回复。这个简单的交接演示了 Swarm 中的代理如何协作解决用户问题。


Hope glimmers brightly,New paths converge gracefully,What can I assist?

Swarm只是探索多智能体系统的众多工具之一。Microsoft AutoGencrewAI是另外两个重要框架:


  • AutoGen专注于复杂的工作流程,并通过跨代理的内存和状态管理提供更为强大的解决方案。

  • crewAI旨在简化业务流程,通过模块化代理自动执行任务。

0 个评论

要回复文章请先登录注册

Debug messages:

Template: default


Session:

Session type: db

[tlu__Anwsion] Array ( [permission] => [client_info] => [human_valid] => )


Plugins:


Loaded Class:

core_config: /data/aiquanzi/system/core/config.php

core_db: /data/aiquanzi/system/core/db.php

Zend_Db: /data/aiquanzi/system/Zend/Db.php

Zend_Db_Adapter_Abstract: /data/aiquanzi/system/Zend/Db/Adapter/Abstract.php

Zend_Db_Adapter_Mysqli: /data/aiquanzi/system/Zend/Db/Adapter/Mysqli.php

Zend_Db_Profiler: /data/aiquanzi/system/Zend/Db/Profiler.php

Zend_Db_Statement_Interface: /data/aiquanzi/system/Zend/Db/Statement/Interface.php

Zend_Db_Statement: /data/aiquanzi/system/Zend/Db/Statement.php

Zend_Db_Statement_Mysqli: /data/aiquanzi/system/Zend/Db/Statement/Mysqli.php

Zend_Registry: /data/aiquanzi/system/Zend/Registry.php

Zend_Cache: /data/aiquanzi/system/Zend/Cache.php

Zend_Cache_Backend: /data/aiquanzi/system/Zend/Cache/Backend.php

Zend_Cache_Backend_Interface: /data/aiquanzi/system/Zend/Cache/Backend/Interface.php

Zend_Cache_Backend_ExtendedInterface: /data/aiquanzi/system/Zend/Cache/Backend/ExtendedInterface.php

Zend_Db_Table_Abstract: /data/aiquanzi/system/Zend/Db/Table/Abstract.php

core_plugins: /data/aiquanzi/system/core/plugins.php

setting_class: /data/aiquanzi/models/setting.php

Zend_Db_Select: /data/aiquanzi/system/Zend/Db/Select.php

Zend_Db_Expr: /data/aiquanzi/system/Zend/Db/Expr.php

Zend_Session_Abstract: /data/aiquanzi/system/Zend/Session/Abstract.php

Zend_Session: /data/aiquanzi/system/Zend/Session.php

Zend_Session_SaveHandler_Interface: /data/aiquanzi/system/Zend/Session/SaveHandler/Interface.php

Zend_Session_SaveHandler_DbTable: /data/aiquanzi/system/Zend/Session/SaveHandler/DbTable.php

Zend_Exception: /data/aiquanzi/system/Zend/Exception.php

Zend_Session_Exception: /data/aiquanzi/system/Zend/Session/Exception.php

Zend_Db_Table_Select: /data/aiquanzi/system/Zend/Db/Table/Select.php

Zend_Db_Table_Rowset_Abstract: /data/aiquanzi/system/Zend/Db/Table/Rowset/Abstract.php

Zend_Db_Table_Rowset: /data/aiquanzi/system/Zend/Db/Table/Rowset.php

Zend_Db_Table_Row_Abstract: /data/aiquanzi/system/Zend/Db/Table/Row/Abstract.php

Zend_Db_Table_Row: /data/aiquanzi/system/Zend/Db/Table/Row.php

Zend_Session_Namespace: /data/aiquanzi/system/Zend/Session/Namespace.php

core_cache: /data/aiquanzi/system/core/cache.php

core_uri: /data/aiquanzi/system/core/uri.php

banip_class: /data/aiquanzi/models/banip.php

Zend_Validate_Interface: /data/aiquanzi/system/Zend/Validate/Interface.php

Zend_Validate: /data/aiquanzi/system/Zend/Validate.php

Zend_Loader: /data/aiquanzi/system/Zend/Loader.php

Zend_Validate_Abstract: /data/aiquanzi/system/Zend/Validate/Abstract.php

core_user: /data/aiquanzi/system/core/user.php

admin_class: /data/aiquanzi/models/admin.php

TPL: /data/aiquanzi/system/class/cls_template.inc.php

Savant3: /data/aiquanzi/system/Savant3.php

account_class: /data/aiquanzi/models/account.php

HTTP: /data/aiquanzi/system/class/cls_http.inc.php

hook_class: /data/aiquanzi/models/hook.php

plugin_class: /data/aiquanzi/models/plugin.php

PLUTPL: /data/aiquanzi/system/class/cls_plugins.inc.php

article_class: /data/aiquanzi/models/article.php

Zend_Filter_Interface: /data/aiquanzi/system/Zend/Filter/Interface.php

Zend_Filter_Digits: /data/aiquanzi/system/Zend/Filter/Digits.php

publish_class: /data/aiquanzi/models/publish.php

FORMAT: /data/aiquanzi/system/class/cls_format.inc.php

Services_BBCode: /data/aiquanzi/system/Services/BBCode.php

topic_class: /data/aiquanzi/models/topic.php

people_class: /data/aiquanzi/models/people.php

reputation_class: /data/aiquanzi/models/reputation.php

question_class: /data/aiquanzi/models/question.php

system_class: /data/aiquanzi/models/system.php

Services_Phpanalysis_Phpanalysis: /data/aiquanzi/system/Services/Phpanalysis/Phpanalysis.php

search_fulltext_class: /data/aiquanzi/models/search/fulltext.php

core_pagination: /data/aiquanzi/system/core/pagination.php

posts_class: /data/aiquanzi/models/posts.php

file_down_class: /data/aiquanzi/plugins/wc_file_down/file_down_model.php

sham_views_class: /data/aiquanzi/plugins/wc_sham_views/sham_views_model.php

article_download_class: /data/aiquanzi/plugins/wc_article_download/article_download_model.php

core_lang: /data/aiquanzi/system/core/lang.php


Database

[ Log time: 1735963703.7 ] [ Expend time: 0.0045430660247803 ] Connect Master DB

[ Log time: 1735963703.706 ] [ Expend time: 0.0017440319061279 ] SELECT `wecenter_system_setting`.* FROM `wecenter_system_setting`

[ Log time: 1735963703.7123 ] [ Expend time: 0.0011360645294189 ] SELECT `wecenter_nav`.`url` FROM `wecenter_nav` WHERE (is_index=1 AND status='Y') LIMIT 1

[ Log time: 1735963703.7151 ] [ Expend time: 0.0010690689086914 ] SELECT `wecenter_ban_ip`.`id` FROM `wecenter_ban_ip` WHERE (ip='18.188.198.81') LIMIT 1

[ Log time: 1735963703.7168 ] [ Expend time: 0.0011491775512695 ] SELECT `wecenter_nav`.* FROM `wecenter_nav` WHERE (status='Y') ORDER BY `sort` desc

[ Log time: 1735963703.7201 ] [ Expend time: 0.00091195106506348 ] SELECT `wecenter_users_group`.* FROM `wecenter_users_group` WHERE (group_id = 99) LIMIT 1

[ Log time: 1735963703.7227 ] [ Expend time: 0.0012640953063965 ] SELECT `wecenter_hook_plugins`.`hook`, `wecenter_hook_plugins`.`plugins` FROM `wecenter_hook_plugins` WHERE (status = 1) ORDER BY `sort` DESC

[ Log time: 1735963703.7254 ] [ Expend time: 0.0017120838165283 ] SELECT `wecenter_plugins`.* FROM `wecenter_plugins` WHERE (state = 1)

[ Log time: 1735963703.7413 ] [ Expend time: 0.0014500617980957 ] SELECT `wecenter_article`.* FROM `wecenter_article` WHERE (id = 60) LIMIT 1

[ Log time: 1735963703.7438 ] [ Expend time: 0.0011570453643799 ] SELECT `wecenter_attach`.* FROM `wecenter_attach` WHERE (item_type = 'article' AND item_id = 60) ORDER BY `is_image` DESC, `id` ASC

[ Log time: 1735963703.7456 ] [ Expend time: 0.0010960102081299 ] SELECT `wecenter_users`.* FROM `wecenter_users` WHERE (is_del = 0 AND uid = 40) LIMIT 1

[ Log time: 1735963703.7466 ] [ Expend time: 0.00091314315795898 ] SELECT `wecenter_users_attrib`.* FROM `wecenter_users_attrib` WHERE (uid = 40) LIMIT 1

[ Log time: 1735963703.7488 ] [ Expend time: 0.0011131763458252 ] SELECT `wecenter_article_vote`.* FROM `wecenter_article_vote` WHERE (`type` = 'article' AND item_id = 60 AND rating = 1)

[ Log time: 1735963703.7516 ] [ Expend time: 0.0011289119720459 ] SELECT `wecenter_topic_relation`.* FROM `wecenter_topic_relation` WHERE (item_id IN(60) AND `type` = 'article')

[ Log time: 1735963703.7529 ] [ Expend time: 0.0011608600616455 ] SELECT `wecenter_topic`.* FROM `wecenter_topic` WHERE (topic_id IN(9,8))

[ Log time: 1735963703.7548 ] [ Expend time: 0.0011229515075684 ] SELECT `wecenter_reputation_topic`.* FROM `wecenter_reputation_topic` WHERE (uid IN(40)) ORDER BY `topic_count` DESC

[ Log time: 1735963703.756 ] [ Expend time: 0.0010981559753418 ] SELECT `wecenter_article_comments`.* FROM `wecenter_article_comments` WHERE (is_del = 0 and article_id = 60) ORDER BY `add_time` ASC LIMIT 100

[ Log time: 1735963703.7569 ] [ Expend time: 0.00079107284545898 ] SELECT COUNT(*) AS `n` FROM `wecenter_article_comments` WHERE (is_del = 0 and article_id = 60)

[ Log time: 1735963703.7636 ] [ Expend time: 0.0012271404266357 ] SELECT *, MATCH(question_content_fulltext) AGAINST('' IN BOOLEAN MODE) AS score FROM wecenter_question WHERE MATCH(question_content_fulltext) AGAINST('' IN BOOLEAN MODE) LIMIT 2000

[ Log time: 1735963703.7667 ] [ Expend time: 0.00085210800170898 ] SELECT `wecenter_topic`.* FROM `wecenter_topic` WHERE (topic_id = 9) LIMIT 1

[ Log time: 1735963703.7678 ] [ Expend time: 0.001011848449707 ] SELECT item_id FROM wecenter_topic_relation WHERE topic_id IN(9) AND `type` = '10'

[ Log time: 1735963703.7689 ] [ Expend time: 0.00099921226501465 ] SELECT topic_id FROM wecenter_topic WHERE parent_id = 9

[ Log time: 1735963703.7699 ] [ Expend time: 0.00099921226501465 ] SELECT `wecenter_topic_merge`.* FROM `wecenter_topic_merge` WHERE (target_id = 9)

[ Log time: 1735963703.7709 ] [ Expend time: 0.00081801414489746 ] SELECT `wecenter_topic`.* FROM `wecenter_topic` WHERE (topic_id = 8) LIMIT 1

[ Log time: 1735963703.772 ] [ Expend time: 0.0010309219360352 ] SELECT item_id FROM wecenter_topic_relation WHERE topic_id IN(8) AND `type` = '10'

[ Log time: 1735963703.773 ] [ Expend time: 0.0009918212890625 ] SELECT topic_id FROM wecenter_topic WHERE parent_id = 8

[ Log time: 1735963703.7741 ] [ Expend time: 0.00099778175354004 ] SELECT `wecenter_topic_merge`.* FROM `wecenter_topic_merge` WHERE (target_id = 8)

[ Log time: 1735963703.7751 ] [ Expend time: 0.0010390281677246 ] SELECT `item_id`, `type` FROM wecenter_topic_relation WHERE `topic_id` IN(9,8)

[ Log time: 1735963703.7765 ] [ Expend time: 0.0011789798736572 ] SELECT `wecenter_posts_index`.* FROM `wecenter_posts_index` WHERE (((post_id IN (59,60) AND post_type = 'article')) AND is_recommend = 1 AND is_del = 0) ORDER BY `add_time` DESC LIMIT 10

[ Log time: 1735963703.7774 ] [ Expend time: 0.00082182884216309 ] SELECT COUNT(*) AS `n` FROM `wecenter_posts_index` WHERE (((post_id IN (59,60) AND post_type = 'article')) AND is_recommend = 1 AND is_del = 0)

[ Log time: 1735963703.7796 ] [ Expend time: 0.0010449886322021 ] SELECT `wecenter_article_download`.* FROM `wecenter_article_download` WHERE (article_id = 60) LIMIT 1

[ Log time: 1735963703.7886 ] [ Expend time: 0.00079607963562012 ] SELECT `wecenter_users`.`avatar_file` FROM `wecenter_users` WHERE (uid=40) LIMIT 1


Cache

[ Log time: 1735963703.7106 ] Backend: File

[ Log time: 1735963703.7107 ] [ Expend time: 0.000061 ] Get Cache: crond, result type: boolean

[ Log time: 1735963703.7191 ] [ Expend time: 0.000092 ] Get Cache: user_group_99, result type: boolean

[ Log time: 1735963703.7204 ] [ Expend time: 0.000036 ] Get Cache: users_group, result type: boolean

[ Log time: 1735963703.7205 ] [ Expend time: 0.000125 ] Save Cache: fkfvhvabwekgrlw_group_users_group, result type: array

[ Log time: 1735963703.7205 ] [ Expend time: 0.000430 ] Save Cache: user_group_99, result type: array

[ Log time: 1735963703.7561 ] [ Expend time: 0.000039 ] Get Cache: db_rows_cache_c5498cbbff364124b7b523a077c2211d, result type: boolean

[ Log time: 1735963703.7592 ] [ Expend time: 0.000024 ] Get Cache: question_related_list_9535e20e774be2ec461eb8a742fee485_10, result type: boolean

[ Log time: 1735963703.7639 ] [ Expend time: 0.000239 ] Save Cache: question_related_list_9535e20e774be2ec461eb8a742fee485_10, result type: boolean

[ Log time: 1735963703.7639 ] [ Expend time: 0.000014 ] Get Cache: update_views_article_aadcdbd2118ce6c859e5429168227647_60, result type: boolean

[ Log time: 1735963703.7641 ] [ Expend time: 0.000148 ] Save Cache: update_views_article_aadcdbd2118ce6c859e5429168227647_60, result type: integer

[ Log time: 1735963703.7753 ] [ Expend time: 0.000025 ] Get Cache: posts_list_by_topic_ids_01a465aeb33afbbb0347b537f243b3ab, result type: boolean

[ Log time: 1735963703.7765 ] [ Expend time: 0.000027 ] Get Cache: db_rows_cache_bcd88664eee2048870053400dd66dd75, result type: boolean

[ Log time: 1735963703.7775 ] [ Expend time: 0.000026 ] Get Cache: posts_list_by_topic_ids_found_rows_2cc026579073ba9c884bdc36d043f6db, result type: boolean


Escape time: 0.10058999061584, 32 queries, PHP Memory usage: 6835.1796875 KB, Server time: 2025-01-04 12:08:23