Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
|
4 |
+
model_name = "mergekit-community/qwen-2.5-o1.like-pluse"
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
6 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
7 |
+
|
8 |
+
def generate_response(prompt):
|
9 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
10 |
+
outputs = model.generate(**inputs, max_length=150, temperature=0.7)
|
11 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
12 |
+
return response
|
13 |
+
|
14 |
+
iface = gr.Interface(
|
15 |
+
fn=generate_response,
|
16 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Введите ваш вопрос"),
|
17 |
+
outputs="text",
|
18 |
+
title="Qwen-2.5-O1.Like-Pluse",
|
19 |
+
description="Интерфейс для взаимодействия с моделью Qwen-2.5-O1.Like-Pluse"
|
20 |
+
)
|
21 |
+
|
22 |
+
iface.launch()
|