Update multi_agent.py
Browse files- multi_agent.py +11 -24
multi_agent.py
CHANGED
|
@@ -11,26 +11,11 @@ def read_image_file(image_file_path: str) -> str:
|
|
| 11 |
def generate_markdown_code(image_data: str) -> str:
|
| 12 |
return f""
|
| 13 |
|
| 14 |
-
def
|
| 15 |
with open(file_path, 'r', encoding='utf-8') as file:
|
| 16 |
return file.read()
|
| 17 |
|
| 18 |
-
def read_py_file(folder_path: str, extension: str) -> str:
|
| 19 |
-
for filename in os.listdir(folder_path):
|
| 20 |
-
if filename.endswith(extension):
|
| 21 |
-
with open(os.path.join(folder_path, filename), "r", encoding="utf-8") as file:
|
| 22 |
-
return file.read()
|
| 23 |
-
|
| 24 |
def format_as_markdown(code: str) -> str:
|
| 25 |
-
"""
|
| 26 |
-
Formats a string of Python code as Markdown.
|
| 27 |
-
|
| 28 |
-
Args:
|
| 29 |
-
code (str): The Python code to format.
|
| 30 |
-
|
| 31 |
-
Returns:
|
| 32 |
-
str: The formatted Markdown string.
|
| 33 |
-
"""
|
| 34 |
markdown_code = '```\n'
|
| 35 |
markdown_code += code
|
| 36 |
markdown_code += '\n```'
|
|
@@ -92,13 +77,15 @@ def run_multi_agent(llm, message):
|
|
| 92 |
print(file_name_py)
|
| 93 |
print(file_name_sh)
|
| 94 |
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
|
|
|
|
|
|
| 102 |
|
| 103 |
#print("### markdown_code = " + markdown_code)
|
| 104 |
|
|
@@ -106,4 +93,4 @@ def run_multi_agent(llm, message):
|
|
| 106 |
#print(chat_result)
|
| 107 |
#print("###")
|
| 108 |
|
| 109 |
-
return markdown_code
|
|
|
|
| 11 |
def generate_markdown_code(image_data: str) -> str:
|
| 12 |
return f""
|
| 13 |
|
| 14 |
+
def read_file(file_path: str) -> str:
|
| 15 |
with open(file_path, 'r', encoding='utf-8') as file:
|
| 16 |
return file.read()
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
def format_as_markdown(code: str) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
markdown_code = '```\n'
|
| 20 |
markdown_code += code
|
| 21 |
markdown_code += '\n```'
|
|
|
|
| 77 |
print(file_name_py)
|
| 78 |
print(file_name_sh)
|
| 79 |
|
| 80 |
+
file_path_py = "coding/" + file_name_py
|
| 81 |
+
code_py = read_file(file_path_py)
|
| 82 |
+
markdown_code_py = format_as_markdown(code_py)
|
| 83 |
+
print(markdown_code_py)
|
| 84 |
+
|
| 85 |
+
file_path_sh = "coding/" + file_name_sh
|
| 86 |
+
code_sh = read_file(file_path_sh)
|
| 87 |
+
markdown_code_sh = format_as_markdown(code_sh)
|
| 88 |
+
print(markdown_code_sh)
|
| 89 |
|
| 90 |
#print("### markdown_code = " + markdown_code)
|
| 91 |
|
|
|
|
| 93 |
#print(chat_result)
|
| 94 |
#print("###")
|
| 95 |
|
| 96 |
+
return markdown_code + "<br />" + markdown_code_sh + "<br />" + markdown_code_py
|