Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,19 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
def chat_fn(message, history):
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
gr.ChatInterface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Заменить модель на свою
|
| 5 |
+
pipe = pipeline("text-generation", model="название_твоей_модели")
|
| 6 |
|
| 7 |
def chat_fn(message, history):
|
| 8 |
+
# Получаем ответ от модели
|
| 9 |
+
output = pipe(message, max_new_tokens=200)[0]['generated_text']
|
| 10 |
+
# Можно очистить префикс, если он дублирует prompt
|
| 11 |
+
return output.strip()
|
| 12 |
|
| 13 |
+
gr.ChatInterface(
|
| 14 |
+
fn=chat_fn,
|
| 15 |
+
title="Flare Chat",
|
| 16 |
+
theme="soft", # Можно убрать или изменить
|
| 17 |
+
examples=["Привет!", "Расскажи шутку", "Кто такой Эйнштейн?"],
|
| 18 |
+
).launch()
|
| 19 |
|