Intelarya.ai / app.py
hexanovapixel's picture
Update app.py
dc0b2cf verified
raw
history blame
932 Bytes
import gradio as gr
from transformers import pipeline
# Cargar modelo ligero
generator = pipeline("text-generation", model="gpt2")
def responder(message, history):
history = history or []
prompt = "Eres Intelarya.ai, una IA educativa que explica claro y paso a paso.\n\n"
for h in history:
prompt += f"Usuario: {h[0]}\nIntelarya: {h[1]}\n"
prompt += f"Usuario: {message}\nIntelarya:"
result = generator(prompt, max_length=150, do_sample=True, temperature=0.7)
response = result[0]["generated_text"].split("Intelarya:")[-1].strip()
history.append((message, response))
return history, history
with gr.Blocks() as demo:
gr.Markdown("# 💎 intelarya.ai")
gr.Markdown("Aprende más rápido. Entiende mejor. Sin complicaciones.")
chatbot = gr.Chatbot()
msg = gr.Textbox()
state = gr.State([])
msg.submit(responder, [msg, state], [chatbot, state])
demo.launch()