bstraehle commited on
Commit
cac4e7b
1 Parent(s): 752352d

Update multi_agent.py

Browse files
Files changed (1) hide show
  1. multi_agent.py +14 -59
multi_agent.py CHANGED
@@ -1,33 +1,14 @@
 
 
1
  from autogen import ConversableAgent, AssistantAgent
2
  from autogen.coding import LocalCommandLineCodeExecutor
3
 
4
- import base64, markdown, os
5
- #from IPython.display import Image
6
-
7
  def read_image_file(image_file_path: str) -> str:
8
- """
9
- Read a PNG image file from the local filesystem and encode it as a base64 string.
10
-
11
- Args:
12
- image_file_path (str): The local file path of the image.
13
-
14
- Returns:
15
- str: The base64-encoded image data.
16
- """
17
  with open(image_file_path, "rb") as image_file:
18
  image_data = image_file.read()
19
  return base64.b64encode(image_data).decode("utf-8")
20
 
21
  def generate_markdown_code(image_data: str) -> str:
22
- """
23
- Generate the markdown code to render an image.
24
-
25
- Args:
26
- image_data (str): The base64-encoded image data.
27
-
28
- Returns:
29
- str: The markdown code to render the image.
30
- """
31
  return f"![Image](data:image/png;base64,{image_data})"
32
 
33
  def run_multi_agent(llm, message):
@@ -37,16 +18,17 @@ def run_multi_agent(llm, message):
37
  timeout=60,
38
  work_dir="coding",
39
  )
40
-
41
  code_executor_agent = ConversableAgent(
42
  name="code_executor_agent",
43
  llm_config=False,
44
  code_execution_config={"executor": executor},
45
  human_input_mode="NEVER",
46
- default_auto_reply=
47
- "Please continue. If everything is done, reply 'TERMINATE'.",
48
  )
49
-
 
 
50
  code_writer_agent = AssistantAgent(
51
  name="code_writer_agent",
52
  llm_config=llm_config,
@@ -54,9 +36,7 @@ def run_multi_agent(llm, message):
54
  human_input_mode="NEVER",
55
  )
56
 
57
- code_writer_agent_system_message = code_writer_agent.system_message
58
-
59
- print(code_writer_agent_system_message)
60
 
61
  chat_result = code_executor_agent.initiate_chat(
62
  code_writer_agent,
@@ -64,38 +44,13 @@ def run_multi_agent(llm, message):
64
  max_turns=10
65
  )
66
 
67
- ###
68
- #for root, dirs, files in os.walk("."):
69
- # for file in files:
70
- # print(os.path.join(root, file))
71
- ###
72
-
73
- #png_file = os.path.join("coding", "ytd_stock_gains.png")
74
-
75
- #print("### "+png_file)
76
-
77
- #current_folder = os.getcwd()
78
- #files_in_folder = os.listdir(current_folder)
79
-
80
- #print(f"Files in {current_folder}:")
81
- #for file in files_in_folder:
82
- # print(file)
83
-
84
- #image_path = "/home/user/app/coding/ytd_stock_gains.png"
85
- #image_path_2 = "/coding/ytd_stock_gains.png"
86
- #image_path_5 = "coding/ytd_stock_gains.png"
87
- #image_path_3 = "/app/coding/ytd_stock_gains.png"
88
- #image_path_4 = "/user/app/coding/ytd_stock_gains.png"
89
-
90
  image_data = read_image_file("/home/user/app/coding/ytd_stock_gains.png")
91
  markdown_code = generate_markdown_code(image_data)
92
 
93
- return markdown_code
94
- #image_path = os.path.join('coding', 'ytd_stock_gains.png')
95
- #image_markdown = f"![YTD Stock Gains]({image_path})"
96
 
97
- #markdown_text = "![YTD Stock Gains](coding/ytd_stock_gains.png)"
98
- #html = markdown.markdown(markdown_text)
99
- #print(html)
100
-
101
- #return html #f"![YTD Stock Gains]({image_path})<br />![YTD Stock Gains]({image_path_2})<br />![YTD Stock Gains]({image_path_3})<br />![YTD Stock Gains]({image_path_4})<br />![YTD Stock Gains]({image_path_5})<br />"
 
1
+ import base64
2
+
3
  from autogen import ConversableAgent, AssistantAgent
4
  from autogen.coding import LocalCommandLineCodeExecutor
5
 
 
 
 
6
  def read_image_file(image_file_path: str) -> str:
 
 
 
 
 
 
 
 
 
7
  with open(image_file_path, "rb") as image_file:
8
  image_data = image_file.read()
9
  return base64.b64encode(image_data).decode("utf-8")
10
 
11
  def generate_markdown_code(image_data: str) -> str:
 
 
 
 
 
 
 
 
 
12
  return f"![Image](data:image/png;base64,{image_data})"
13
 
14
  def run_multi_agent(llm, message):
 
18
  timeout=60,
19
  work_dir="coding",
20
  )
21
+
22
  code_executor_agent = ConversableAgent(
23
  name="code_executor_agent",
24
  llm_config=False,
25
  code_execution_config={"executor": executor},
26
  human_input_mode="NEVER",
27
+ default_auto_reply="Please continue. If everything is done, reply 'TERMINATE'.",
 
28
  )
29
+
30
+ print("### code_executor_agent.system_message = " + code_executor_agent.system_message)
31
+
32
  code_writer_agent = AssistantAgent(
33
  name="code_writer_agent",
34
  llm_config=llm_config,
 
36
  human_input_mode="NEVER",
37
  )
38
 
39
+ print("### code_writer_agent.system_message = " + code_writer_agent.system_message)
 
 
40
 
41
  chat_result = code_executor_agent.initiate_chat(
42
  code_writer_agent,
 
44
  max_turns=10
45
  )
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  image_data = read_image_file("/home/user/app/coding/ytd_stock_gains.png")
48
  markdown_code = generate_markdown_code(image_data)
49
 
50
+ print("### markdown_code = " + markdown_code)
 
 
51
 
52
+ print("###")
53
+ print(chat_result)
54
+ print("###")
55
+
56
+ return markdown_code