Polish Space UI with card layout and controls
Browse files
app.py
CHANGED
|
@@ -261,31 +261,47 @@ def run_ui(
|
|
| 261 |
return f"Error: {exc}", json.dumps({"error": str(exc)}, ensure_ascii=False, indent=2)
|
| 262 |
|
| 263 |
|
| 264 |
-
with gr.Blocks(title="DeepResearch Space Starter") as demo:
|
| 265 |
-
gr.
|
| 266 |
"""
|
| 267 |
-
#
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
|
|
|
|
|
|
| 271 |
"""
|
| 272 |
)
|
| 273 |
|
| 274 |
with gr.Row():
|
| 275 |
-
with gr.Column(scale=
|
| 276 |
question = gr.Textbox(
|
| 277 |
-
label="Question",
|
| 278 |
placeholder="e.g. Compare top open-source deep research agents and summarize differences.",
|
| 279 |
-
lines=
|
| 280 |
-
)
|
| 281 |
-
model = gr.Dropdown(
|
| 282 |
-
label="Model",
|
| 283 |
-
choices=DEFAULT_FREE_MODELS,
|
| 284 |
-
value=DEFAULT_MODEL if DEFAULT_MODEL in DEFAULT_FREE_MODELS else DEFAULT_FREE_MODELS[0],
|
| 285 |
-
allow_custom_value=True,
|
| 286 |
-
info="You can also type your own model id.",
|
| 287 |
)
|
| 288 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 289 |
max_turns = gr.Slider(label="Max Turns", minimum=2, maximum=20, value=8, step=1)
|
| 290 |
max_search_results = gr.Slider(
|
| 291 |
label="Search Results Per Query", minimum=1, maximum=10, value=5, step=1
|
|
@@ -293,16 +309,30 @@ This starter uses free HF Inference models by default. You can switch models lat
|
|
| 293 |
temperature = gr.Slider(
|
| 294 |
label="Temperature", minimum=0.0, maximum=1.5, value=0.4, step=0.1
|
| 295 |
)
|
| 296 |
-
|
| 297 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
answer = gr.Markdown(label="Final Answer")
|
| 299 |
-
|
|
|
|
| 300 |
|
| 301 |
run_btn.click(
|
| 302 |
fn=run_ui,
|
| 303 |
inputs=[question, model, max_turns, max_search_results, temperature],
|
| 304 |
outputs=[answer, trace],
|
| 305 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
|
| 307 |
|
| 308 |
if __name__ == "__main__":
|
|
|
|
| 261 |
return f"Error: {exc}", json.dumps({"error": str(exc)}, ensure_ascii=False, indent=2)
|
| 262 |
|
| 263 |
|
| 264 |
+
with gr.Blocks(title="DeepResearch Space Starter", theme=gr.themes.Soft()) as demo:
|
| 265 |
+
gr.HTML(
|
| 266 |
"""
|
| 267 |
+
<div style="padding: 18px 20px; border-radius: 16px; background: linear-gradient(90deg,#1d4ed8 0%,#4f46e5 50%,#7c3aed 100%); color: white; margin-bottom: 12px;">
|
| 268 |
+
<div style="font-size: 26px; font-weight: 700; line-height: 1.2;">DeepResearch Space Starter</div>
|
| 269 |
+
<div style="opacity: 0.95; margin-top: 6px;">
|
| 270 |
+
Multi-turn research agent with search + visit tools. Start with free models now, switch to your own model later.
|
| 271 |
+
</div>
|
| 272 |
+
</div>
|
| 273 |
"""
|
| 274 |
)
|
| 275 |
|
| 276 |
with gr.Row():
|
| 277 |
+
with gr.Column(scale=5):
|
| 278 |
question = gr.Textbox(
|
| 279 |
+
label="Research Question",
|
| 280 |
placeholder="e.g. Compare top open-source deep research agents and summarize differences.",
|
| 281 |
+
lines=6,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
)
|
| 283 |
with gr.Row():
|
| 284 |
+
run_btn = gr.Button("Run Research", variant="primary", size="lg")
|
| 285 |
+
clear_btn = gr.Button("Clear", variant="secondary", size="lg")
|
| 286 |
+
gr.Examples(
|
| 287 |
+
examples=[
|
| 288 |
+
["Compare RAG and fine-tuning: trade-offs, cost, and when to use each."],
|
| 289 |
+
["Summarize the differences between Qwen2.5, Llama 3.1, and Mistral 7B for agent tasks."],
|
| 290 |
+
["What are the key design patterns for long-context research agents?"],
|
| 291 |
+
],
|
| 292 |
+
inputs=question,
|
| 293 |
+
label="Quick Examples",
|
| 294 |
+
)
|
| 295 |
+
|
| 296 |
+
with gr.Column(scale=3):
|
| 297 |
+
with gr.Accordion("Model & Runtime Settings", open=False):
|
| 298 |
+
model = gr.Dropdown(
|
| 299 |
+
label="Model",
|
| 300 |
+
choices=DEFAULT_FREE_MODELS,
|
| 301 |
+
value=DEFAULT_MODEL if DEFAULT_MODEL in DEFAULT_FREE_MODELS else DEFAULT_FREE_MODELS[0],
|
| 302 |
+
allow_custom_value=True,
|
| 303 |
+
info="You can type any model id supported by HF Inference API.",
|
| 304 |
+
)
|
| 305 |
max_turns = gr.Slider(label="Max Turns", minimum=2, maximum=20, value=8, step=1)
|
| 306 |
max_search_results = gr.Slider(
|
| 307 |
label="Search Results Per Query", minimum=1, maximum=10, value=5, step=1
|
|
|
|
| 309 |
temperature = gr.Slider(
|
| 310 |
label="Temperature", minimum=0.0, maximum=1.5, value=0.4, step=0.1
|
| 311 |
)
|
| 312 |
+
gr.Markdown(
|
| 313 |
+
"""
|
| 314 |
+
**Tip**
|
| 315 |
+
- Add `HF_TOKEN` in Space Secrets for stable access.
|
| 316 |
+
- Keep `Max Turns` low first, then increase for harder queries.
|
| 317 |
+
"""
|
| 318 |
+
)
|
| 319 |
+
|
| 320 |
+
with gr.Row():
|
| 321 |
+
with gr.Column():
|
| 322 |
answer = gr.Markdown(label="Final Answer")
|
| 323 |
+
with gr.Column():
|
| 324 |
+
trace = gr.Code(label="Execution Trace (JSON)", language="json")
|
| 325 |
|
| 326 |
run_btn.click(
|
| 327 |
fn=run_ui,
|
| 328 |
inputs=[question, model, max_turns, max_search_results, temperature],
|
| 329 |
outputs=[answer, trace],
|
| 330 |
)
|
| 331 |
+
clear_btn.click(
|
| 332 |
+
fn=lambda: ("", "", "{}"),
|
| 333 |
+
inputs=[],
|
| 334 |
+
outputs=[question, answer, trace],
|
| 335 |
+
)
|
| 336 |
|
| 337 |
|
| 338 |
if __name__ == "__main__":
|