TRaw commited on
Commit
521619e
·
1 Parent(s): 35d2072

Upload 21 files

Browse files
.gitattributes ADDED
@@ -0,0 +1 @@
 
 
1
+ AutoGenPanel.gif filter=lfs diff=lfs merge=lfs -text
AutoGenPanel.gif ADDED

Git LFS Details

  • SHA256: 8adc29ebe34c0367207cba7effdb5563fd8b8a3cad754b6a7feed25560894c17
  • Pointer size: 132 Bytes
  • Size of remote file: 9.88 MB
Dockerfile ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10.13-slim-bookworm
2
+
3
+ # Add user
4
+ RUN adduser --disabled-password --gecos '' autogen
5
+ RUN adduser autogen sudo
6
+
7
+ # Setup working directory
8
+ WORKDIR /home/autogen
9
+ COPY . /home/autogen/
10
+
11
+ # Setup permissions
12
+ RUN chown -R autogen:autogen /home/autogen
13
+ RUN chmod -R 755 /home/autogen
14
+
15
+ # Setup user to not run as root
16
+ RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
17
+ USER autogen
18
+
19
+ # Install app requirements
20
+ RUN pip3 install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
21
+ RUN pip3 install -U pip && pip3 install --no-cache-dir -r requirements.txt
22
+ ENV PATH="${PATH}:/home/autogen/.local/bin"
23
+
24
+ EXPOSE 7860
25
+ ENTRYPOINT ["panel", "serve", "app.py", "--address", "0.0.0.0", "--port", "7860", "--allow-websocket-origin", "*"]
README.md CHANGED
@@ -5,6 +5,29 @@ colorFrom: gray
5
  colorTo: green
6
  sdk: docker
7
  pinned: false
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  colorTo: green
6
  sdk: docker
7
  pinned: false
8
+ license: mit
9
  ---
10
 
11
+ # Microsoft AutoGen: Play Ground
12
+
13
+ This demo is an AutoGen playground implemented with [Panel](https://panel.holoviz.org/index.html).
14
+
15
+ ## Run app
16
+ ```
17
+ # Install dependencies
18
+ pip install -U -r requirements.txt
19
+
20
+ # Launch app
21
+ bash run.sh
22
+ ```
23
+
24
+ ## Run docker locally
25
+ ```
26
+ docker build -t autogen/groupchat .
27
+ docker run -it autogen/groupchat -p 5006:5006
28
+ ```
29
+
30
+ #### [AutoGen](https://github.com/microsoft/autogen) [SourceCode](https://github.com/thinkall/autogen-demos)
31
+ ![](autogen_playground.png)
32
+
33
+ ![](AutoGenPanel.gif)
app.py ADDED
@@ -0,0 +1,557 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ import os
3
+ import random
4
+ import time
5
+ from functools import partial
6
+
7
+ import autogen
8
+ import panel as pn
9
+ from autogen_utils import (
10
+ MathUserProxyAgent,
11
+ RetrieveUserProxyAgent,
12
+ check_termination_and_human_reply,
13
+ generate_code,
14
+ get_retrieve_config,
15
+ initialize_agents,
16
+ )
17
+ from configs import DEFAULT_TERMINATE_MESSAGE, Q1, Q2, Q3, TIMEOUT, TITLE
18
+ from custom_widgets import RowAgentWidget
19
+ from panel.chat import ChatInterface
20
+ from panel.widgets import Button, CodeEditor, PasswordInput, Switch, TextInput
21
+
22
+ pn.extension("codeeditor")
23
+
24
+ template = pn.template.BootstrapTemplate(title=TITLE)
25
+
26
+
27
+ def get_description_text():
28
+ return f"""
29
+ # {TITLE}
30
+
31
+ This is an AutoGen group chat playground built with [Panel](https://panel.holoviz.org/). You can use it to interact with the AutoGen agents. Scroll down to see the code for creating and using the agents.
32
+
33
+ #### [[AutoGen](https://github.com/microsoft/autogen)] [[Discord](https://discord.gg/pAbnFJrkgZ)] [[Paper](https://arxiv.org/abs/2308.08155)] [[SourceCode](https://github.com/thinkall/autogen-demos)]
34
+ """
35
+
36
+
37
+ template.main.append(
38
+ pn.pane.Markdown(get_description_text(), sizing_mode="stretch_width")
39
+ )
40
+
41
+ txt_model = TextInput(
42
+ name="Model Name",
43
+ placeholder="Enter your model name here...",
44
+ value="gpt-35-turbo",
45
+ sizing_mode="stretch_width",
46
+ )
47
+ pwd_openai_key = PasswordInput(
48
+ name="OpenAI API Key",
49
+ placeholder="Enter your OpenAI API Key here...",
50
+ sizing_mode="stretch_width",
51
+ )
52
+ pwd_openai_url = PasswordInput(
53
+ name="OpenAI Base Url",
54
+ placeholder="Enter your OpenAI Base Url here...",
55
+ sizing_mode="stretch_width",
56
+ )
57
+ pwd_aoai_key = PasswordInput(
58
+ name="Azure OpenAI API Key",
59
+ placeholder="Enter your Azure OpenAI API Key here...",
60
+ sizing_mode="stretch_width",
61
+ )
62
+ pwd_aoai_url = PasswordInput(
63
+ name="Azure OpenAI Base Url",
64
+ placeholder="Enter your Azure OpenAI Base Url here...",
65
+ sizing_mode="stretch_width",
66
+ )
67
+ file_cfg = pn.widgets.FileInput(filename="OAI_CONFIG_LIST", sizing_mode="stretch_width")
68
+ template.main.append(
69
+ pn.Row(
70
+ txt_model, pwd_openai_key, pwd_openai_url, pwd_aoai_key, pwd_aoai_url, file_cfg
71
+ )
72
+ )
73
+
74
+
75
+ def get_config(tmpfilename="OAI_CONFIG_LIST"):
76
+ os.makedirs(".chromadb", exist_ok=True)
77
+ if file_cfg.value:
78
+ if os.path.exists(f".chromadb/{tmpfilename}"):
79
+ os.remove(f".chromadb/{tmpfilename}")
80
+ file_cfg.save(f".chromadb/{tmpfilename}")
81
+ cfg_fpath = f".chromadb/{tmpfilename}"
82
+ else:
83
+ cfg_fpath = "OAI_CONFIG_LIST" # for local testing
84
+ config_list = autogen.config_list_from_json(
85
+ cfg_fpath,
86
+ file_location=".",
87
+ )
88
+ if not config_list:
89
+ os.environ["MODEL"] = txt_model.value
90
+ os.environ["OPENAI_API_KEY"] = pwd_openai_key.value
91
+ os.environ["OPENAI_API_BASE"] = pwd_openai_url.value
92
+ os.environ["AZURE_OPENAI_API_KEY"] = pwd_aoai_key.value
93
+ os.environ["AZURE_OPENAI_API_BASE"] = pwd_aoai_url.value
94
+
95
+ config_list = autogen.config_list_from_models(
96
+ model_list=[os.environ.get("MODEL", "gpt-35-turbo")],
97
+ )
98
+ for cfg in config_list:
99
+ if cfg.get("api_type", "open_ai") == "open_ai":
100
+ base_url = os.environ.get("OPENAI_API_BASE", "").strip()
101
+ if base_url:
102
+ cfg["base_url"] = base_url
103
+ if not config_list:
104
+ config_list = [
105
+ {
106
+ "api_key": "",
107
+ "base_url": "",
108
+ "api_type": "azure",
109
+ "api_version": "2023-07-01-preview",
110
+ "model": "gpt-35-turbo",
111
+ }
112
+ ]
113
+
114
+ llm_config = {
115
+ "timeout": TIMEOUT,
116
+ "cache_seed": 42,
117
+ "config_list": config_list,
118
+ "temperature": 0,
119
+ }
120
+
121
+ return llm_config
122
+
123
+
124
+ btn_add = Button(name="+", button_type="success")
125
+ btn_remove = Button(name="-", button_type="danger")
126
+ switch_code = Switch(
127
+ name="Run Code", sizing_mode="fixed", width=50, height=30, align="end"
128
+ )
129
+ select_speaker_method = pn.widgets.Select(
130
+ name="", options=["round_robin", "auto", "random"], value="round_robin"
131
+ )
132
+ template.main.append(
133
+ pn.Row(
134
+ pn.pane.Markdown("## Add or Remove Agents: "),
135
+ btn_add,
136
+ btn_remove,
137
+ pn.pane.Markdown("### Run Code: "),
138
+ switch_code,
139
+ pn.pane.Markdown("### Speaker Selection Method: "),
140
+ select_speaker_method,
141
+ )
142
+ )
143
+
144
+ column_agents = pn.Column(
145
+ RowAgentWidget(
146
+ value=[
147
+ "User_Proxy",
148
+ "",
149
+ "UserProxyAgent",
150
+ "",
151
+ ]
152
+ ),
153
+ sizing_mode="stretch_width",
154
+ )
155
+ column_agents.append(
156
+ RowAgentWidget(
157
+ value=[
158
+ "Assistant_Agent",
159
+ "",
160
+ "AssistantAgent",
161
+ "",
162
+ ]
163
+ ),
164
+ )
165
+
166
+ template.main.append(column_agents)
167
+
168
+
169
+ def add_agent(event):
170
+ column_agents.append(RowAgentWidget(value=["", "", "AssistantAgent", ""]))
171
+
172
+
173
+ def remove_agent(event):
174
+ if len(column_agents) > 0:
175
+ column_agents.pop(-1)
176
+
177
+
178
+ btn_add.on_click(add_agent)
179
+ btn_remove.on_click(remove_agent)
180
+
181
+
182
+ async def send_messages(recipient, messages, sender, config):
183
+ # print(f"{sender.name} -> {recipient.name}: {messages[-1]['content']}")
184
+ chatiface.send(messages[-1]["content"], user=sender.name, respond=False)
185
+ return False, None # required to ensure the agent communication flow continues
186
+
187
+
188
+ class myGroupChatManager(autogen.GroupChatManager):
189
+ def _send_messages(self, message, sender, config):
190
+ message = self._message_to_dict(message)
191
+
192
+ if message.get("role") == "function":
193
+ content = message["content"]
194
+ else:
195
+ content = message.get("content")
196
+ if content is not None:
197
+ if "context" in message:
198
+ content = autogen.OpenAIWrapper.instantiate(
199
+ content,
200
+ message["context"],
201
+ self.llm_config
202
+ and self.llm_config.get("allow_format_str_template", False),
203
+ )
204
+ if "function_call" in message:
205
+ function_call = dict(message["function_call"])
206
+ content = f"Suggested function Call: {function_call.get('name', '(No function name found)')}"
207
+ chatiface.send(content, user=sender.name, respond=False)
208
+ return False, None # required to ensure the agent communication flow continues
209
+
210
+ def _process_received_message(self, message, sender, silent):
211
+ message = self._message_to_dict(message)
212
+ # When the agent receives a message, the role of the message is "user". (If 'role' exists and is 'function', it will remain unchanged.)
213
+ valid = self._append_oai_message(message, "user", sender)
214
+ if not valid:
215
+ raise ValueError(
216
+ "Received message can't be converted into a valid ChatCompletion message. Either content or function_call must be provided."
217
+ )
218
+ if not silent:
219
+ self._print_received_message(message, sender)
220
+ self._send_messages(message, sender, None)
221
+
222
+
223
+ def init_groupchat(event, collection_name):
224
+ llm_config = get_config(collection_name)
225
+ agents = []
226
+ for row_agent in column_agents:
227
+ agent_name = row_agent[0][0].value
228
+ system_msg = row_agent[0][1].value
229
+ agent_type = row_agent[0][2].value
230
+ docs_path = row_agent[1].value
231
+ retrieve_config = (
232
+ get_retrieve_config(
233
+ docs_path,
234
+ txt_model.value,
235
+ collection_name=collection_name,
236
+ )
237
+ if agent_type == "RetrieveUserProxyAgent"
238
+ else None
239
+ )
240
+ code_execution_config = (
241
+ {
242
+ "work_dir": "coding",
243
+ "use_docker": False, # set to True or image name like "python:3" to use docker
244
+ }
245
+ if switch_code.value
246
+ else False
247
+ )
248
+ agent = initialize_agents(
249
+ llm_config,
250
+ agent_name,
251
+ system_msg,
252
+ agent_type,
253
+ retrieve_config,
254
+ code_execution_config,
255
+ )
256
+ agent.register_reply(
257
+ [autogen.Agent, None], reply_func=send_messages, config={"callback": None}
258
+ )
259
+ agents.append(agent)
260
+ if len(agents) >= 3:
261
+ groupchat = autogen.GroupChat(
262
+ agents=agents,
263
+ messages=[],
264
+ max_round=12,
265
+ speaker_selection_method=select_speaker_method.value,
266
+ allow_repeat_speaker=False,
267
+ )
268
+ manager = myGroupChatManager(groupchat=groupchat, llm_config=llm_config)
269
+ else:
270
+ manager = None
271
+ groupchat = None
272
+ return agents, manager, groupchat
273
+
274
+
275
+ async def agents_chat(init_sender, manager, contents, agents):
276
+ recipient = (
277
+ manager
278
+ if len(agents) > 2
279
+ else agents[1]
280
+ if agents[1] != init_sender
281
+ else agents[0]
282
+ )
283
+ if isinstance(init_sender, (RetrieveUserProxyAgent, MathUserProxyAgent)):
284
+ await init_sender.a_initiate_chat(recipient, problem=contents)
285
+ else:
286
+ await init_sender.a_initiate_chat(recipient, message=contents)
287
+
288
+
289
+ async def reply_chat(contents, user, instance):
290
+ if hasattr(instance, "collection_name"):
291
+ collection_name = instance.collection_name
292
+ else:
293
+ collection_name = f"{int(time.time())}_{random.randint(0, 100000)}"
294
+ instance.collection_name = collection_name
295
+
296
+ column_agents_list = [[a.value for a in agent[0]] for agent in column_agents] + [
297
+ switch_code.value
298
+ ]
299
+ if (
300
+ not hasattr(instance, "agent_list")
301
+ or instance.agents_list != column_agents_list
302
+ ):
303
+ agents, manager, groupchat = init_groupchat(None, collection_name)
304
+ instance.manager = manager
305
+ instance.agents = agents
306
+ instance.agents_list = column_agents_list
307
+ else:
308
+ agents = instance.agents
309
+ manager = instance.manager
310
+
311
+ if len(agents) <= 1:
312
+ return "Please add more agents."
313
+
314
+ init_sender = None
315
+ for agent in agents:
316
+ if "UserProxy" in str(type(agent)):
317
+ init_sender = agent
318
+ break
319
+ for agent in agents:
320
+ # Hack for get human input
321
+ agent._reply_func_list.pop(1)
322
+ agent.register_reply(
323
+ [autogen.Agent, None],
324
+ partial(check_termination_and_human_reply, instance=instance),
325
+ 1,
326
+ )
327
+ if manager is not None:
328
+ for agent in agents:
329
+ agent._reply_func_list.pop(0)
330
+
331
+ if not init_sender:
332
+ init_sender = agents[0]
333
+ await generate_code(agents, manager, contents, code_editor, groupchat)
334
+ await agents_chat(init_sender, manager, contents, agents)
335
+ return "The task is done. Please start a new task."
336
+
337
+
338
+ chatiface = ChatInterface(
339
+ callback=reply_chat,
340
+ height=600,
341
+ )
342
+
343
+ template.main.append(chatiface)
344
+
345
+ btn_msg1 = Button(name=Q1, sizing_mode="stretch_width")
346
+ btn_msg2 = Button(name=Q2, sizing_mode="stretch_width")
347
+ btn_msg3 = Button(name=Q3, sizing_mode="stretch_width")
348
+ template.main.append(
349
+ pn.Column(
350
+ pn.pane.Markdown("## Message Examples: ", sizing_mode="stretch_width"),
351
+ btn_msg1,
352
+ btn_msg2,
353
+ btn_msg3,
354
+ sizing_mode="stretch_width",
355
+ )
356
+ )
357
+
358
+
359
+ def load_message(event):
360
+ if event.obj.name == Q1:
361
+ chatiface.send(Q1)
362
+ elif event.obj.name == Q2:
363
+ chatiface.send(Q2)
364
+ elif event.obj.name == Q3:
365
+ chatiface.send(Q3)
366
+
367
+
368
+ btn_msg1.on_click(load_message)
369
+ btn_msg2.on_click(load_message)
370
+ btn_msg3.on_click(load_message)
371
+
372
+
373
+ btn_example1 = Button(
374
+ name="General 2 agents", button_type="primary", sizing_mode="stretch_width"
375
+ )
376
+ btn_example2 = Button(
377
+ name="RAG 2 agents", button_type="primary", sizing_mode="stretch_width"
378
+ )
379
+ btn_example3 = Button(
380
+ name="Software Dev 3 agents", button_type="primary", sizing_mode="stretch_width"
381
+ )
382
+ btn_example4 = Button(
383
+ name="Research 6 agents", button_type="primary", sizing_mode="stretch_width"
384
+ )
385
+ template.main.append(
386
+ pn.Row(
387
+ pn.pane.Markdown("## Agent Examples: ", sizing_mode="stretch_width"),
388
+ btn_example1,
389
+ btn_example2,
390
+ btn_example3,
391
+ btn_example4,
392
+ sizing_mode="stretch_width",
393
+ )
394
+ )
395
+
396
+
397
+ def clear_agents():
398
+ while len(column_agents) > 0:
399
+ column_agents.pop(-1)
400
+
401
+
402
+ def load_example(event):
403
+ clear_agents()
404
+ if event.obj.name == "RAG 2 agents":
405
+ column_agents.append(
406
+ RowAgentWidget(
407
+ value=[
408
+ "Boss_Assistant",
409
+ "Assistant who has extra content retrieval power for solving difficult problems.",
410
+ "RetrieveUserProxyAgent",
411
+ "",
412
+ ]
413
+ ),
414
+ )
415
+ column_agents.append(
416
+ RowAgentWidget(
417
+ value=[
418
+ "Senior_Python_Engineer",
419
+ f"You are a senior python engineer. {DEFAULT_TERMINATE_MESSAGE}",
420
+ "RetrieveAssistantAgent",
421
+ "",
422
+ ]
423
+ ),
424
+ )
425
+ elif event.obj.name == "General 2 agents":
426
+ column_agents.append(
427
+ RowAgentWidget(
428
+ value=[
429
+ "User_Proxy",
430
+ "",
431
+ "UserProxyAgent",
432
+ "",
433
+ ]
434
+ ),
435
+ )
436
+ column_agents.append(
437
+ RowAgentWidget(
438
+ value=[
439
+ "Assistant_Agent",
440
+ "",
441
+ "AssistantAgent",
442
+ "",
443
+ ]
444
+ ),
445
+ )
446
+ elif event.obj.name == "Software Dev 3 agents":
447
+ column_agents.append(
448
+ RowAgentWidget(
449
+ value=[
450
+ "Boss",
451
+ f"The boss who ask questions and give tasks. {DEFAULT_TERMINATE_MESSAGE}",
452
+ "UserProxyAgent",
453
+ "",
454
+ ]
455
+ ),
456
+ )
457
+ column_agents.append(
458
+ RowAgentWidget(
459
+ value=[
460
+ "Senior_Python_Engineer",
461
+ f"You are a senior python engineer. {DEFAULT_TERMINATE_MESSAGE}",
462
+ "AssistantAgent",
463
+ "",
464
+ ]
465
+ ),
466
+ )
467
+ column_agents.append(
468
+ RowAgentWidget(
469
+ value=[
470
+ "Product_Manager",
471
+ f"You are a product manager. {DEFAULT_TERMINATE_MESSAGE}",
472
+ "AssistantAgent",
473
+ "",
474
+ ]
475
+ ),
476
+ )
477
+ elif event.obj.name == "Research 6 agents":
478
+ column_agents.append(
479
+ RowAgentWidget(
480
+ value=[
481
+ "Admin",
482
+ "A human admin. Interact with the planner to discuss the plan. Plan execution needs to be approved by this admin.",
483
+ "UserProxyAgent",
484
+ "",
485
+ ]
486
+ ),
487
+ )
488
+ column_agents.append(
489
+ RowAgentWidget(
490
+ value=[
491
+ "Engineer",
492
+ """Engineer. You follow an approved plan. You write python/shell code to solve tasks. Wrap the code in a code block that specifies the script type. The user can't modify your code. So do not suggest incomplete code which requires others to modify. Don't use a code block if it's not intended to be executed by the executor.
493
+ Don't include multiple code blocks in one response. Do not ask others to copy and paste the result. Check the execution result returned by the executor.
494
+ If the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.
495
+ """,
496
+ "AssistantAgent",
497
+ "",
498
+ ]
499
+ ),
500
+ )
501
+ column_agents.append(
502
+ RowAgentWidget(
503
+ value=[
504
+ "Scientist",
505
+ """Scientist. You follow an approved plan. You are able to categorize papers after seeing their abstracts printed. You don't write code.""",
506
+ "AssistantAgent",
507
+ "",
508
+ ]
509
+ ),
510
+ )
511
+ column_agents.append(
512
+ RowAgentWidget(
513
+ value=[
514
+ "Planner",
515
+ """Planner. Suggest a plan. Revise the plan based on feedback from admin and critic, until admin approval.
516
+ The plan may involve an engineer who can write code and a scientist who doesn't write code.
517
+ Explain the plan first. Be clear which step is performed by an engineer, and which step is performed by a scientist.
518
+ """,
519
+ "AssistantAgent",
520
+ "",
521
+ ]
522
+ ),
523
+ )
524
+ column_agents.append(
525
+ RowAgentWidget(
526
+ value=[
527
+ "Critic",
528
+ "Critic. Double check plan, claims, code from other agents and provide feedback. Check whether the plan includes adding verifiable info such as source URL.",
529
+ "AssistantAgent",
530
+ "",
531
+ ]
532
+ ),
533
+ )
534
+
535
+ column_agents.append(
536
+ RowAgentWidget(
537
+ value=[
538
+ "Executor",
539
+ "Executor. Execute the code written by the engineer and report the result.",
540
+ "UserProxyAgent",
541
+ "",
542
+ ]
543
+ ),
544
+ )
545
+
546
+
547
+ btn_example1.on_click(load_example)
548
+ btn_example2.on_click(load_example)
549
+ btn_example3.on_click(load_example)
550
+ btn_example4.on_click(load_example)
551
+
552
+ code_editor = CodeEditor(
553
+ value="", sizing_mode="stretch_width", language="python", height=300
554
+ )
555
+ template.main.append(code_editor)
556
+
557
+ template.servable(title=TITLE)
autogen_playground.png ADDED
configs.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import autogen
2
+
3
+ TIMEOUT = 60
4
+ TITLE = "Microsoft AutoGen Group Chat Playground"
5
+ Q1 = "What's AutoGen?"
6
+ Q2 = "Write a python function to compute the sum of numbers."
7
+ Q3 = "find papers on LLM applications from arxiv in the last week, create a markdown table of different domains."
8
+
9
+ DEFAULT_SYSTEM_MESSAGE = autogen.AssistantAgent.DEFAULT_SYSTEM_MESSAGE
10
+ DEFAULT_TERMINATE_MESSAGE = "Reply `TERMINATE` in the end if the task is done."
11
+ DEFAULT_AUTO_REPLY = "Good, thank you. Reply `TERMINATE` to finish."
custom_widgets.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import panel as pn
2
+ import param
3
+ from panel.viewable import Viewer
4
+ from panel.widgets import Button, PasswordInput, Select, TextAreaInput, TextInput
5
+
6
+ DEFAULT_LIST = [
7
+ "https://raw.githubusercontent.com/microsoft/autogen/main/README.md",
8
+ "https://raw.githubusercontent.com/microsoft/FLAML/main/website/docs/Examples/Integrate%20-%20Spark.md",
9
+ ]
10
+
11
+
12
+ class RowAgentWidget(Viewer):
13
+ """A widget for creating a row of agent widgets. Including agent name, system message, and agent type."""
14
+
15
+ value = param.List(
16
+ default=[
17
+ "",
18
+ "",
19
+ "AssistantAgent",
20
+ DEFAULT_LIST,
21
+ ],
22
+ doc="Agent name, system message, and agent type",
23
+ )
24
+
25
+ def __init__(self, **params):
26
+ layout_params = {key: value for key, value in params.items() if key not in ["value"]}
27
+ params = {key: value for key, value in params.items() if key not in layout_params}
28
+ self._agent_name = TextInput(
29
+ name="",
30
+ value=params.get("value")[0],
31
+ placeholder="Agent Name (can only contain letters, numbers, and underscores))",
32
+ min_width=100,
33
+ sizing_mode="scale_width",
34
+ )
35
+ self._system_msg = TextInput(
36
+ name="",
37
+ value=params.get("value")[1],
38
+ placeholder="System Message, leave empty to use default",
39
+ min_width=400,
40
+ sizing_mode="scale_width",
41
+ )
42
+ self._agent_type = Select(
43
+ name="",
44
+ value=params.get("value")[2],
45
+ min_width=100,
46
+ options=[
47
+ "AssistantAgent",
48
+ "UserProxyAgent",
49
+ "RetrieveUserProxyAgent",
50
+ "RetrieveAssistantAgent",
51
+ "CompressibleAgent",
52
+ "GPTAssistantAgent",
53
+ "LLaVAAgent",
54
+ "MathUserProxyAgent",
55
+ # "TeachableAgent",
56
+ ],
57
+ sizing_mode="scale_width",
58
+ )
59
+ self._rag_docs = TextAreaInput(
60
+ name="",
61
+ value=f"{DEFAULT_LIST}",
62
+ placeholder="List of links to docs",
63
+ sizing_mode="scale_width",
64
+ auto_grow=True,
65
+ visible=False,
66
+ )
67
+
68
+ super().__init__(**params)
69
+ self._layout = pn.Column(
70
+ pn.Row(self._agent_name, self._system_msg, self._agent_type, sizing_mode="scale_width"),
71
+ self._rag_docs,
72
+ sizing_mode="scale_width",
73
+ )
74
+ self._sync_widgets()
75
+
76
+ def __panel__(self):
77
+ return self._layout
78
+
79
+ @param.depends("value", watch=True)
80
+ def _sync_widgets(self):
81
+ self._agent_name.value = self.value[0]
82
+ self._system_msg.value = self.value[1]
83
+ self._agent_type.value = self.value[2]
84
+ if self.value[2] == "RetrieveUserProxyAgent":
85
+ self._rag_docs.visible = True
86
+ else:
87
+ self._rag_docs.visible = False
88
+
89
+ @param.depends("_agent_name.value", "_system_msg.value", "_agent_type.value", "_rag_docs.value", watch=True)
90
+ def _sync_params(self):
91
+ self.value = [self._agent_name.value, self._system_msg.value, self._agent_type.value, self._rag_docs.value]
dockerignore ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .docusaurus/
2
+ node_modules/
3
+ # Project
4
+ /.vs
5
+ .vscode
6
+
7
+ # Log files
8
+ *.log
9
+
10
+ # Python virtualenv
11
+ .venv
12
+
13
+ # Byte-compiled / optimized / DLL files
14
+ __pycache__/
15
+ *.py[cod]
16
+ *$py.class
17
+
18
+ # C extensions
19
+ *.so
20
+
21
+ # Distribution / packaging
22
+ .Python
23
+ build/
24
+ develop-eggs/
25
+ dist/
26
+ downloads/
27
+ eggs/
28
+ .eggs/
29
+ lib/
30
+ lib64/
31
+ parts/
32
+ sdist/
33
+ var/
34
+ wheels/
35
+ share/python-wheels/
36
+ *.egg-info/
37
+ .installed.cfg
38
+ *.egg
39
+ MANIFEST
40
+
41
+ # PyInstaller
42
+ # Usually these files are written by a python script from a template
43
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
44
+ *.manifest
45
+ *.spec
46
+
47
+ # Installer logs
48
+ pip-log.txt
49
+ pip-delete-this-directory.txt
50
+
51
+ # Unit test / coverage reports
52
+ htmlcov/
53
+ .tox/
54
+ .nox/
55
+ .coverage
56
+ .coverage.*
57
+ .cache
58
+ nosetests.xml
59
+ coverage.xml
60
+ *.cover
61
+ *.py,cover
62
+ .hypothesis/
63
+ .pytest_cache/
64
+ cover/
65
+
66
+ # Translations
67
+ *.mo
68
+ *.pot
69
+
70
+ # Django stuff:
71
+ *.log
72
+ local_settings.py
73
+ db.sqlite3
74
+ db.sqlite3-journal
75
+
76
+ # Flask stuff:
77
+ instance/
78
+ .webassets-cache
79
+
80
+ # Scrapy stuff:
81
+ .scrapy
82
+
83
+ # Sphinx documentation
84
+ docs/_build/
85
+
86
+ # PyBuilder
87
+ .pybuilder/
88
+ target/
89
+
90
+ # Jupyter Notebook
91
+ .ipynb_checkpoints
92
+
93
+ # IPython
94
+ profile_default/
95
+ ipython_config.py
96
+
97
+ # pyenv
98
+ # For a library or package, you might want to ignore these files since the code is
99
+ # intended to run in multiple environments; otherwise, check them in:
100
+ # .python-version
101
+
102
+ # pipenv
103
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
104
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
105
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
106
+ # install all needed dependencies.
107
+ #Pipfile.lock
108
+
109
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
110
+ __pypackages__/
111
+
112
+ # Celery stuff
113
+ celerybeat-schedule
114
+ celerybeat.pid
115
+
116
+ # SageMath parsed files
117
+ *.sage.py
118
+
119
+ # Environments
120
+ .env
121
+ .venv
122
+ env/
123
+ venv/
124
+ ENV/
125
+ env.bak/
126
+ venv.bak/
127
+
128
+ # Spyder project settings
129
+ .spyderproject
130
+ .spyproject
131
+
132
+ # Rope project settings
133
+ .ropeproject
134
+
135
+ # mkdocs documentation
136
+ /site
137
+
138
+ # mypy
139
+ .mypy_cache/
140
+ .dmypy.json
141
+ dmypy.json
142
+
143
+ # Pyre type checker
144
+ .pyre/
145
+
146
+ # pytype static type analyzer
147
+ .pytype/
148
+
149
+ # Cython debug symbols
150
+ cython_debug/
151
+
152
+ logs
153
+
154
+ .idea/*
155
+ .DS_Store
156
+
157
+ output/
158
+ *.pkl
159
+
160
+ # local config files
161
+ *.config.local
162
+ # OAI_CONFIG_LIST
163
+ key_openai.txt
164
+ key_aoai.txt
165
+ base_aoai.txt
166
+ wolfram.txt
167
+
168
+ # DB on disk for TeachableAgent
169
+ tmp/
170
+
171
+ .cache
172
+ test*
173
+ coding
174
+ .chromadb
gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
gitignore ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .docusaurus/
2
+ node_modules/
3
+ # Project
4
+ /.vs
5
+ .vscode
6
+
7
+ # Log files
8
+ *.log
9
+
10
+ # Python virtualenv
11
+ .venv
12
+
13
+ # Byte-compiled / optimized / DLL files
14
+ __pycache__/
15
+ *.py[cod]
16
+ *$py.class
17
+
18
+ # C extensions
19
+ *.so
20
+
21
+ # Distribution / packaging
22
+ .Python
23
+ build/
24
+ develop-eggs/
25
+ dist/
26
+ downloads/
27
+ eggs/
28
+ .eggs/
29
+ lib/
30
+ lib64/
31
+ parts/
32
+ sdist/
33
+ var/
34
+ wheels/
35
+ share/python-wheels/
36
+ *.egg-info/
37
+ .installed.cfg
38
+ *.egg
39
+ MANIFEST
40
+
41
+ # PyInstaller
42
+ # Usually these files are written by a python script from a template
43
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
44
+ *.manifest
45
+ *.spec
46
+
47
+ # Installer logs
48
+ pip-log.txt
49
+ pip-delete-this-directory.txt
50
+
51
+ # Unit test / coverage reports
52
+ htmlcov/
53
+ .tox/
54
+ .nox/
55
+ .coverage
56
+ .coverage.*
57
+ .cache
58
+ nosetests.xml
59
+ coverage.xml
60
+ *.cover
61
+ *.py,cover
62
+ .hypothesis/
63
+ .pytest_cache/
64
+ cover/
65
+
66
+ # Translations
67
+ *.mo
68
+ *.pot
69
+
70
+ # Django stuff:
71
+ *.log
72
+ local_settings.py
73
+ db.sqlite3
74
+ db.sqlite3-journal
75
+
76
+ # Flask stuff:
77
+ instance/
78
+ .webassets-cache
79
+
80
+ # Scrapy stuff:
81
+ .scrapy
82
+
83
+ # Sphinx documentation
84
+ docs/_build/
85
+
86
+ # PyBuilder
87
+ .pybuilder/
88
+ target/
89
+
90
+ # Jupyter Notebook
91
+ .ipynb_checkpoints
92
+
93
+ # IPython
94
+ profile_default/
95
+ ipython_config.py
96
+
97
+ # pyenv
98
+ # For a library or package, you might want to ignore these files since the code is
99
+ # intended to run in multiple environments; otherwise, check them in:
100
+ # .python-version
101
+
102
+ # pipenv
103
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
104
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
105
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
106
+ # install all needed dependencies.
107
+ #Pipfile.lock
108
+
109
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
110
+ __pypackages__/
111
+
112
+ # Celery stuff
113
+ celerybeat-schedule
114
+ celerybeat.pid
115
+
116
+ # SageMath parsed files
117
+ *.sage.py
118
+
119
+ # Environments
120
+ .env
121
+ .venv
122
+ env/
123
+ venv/
124
+ ENV/
125
+ env.bak/
126
+ venv.bak/
127
+
128
+ # Spyder project settings
129
+ .spyderproject
130
+ .spyproject
131
+
132
+ # Rope project settings
133
+ .ropeproject
134
+
135
+ # mkdocs documentation
136
+ /site
137
+
138
+ # mypy
139
+ .mypy_cache/
140
+ .dmypy.json
141
+ dmypy.json
142
+
143
+ # Pyre type checker
144
+ .pyre/
145
+
146
+ # pytype static type analyzer
147
+ .pytype/
148
+
149
+ # Cython debug symbols
150
+ cython_debug/
151
+
152
+ logs
153
+
154
+ .idea/*
155
+ .DS_Store
156
+
157
+ output/
158
+ *.pkl
159
+
160
+ # local config files
161
+ *.config.local
162
+ OAI_CONFIG_LIST
163
+ key_openai.txt
164
+ key_aoai.txt
165
+ base_aoai.txt
166
+ wolfram.txt
167
+
168
+ # DB on disk for TeachableAgent
169
+ tmp/
170
+
171
+ .cache
172
+ test*
173
+ coding
174
+ .chromadb
icons/autogen-icons_agent_blue.png ADDED
icons/autogen-icons_agent_dark.png ADDED
icons/autogen-icons_agent_gray.png ADDED
icons/autogen-icons_agent_green.png ADDED
icons/autogen-icons_agent_orange.png ADDED
icons/autogen-icons_agent_plum.png ADDED
icons/autogen-icons_agent_turquoise.png ADDED
icons/autogen-icons_user_blue.png ADDED
icons/autogen-icons_user_green.png ADDED
icons/autogen-icons_user_orange.png ADDED
requirements.txt CHANGED
@@ -1,6 +1,6 @@
1
- panel
2
- jupyter
3
- transformers
4
- numpy
5
- torch
6
- aiohttp
 
1
+ pyautogen[retrievechat,mathchat,lmm]~=0.2.0b6
2
+ panel>=1.3.1
3
+ cloudpickle
4
+ diskcache
5
+ yfinance
6
+ isort