ST-x-Tony commited on
Commit
2a8b709
·
verified ·
1 Parent(s): c2e0682

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -17
app.py CHANGED
@@ -12,7 +12,7 @@ import asyncio
12
  import traceback
13
 
14
  import gradio as gr
15
- import spaces # <-- ADDED: required for ZeroGPU
16
 
17
 
18
  # ============================================================
@@ -490,8 +490,9 @@ async def do_research(
490
  question
491
  ).strip():
492
 
 
493
  return (
494
- [],
495
  "⚪ Enter a question to start.",
496
  "",
497
  "",
@@ -588,19 +589,12 @@ async def do_research(
588
  )
589
 
590
  # ----------------------------------------------------
591
- # OLD-COMPATIBLE GRADIO CHAT FORMAT
592
- #
593
- # IMPORTANT:
594
- # No type="messages".
595
- # This works with the Gradio version shown
596
- # in the uploaded Space logs.
597
  # ----------------------------------------------------
598
 
599
  history = [
600
- (
601
- question,
602
- answer,
603
- )
604
  ]
605
 
606
  return (
@@ -637,10 +631,8 @@ async def do_research(
637
  )
638
 
639
  history = [
640
- (
641
- question,
642
- error,
643
- )
644
  ]
645
 
646
  return (
@@ -656,7 +648,7 @@ async def do_research(
656
  # GRADIO SYNC WRAPPER – DECORATED FOR ZEROGPU
657
  # ============================================================
658
 
659
- @spaces.GPU # <-- ADDED: required for ZeroGPU allocation
660
  def run_research(
661
  question,
662
  max_results,
@@ -792,6 +784,7 @@ with gr.Blocks(
792
  scale=7,
793
  ):
794
 
 
795
  chatbot = gr.Chatbot(
796
  label="X-RUDRA",
797
  height=600,
 
12
  import traceback
13
 
14
  import gradio as gr
15
+ import spaces # required for ZeroGPU
16
 
17
 
18
  # ============================================================
 
490
  question
491
  ).strip():
492
 
493
+ # Return empty history (list of dicts) and empty messages
494
  return (
495
+ [], # chat history as list of dicts
496
  "⚪ Enter a question to start.",
497
  "",
498
  "",
 
589
  )
590
 
591
  # ----------------------------------------------------
592
+ # CHAT HISTORY MUST BE LIST OF DICTS
 
 
 
 
 
593
  # ----------------------------------------------------
594
 
595
  history = [
596
+ {"role": "user", "content": question},
597
+ {"role": "assistant", "content": answer},
 
 
598
  ]
599
 
600
  return (
 
631
  )
632
 
633
  history = [
634
+ {"role": "user", "content": question},
635
+ {"role": "assistant", "content": error},
 
 
636
  ]
637
 
638
  return (
 
648
  # GRADIO SYNC WRAPPER – DECORATED FOR ZEROGPU
649
  # ============================================================
650
 
651
+ @spaces.GPU
652
  def run_research(
653
  question,
654
  max_results,
 
784
  scale=7,
785
  ):
786
 
787
+ # Chatbot – no 'type' argument; Gradio defaults to "messages" format (dicts)
788
  chatbot = gr.Chatbot(
789
  label="X-RUDRA",
790
  height=600,