|
|
|
import gradio as gr |
|
from generate import generate_response |
|
|
|
|
|
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) |
|
|
|
|
|
demo.launch() |
|
|