Spaces:
Runtime error
Runtime error
shaktibiplab
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,15 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
|
4 |
-
# Load model and tokenizer
|
5 |
model_name = "deepseek-ai/DeepSeek-V3"
|
6 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
-
model = AutoModelForCausalLM.from_pretrained(
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
# Function to handle chatbot response
|
10 |
def chat_with_deepseek(prompt):
|
11 |
inputs = tokenizer(prompt, return_tensors="pt")
|
12 |
outputs = model.generate(
|
@@ -18,16 +21,11 @@ def chat_with_deepseek(prompt):
|
|
18 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
19 |
return response
|
20 |
|
21 |
-
# Gradio interface
|
22 |
with gr.Blocks() as demo:
|
23 |
gr.Markdown("# DeepSeek Chatbot")
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
with gr.Column():
|
28 |
-
submit_btn = gr.Button("Send")
|
29 |
-
chatbot_output = gr.Textbox(label="Response", placeholder="Chatbot response will appear here")
|
30 |
-
|
31 |
submit_btn.click(chat_with_deepseek, inputs=user_input, outputs=chatbot_output)
|
32 |
|
33 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
|
|
|
4 |
model_name = "deepseek-ai/DeepSeek-V3"
|
5 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
6 |
+
model = AutoModelForCausalLM.from_pretrained(
|
7 |
+
model_name,
|
8 |
+
trust_remote_code=True,
|
9 |
+
device_map="auto",
|
10 |
+
quantization_config=None
|
11 |
+
)
|
12 |
|
|
|
13 |
def chat_with_deepseek(prompt):
|
14 |
inputs = tokenizer(prompt, return_tensors="pt")
|
15 |
outputs = model.generate(
|
|
|
21 |
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
22 |
return response
|
23 |
|
|
|
24 |
with gr.Blocks() as demo:
|
25 |
gr.Markdown("# DeepSeek Chatbot")
|
26 |
+
user_input = gr.Textbox(label="Enter your message")
|
27 |
+
chatbot_output = gr.Textbox(label="Response")
|
28 |
+
submit_btn = gr.Button("Send")
|
|
|
|
|
|
|
|
|
29 |
submit_btn.click(chat_with_deepseek, inputs=user_input, outputs=chatbot_output)
|
30 |
|
31 |
demo.launch()
|