EvoConvo / app.py
HemanM's picture
Update app.py
b19b35a verified
raw
history blame
1.12 kB
# app.py — Gradio interface for EvoDecoder conversational chatbot
import gradio as gr
from generate import generate_response
# Initialize Gradio Chatbot with OpenAI-style message format
with gr.Blocks(title="🧠 Chat with EvoDecoder — Lightweight Conversational AI") as demo:
gr.Markdown("## 🧠 Chat with EvoDecoder — Lightweight Conversational AI")
chatbot = gr.Chatbot(label="Chat with Evo", type="messages")
msg = gr.Textbox(placeholder="Ask Evo anything...", label="Your message")
clear = gr.Button("Clear Chat")
def chat_fn(history, message):
"""Handles each user input and appends Evo's response."""
history = history or []
response = generate_response(message)
history.append({"role": "user", "content": message})
history.append({"role": "assistant", "content": response})
return history
def clear_fn():
"""Clears the chat history."""
return []
msg.submit(chat_fn, [chatbot, msg], chatbot)
msg.submit(lambda: "", None, msg)
clear.click(clear_fn, outputs=chatbot)
# Launch the app
demo.launch()