conda create -n python=3.10

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

二、設(shè)置OpenAI API

import os
os.environ['OPENAI_API_KEY'] =''

三、下面是一個(gè)handoff的例子

from swarm import Swarm, Agent

client = Swarm()

english_agent = Agent(
name="English Agent",
instructions="You only speak English.",
)

spanish_agent = Agent(
name="Spanish Agent",
instructions="You only speak Spanish.",
)

def transfer_to_spanish_agent():
"""Transfer spanish speaking users immediately."""
return spanish_agent

english_agent.functions.append(transfer_to_spanish_agent)

messages = [{"role": "user", "content": "Hola. ?Como estás?"}]
response = client.run(agent=english_agent, messages=messages)

print(response.messages[-1]["content"])

輸出:

?Hola! Estoy bien, gracias. ?Y tú, cómo estás?

文章轉(zhuǎn)自微信公眾號(hào)@ArronAI

上一篇:

LLM之Agent(十一)| 多智能體框架CrewAI與AutoGen相比

下一篇:

擴(kuò)散模型實(shí)戰(zhàn)(一):基本原理介紹
#你可能也喜歡這些API文章!

我們有何不同?

API服務(wù)商零注冊

多API并行試用

數(shù)據(jù)驅(qū)動(dòng)選型,提升決策效率

查看全部API→
??

熱門場景實(shí)測,選對(duì)API

#AI文本生成大模型API

對(duì)比大模型API的內(nèi)容創(chuàng)意新穎性、情感共鳴力、商業(yè)轉(zhuǎn)化潛力

25個(gè)渠道
一鍵對(duì)比試用API 限時(shí)免費(fèi)

#AI深度推理大模型API

對(duì)比大模型API的邏輯推理準(zhǔn)確性、分析深度、可視化建議合理性

10個(gè)渠道
一鍵對(duì)比試用API 限時(shí)免費(fèi)