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 (for en version)
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,9 @@ 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("logs.md", "w") as f:
|
||||
# f.write("\n".join(formatted_logs))
|
||||
return "\n".join(formatted_logs)
|
||||
|
||||
|
||||
# Dictionary containing module descriptions
|
||||
@@ -929,6 +935,14 @@ def create_ui():
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.log-display {
|
||||
border-radius: 10px;
|
||||
padding: 15px;
|
||||
margin-bottom: 20px;
|
||||
min-height: 50vh;
|
||||
max-height: 75vh;
|
||||
}
|
||||
|
||||
/* Environment variable management style */
|
||||
.env-manager-container {
|
||||
border-radius: 10px;
|
||||
@@ -1063,7 +1077,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="Please enter your question...",
|
||||
@@ -1103,20 +1117,32 @@ def create_ui():
|
||||
label="Token Count", interactive=False, elem_classes="token-count"
|
||||
)
|
||||
|
||||
# Example questions
|
||||
examples = [
|
||||
"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.",
|
||||
"Browse Amazon and find a product that is attractive to programmers. Please provide the product name and price",
|
||||
"Write a hello world python file and save it locally",
|
||||
]
|
||||
|
||||
gr.Examples(examples=examples, inputs=question_input)
|
||||
|
||||
gr.HTML("""
|
||||
<div class="footer" id="about">
|
||||
<h3>About OWL Multi-Agent Collaboration System</h3>
|
||||
<p>OWL is an advanced multi-agent collaboration system developed based on the CAMEL framework, designed to solve complex problems through agent collaboration.</p>
|
||||
<p>© 2025 CAMEL-AI.org. Based on Apache License 2.0 open source license</p>
|
||||
<p><a href="https://github.com/camel-ai/owl" target="_blank">GitHub</a></p>
|
||||
</div>
|
||||
""")
|
||||
|
||||
with gr.Tabs(): # Set conversation record as the default selected tab
|
||||
with gr.TabItem("Conversation Record"):
|
||||
# Add conversation record display area
|
||||
log_display2 = gr.Textbox(
|
||||
label="Conversation Record",
|
||||
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("Refresh Record")
|
||||
@@ -1210,24 +1236,6 @@ def create_ui():
|
||||
|
||||
refresh_button.click(fn=update_env_table, outputs=[env_table])
|
||||
|
||||
# Example questions
|
||||
examples = [
|
||||
"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.",
|
||||
"Browse Amazon and find a product that is attractive to programmers. Please provide the product name and price",
|
||||
"Write a hello world python file and save it locally",
|
||||
]
|
||||
|
||||
gr.Examples(examples=examples, inputs=question_input)
|
||||
|
||||
gr.HTML("""
|
||||
<div class="footer" id="about">
|
||||
<h3>About OWL Multi-Agent Collaboration System</h3>
|
||||
<p>OWL is an advanced multi-agent collaboration system developed based on the CAMEL framework, designed to solve complex problems through agent collaboration.</p>
|
||||
<p>© 2025 CAMEL-AI.org. Based on Apache License 2.0 open source license</p>
|
||||
<p><a href="https://github.com/camel-ai/owl" target="_blank">GitHub</a></p>
|
||||
</div>
|
||||
""")
|
||||
|
||||
# Set up event handling
|
||||
run_button.click(
|
||||
fn=process_with_live_logs,
|
||||
|
||||
@@ -238,9 +238,8 @@ def get_latest_logs(max_lines=100, queue_source=None):
|
||||
if not log.endswith("\n"):
|
||||
formatted_logs.append("\n")
|
||||
|
||||
with open("tmp.md", "w") as f:
|
||||
f.write("\n".join(formatted_logs))
|
||||
|
||||
# with open("logs.md", "w") as f:
|
||||
# f.write("\n".join(formatted_logs))
|
||||
return "\n".join(formatted_logs)
|
||||
|
||||
|
||||
@@ -911,14 +910,6 @@ def create_ui():
|
||||
white-space: pre-wrap;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
/* 环境变量管理样式 */
|
||||
.env-manager-container {
|
||||
border-radius: 10px;
|
||||
padding: 15px;
|
||||
background-color: #f9f9f9;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.log-display {
|
||||
border-radius: 10px;
|
||||
@@ -928,6 +919,14 @@ def create_ui():
|
||||
max-height: 75vh;
|
||||
}
|
||||
|
||||
/* 环境变量管理样式 */
|
||||
.env-manager-container {
|
||||
border-radius: 10px;
|
||||
padding: 15px;
|
||||
background-color: #f9f9f9;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.env-controls, .api-help-container {
|
||||
border-radius: 8px;
|
||||
padding: 15px;
|
||||
|
||||
Reference in New Issue
Block a user