Terrasse commited on
Commit
5816c60
·
1 Parent(s): 48678c8

better webapp displaying logs in Markdown Box (for en version)

Browse files
Files changed (2) hide show
  1. owl/webapp.py +40 -32
  2. owl/webapp_zh.py +10 -11
owl/webapp.py CHANGED
@@ -180,7 +180,11 @@ def get_latest_logs(max_lines=100, queue_source=None):
180
  lines = [line.strip() for line in content.split("\n")]
181
  content = "\n".join(lines)
182
 
183
- return f"[{role.title()} Agent]: {content}"
 
 
 
 
184
 
185
  for log in filtered_logs:
186
  formatted_messages = []
@@ -234,7 +238,9 @@ def get_latest_logs(max_lines=100, queue_source=None):
234
  if not log.endswith("\n"):
235
  formatted_logs.append("\n")
236
 
237
- return "".join(formatted_logs)
 
 
238
 
239
 
240
  # Dictionary containing module descriptions
@@ -929,6 +935,14 @@ def create_ui():
929
  line-height: 1.4;
930
  }
931
 
 
 
 
 
 
 
 
 
932
  /* Environment variable management style */
933
  .env-manager-container {
934
  border-radius: 10px;
@@ -1063,7 +1077,7 @@ def create_ui():
1063
  """)
1064
 
1065
  with gr.Row():
1066
- with gr.Column(scale=1):
1067
  question_input = gr.Textbox(
1068
  lines=5,
1069
  placeholder="Please enter your question...",
@@ -1103,20 +1117,32 @@ def create_ui():
1103
  label="Token Count", interactive=False, elem_classes="token-count"
1104
  )
1105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1106
  with gr.Tabs(): # Set conversation record as the default selected tab
1107
  with gr.TabItem("Conversation Record"):
1108
  # Add conversation record display area
1109
- log_display2 = gr.Textbox(
1110
- label="Conversation Record",
1111
- lines=25,
1112
- max_lines=100,
1113
- interactive=False,
1114
- autoscroll=True,
1115
- show_copy_button=True,
1116
- elem_classes="log-display",
1117
- container=True,
1118
- value="",
1119
- )
1120
 
1121
  with gr.Row():
1122
  refresh_logs_button2 = gr.Button("Refresh Record")
@@ -1210,24 +1236,6 @@ def create_ui():
1210
 
1211
  refresh_button.click(fn=update_env_table, outputs=[env_table])
1212
 
1213
- # Example questions
1214
- examples = [
1215
- "Open Google search, summarize the github stars, fork counts, etc. of camel-ai's camel framework, and write the numbers into a python file using the plot package, save it locally, and run the generated python file.",
1216
- "Browse Amazon and find a product that is attractive to programmers. Please provide the product name and price",
1217
- "Write a hello world python file and save it locally",
1218
- ]
1219
-
1220
- gr.Examples(examples=examples, inputs=question_input)
1221
-
1222
- gr.HTML("""
1223
- <div class="footer" id="about">
1224
- <h3>About OWL Multi-Agent Collaboration System</h3>
1225
- <p>OWL is an advanced multi-agent collaboration system developed based on the CAMEL framework, designed to solve complex problems through agent collaboration.</p>
1226
- <p>© 2025 CAMEL-AI.org. Based on Apache License 2.0 open source license</p>
1227
- <p><a href="https://github.com/camel-ai/owl" target="_blank">GitHub</a></p>
1228
- </div>
1229
- """)
1230
-
1231
  # Set up event handling
1232
  run_button.click(
1233
  fn=process_with_live_logs,
 
180
  lines = [line.strip() for line in content.split("\n")]
181
  content = "\n".join(lines)
182
 
183
+ role_emoji = "🙋" if role.lower() == "user" else "🤖"
184
+ # return f"[{role.title()} Agent]: {content}"
185
+ return f"""### {role_emoji} {role.title()} Agent
186
+
187
+ {content}"""
188
 
189
  for log in filtered_logs:
190
  formatted_messages = []
 
238
  if not log.endswith("\n"):
239
  formatted_logs.append("\n")
240
 
241
+ # with open("logs.md", "w") as f:
242
+ # f.write("\n".join(formatted_logs))
243
+ return "\n".join(formatted_logs)
244
 
245
 
246
  # Dictionary containing module descriptions
 
935
  line-height: 1.4;
936
  }
937
 
938
+ .log-display {
939
+ border-radius: 10px;
940
+ padding: 15px;
941
+ margin-bottom: 20px;
942
+ min-height: 50vh;
943
+ max-height: 75vh;
944
+ }
945
+
946
  /* Environment variable management style */
947
  .env-manager-container {
948
  border-radius: 10px;
 
1077
  """)
1078
 
1079
  with gr.Row():
1080
+ with gr.Column(scale=0.5):
1081
  question_input = gr.Textbox(
1082
  lines=5,
1083
  placeholder="Please enter your question...",
 
1117
  label="Token Count", interactive=False, elem_classes="token-count"
1118
  )
1119
 
1120
+ # Example questions
1121
+ examples = [
1122
+ "Open Google search, summarize the github stars, fork counts, etc. of camel-ai's camel framework, and write the numbers into a python file using the plot package, save it locally, and run the generated python file.",
1123
+ "Browse Amazon and find a product that is attractive to programmers. Please provide the product name and price",
1124
+ "Write a hello world python file and save it locally",
1125
+ ]
1126
+
1127
+ gr.Examples(examples=examples, inputs=question_input)
1128
+
1129
+ gr.HTML("""
1130
+ <div class="footer" id="about">
1131
+ <h3>About OWL Multi-Agent Collaboration System</h3>
1132
+ <p>OWL is an advanced multi-agent collaboration system developed based on the CAMEL framework, designed to solve complex problems through agent collaboration.</p>
1133
+ <p>© 2025 CAMEL-AI.org. Based on Apache License 2.0 open source license</p>
1134
+ <p><a href="https://github.com/camel-ai/owl" target="_blank">GitHub</a></p>
1135
+ </div>
1136
+ """)
1137
+
1138
  with gr.Tabs(): # Set conversation record as the default selected tab
1139
  with gr.TabItem("Conversation Record"):
1140
  # Add conversation record display area
1141
+ with gr.Box():
1142
+ log_display2 = gr.Markdown(
1143
+ value="暂无对话记录",
1144
+ elem_classes="log-display",
1145
+ )
 
 
 
 
 
 
1146
 
1147
  with gr.Row():
1148
  refresh_logs_button2 = gr.Button("Refresh Record")
 
1236
 
1237
  refresh_button.click(fn=update_env_table, outputs=[env_table])
1238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1239
  # Set up event handling
1240
  run_button.click(
1241
  fn=process_with_live_logs,
owl/webapp_zh.py CHANGED
@@ -238,9 +238,8 @@ def get_latest_logs(max_lines=100, queue_source=None):
238
  if not log.endswith("\n"):
239
  formatted_logs.append("\n")
240
 
241
- with open("tmp.md", "w") as f:
242
- f.write("\n".join(formatted_logs))
243
-
244
  return "\n".join(formatted_logs)
245
 
246
 
@@ -911,14 +910,6 @@ def create_ui():
911
  white-space: pre-wrap;
912
  line-height: 1.4;
913
  }
914
-
915
- /* 环境变量管理样式 */
916
- .env-manager-container {
917
- border-radius: 10px;
918
- padding: 15px;
919
- background-color: #f9f9f9;
920
- margin-bottom: 20px;
921
- }
922
 
923
  .log-display {
924
  border-radius: 10px;
@@ -928,6 +919,14 @@ def create_ui():
928
  max-height: 75vh;
929
  }
930
 
 
 
 
 
 
 
 
 
931
  .env-controls, .api-help-container {
932
  border-radius: 8px;
933
  padding: 15px;
 
238
  if not log.endswith("\n"):
239
  formatted_logs.append("\n")
240
 
241
+ # with open("logs.md", "w") as f:
242
+ # f.write("\n".join(formatted_logs))
 
243
  return "\n".join(formatted_logs)
244
 
245
 
 
910
  white-space: pre-wrap;
911
  line-height: 1.4;
912
  }
 
 
 
 
 
 
 
 
913
 
914
  .log-display {
915
  border-radius: 10px;
 
919
  max-height: 75vh;
920
  }
921
 
922
+ /* 环境变量管理样式 */
923
+ .env-manager-container {
924
+ border-radius: 10px;
925
+ padding: 15px;
926
+ background-color: #f9f9f9;
927
+ margin-bottom: 20px;
928
+ }
929
+
930
  .env-controls, .api-help-container {
931
  border-radius: 8px;
932
  padding: 15px;