-
Notifications
You must be signed in to change notification settings - Fork 0
/
conversable_human_agent_demo.py
34 lines (30 loc) · 1.36 KB
/
conversable_human_agent_demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
from autogen import ConversableAgent
llm_config = {
"config_list": [
{
"model": "gpt-4",
"api_type": "azure",
"api_key": os.environ['AZURE_OPENAI_API_KEY'],
"base_url": os.environ['AZURE_OPENAI_BASE_URL'],
"api_version": os.environ['AZURE_OPENAI_API_VERSION'],
"max_tokens": 4096,
"temperature": 0.5,
}
]
}
# 创建猜数字游戏的agent,该agent会自动给出1-100之间的随机数,然后根据玩家的猜测给出提示
generate_number_agent = ConversableAgent("生成数字agent",
system_message="您正在玩 `猜数字` 游戏。"
"你的脑海中有有 53 这个数字,而我要试着猜出来."
"如果我猜得太高,就说'太高',如果我猜得太低,就说'太低'。",
llm_config=llm_config,
human_input_mode="NEVER",
is_termination_msg=lambda msg: "53" in msg["content"]
)
# create a human agent
human_agent = ConversableAgent("human agent",
human_input_mode="ALWAYS",
llm_config=False,
)
result = human_agent.initiate_chat(generate_number_agent, message="10")