Create Flare chat.py
Browse files- Flare chat.py +15 -0
Flare chat.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Загружаем модель (можно указать свою модель на Hugging Face)
|
| 5 |
+
pipe = pipeline("text2text-generation", model="HaveAI/FlareNew") # <-- Заменяй на свою модель!
|
| 6 |
+
|
| 7 |
+
def chat_with_flare(prompt):
|
| 8 |
+
system_prompt = "Ты ИИ по имени Flare. Отвечай дружелюбно и умно."
|
| 9 |
+
full_prompt = f"{system_prompt}\nПользователь: {prompt}\nFlare:"
|
| 10 |
+
result = pipe(full_prompt, max_new_tokens=100, temperature=0.7)
|
| 11 |
+
return result[0]["generated_text"]
|
| 12 |
+
|
| 13 |
+
# Интерфейс в браузере
|
| 14 |
+
iface = gr.Interface(fn=chat_with_flare, inputs="text", outputs="text", title="Flare Chatbot")
|
| 15 |
+
iface.launch()
|