eaglesarezzo commited on
Commit
4652799
·
verified ·
1 Parent(s): 9313368

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -27,7 +27,7 @@ cv2.setNumThreads(1)
27
  @spaces.GPU(duration=20)
28
  def respond(
29
  message,
30
- history: list[list[str, str]],
31
  model,
32
  system_message,
33
  max_tokens,
@@ -94,12 +94,12 @@ def respond(
94
  outputs = ""
95
  for output in stream:
96
  outputs += output
97
- yield outputs
98
  except Exception as e:
99
- yield f"Error during response generation: {str(e)}"
100
 
101
  def select_topic(topic):
102
- return gr.update(visible=True), topic
103
 
104
  with gr.Blocks(css="""
105
  .gradio-container {
@@ -156,9 +156,9 @@ with gr.Blocks(css="""
156
  top_k = gr.Slider(minimum=0, maximum=100, value=30, step=1, label="Top-k")
157
  repeat_penalty = gr.Slider(minimum=0.0, maximum=2.0, value=1.1, step=0.1, label="Repetition penalty")
158
 
159
- blockchain_btn.click(lambda: select_topic("blockchain"), inputs=None, outputs=[chatbot, selected_topic])
160
- metaverse_btn.click(lambda: select_topic("metaverse"), inputs=None, outputs=[chatbot, selected_topic])
161
- payment_btn.click(lambda: select_topic("payment"), inputs=None, outputs=[chatbot, selected_topic])
162
 
163
  submit_btn.click(
164
  respond,
 
27
  @spaces.GPU(duration=20)
28
  def respond(
29
  message,
30
+ history,
31
  model,
32
  system_message,
33
  max_tokens,
 
94
  outputs = ""
95
  for output in stream:
96
  outputs += output
97
+ yield history + [[message, outputs]]
98
  except Exception as e:
99
+ yield history + [[message, f"Error during response generation: {str(e)}"]]
100
 
101
  def select_topic(topic):
102
+ return gr.update(visible=True), topic, gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=False)
103
 
104
  with gr.Blocks(css="""
105
  .gradio-container {
 
156
  top_k = gr.Slider(minimum=0, maximum=100, value=30, step=1, label="Top-k")
157
  repeat_penalty = gr.Slider(minimum=0.0, maximum=2.0, value=1.1, step=0.1, label="Repetition penalty")
158
 
159
+ blockchain_btn.click(lambda: select_topic("blockchain"), inputs=None, outputs=[chatbot, selected_topic, blockchain_btn, metaverse_btn, payment_btn])
160
+ metaverse_btn.click(lambda: select_topic("metaverse"), inputs=None, outputs=[chatbot, selected_topic, blockchain_btn, metaverse_btn, payment_btn])
161
+ payment_btn.click(lambda: select_topic("payment"), inputs=None, outputs=[chatbot, selected_topic, blockchain_btn, metaverse_btn, payment_btn])
162
 
163
  submit_btn.click(
164
  respond,