2025-02-17 16:43:12 +08:00
2025-02-16 16:49:36 +08:00
1
2025-01-18 17:53:58 +08:00
2025-02-17 16:43:12 +08:00
1
2025-01-18 17:53:58 +08:00
2025-02-07 10:21:16 +08:00
2025-02-04 12:48:54 +08:00
1
2025-01-18 17:53:58 +08:00
1
2025-01-18 17:53:58 +08:00
1
2025-01-18 17:53:58 +08:00
1
2025-01-18 17:53:58 +08:00
2025-02-07 10:21:16 +08:00

Ubuntu20.04 + python3.11.9 + django #1、安装python3.11.9 sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget wget https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tgz tar zxvf Python-3.11.9.tgz cd Python-3.11.9 ./configure --enable-optimizations make -j$(nproc) sudo make altinstall python3.11 -m ensurepip --upgrade wget https://bootstrap.pypa.io/get-pip.py python3.11 get-pip.py #2、安装python虚拟环境和依赖 cd /opt/matagent python3.11 -m venv pyautogen source pyautogen/bin/activate #安装pyautogen pip install pyautogen==0.2.34 pip install flaml[automl] pip install chromadb pip install Image #安装django pip install django pip install djangorestframework pip install requests #安装 websocket支持 channels+asgi pip install channels pip install asgiref # Django Channels 依赖的包 #运行服务支持http+websocket websocket接口 ws://192.168.42.130:8000/matagent/chat DJANGO_SETTINGS_MODULE=matagent.settings uvicorn matagent.asgi:application --host 0.0.0.0 --port 8000 #安装nginx sudo apt-get update sudo apt-get install nginx --查看状态 sudo systemctl status nginx --修改配置 /etc/nginx/default nginx配置在default

#pip install autogen-agentchat[websockets]~=0.2 fastapi uvicorn

完整agent的console版本

matagent_main.py是入口点。 安装requirements.txt里面的pyautogen然后运行即可。 .coding目录不要删除里面包含的是一个配置好的AGENT执行python代码的环境否则会报错。 如果存在问题,检查.coding/pyvenv.cfg文件配置 data目录记录了实验数据PL和UV数据不要删除否则会报错。

代码中agent之间的状态流转逻辑通常为每个group的state_transition函数中其中return 'auto'表示自动选择合适的agent。

简单agent的ui版本

cd ui-simple chainlit run --port 8989 appUI.py

chainlit继承了pyautogen的AssistantAgent在这个基础上实现了chainlit的接口。 class ChainlitAssistantAgent(AssistantAgent): class ChainlitUserProxyAgent(UserProxyAgent): 同时重载了两个方法以发送数据到前端。

"""
Wrapper for AutoGens Assistant Agent
"""
def send(
    self,
    message: Union[Dict, str],
    recipient: Agent,
    request_reply: Optional[bool] = None,
    silent: Optional[bool] = False,
) -> bool:
    cl.run_sync(
        cl.Message(
            content=f'**{self.name}** Sending message to "{recipient.name}":\n\n{message}',
            author=self.name,
        ).send()
    )
    super(ChainlitAssistantAgent, self).send(
        message=message,
        recipient=recipient,
        request_reply=request_reply,
        silent=silent,
    )
Description
多智能体
Readme MIT 122 MiB
Languages
C# 89.3%
Python 6.2%
Less 1.7%
Vue 1.6%
TypeScript 1.2%