File size: 1,188 Bytes
78efc3f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from .reranker import rerank_context

# ---------------------------------------------------------------------
# Gradio Interface with MCP support
# ---------------------------------------------------------------------
ui = gr.Interface(
    fn=rerank_context,
    inputs=[
        gr.Textbox(
            label="Query", 
            lines=2, 
            placeholder="Paste user query here",
            info="Enter user query"
        ),
        gr.Textbox(
            label="Retrieved Context", 
            lines=8, 
            placeholder="Paste retrieved context here",
            info="Provide the context/documents to use for reranking"
        ),
    ],
    outputs=gr.Textbox(
        label="Reranked Context",
        lines=6,
        show_copy_button=True
    ),
    title="RAG Reranking Service UI",
    description="Reranks previously retrieved context. Intended for use in RAG pipelines (i.e. context supplied by semantic retriever service) as an MCP server.",
)

# Launch with MCP server enabled
if __name__ == "__main__":
    ui.launch(
        server_name="0.0.0.0",
        server_port=7860,
        mcp_server=True,
        show_error=True
    )