File size: 1,702 Bytes
e557b05
1cb13b6
e9037c9
e557b05
e9037c9
 
 
 
b256639
e9037c9
 
b256639
e9037c9
 
 
b256639
e9037c9
 
b256639
e9037c9
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from generate import generate_response
from web_search import web_search  # RAG fallback

def evo_qa(question, context, use_rag, temperature):
    # If no context and RAG is enabled, fetch from web
    if not context.strip() and use_rag:
        context = web_search(question)

    # Generate answer using Evo
    answer = generate_response(prompt=question, external_context=context, temperature=temperature)

    if not answer.strip():
        return "(No meaningful response generated.)"
    return answer

with gr.Blocks(title="EvoRAG — SQuAD-Tuned QA with Optional Web Retrieval") as demo:
    gr.Markdown("🧠 **EvoRAG — SQuAD-Tuned QA with Optional Web Retrieval**\nAsk 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.Row():
        with gr.Column():
            question = gr.Textbox(label="❓ Question", placeholder="Enter your question...")
            context = gr.Textbox(label="📄 Context (Optional)", placeholder="Paste context or leave blank to use RAG")
            use_rag = gr.Checkbox(label="🔍 Use RAG (Live Web Search)", value=False)
            temperature = gr.Slider(minimum=0.1, maximum=1.5, value=1.0, label="🔥 Temperature")
            submit = gr.Button("Submit")
            clear = gr.Button("Clear")

        with gr.Column():
            answer = gr.Textbox(label="🤖 Evo's Answer", interactive=False, lines=6)

    submit.click(fn=evo_qa, inputs=[question, context, use_rag, temperature], outputs=answer)
    clear.click(fn=lambda: ("", "", False, 1.0, ""), inputs=[], outputs=[question, context, use_rag, temperature, answer])

demo.launch()