|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
def chat_with_model(user_input): |
|
messages = [{"role": "user", "content": user_input}] |
|
pipe = pipeline("text-generation", model="deepseek-ai/DeepSeek-R1", trust_remote_code=True) |
|
response = pipe(messages) |
|
return response[0]['generated_text'] |
|
|
|
iface = gr.Interface( |
|
fn=chat_with_model, |
|
inputs=gr.Textbox(label="Enter your message"), |
|
outputs=gr.Textbox(label="Model Response"), |
|
title="Chat with DeepSeek-R1", |
|
description="Enter a message to interact with the DeepSeek-R1 model." |
|
) |
|
|
|
iface.launch() |
|
|