File size: 1,553 Bytes
e557b05 1cb13b6 e557b05 b256639 cd64e90 5cef79d b256639 |
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 32 33 34 35 36 37 38 39 40 41 42 |
import gradio as gr
from generate import generate_response
def answer_question(question, context, use_rag, temperature):
if not question.strip():
return "❌ Please enter a question."
answer = generate_response(
question=question,
context=context.strip(),
use_rag=use_rag,
temperature=temperature
)
return answer or "(No meaningful response generated.)"
title = "🧠 EvoRAG — SQuAD-Tuned QA with Optional Web Retrieval"
description = "Ask a question with optional context. Evo was fine-tuned on SQuAD v2. Toggle RAG for live web search if no context is available."
with gr.Blocks() as demo:
gr.Markdown(f"# {title}")
gr.Markdown(description)
with gr.Row():
question = gr.Textbox(label="❓ Question", placeholder="e.g. What is the capital of Japan?")
context = gr.Textbox(label="📄 Context (Optional)", placeholder="Paste context or leave blank to use RAG", lines=4)
with gr.Row():
use_rag = gr.Checkbox(label="🔍 Use RAG (Live Web Search)", value=False)
temperature = gr.Slider(0.1, 1.5, value=1.0, step=0.1, label="🔥 Temperature")
with gr.Row():
submit = gr.Button("Submit")
clear = gr.Button("Clear")
output = gr.Textbox(label="🤖 Evo's Answer", lines=4)
submit.click(fn=answer_question, inputs=[question, context, use_rag, temperature], outputs=output)
clear.click(fn=lambda: ("", "", False, 1.0, ""), inputs=[], outputs=[question, context, use_rag, temperature, output])
demo.launch()
|