您的位置:首页 > 健康 > 养生 > 销售软件哪个好_网站建设工作室需要哪些设备_刷百度关键词排名优化_汕头最好的seo外包

销售软件哪个好_网站建设工作室需要哪些设备_刷百度关键词排名优化_汕头最好的seo外包

2025/4/8 18:56:00 来源:https://blog.csdn.net/serviceLive/article/details/146265537  浏览:    关键词:销售软件哪个好_网站建设工作室需要哪些设备_刷百度关键词排名优化_汕头最好的seo外包
销售软件哪个好_网站建设工作室需要哪些设备_刷百度关键词排名优化_汕头最好的seo外包

概述

如https://github.com/microsoft/autogen所述,autogen是一多智能体的框架,属于微软旗下的产品。

依靠AutoGen我们可以快速构建出一个多智能体应用,以满足我们各种业务场景。

环境说明

  • python,3.10
  • AutoGen,0.4.2
  • chainlit,2.0.2
  • 大模型,deepseek 

安装依赖

pip install autogen-agentchat openai autogen-ext

        使用UI交互界面为Chainlit 安装chainlit命令

pip install chainlit

3.示例一,聊天机器人

应用场景:创建一个聊天机器人,让他给你回复

代码

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File    : ai_hub.py
# @Software: PyCharm
import chainlit as cl
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models.openai import OpenAIChatCompletionClient@cl.on_chat_start
async def main():await cl.Message(content="sir 我是贾维斯,有什么可以帮您?").send()async def run_team(query: str):model_client = OpenAIChatCompletionClient(model="deepseek-chat", base_url="https://api.deepseek.com",api_key="YOU DEEPSEEK API KEY", model_info={"vision": False,"function_calling": False,"json_output": True,"family": "unknown",}, )assistant_agent = AssistantAgent("assistant", model_client=model_client,system_message="你是一个机器人,请根据你所会的知识与用户进行友好交流!")team = RoundRobinGroupChat(participants=[assistant_agent], max_turns=1)response_stream = team.run_stream(task=query)async for msg in response_stream:if hasattr(msg, "source") and msg.source != "user" and hasattr(msg, "content"):msg = cl.Message(content=msg.content, author="Agent Team")await msg.send()@cl.on_message
async def main(message: cl.Message):await run_team(message.content)

启动机器人

chainlit run .\ai_hub.py -w

结果及界面

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com