sufian7755 commited on
Commit
21eaa69
·
verified ·
1 Parent(s): 1406ec8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py CHANGED
@@ -1 +1,25 @@
 
 
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM
3
 
4
+ # Load DeepSeek-R1 model
5
+ model_name = "deepseek-ai/DeepSeek-R1"
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForCausalLM.from_pretrained(model_name)
8
+
9
+ # Chat function
10
+ def chat_with_ai(prompt):
11
+ inputs = tokenizer(prompt, return_tensors="pt")
12
+ outputs = model.generate(**inputs, max_new_tokens=250)
13
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
14
+ return response
15
+
16
+ # Gradio UI
17
+ ui = gr.Interface(
18
+ fn=chat_with_ai,
19
+ inputs=gr.Textbox(label="Ask me anything..."),
20
+ outputs="text",
21
+ title="💬 DeepSeek-R1 AI",
22
+ description="Chat with your own DeepSeek-R1 model hosted on Hugging Face Cloud!"
23
+ )
24
+
25
+ ui.launch()