Flareeducation / Name.py
HaveAI's picture
Rename App.py to Name.py
ec0cba0 verified
raw
history blame contribute delete
924 Bytes
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()