Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,23 @@
|
|
1 |
from transformers import pipeline
|
|
|
2 |
|
|
|
3 |
generator = pipeline("text2text-generation", model="google/flan-t5-small")
|
4 |
|
|
|
5 |
def chat(message):
|
6 |
-
|
7 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
|
4 |
+
# Загружаем модель
|
5 |
generator = pipeline("text2text-generation", model="google/flan-t5-small")
|
6 |
|
7 |
+
# Функция чата
|
8 |
def chat(message):
|
9 |
+
response = generator(message, max_new_tokens=100)[0]['generated_text']
|
10 |
+
return response
|
11 |
+
|
12 |
+
# Интерфейс Gradio
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=chat,
|
15 |
+
inputs=gr.Textbox(lines=2, placeholder="Напиши сообщение..."),
|
16 |
+
outputs="text",
|
17 |
+
title="FlareGPT Light",
|
18 |
+
description="Чат с лёгкой моделью на Hugging Face Space"
|
19 |
+
)
|
20 |
+
|
21 |
+
# ОБЯЗАТЕЛЬНО
|
22 |
+
if __name__ == "__main__":
|
23 |
+
iface.launch()
|