Spaces:
Runtime error
Runtime error
Commit
·
b15f1fd
1
Parent(s):
c597e48
Add application file
Browse files- app.py +23 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the model
|
5 |
+
pipe = pipeline("text-generation", model="deepseek-ai/DeepSeek-R1", trust_remote_code=True)
|
6 |
+
|
7 |
+
# Define the function that will be called by Gradio
|
8 |
+
def generate_response(message):
|
9 |
+
messages = [{"role": "user", "content": message}]
|
10 |
+
response = pipe(messages)
|
11 |
+
return response[0]['generated_text']
|
12 |
+
|
13 |
+
# Create a Gradio interface
|
14 |
+
iface = gr.Interface(
|
15 |
+
fn=generate_response,
|
16 |
+
inputs=gr.Textbox(lines=2, placeholder="Enter your message here..."),
|
17 |
+
outputs="text",
|
18 |
+
title="DeepSeek-R1 Chatbot",
|
19 |
+
description="Ask anything to the DeepSeek-R1 model."
|
20 |
+
)
|
21 |
+
|
22 |
+
# Launch the interface
|
23 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
torch
|
3 |
+
gradio
|