Update multi_agent.py
Browse files- multi_agent.py +34 -0
multi_agent.py
CHANGED
@@ -11,6 +11,34 @@ def read_image_file(image_file_path: str) -> str:
|
|
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):
|
15 |
llm_config = {"model": llm}
|
16 |
|
@@ -49,6 +77,12 @@ def run_multi_agent(llm, message):
|
|
49 |
|
50 |
print("### markdown_code = " + markdown_code)
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
print("###")
|
53 |
print(chat_result)
|
54 |
print("###")
|
|
|
11 |
def generate_markdown_code(image_data: str) -> str:
|
12 |
return f"![Image](data:image/png;base64,{image_data})"
|
13 |
|
14 |
+
def read_python_file(file_path: str) -> str:
|
15 |
+
"""
|
16 |
+
Reads a Python file and returns its contents as a string.
|
17 |
+
|
18 |
+
Args:
|
19 |
+
file_path (str): The path to the Python file.
|
20 |
+
|
21 |
+
Returns:
|
22 |
+
str: The contents of the Python file.
|
23 |
+
"""
|
24 |
+
with open(file_path, 'r', encoding='utf-8') as file:
|
25 |
+
return file.read()
|
26 |
+
|
27 |
+
def format_as_markdown(code: str) -> str:
|
28 |
+
"""
|
29 |
+
Formats a string of Python code as Markdown.
|
30 |
+
|
31 |
+
Args:
|
32 |
+
code (str): The Python code to format.
|
33 |
+
|
34 |
+
Returns:
|
35 |
+
str: The formatted Markdown string.
|
36 |
+
"""
|
37 |
+
markdown_code = '```python\n'
|
38 |
+
markdown_code += code
|
39 |
+
markdown_code += '\n```'
|
40 |
+
return markdown_code
|
41 |
+
|
42 |
def run_multi_agent(llm, message):
|
43 |
llm_config = {"model": llm}
|
44 |
|
|
|
77 |
|
78 |
print("### markdown_code = " + markdown_code)
|
79 |
|
80 |
+
file_path = "/home/user/app/coding/ytd_stock_gains.py"
|
81 |
+
code = read_python_file(file_path)
|
82 |
+
markdown_code += format_as_markdown(code)
|
83 |
+
|
84 |
+
print("### markdown_code = " + markdown_code)
|
85 |
+
|
86 |
print("###")
|
87 |
print(chat_result)
|
88 |
print("###")
|