TomLii commited on
Commit
b716750
·
1 Parent(s): a841871

Refine Space layout with cleaner visual hierarchy

Browse files
Files changed (1) hide show
  1. app.py +99 -46
app.py CHANGED
@@ -47,6 +47,47 @@ TOOL_RESPONSE_TEMPLATE = """<tool_response>
47
  {payload}
48
  </tool_response>"""
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
  @dataclass
52
  class AgentState:
@@ -261,12 +302,20 @@ 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", 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>
@@ -275,53 +324,57 @@ with gr.Blocks(title="DeepResearch Space Starter", theme=gr.themes.Soft()) as de
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
 
 
 
 
 
 
 
 
308
  )
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,
 
47
  {payload}
48
  </tool_response>"""
49
 
50
+ CUSTOM_CSS = """
51
+ .gradio-container {
52
+ max-width: 1200px !important;
53
+ }
54
+
55
+ .banner-card {
56
+ padding: 22px 24px;
57
+ border-radius: 18px;
58
+ background: linear-gradient(100deg, #1d4ed8 0%, #4338ca 45%, #6d28d9 100%);
59
+ color: #ffffff;
60
+ box-shadow: 0 10px 30px rgba(37, 56, 138, 0.22);
61
+ margin-bottom: 14px;
62
+ }
63
+
64
+ .banner-title {
65
+ font-size: 28px;
66
+ font-weight: 700;
67
+ line-height: 1.15;
68
+ }
69
+
70
+ .banner-subtitle {
71
+ margin-top: 8px;
72
+ opacity: 0.95;
73
+ font-size: 14px;
74
+ }
75
+
76
+ .section-card {
77
+ border: 1px solid #e5e7eb;
78
+ border-radius: 14px;
79
+ padding: 12px 12px 6px;
80
+ background: #ffffff;
81
+ }
82
+
83
+ .section-title {
84
+ font-size: 14px;
85
+ font-weight: 700;
86
+ color: #374151;
87
+ margin-bottom: 8px;
88
+ }
89
+ """
90
+
91
 
92
  @dataclass
93
  class AgentState:
 
302
  return f"Error: {exc}", json.dumps({"error": str(exc)}, ensure_ascii=False, indent=2)
303
 
304
 
305
+ with gr.Blocks(
306
+ title="DeepResearch Space Starter",
307
+ theme=gr.themes.Soft(
308
+ text_size="md",
309
+ radius_size="md",
310
+ spacing_size="md",
311
+ ),
312
+ css=CUSTOM_CSS,
313
+ ) as demo:
314
  gr.HTML(
315
  """
316
+ <div class="banner-card">
317
+ <div class="banner-title">DeepResearch Space Starter</div>
318
+ <div class="banner-subtitle">
319
  Multi-turn research agent with search + visit tools. Start with free models now, switch to your own model later.
320
  </div>
321
  </div>
 
324
 
325
  with gr.Row():
326
  with gr.Column(scale=5):
327
+ with gr.Group(elem_classes="section-card"):
328
+ gr.HTML('<div class="section-title">Research Question</div>')
329
+ question = gr.Textbox(
330
+ show_label=False,
331
+ placeholder="e.g. Compare top open-source deep research agents and summarize differences.",
332
+ lines=6,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  )
334
+ with gr.Row():
335
+ run_btn = gr.Button("Run Research", variant="primary", size="lg")
336
+ clear_btn = gr.Button("Clear", variant="secondary", size="lg")
337
+ gr.Examples(
338
+ examples=[
339
+ ["Compare RAG and fine-tuning: trade-offs, cost, and when to use each."],
340
+ ["Summarize the differences between Qwen2.5, Llama 3.1, and Mistral 7B for agent tasks."],
341
+ ["What are the key design patterns for long-context research agents?"],
342
+ ],
343
+ inputs=question,
344
+ label="Quick Examples",
345
  )
346
+
347
+ with gr.Column(scale=3):
348
+ with gr.Group(elem_classes="section-card"):
349
+ with gr.Accordion("Model & Runtime Settings", open=False):
350
+ model = gr.Dropdown(
351
+ label="Model",
352
+ choices=DEFAULT_FREE_MODELS,
353
+ value=DEFAULT_MODEL if DEFAULT_MODEL in DEFAULT_FREE_MODELS else DEFAULT_FREE_MODELS[0],
354
+ allow_custom_value=True,
355
+ info="You can type any model id supported by HF Inference API.",
356
+ )
357
+ max_turns = gr.Slider(label="Max Turns", minimum=2, maximum=20, value=8, step=1)
358
+ max_search_results = gr.Slider(
359
+ label="Search Results Per Query", minimum=1, maximum=10, value=5, step=1
360
+ )
361
+ temperature = gr.Slider(
362
+ label="Temperature", minimum=0.0, maximum=1.5, value=0.4, step=0.1
363
+ )
364
+ gr.Markdown(
365
+ """
366
+ **Tips**
367
  - Add `HF_TOKEN` in Space Secrets for stable access.
368
+ - Start with fewer turns for speed, then increase for harder tasks.
369
  """
370
+ )
371
 
372
+ with gr.Group(elem_classes="section-card"):
373
+ with gr.Tabs():
374
+ with gr.TabItem("Final Answer"):
375
+ answer = gr.Markdown(label="Final Answer")
376
+ with gr.TabItem("Execution Trace (JSON)"):
377
+ trace = gr.Code(label="Execution Trace (JSON)", language="json")
378
 
379
  run_btn.click(
380
  fn=run_ui,