File size: 924 Bytes
2558e22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from transformers import pipeline

# Загружаем модель для генерации текста (можешь заменить на свою)
pipe = pipeline("text2text-generation", model="google/flan-t5-small")

# Основная функция общения
def chat_with_flare(prompt):
    system_prompt = "You are a friendly Chatbot Flare."
    full_prompt = f"{system_prompt}\nUser: {prompt}\nFlare:"
    result = pipe(full_prompt, max_new_tokens=100)
    return result[0]['generated_text'].replace(full_prompt, "").strip()

# Интерфейс через Gradio
import gradio as gr

iface = gr.Interface(
    fn=chat_with_flare,
    inputs=gr.Textbox(lines=4, placeholder="Введите сообщение..."),
    outputs="text",
    title="Flare Chatbot",
    description="Привет! Я Flare — дружелюбный чатбот. Задай мне любой вопрос!"
)

iface.launch()