feat: improve webapp log-display box (#338)
Browse files- owl/webapp.py +37 -32
- owl/webapp_zh.py +37 -32
owl/webapp.py
CHANGED
@@ -180,7 +180,10 @@ 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 |
-
|
|
|
|
|
|
|
184 |
|
185 |
for log in filtered_logs:
|
186 |
formatted_messages = []
|
@@ -234,7 +237,7 @@ 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 +932,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 +1074,7 @@ def create_ui():
|
|
1063 |
""")
|
1064 |
|
1065 |
with gr.Row():
|
1066 |
-
with gr.Column(scale=
|
1067 |
question_input = gr.Textbox(
|
1068 |
lines=5,
|
1069 |
placeholder="Please enter your question...",
|
@@ -1103,20 +1114,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 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
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 +1233,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_emoji} {role.title()} Agent
|
185 |
+
|
186 |
+
{content}"""
|
187 |
|
188 |
for log in filtered_logs:
|
189 |
formatted_messages = []
|
|
|
237 |
if not log.endswith("\n"):
|
238 |
formatted_logs.append("\n")
|
239 |
|
240 |
+
return "\n".join(formatted_logs)
|
241 |
|
242 |
|
243 |
# Dictionary containing module descriptions
|
|
|
932 |
line-height: 1.4;
|
933 |
}
|
934 |
|
935 |
+
.log-display {
|
936 |
+
border-radius: 10px;
|
937 |
+
padding: 15px;
|
938 |
+
margin-bottom: 20px;
|
939 |
+
min-height: 50vh;
|
940 |
+
max-height: 75vh;
|
941 |
+
}
|
942 |
+
|
943 |
/* Environment variable management style */
|
944 |
.env-manager-container {
|
945 |
border-radius: 10px;
|
|
|
1074 |
""")
|
1075 |
|
1076 |
with gr.Row():
|
1077 |
+
with gr.Column(scale=0.5):
|
1078 |
question_input = gr.Textbox(
|
1079 |
lines=5,
|
1080 |
placeholder="Please enter your question...",
|
|
|
1114 |
label="Token Count", interactive=False, elem_classes="token-count"
|
1115 |
)
|
1116 |
|
1117 |
+
# Example questions
|
1118 |
+
examples = [
|
1119 |
+
"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.",
|
1120 |
+
"Browse Amazon and find a product that is attractive to programmers. Please provide the product name and price",
|
1121 |
+
"Write a hello world python file and save it locally",
|
1122 |
+
]
|
1123 |
+
|
1124 |
+
gr.Examples(examples=examples, inputs=question_input)
|
1125 |
+
|
1126 |
+
gr.HTML("""
|
1127 |
+
<div class="footer" id="about">
|
1128 |
+
<h3>About OWL Multi-Agent Collaboration System</h3>
|
1129 |
+
<p>OWL is an advanced multi-agent collaboration system developed based on the CAMEL framework, designed to solve complex problems through agent collaboration.</p>
|
1130 |
+
<p>© 2025 CAMEL-AI.org. Based on Apache License 2.0 open source license</p>
|
1131 |
+
<p><a href="https://github.com/camel-ai/owl" target="_blank">GitHub</a></p>
|
1132 |
+
</div>
|
1133 |
+
""")
|
1134 |
+
|
1135 |
with gr.Tabs(): # Set conversation record as the default selected tab
|
1136 |
with gr.TabItem("Conversation Record"):
|
1137 |
# Add conversation record display area
|
1138 |
+
with gr.Box():
|
1139 |
+
log_display2 = gr.Markdown(
|
1140 |
+
value="No conversation records yet.",
|
1141 |
+
elem_classes="log-display",
|
1142 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
1143 |
|
1144 |
with gr.Row():
|
1145 |
refresh_logs_button2 = gr.Button("Refresh Record")
|
|
|
1233 |
|
1234 |
refresh_button.click(fn=update_env_table, outputs=[env_table])
|
1235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1236 |
# Set up event handling
|
1237 |
run_button.click(
|
1238 |
fn=process_with_live_logs,
|
owl/webapp_zh.py
CHANGED
@@ -180,7 +180,10 @@ 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 |
-
|
|
|
|
|
|
|
184 |
|
185 |
for log in filtered_logs:
|
186 |
formatted_messages = []
|
@@ -234,7 +237,7 @@ 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
|
@@ -904,6 +907,14 @@ def create_ui():
|
|
904 |
white-space: pre-wrap;
|
905 |
line-height: 1.4;
|
906 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
907 |
|
908 |
/* 环境变量管理样式 */
|
909 |
.env-manager-container {
|
@@ -1039,7 +1050,7 @@ def create_ui():
|
|
1039 |
""")
|
1040 |
|
1041 |
with gr.Row():
|
1042 |
-
with gr.Column(scale=
|
1043 |
question_input = gr.Textbox(
|
1044 |
lines=5,
|
1045 |
placeholder="请输入您的问题...",
|
@@ -1079,20 +1090,32 @@ def create_ui():
|
|
1079 |
label="令牌计数", interactive=False, elem_classes="token-count"
|
1080 |
)
|
1081 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1082 |
with gr.Tabs(): # 设置对话记录为默认选中的标签页
|
1083 |
with gr.TabItem("对话记录"):
|
1084 |
# 添加对话记录显示区域
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
autoscroll=True,
|
1091 |
-
show_copy_button=True,
|
1092 |
-
elem_classes="log-display",
|
1093 |
-
container=True,
|
1094 |
-
value="",
|
1095 |
-
)
|
1096 |
|
1097 |
with gr.Row():
|
1098 |
refresh_logs_button2 = gr.Button("刷新记录")
|
@@ -1180,24 +1203,6 @@ def create_ui():
|
|
1180 |
|
1181 |
refresh_button.click(fn=update_env_table, outputs=[env_table])
|
1182 |
|
1183 |
-
# 示例问题
|
1184 |
-
examples = [
|
1185 |
-
"打开百度搜索,总结一下camel-ai的camel框架的github star、fork数目等,并把数字用plot包写成python文件保存到本地,并运行生成的python文件。",
|
1186 |
-
"浏览亚马逊并找出一款对程序员有吸引力的产品。请提供产品名称和价格",
|
1187 |
-
"写一个hello world的python文件,保存到本地",
|
1188 |
-
]
|
1189 |
-
|
1190 |
-
gr.Examples(examples=examples, inputs=question_input)
|
1191 |
-
|
1192 |
-
gr.HTML("""
|
1193 |
-
<div class="footer" id="about">
|
1194 |
-
<h3>关于 OWL 多智能体协作系统</h3>
|
1195 |
-
<p>OWL 是一个基于CAMEL框架开发的先进多智能体协作系统,旨在通过智能体协作解决复杂问题。</p>
|
1196 |
-
<p>© 2025 CAMEL-AI.org. 基于Apache License 2.0开源协议</p>
|
1197 |
-
<p><a href="https://github.com/camel-ai/owl" target="_blank">GitHub</a></p>
|
1198 |
-
</div>
|
1199 |
-
""")
|
1200 |
-
|
1201 |
# 设置事件处理
|
1202 |
run_button.click(
|
1203 |
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_emoji} {role.title()} Agent
|
185 |
+
|
186 |
+
{content}"""
|
187 |
|
188 |
for log in filtered_logs:
|
189 |
formatted_messages = []
|
|
|
237 |
if not log.endswith("\n"):
|
238 |
formatted_logs.append("\n")
|
239 |
|
240 |
+
return "\n".join(formatted_logs)
|
241 |
|
242 |
|
243 |
# Dictionary containing module descriptions
|
|
|
907 |
white-space: pre-wrap;
|
908 |
line-height: 1.4;
|
909 |
}
|
910 |
+
|
911 |
+
.log-display {
|
912 |
+
border-radius: 10px;
|
913 |
+
padding: 15px;
|
914 |
+
margin-bottom: 20px;
|
915 |
+
min-height: 50vh;
|
916 |
+
max-height: 75vh;
|
917 |
+
}
|
918 |
|
919 |
/* 环境变量管理样式 */
|
920 |
.env-manager-container {
|
|
|
1050 |
""")
|
1051 |
|
1052 |
with gr.Row():
|
1053 |
+
with gr.Column(scale=0.5):
|
1054 |
question_input = gr.Textbox(
|
1055 |
lines=5,
|
1056 |
placeholder="请输入您的问题...",
|
|
|
1090 |
label="令牌计数", interactive=False, elem_classes="token-count"
|
1091 |
)
|
1092 |
|
1093 |
+
# 示例问题
|
1094 |
+
examples = [
|
1095 |
+
"打开百度搜索,总结一下camel-ai的camel框架的github star、fork数目等,并把数字用plot包写成python文件保存到本地,并运行生成的python文件。",
|
1096 |
+
"浏览亚马逊并找出一款对程序员有吸引力的产品。请提供产品名称和价格",
|
1097 |
+
"写一个hello world的python文件,保存到本地",
|
1098 |
+
]
|
1099 |
+
|
1100 |
+
gr.Examples(examples=examples, inputs=question_input)
|
1101 |
+
|
1102 |
+
gr.HTML("""
|
1103 |
+
<div class="footer" id="about">
|
1104 |
+
<h3>关于 OWL 多智能体协作系统</h3>
|
1105 |
+
<p>OWL 是一个基于CAMEL框架开发的先进多智能体协作系统,旨在通过智能体协作解决复杂问题。</p>
|
1106 |
+
<p>© 2025 CAMEL-AI.org. 基于Apache License 2.0开源协议</p>
|
1107 |
+
<p><a href="https://github.com/camel-ai/owl" target="_blank">GitHub</a></p>
|
1108 |
+
</div>
|
1109 |
+
""")
|
1110 |
+
|
1111 |
with gr.Tabs(): # 设置对话记录为默认选中的标签页
|
1112 |
with gr.TabItem("对话记录"):
|
1113 |
# 添加对话记录显示区域
|
1114 |
+
with gr.Box():
|
1115 |
+
log_display2 = gr.Markdown(
|
1116 |
+
value="暂无对话记录。",
|
1117 |
+
elem_classes="log-display",
|
1118 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
1119 |
|
1120 |
with gr.Row():
|
1121 |
refresh_logs_button2 = gr.Button("刷新记录")
|
|
|
1203 |
|
1204 |
refresh_button.click(fn=update_env_table, outputs=[env_table])
|
1205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1206 |
# 设置事件处理
|
1207 |
run_button.click(
|
1208 |
fn=process_with_live_logs,
|