前提条件:在windows上安装docker
代码如下:
import os
import autogen
from autogen import AssistantAgent, UserProxyAgent
llm_config = {
"config_list": [
{
"model": "GLM-4-Plus",
"api_key": "your api key",
"base_url": "https://open.bigmodel.cn/api/paas/v4/",
}
]
}
with autogen.coding.DockerCommandLineCodeExecutor(work_dir="coding") as code_executor:
assistant = AssistantAgent("assistant", llm_config=llm_config)
user_proxy = UserProxyAgent(
"user_proxy", code_execution_config={"executor": code_executor}
)
# Start the chat
user_proxy.initiate_chat(
assistant,
message="1 plus 1 equals what?",
)
运行结果:
查看安装的镜像:
docker images
希望这些内容对你有所帮助!如果有任何问题,欢迎在评论区留言。