deepseekv3 / app.py
shaktibiplab's picture
Update app.py
2905875 verified
raw
history blame contribute delete
964 Bytes
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "deepseek-ai/DeepSeek-V3"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
trust_remote_code=True,
device_map="auto",
quantization_config=None
)
def chat_with_deepseek(prompt):
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(
inputs["input_ids"],
max_length=512,
num_return_sequences=1,
pad_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
return response
with gr.Blocks() as demo:
gr.Markdown("# DeepSeek Chatbot")
user_input = gr.Textbox(label="Enter your message")
chatbot_output = gr.Textbox(label="Response")
submit_btn = gr.Button("Send")
submit_btn.click(chat_with_deepseek, inputs=user_input, outputs=chatbot_output)
demo.launch()