mirror of
https://github.com/camel-ai/owl.git
synced 2026-03-22 05:57:17 +08:00
better webapp displaying logs in Markdown Box
This commit is contained in:
@@ -180,7 +180,11 @@ def get_latest_logs(max_lines=100, queue_source=None):
|
||||
lines = [line.strip() for line in content.split("\n")]
|
||||
content = "\n".join(lines)
|
||||
|
||||
return f"[{role.title()} Agent]: {content}"
|
||||
role_emoji = "🙋" if role.lower() == "user" else "🤖"
|
||||
# return f"[{role.title()} Agent]: {content}"
|
||||
return f"""### {role_emoji} {role.title()} Agent
|
||||
|
||||
{content}"""
|
||||
|
||||
for log in filtered_logs:
|
||||
formatted_messages = []
|
||||
@@ -234,7 +238,10 @@ def get_latest_logs(max_lines=100, queue_source=None):
|
||||
if not log.endswith("\n"):
|
||||
formatted_logs.append("\n")
|
||||
|
||||
return "".join(formatted_logs)
|
||||
with open("tmp.md", "w") as f:
|
||||
f.write("\n".join(formatted_logs))
|
||||
|
||||
return "\n".join(formatted_logs)
|
||||
|
||||
|
||||
# Dictionary containing module descriptions
|
||||
@@ -912,6 +919,14 @@ def create_ui():
|
||||
background-color: #f9f9f9;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.log-display {
|
||||
border-radius: 10px;
|
||||
padding: 15px;
|
||||
margin-bottom: 20px;
|
||||
min-height: 50vh;
|
||||
max-height: 75vh;
|
||||
}
|
||||
|
||||
.env-controls, .api-help-container {
|
||||
border-radius: 8px;
|
||||
@@ -1039,7 +1054,7 @@ def create_ui():
|
||||
""")
|
||||
|
||||
with gr.Row():
|
||||
with gr.Column(scale=1):
|
||||
with gr.Column(scale=0.5):
|
||||
question_input = gr.Textbox(
|
||||
lines=5,
|
||||
placeholder="请输入您的问题...",
|
||||
@@ -1079,20 +1094,32 @@ def create_ui():
|
||||
label="令牌计数", interactive=False, elem_classes="token-count"
|
||||
)
|
||||
|
||||
# 示例问题
|
||||
examples = [
|
||||
"打开百度搜索,总结一下camel-ai的camel框架的github star、fork数目等,并把数字用plot包写成python文件保存到本地,并运行生成的python文件。",
|
||||
"浏览亚马逊并找出一款对程序员有吸引力的产品。请提供产品名称和价格",
|
||||
"写一个hello world的python文件,保存到本地",
|
||||
]
|
||||
|
||||
gr.Examples(examples=examples, inputs=question_input)
|
||||
|
||||
gr.HTML("""
|
||||
<div class="footer" id="about">
|
||||
<h3>关于 OWL 多智能体协作系统</h3>
|
||||
<p>OWL 是一个基于CAMEL框架开发的先进多智能体协作系统,旨在通过智能体协作解决复杂问题。</p>
|
||||
<p>© 2025 CAMEL-AI.org. 基于Apache License 2.0开源协议</p>
|
||||
<p><a href="https://github.com/camel-ai/owl" target="_blank">GitHub</a></p>
|
||||
</div>
|
||||
""")
|
||||
|
||||
with gr.Tabs(): # 设置对话记录为默认选中的标签页
|
||||
with gr.TabItem("对话记录"):
|
||||
# 添加对话记录显示区域
|
||||
log_display2 = gr.Textbox(
|
||||
label="对话记录",
|
||||
lines=25,
|
||||
max_lines=100,
|
||||
interactive=False,
|
||||
autoscroll=True,
|
||||
show_copy_button=True,
|
||||
elem_classes="log-display",
|
||||
container=True,
|
||||
value="",
|
||||
)
|
||||
with gr.Box():
|
||||
log_display2 = gr.Markdown(
|
||||
value="暂无对话记录",
|
||||
elem_classes="log-display",
|
||||
)
|
||||
|
||||
with gr.Row():
|
||||
refresh_logs_button2 = gr.Button("刷新记录")
|
||||
@@ -1180,24 +1207,6 @@ def create_ui():
|
||||
|
||||
refresh_button.click(fn=update_env_table, outputs=[env_table])
|
||||
|
||||
# 示例问题
|
||||
examples = [
|
||||
"打开百度搜索,总结一下camel-ai的camel框架的github star、fork数目等,并把数字用plot包写成python文件保存到本地,并运行生成的python文件。",
|
||||
"浏览亚马逊并找出一款对程序员有吸引力的产品。请提供产品名称和价格",
|
||||
"写一个hello world的python文件,保存到本地",
|
||||
]
|
||||
|
||||
gr.Examples(examples=examples, inputs=question_input)
|
||||
|
||||
gr.HTML("""
|
||||
<div class="footer" id="about">
|
||||
<h3>关于 OWL 多智能体协作系统</h3>
|
||||
<p>OWL 是一个基于CAMEL框架开发的先进多智能体协作系统,旨在通过智能体协作解决复杂问题。</p>
|
||||
<p>© 2025 CAMEL-AI.org. 基于Apache License 2.0开源协议</p>
|
||||
<p><a href="https://github.com/camel-ai/owl" target="_blank">GitHub</a></p>
|
||||
</div>
|
||||
""")
|
||||
|
||||
# 设置事件处理
|
||||
run_button.click(
|
||||
fn=process_with_live_logs,
|
||||
|
||||
Reference in New Issue
Block a user