File size: 1,116 Bytes
b19b35a
e557b05
 
 
b19b35a
 
2474a23
e557b05
a0acc08
b19b35a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a0acc08
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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()