IPF commited on
Commit
6d50b29
ยท
verified ยท
1 Parent(s): fa89abe

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -44
app.py CHANGED
@@ -467,23 +467,6 @@ html:not(.dark) #terminal-question-input textarea:focus {
467
  background: rgba(239,68,68,0.22) !important;
468
  border-color: rgba(239,68,68,0.55) !important;
469
  }
470
- .folder-upload-btn {
471
- min-height: 26px !important;
472
- }
473
- .folder-upload-btn button,
474
- .folder-upload-btn .lg,
475
- .folder-upload-btn .gr-button {
476
- min-height: 26px !important;
477
- height: 26px !important;
478
- padding: 0 10px !important;
479
- border-radius: 999px !important;
480
- background: rgba(124,92,252,0.10) !important;
481
- color: #6C56D9 !important;
482
- border: 1px solid rgba(124,92,252,0.20) !important;
483
- font-size: 11px !important;
484
- font-weight: 600 !important;
485
- box-shadow: none !important;
486
- }
487
 
488
  /* โ”€โ”€ Section labels above answer / log โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ */
489
  .sec-label {
@@ -1326,14 +1309,6 @@ def _uploaded_corpus_signature(uploaded_value: Any) -> str:
1326
  return str(uploaded_value)
1327
 
1328
 
1329
- def _coalesce_uploaded_corpus(folder_value: Any, files_value: Any) -> Any:
1330
- if folder_value not in (None, "", []):
1331
- return folder_value
1332
- if files_value not in (None, "", []):
1333
- return files_value
1334
- return None
1335
-
1336
-
1337
  def _copy_uploaded_corpus_files(work_dir: Path, uploaded_files: List[str]) -> None:
1338
  files = [Path(path) for path in uploaded_files if path and os.path.exists(path)]
1339
  if not files:
@@ -2277,7 +2252,6 @@ def build_ui() -> gr.Blocks:
2277
  model = gr.Dropdown(
2278
  choices=[
2279
  ("GPT-5.4 nano", "gpt-5.4-nano"),
2280
- ("GPT-5 nano", "gpt-5-nano"),
2281
  ],
2282
  value="gpt-5.4-nano",
2283
  label="Model",
@@ -2305,20 +2279,15 @@ def build_ui() -> gr.Blocks:
2305
  )
2306
  uploaded_files = gr.File(
2307
  label="",
2308
- file_count="multiple",
 
 
 
 
 
 
2309
  visible=False,
2310
  )
2311
- with gr.Column(visible=False) as folder_hint_row:
2312
- corpus_hint = gr.HTML(
2313
- value='<div style="font-size:10.5px;color:#4E4E72;line-height:1.9;margin-top:8px">'
2314
- 'If you want to upload a folder, click here to choose it. For docs, drag them into the box above.'
2315
- '</div>',
2316
- )
2317
- uploaded_folder = gr.UploadButton(
2318
- "Click here",
2319
- file_count="directory",
2320
- elem_classes=["folder-upload-btn"],
2321
- )
2322
 
2323
  # Status
2324
  status_text = gr.Textbox(
@@ -2381,7 +2350,7 @@ def build_ui() -> gr.Blocks:
2381
  corpus_source.change(
2382
  fn=_toggle_upload,
2383
  inputs=[corpus_source],
2384
- outputs=[uploaded_files, folder_hint_row],
2385
  )
2386
 
2387
  def clear_all(runtime_state):
@@ -2396,18 +2365,17 @@ def build_ui() -> gr.Blocks:
2396
  outputs=[terminal, terminal_question, status_text, runtime_state, run_btn],
2397
  )
2398
 
2399
- def _run_with_qa_mode(api_key, question, model, max_turns, corpus_source, uploaded_files, uploaded_folder, runtime_state):
2400
- uploaded_corpus = _coalesce_uploaded_corpus(uploaded_folder, uploaded_files)
2401
- yield from run_search(api_key, question, model, max_turns, "QA", corpus_source, uploaded_corpus, runtime_state)
2402
 
2403
  run_event = run_btn.click(
2404
  fn=_run_with_qa_mode,
2405
- inputs=[api_key, terminal_question, model, max_turns, corpus_source, uploaded_files, uploaded_folder, runtime_state],
2406
  outputs=[terminal, status_text, runtime_state, run_btn],
2407
  )
2408
  terminal_question.submit(
2409
  fn=_run_with_qa_mode,
2410
- inputs=[api_key, terminal_question, model, max_turns, corpus_source, uploaded_files, uploaded_folder, runtime_state],
2411
  outputs=[terminal, status_text, runtime_state, run_btn],
2412
  )
2413
  stop_btn.click(fn=None, cancels=[run_event])
 
467
  background: rgba(239,68,68,0.22) !important;
468
  border-color: rgba(239,68,68,0.55) !important;
469
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
470
 
471
  /* โ”€โ”€ Section labels above answer / log โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ */
472
  .sec-label {
 
1309
  return str(uploaded_value)
1310
 
1311
 
 
 
 
 
 
 
 
 
1312
  def _copy_uploaded_corpus_files(work_dir: Path, uploaded_files: List[str]) -> None:
1313
  files = [Path(path) for path in uploaded_files if path and os.path.exists(path)]
1314
  if not files:
 
2252
  model = gr.Dropdown(
2253
  choices=[
2254
  ("GPT-5.4 nano", "gpt-5.4-nano"),
 
2255
  ],
2256
  value="gpt-5.4-nano",
2257
  label="Model",
 
2279
  )
2280
  uploaded_files = gr.File(
2281
  label="",
2282
+ file_count="directory",
2283
+ visible=False,
2284
+ )
2285
+ corpus_hint = gr.HTML(
2286
+ value='<div style="font-size:10.5px;color:#4E4E72;line-height:1.9;margin-top:8px">'
2287
+ 'Choose a folder here &nbsp;ยท&nbsp; Max 25 MB total &nbsp;ยท&nbsp; 5 MB per file'
2288
+ '</div>',
2289
  visible=False,
2290
  )
 
 
 
 
 
 
 
 
 
 
 
2291
 
2292
  # Status
2293
  status_text = gr.Textbox(
 
2350
  corpus_source.change(
2351
  fn=_toggle_upload,
2352
  inputs=[corpus_source],
2353
+ outputs=[uploaded_files, corpus_hint],
2354
  )
2355
 
2356
  def clear_all(runtime_state):
 
2365
  outputs=[terminal, terminal_question, status_text, runtime_state, run_btn],
2366
  )
2367
 
2368
+ def _run_with_qa_mode(api_key, question, model, max_turns, corpus_source, uploaded_files, runtime_state):
2369
+ yield from run_search(api_key, question, model, max_turns, "QA", corpus_source, uploaded_files, runtime_state)
 
2370
 
2371
  run_event = run_btn.click(
2372
  fn=_run_with_qa_mode,
2373
+ inputs=[api_key, terminal_question, model, max_turns, corpus_source, uploaded_files, runtime_state],
2374
  outputs=[terminal, status_text, runtime_state, run_btn],
2375
  )
2376
  terminal_question.submit(
2377
  fn=_run_with_qa_mode,
2378
+ inputs=[api_key, terminal_question, model, max_turns, corpus_source, uploaded_files, runtime_state],
2379
  outputs=[terminal, status_text, runtime_state, run_btn],
2380
  )
2381
  stop_btn.click(fn=None, cancels=[run_event])