AbuSaleh28 commited on
Commit
91d439f
·
verified ·
1 Parent(s): 2a8660c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
  import os
 
3
  from groq import Groq
4
 
5
  # Initialize the Groq client via Hugging Face Secrets
@@ -17,6 +18,15 @@ custom_css = """
17
  .sidebar-panel { background: #111827 !important; border: 1px solid #1f2937 !important; border-radius: 12px !important; }
18
  .chat-window { border: 1px solid #1f2937 !important; border-radius: 12px !important; background: #111827 !important; }
19
  """
 
 
 
 
 
 
 
 
 
20
 
21
  def chat_stream(message, history, model, system_prompt, temperature, max_tokens):
22
  """
 
1
  import gradio as gr
2
  import os
3
+ import spaces
4
  from groq import Groq
5
 
6
  # Initialize the Groq client via Hugging Face Secrets
 
18
  .sidebar-panel { background: #111827 !important; border: 1px solid #1f2937 !important; border-radius: 12px !important; }
19
  .chat-window { border: 1px solid #1f2937 !important; border-radius: 12px !important; background: #111827 !important; }
20
  """
21
+ @spaces.GPU
22
+ def chat_stream(message, history, model, system_prompt, temperature, max_tokens):
23
+ """
24
+ Handles streaming responses using the standard history list layout.
25
+ """
26
+ if not message.strip():
27
+ yield history
28
+ return
29
+
30
 
31
  def chat_stream(message, history, model, system_prompt, temperature, max_tokens):
32
  """