File size: 661 Bytes
8cc1f9a
 
fde5a4a
 
 
c647451
fde5a4a
 
 
 
 
d8ecca8
fde5a4a
 
 
 
 
 
 
7514661
fde5a4a
 
 
 
 
 
 
7514661
94082cb
b1ce122
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import gradio as gr

import torch
from transformers import pipeline

model_id = "deepseek-ai/DeepSeek-R1"
pipe = pipeline(
    "text-generation",
    model=model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True,
)
messages = [
    {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
    {"role": "user", "content": "Who are you?"},
]


def model(params):
    outputs = pipe(
    messages,
    max_new_tokens=256,
    )
    output = outputs[0]["generated_text"][-1]
    print(output)
    return output

app = gr.Interface(fn=model, inputs="textbox", outputs="textbox")
app.launch()