HaveAI commited on
Commit
2558e22
·
verified ·
1 Parent(s): 2468f54

Create App.py

Browse files
Files changed (1) hide show
  1. App.py +24 -0
App.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+ # Загружаем модель для генерации текста (можешь заменить на свою)
4
+ pipe = pipeline("text2text-generation", model="google/flan-t5-small")
5
+
6
+ # Основная функция общения
7
+ def chat_with_flare(prompt):
8
+ system_prompt = "You are a friendly Chatbot Flare."
9
+ full_prompt = f"{system_prompt}\nUser: {prompt}\nFlare:"
10
+ result = pipe(full_prompt, max_new_tokens=100)
11
+ return result[0]['generated_text'].replace(full_prompt, "").strip()
12
+
13
+ # Интерфейс через Gradio
14
+ import gradio as gr
15
+
16
+ iface = gr.Interface(
17
+ fn=chat_with_flare,
18
+ inputs=gr.Textbox(lines=4, placeholder="Введите сообщение..."),
19
+ outputs="text",
20
+ title="Flare Chatbot",
21
+ description="Привет! Я Flare — дружелюбный чатбот. Задай мне любой вопрос!"
22
+ )
23
+
24
+ iface.launch()