Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,15 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
-
import torch
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
generator = pipeline("text-generation", model="
|
| 7 |
|
| 8 |
def chat(message, history):
|
| 9 |
-
# Промпт для стиля ChatGPT
|
| 10 |
-
prompt = f"Ты полезный ассистент
|
| 11 |
-
response = generator(prompt, max_length=
|
| 12 |
# Извлекаем ответ
|
| 13 |
-
ai_reply = response.split("
|
| 14 |
history.append((message, ai_reply))
|
| 15 |
return history, ""
|
| 16 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
|
|
|
| 3 |
|
| 4 |
+
# Меньшая русская модель (работает на free tier)
|
| 5 |
+
generator = pipeline("text-generation", model="sberbank-ai/rugpt3small_based_on_gpt2")
|
| 6 |
|
| 7 |
def chat(message, history):
|
| 8 |
+
# Промпт для стиля ChatGPT на русском
|
| 9 |
+
prompt = f"Ты полезный ассистент. Отвечай кратко и точно. Вопрос: {message}\nОтвет:"
|
| 10 |
+
response = generator(prompt, max_length=100, num_return_sequences=1, temperature=0.8)[0]['generated_text']
|
| 11 |
# Извлекаем ответ
|
| 12 |
+
ai_reply = response.split("Ответ:")[-1].strip()
|
| 13 |
history.append((message, ai_reply))
|
| 14 |
return history, ""
|
| 15 |
|