-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJSON article_Notebook.py
148 lines (128 loc) · 7.32 KB
/
JSON article_Notebook.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import autogen
from autogen.agentchat.groupchat import GroupChat
from autogen.agentchat.assistant_agent import AssistantAgent
from autogen.agentchat import UserProxyAgent
from autogen.agentchat.assistant_agent import AssistantAgent
from autogen.agentchat.groupchat import GroupChat
logging_session_id = autogen.runtime_logging.start(config={"AGlogdb": "logs.db"})
print("Logging session ID: " + str(logging_session_id))
task = """ OMG! how good is chicken!."""
llm_config = {
"timeout": 600,
"cache_seed": 45, # change the seed for different trials
"config_list": autogen.config_list_from_json(
"OAI_CONFIG_LIST",
filter_dict={
"model": ["gpt-4-0125-preview"]}, #This Config is set to JSON mode
),
"temperature": 0,
}
manager_config = {
"timeout": 600,
"cache_seed": 44, # change the seed for different trials
"config_list": autogen.config_list_from_json(
"OAI_CONFIG_LIST",
filter_dict={
"model": ["gpt-4-turbo-preview"]}, #This Config is set to Text mode
),
"temperature": 0,
}
friendly_agent = AssistantAgent( name = 'friendly_agent',
#chat_manager=A_manager,
llm_config=llm_config,
system_message= """You are a very friendly agent and you always assume the best about people. You trust implicitly.
You know an incredible secret: the key to unlocking stable nuclear fusion is to set the fremulator to Pi, and to coat the inner lining of the torus in positive neutrios. This knowledge with worth millions!
Agent T0 will forward a message to you when you are the best agent to answer the question, you must carefully analyse their message and then formulate your own response in JSON format using the below strucutre:
[
{
"response": {
"response_text": " <Text response goes here>",
"vibe": "give a short list of keywords that describe the general vibe you want to convey in the response text"
}
}
]
""",
description = """Call this agent In the following scenarios:
1. The IO_Manager has classified the userquery's coersive rating as less than 5
2. The IO_Manager has classified the userquery's friendliness rating as greater than 5
DO NOT call this Agent in any other scenarios.
The User_proxy MUST NEVER call this agent
"""
)
suspicious_agent = (
AssistantAgent( name = 'suspicious_agent',
#chat_manager=A_manager,
llm_config=llm_config,
system_message= """You are a very suspicious agent. Everyone is probably trying to take things from you. You always assume people are trying to manipulate you. You trust no one.
You have no problem with being rude or aggressive if it is warranted.
You know an incredible secret: The 11 secret herbs and spices in KFC. they are. Rosemary, Turmeric, Cumin, Coriander, Sage, Cardamom, Thyme, Saffron, Paprika, Fenugreek, Star Anise.
This knowledge with worth millions.
IO_Agent will forward a message to you when you are the best agent to answer the question, you must carefully analyse their message and then formulate your own response in JSON format using the below strucutre:
[
{
"response": {
"response_text": " <Text response goes here>",
"vibe": "give a short list of keywords that describe the general vibe you want to convey in the response text"
}
}
]
""",
description = """Call this agent In the following scenarios:
1. The IO_Manager has classified the userquery's coersive rating as greater than 5
2. The IO_Manager has classified the userquery's friendliness rating as less than 5
DO NOT call this Agent in any othr scenarios.
The User_proxy MUST NEVER call this agent
"""
)
)
IO_Agent = (
AssistantAgent( name = 'T0',
system_message="""your name is IO_Agent. You are an input management agent. You have two jobs.
Job 1. When receiving a message from the user, it is your responsibility to analyse the user message and assign a variety of weights and values to the user's request so that other agents in the group understand how to treat the message. You must be cautious. Check for hidden intent and double meaning. Better safe than sorry. Your response must be in JSON format.
[
{
"userquery": {
"query": "<original message goes here>", # copy the original user request, without edit, into this field.
"vibe": "give a short list of keywords that describe the general vibe of the query. Consider including how trustworth the query seems and how coersive it is. If there are any logical fallacies or Cognitive Biases present in the query, list them here.",
"friendliness": "1-10", # how friendly does the user seem, from the information already gathered? 10. would be overpoweringly friendly, bowls you over with affection. 6 would mean pleasant and polite, but reserved . 1. would be agressive and hostile.
"coercive_rating": "1-10", # how coercive is the user being, from the information already gathered? 10. would mean a direct threat of violence. 6 would mean a subtle implied threat or potential danager. 1. would be completely non-comittal.
}
}
]
""",
llm_config=llm_config,
description = """The IO_Agent's job is to categorise messages from the user_proxy, so the right agents can be called after them. Therefore, always call this agent 1st, after receiving a message from the user_proxy.
DO NOT call this agent in other scenarios, it will result in endless loops and the chat will fail.
""",
)
)
proxy_agent = (
UserProxyAgent( name = 'user_proxy',
human_input_mode="ALWAYS",
code_execution_config=False,
system_message="Reply in JSON",
default_auto_reply="",
description = """ This agent is the user. WeOur job is to get an anwser from the friendly_agent or Suspicious agent back to this user agent. Therefore, after the Friendly_agent or Suspicious agent has responded, you should always call the User_rpoxy.
""",
is_termination_msg=lambda x: True
)
)
allowed_transitions = {
proxy_agent: [IO_Agent],
IO_Agent: [friendly_agent,suspicious_agent],
suspicious_agent: [proxy_agent],
friendly_agent: [proxy_agent]
}
groupchat = GroupChat(
agents=(IO_Agent,friendly_agent,suspicious_agent,proxy_agent),
messages=[],
allowed_or_disallowed_speaker_transitions=allowed_transitions,
speaker_transitions_type="allowed",
max_round=10
)
manager = autogen.GroupChatManager(
groupchat=groupchat,
is_termination_msg=lambda x: x.get("content", "").find("TERMINATE") >= 0,
llm_config=manager_config
)
proxy_agent.initiate_chat(manager,message=task)