ruslanmv commited on
Commit
5146aa4
·
verified ·
1 Parent(s): 2cbd42d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -5,10 +5,9 @@ from functools import lru_cache
5
  # Cache model loading to optimize performance
6
  @lru_cache(maxsize=3)
7
  def load_hf_model(model_name):
8
- # Use the Gradio-built huggingface loader instead of transformers_gradio
9
  return gr.load(
10
  name=f"deepseek-ai/{model_name}",
11
- src="huggingface", # Changed from transformers_gradio.registry
12
  api_name="/chat"
13
  )
14
 
@@ -58,7 +57,8 @@ with gr.Blocks(theme=gr.themes.Soft(), title="DeepSeek Chatbot") as demo:
58
 
59
  with gr.Row():
60
  with gr.Column():
61
- chatbot_output = gr.Chatbot(label="DeepSeek Chatbot", height=500)
 
62
  msg = gr.Textbox(label="Your Message", placeholder="Type your message here...")
63
  with gr.Row():
64
  submit_btn = gr.Button("Submit", variant="primary")
@@ -101,10 +101,11 @@ with gr.Blocks(theme=gr.themes.Soft(), title="DeepSeek Chatbot") as demo:
101
  [chatbot_output, chat_history, msg]
102
  )
103
 
104
- # Add GPU support for Hugging Face Spaces
105
- demo.fn = spaces.GPU()(demo.fn)
106
- for fn in demo.fns.values():
107
- fn.api_name = False
108
 
109
  if __name__ == "__main__":
110
- demo.launch()
 
 
 
5
  # Cache model loading to optimize performance
6
  @lru_cache(maxsize=3)
7
  def load_hf_model(model_name):
 
8
  return gr.load(
9
  name=f"deepseek-ai/{model_name}",
10
+ src="huggingface",
11
  api_name="/chat"
12
  )
13
 
 
57
 
58
  with gr.Row():
59
  with gr.Column():
60
+ # Specify type='messages' to avoid deprecation warning
61
+ chatbot_output = gr.Chatbot(label="DeepSeek Chatbot", height=500, type="messages")
62
  msg = gr.Textbox(label="Your Message", placeholder="Type your message here...")
63
  with gr.Row():
64
  submit_btn = gr.Button("Submit", variant="primary")
 
101
  [chatbot_output, chat_history, msg]
102
  )
103
 
104
+ # Remove (or replace) the old `demo.fn = spaces.GPU()(demo.fn)` line
105
+ # If you need GPU acceleration in Spaces, wrap demo.launch() with spaces.GPU()
106
+ # as shown below. Otherwise, remove the spaces.GPU() call.
 
107
 
108
  if __name__ == "__main__":
109
+ # Launch the Gradio app with GPU from Hugging Face Spaces
110
+ # If you DON'T need GPU from `spaces`, just do: demo.launch()
111
+ spaces.GPU()(demo.launch)()