Update app.py
Browse files4 unmodified lines567889111011121343 unmodified lines57585960616162636436 unmodified lines1011021031041051061071041051061071081101091101114 unmodified lines# Cache model loading to optimize performance@lru_cache(maxsize=3)def load_hf_model(model_name): # Use the Gradio-built huggingface loader instead of transformers_gradio return gr.load( name=f"deepseek-ai/{model_name}", src="huggingface", # Changed from transformers_gradio.registry src="huggingface", api_name="/chat" )
43 unmodified lines
with gr.Row(): with gr.Column(): # Specify type='messages' to avoid deprecation warning chatbot_output = gr.Chatbot(label="DeepSeek Chatbot", height=500) chatbot_output = gr.Chatbot(label="DeepSeek Chatbot", height=500, type="messages") msg = gr.Textbox(label="Your Message", placeholder="Type your message here...") with gr.Row(): submit_btn = gr.Button("Submit", variant="primary")36 unmodified lines [chatbot_output, chat_history, msg] )
# Add GPU support for Hugging Face Spacesdemo.fn = spaces.GPU()(demo.fn)for fn in demo.fns.values(): fn.api_name = False# Remove (or replace) the old `demo.fn = spaces.GPU()(demo.fn)` line# If you need GPU acceleration in Spaces, wrap demo.launch() with spaces.GPU()# as shown below. Otherwise, remove the spaces.GPU() call.
if __name__ == "__main__": demo.launch() # Launch the Gradio app with GPU from Hugging Face Spaces # If you DON'T need GPU from `spaces`, just do: demo.launch() spaces.GPU()(demo.launch)()app.py+9-8