在體驗了華為云的 Flexus 云服務(wù)器 X 實例 后,感受到其卓越的性能和靈活性,通過彈性伸縮服務(wù)和負載均衡,能夠輕松應(yīng)對市場的瞬息萬變,確保業(yè)務(wù)的連續(xù)性和穩(wěn)定性。數(shù)據(jù)的可靠性和安全性也得到了極大的保障,華為云數(shù)據(jù)庫服務(wù)和網(wǎng)絡(luò)安全服務(wù)的結(jié)合,讓數(shù)據(jù)存儲和業(yè)務(wù)運行更加安全無憂。
對于個人開發(fā)者和測試人員來說,F(xiàn)lexus 云服務(wù)器 X 實例 的按需計費模式極大地降低了成本,同時提供了高可用性和可靠性,體驗上可以媲美自建環(huán)境。全棧的開發(fā)測試工具鏈更是提升了開發(fā)效率,讓創(chuàng)新和迭代變得更加迅速,點擊這里體驗~
下面就來一起體驗下吧!
一、什么是多智能體?****
多智能體系統(tǒng)是由多個智能體精妙組合而成的集合體,其核心宗旨在于將龐大且復雜的系統(tǒng)解構(gòu)為一系列小型、高度互聯(lián)、且能自主通信與協(xié)同工作的子系統(tǒng),從而顯著提升系統(tǒng)的可管理性與靈活性。這一領(lǐng)域的研究深入探索了智能體的認知知識、追求目標、掌握技能、規(guī)劃路徑,以及如何通過高效的協(xié)調(diào)機制促使它們共同行動以解決復雜問題。
二、什么是 AutoGen?****
AutoGen 是一個開源編程框架,用于構(gòu)建 AI 代理并促進多個代理之間的協(xié)作以解決任務(wù)。AutoGen 旨在簡化代理 AI 的開發(fā)和研究,就像 PyTorch 對深度學習所做的那樣。它提供的功能包括能夠相互交互的代理、促進使用各種大型語言模型 (LLM) 和工具使用支持、自主和人機交互工作流程以及多代理對話模式。
三、部署 AutoGen****
3.1 更新 apt 軟件源****
首先,更新下云服務(wù)器的 apt 軟件源,執(zhí)行如下命令更新。
root@flexusx-7305:~# sudo apt update
Hit:1 http://repo.huaweicloud.com/ubuntu focal InRelease
Get:2 http://repo.huaweicloud.com/ubuntu focal-updates InRelease [128 kB]
Hit:3 http://repo.huaweicloud.com/ubuntu focal-backports InRelease
Hit:4 http://repo.huaweicloud.com/ubuntu focal-security InRelease
Ign:5 https://download.docker.com/linux/ubuntu focal InRelease
Get:6 http://repo.huaweicloud.com/ubuntu focal-updates/main amd64 Packages [3,563 kB]
Err:7 https://download.docker.com/linux/ubuntu focal Release
Could not handshake: Error in the pull function. [IP: 18.155.68.38 443]
Get:8 http://repo.huaweicloud.com/ubuntu focal-updates/universe i386 Packages [807 kB]
Get:9 http://repo.huaweicloud.com/ubuntu focal-updates/universe amd64 Packages [1,231 kB]
Hit:10 https://packages.redis.io/deb focal InRelease
Reading package lists... Done
執(zhí)行如下命令安裝software-properties-common。
root@flexusx-7305:~# sudo apt install software-properties-common
3.2 安裝 python 3.10****
添加 ppa:deadsnakes/ppa,如下所示。
root@flexusx-7305:~# sudo add-apt-repository ppa:deadsnakes/ppa
AutoGen 需要 python 3.9 以上的版本,本文安裝 python 3.10,如下所示。
root@flexusx-7305:~# sudo apt install python3.10
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
redis-server redis-tools
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libpython3.10-minimal libpython3.10-stdlib python3.10-minimal
Suggested packages:
python3.10-venv binfmt-support
The following NEW packages will be installed:
libpython3.10-minimal libpython3.10-stdlib python3.10 python3.10-minimal
0 upgraded, 4 newly installed, 0 to remove and 33 not upgraded.
Need to get 5,221 kB of archives.
After this operation, 20.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 libpython3.10-minimal amd64 3.10.15-1+focal1 [825 kB]
Get:2 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.10-minimal amd64 3.10.15-1+focal1 [2,077 kB]
Get:3 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 libpython3.10-stdlib amd64 3.10.15-1+focal1 [1,763 kB]
Get:4 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.10 amd64 3.10.15-1+focal1 [556 kB]
Fetched 5,221 kB in 3s (1,707 kB/s)
Selecting previously unselected package libpython3.10-minimal:amd64.
(Reading database ... 117364 files and directories currently installed.)
Preparing to unpack .../libpython3.10-minimal_3.10.15-1+focal1_amd64.deb ...
Unpacking libpython3.10-minimal:amd64 (3.10.15-1+focal1) ...
Selecting previously unselected package python3.10-minimal.
Preparing to unpack .../python3.10-minimal_3.10.15-1+focal1_amd64.deb ...
Unpacking python3.10-minimal (3.10.15-1+focal1) ...
Selecting previously unselected package libpython3.10-stdlib:amd64.
Preparing to unpack .../libpython3.10-stdlib_3.10.15-1+focal1_amd64.deb ...
Unpacking libpython3.10-stdlib:amd64 (3.10.15-1+focal1) ...
Selecting previously unselected package python3.10.
Preparing to unpack .../python3.10_3.10.15-1+focal1_amd64.deb ...
Unpacking python3.10 (3.10.15-1+focal1) ...
Setting up libpython3.10-minimal:amd64 (3.10.15-1+focal1) ...
Setting up python3.10-minimal (3.10.15-1+focal1) ...
Setting up libpython3.10-stdlib:amd64 (3.10.15-1+focal1) ...
Setting up python3.10 (3.10.15-1+focal1) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
root@flexusx-7305:~#
創(chuàng)建 python 軟連接,讓 /usr/bin/python 指向 /usr/bin/python3.10,如果 python3 命令不是 3.10 版本,同樣也需要創(chuàng)建軟連接,然后查看 python 版本,如下所示。
root@flexusx-7305:~# ln -s /usr/bin/python3.10 /usr/bin/python
root@flexusx-7305:~# python --version
Python 3.10.15
root@flexusx-7305:~#
安裝 python3.10-venv 用于創(chuàng)建 python 虛擬環(huán)境,如下所示。
root@flexusx-7305:~# apt install python3.10-venv
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
redis-server redis-tools
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
python3.10-distutils python3.10-lib2to3
The following NEW packages will be installed:
python3.10-distutils python3.10-lib2to3 python3.10-venv
0 upgraded, 3 newly installed, 0 to remove and 33 not upgraded.
Need to get 3,243 kB of archives.
After this operation, 4,528 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.10-lib2to3 all 3.10.15-1+focal1 [126 kB]
Get:2 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.10-distutils all 3.10.15-1+focal1 [187 kB]
Get:3 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal/main amd64 python3.10-venv amd64 3.10.15-1+focal1 [2,931 kB]
Fetched 3,243 kB in 4s (880 kB/s)
Selecting previously unselected package python3.10-lib2to3.
(Reading database ... 118026 files and directories currently installed.)
Preparing to unpack .../python3.10-lib2to3_3.10.15-1+focal1_all.deb ...
Unpacking python3.10-lib2to3 (3.10.15-1+focal1) ...
Selecting previously unselected package python3.10-distutils.
Preparing to unpack .../python3.10-distutils_3.10.15-1+focal1_all.deb ...
Unpacking python3.10-distutils (3.10.15-1+focal1) ...
Selecting previously unselected package python3.10-venv.
Preparing to unpack .../python3.10-venv_3.10.15-1+focal1_amd64.deb ...
Unpacking python3.10-venv (3.10.15-1+focal1) ...
Setting up python3.10-lib2to3 (3.10.15-1+focal1) ...
Setting up python3.10-distutils (3.10.15-1+focal1) ...
Setting up python3.10-venv (3.10.15-1+focal1) ...
創(chuàng)建用于部署 AutoGen 的虛擬環(huán)境,執(zhí)行如下命令。
root@flexusx-7305:~# python3 -m venv autogentest
root@flexusx-7305:~# source autogentest/bin/activate
(autogentest) root@flexusx-7305:~#
3.3 安裝 AutoGen****
進入環(huán)境 AutoGen,執(zhí)行命令安裝 AutoGen,如下所示。
(autogentest) root@flexusx-7305:~# pip install autogen
Collecting autogen
Downloading autogen-0.3.0-py3-none-any.whl (345 kB)
|████████████████████████████████| 345 kB 968 kB/s
Collecting openai>=1.3
Using cached openai-1.45.0-py3-none-any.whl (374 kB)
Collecting docker
Downloading docker-7.1.0-py3-none-any.whl (147 kB)
|████████████████████████████████| 147 kB 17.6 MB/s
Collecting diskcache
Using cached diskcache-5.6.3-py3-none-any.whl (45 kB)
Collecting flaml
Using cached FLAML-2.2.0-py3-none-any.whl (297 kB)
Collecting termcolor
Using cached termcolor-2.4.0-py3-none-any.whl (7.7 kB)
Collecting numpy<2,>=1.17.0
Using cached numpy-1.24.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.3 MB)
Collecting pydantic!=2.6.0,<3,>=1.10
Using cached pydantic-2.9.1-py3-none-any.whl (434 kB)
Collecting tiktoken
Using cached tiktoken-0.7.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB)
Collecting python-dotenv
Using cached python_dotenv-1.0.1-py3-none-any.whl (19 kB)
Collecting packaging
Using cached packaging-24.1-py3-none-any.whl (53 kB)
Collecting httpx<1,>=0.23.0
Using cached httpx-0.27.2-py3-none-any.whl (76 kB)
Collecting jiter<1,>=0.4.0
Using cached jiter-0.5.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (319 kB)
查看 AutoGen 版本,執(zhí)行如下命令查看。
(autogentest) root@flexusx-7305:~# pip list | grep autogen
autogen 0.3.0
(autogentest) root@flexusx-7305:~#
3.4 安裝 AutoGen Studio****
執(zhí)行 wget 命令下載 autogenstudio 包,或者執(zhí)行 pip install autogenstudio,如下所示。
(autogentest)root@flexusx-7305:~#wget https://files.pythonhosted.org/packages/4c/ec/adb715c79656b18b31bfdfbc0253f7f4486b22fd7f7f3a21234bf5d0597c/autogenstudio-0.1.5-py3-none-any.whl
--2024-09-1511:55:58-- https://files.pythonhosted.org/packages/4c/ec/adb715c79656b18b31bfdfbc0253f7f4486b22fd7f7f3a21234bf5d0597c/autogenstudio-0.1.5-py3-none-any.whl
Resolving files.pythonhosted.org (files.pythonhosted.org)... 151.101.88.223, 2a04:4e42:15::223
Connecting to files.pythonhosted.org (files.pythonhosted.org)|151.101.88.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4434948 (4.2M) [application/octet-stream]
Saving to: ‘a(chǎn)utogenstudio-0.1.5-py3-none-any.whl’
autogenstudio-0.1.5-py3-none-any.whl 100%[======================>] 4.23M 6.43MB/s in 0.7s
2024-09-15 11:55:59 (6.43 MB/s) - ‘a(chǎn)utogenstudio-0.1.5-py3-none-any.whl’ saved [4434948/4434948]
pip 安裝 autogenstudio,如下所示。
(autogentest) root@flexusx-7305:~# pip install autogenstudio-0.1.5-py3-none-any.whl
Processing ./autogenstudio-0.1.5-py3-none-any.whl
Collecting arxiv
Downloading arxiv-2.1.3-py3-none-any.whl (11 kB)
Collecting pydantic
Using cached pydantic-2.9.1-py3-none-any.whl (434 kB)
Collecting numpy<2.0.0
Downloading numpy-1.26.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB) 18.2/18.2 MB 49.9 MB/s eta 0:00:00
Collecting sqlmodel
Downloading sqlmodel-0.0.22-py3-none-any.whl (28 kB)
Collecting fastapi
Downloading fastapi-0.114.2-py3-none-any.whl (94 kB)94.0/94.0 kB 864.9 kB/s eta 0:00:00
Collecting typer
Downloading typer-0.12.5-py3-none-any.whl (47 kB) 47.3/47.3 kB 3.9 MB/s eta 0:00:00
Collecting alembic
Downloading alembic-1.13.2-py3-none-any.whl (232 kB)233.0/233.0 kB 3.1 MB/s eta 0:00:00
Collecting loguru
Downloading loguru-0.7.2-py3-none-any.whl (62 kB)62.5/62.5 kB 13.6 MB/s eta 0:00:00
至此,所有部署工作完成。
四、運行 AutoGen Studio****
啟動 AutoGen Studio,指定端口,如下所示。
(autogentest) root@flexusx-7305:~# autogenstudio ui --host 0.0.0.0 --port 3001
2024-09-15 14:22:26.963 | INFO | autogenstudio.utils.utils:get_db_uri:253 - Using database URI: sqlite:root/.autogenstudio/database.sqlite
2024-09-15 14:22:26.963 | INFO | autogenstudio.utils.utils:init_app_folders:288 - Initialized application data folder: /root/.autogenstudio
INFO: Started server process [153974]
INFO: Waiting for application startup.
***** App started *****
2024-09-15 14:22:27.006 | INFO | autogenstudio.database.utils:init_db_samples:148 - Database already initialized with Default and Travel Planning Workflows
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:3001 (Press CTRL+C to quit)
訪問 http://服務(wù)器 IP:3001,界面如下所示。
點擊 Build 按鈕,進入構(gòu)建頁面,如下所示。
下面通過展示實例測試多智能體交互。
五、實例展示****
5.1 構(gòu)建實例****
創(chuàng)建 test.py 文件,復制如下代碼。
import os
from autogen import AssistantAgent, UserProxyAgent
llm_config = {"model": "",
"api_key": "",
"base_url": ""
}
assistant = AssistantAgent("assistant", llm_config=llm_config)
user_proxy = UserProxyAgent("user_proxy",
llm_config=False,
human_input_mode="NEVER",
code_execution_config=False)
開始對話
chat_result = user_proxy.initiate_chat(
assistant,
message="北京有哪些景點?",
max_turns=2
)
其中, 需要替換為模型名稱, 為密鑰, 為基礎(chǔ) URL,API 需要兼容 OpenAI API。
5.2 運行****
執(zhí)行 python test.py 運行代碼,如下所示。
(autogentest) root@flexusx-7305:~# python test.py
user_proxy (to assistant):
北京有哪些景點?
assistant (to user_proxy):
北京是中國的首都,擁有豐富的歷史遺產(chǎn)和文化景點。其中一些最著名的景點包括:
故宮:清朝的皇宮,也是世界上最大的宮殿建筑群。
天安門廣場: мире 最大的城市廣場之一,是許多重要事件的發(fā)生地。
長城:世界上最長的墻,也是中國最著名的景點之一。
juven]).
頤和園:清朝皇帝的夏宮,被譽為“中國園林之母”。
圓明園:清朝皇帝的私家園林,也是中國最大的園林之一。
天壇:明清兩代皇帝在這里祭祀天地和祖先的場所。
東城區(qū):位于北京中心的商業(yè)區(qū),擁有眾多高檔購物商場和餐廳。
西單:北京最繁華的購物街之一。
北京奧林匹克公園:2008 年北京奧運會的舉辦地,內(nèi)有鳥巢等標志性建筑。
(autogentest) root@flexusx-7305:~#
六、總結(jié)****
通過深入探索并充分體驗 “Flexus 云服務(wù)器 X 實例” 后,順利部署了 AutoGen 及其配套的開發(fā)環(huán)境 AutoGen Studio,并展示了其高效運行的成果。此次實踐不僅突顯了 Flexus 云服務(wù)器 X 實例 在部署與應(yīng)用上的便捷與高效特性,更以其絲滑無阻的操作體驗,讓即便是技術(shù)新手也能迅速掌握,日常運維工作因此變得前所未有的輕松與高效。對于渴望在代碼管理領(lǐng)域?qū)崿F(xiàn)高效與流暢體驗的用戶而言,F(xiàn)lexus 云服務(wù)器 X 實例 無疑是一個不容錯過的理想之選。立即行動,親身體驗其卓越性能與便捷管理帶來的無限可能!
審核編輯 黃宇
-
云服務(wù)器
+關(guān)注
關(guān)注
0文章
662瀏覽量
13381 -
華為云
+關(guān)注
關(guān)注
3文章
2607瀏覽量
17478
發(fā)布評論請先 登錄
相關(guān)推薦
評論