-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
114 lines (94 loc) · 3 KB
/
main.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
import sys
import argparse
import autogen
from agents import *
from tools import *
# Engineer + Executor
def engineer(prompt):
user = user_proxy()
executor = kubectl_executor()
engineer = kube_engineer(llm_config)
user.reset()
executor.reset()
engineer.reset()
group_chat = autogen.GroupChat(
agents=[user, engineer, executor],
max_round=20,
messages=[],
speaker_selection_method=engineer_selection(engineer, executor, user),
send_introductions=True,
)
manager = autogen.GroupChatManager(groupchat=group_chat, llm_config=llm_config)
group_chat_result = user.initiate_chat(
manager,
message=react_prompt_message,
question=prompt,
)
# Planner + Advisor
def advisor(prompt):
user = user_proxy()
planner = kube_planner(llm_config)
advisor = advisor_agent()
user.reset()
planner.reset()
advisor.reset()
group_chat = autogen.GroupChat(
agents=[user, planner, advisor],
max_round=50,
messages=[],
speaker_selection_method=planner_selection(user, planner, advisor),
send_introductions=True,
)
group_chat_result = user.initiate_chat(
autogen.GroupChatManager(groupchat=group_chat, llm_config=llm_config),
message=prompt,
)
# Planner + Advisor + Engineer
def PAE(prompt):
user = user_proxy()
executor = kubectl_executor()
engineer = kube_engineer(llm_config)
planner = kube_planner(llm_config)
advisor = advisor_agent()
user.reset()
executor.reset()
engineer.reset()
planner.reset()
advisor.reset()
group_chat = autogen.GroupChat(
agents=[user, engineer, planner, executor, advisor],
max_round=50,
messages=[],
speaker_selection_method=ocm_selection(
advisor, planner, engineer, executor, user
),
send_introductions=True,
)
manager = autogen.GroupChatManager(groupchat=group_chat, llm_config=llm_config)
group_chat_result = user.initiate_chat(
manager,
message=prompt,
)
print(">> END =================================================================")
# print(group_chat_result.summary)
def perform_task(runner, message):
runners = {"engineer": engineer, "advisor": advisor, "all": PAE}
task = runners.get(runner)
if task:
task(message)
else:
print(f"No valid runner '{runner}' was provided for task: {message}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Run a task based on the runner type.")
parser.add_argument("message", type=str, help="The message to indicate the task.")
parser.add_argument(
"--runner",
type=str,
default="all",
choices=["engineer", "advisor", "all"],
help="Specify the type of runner engineer, advisor or 'all' to execute the task.",
)
args = parser.parse_args()
if not args.message:
print("No valid message!")
perform_task(args.runner, args.message)