Spaces:
Sleeping
Sleeping
app.py
Browse filesimport gradio as gr
from transformers import AutoTokenizer, AutoModelForCausalLM
# Load the DeepSeek-R1 model
model_name = "deepseek-ai/DeepSeek-R1"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
# Function for chatting
def chat_with_ai(prompt):
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=200)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
return response
# Gradio interface
ui = gr.Interface(
fn=chat_with_ai,
inputs=gr.Textbox(label="Ask me anything..."),
outputs="text",
title="💬 DeepSeek-R1 AI",
description="Chat with your own DeepSeek-R1 model hosted on Hugging Face!"
)
ui.launch()