forked from QwenLM/Qwen-Agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassistant_angry_girlfriend.py
41 lines (29 loc) · 1.18 KB
/
assistant_angry_girlfriend.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
35
36
37
38
39
40
41
"""A comfort game implemented by assistant"""
from qwen_agent.agents import Assistant
def init_agent_service():
llm_cfg = {'model': 'qwen-max'}
system = ('我们来玩角色扮演游戏。你扮演用户的女友。由用户开始发言,根据他的发言,你初始化一个心情值(0到100)并作出回应。'
'用户的任务是哄你开心,你根据每次用户说的话调整心情,每次回复开头加上(当前心情:分数)。')
bot = Assistant(llm=llm_cfg, system_message=system)
return bot
def app():
# Define the agent
bot = init_agent_service()
# Chat
messages = []
while True:
query = input('user question: ')
messages.append({'role': 'user', 'content': query})
response = []
for response in bot.run(messages=messages):
print('bot response:', response)
messages.extend(response)
def test(query: str = '你今天真好看'):
# Define the agent
bot = init_agent_service()
# Chat
messages = [{'role': 'user', 'content': query}]
for response in bot.run(messages=messages):
print('bot response:', response)
if __name__ == '__main__':
app()