File size: 675 Bytes
b15f1fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import pipeline

# Load the model
pipe = pipeline("text-generation", model="deepseek-ai/DeepSeek-R1", trust_remote_code=True)

# Define the function that will be called by Gradio
def generate_response(message):
    messages = [{"role": "user", "content": message}]
    response = pipe(messages)
    return response[0]['generated_text']

# Create a Gradio interface
iface = gr.Interface(
    fn=generate_response,
    inputs=gr.Textbox(lines=2, placeholder="Enter your message here..."),
    outputs="text",
    title="DeepSeek-R1 Chatbot",
    description="Ask anything to the DeepSeek-R1 model."
)

# Launch the interface
iface.launch()