Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -129,7 +129,7 @@ def index_from_url(url: str) -> Tuple[str, str]:
|
|
| 129 |
# MCP Tools
|
| 130 |
# =============================
|
| 131 |
|
| 132 |
-
def
|
| 133 |
"""
|
| 134 |
Search within an indexed PDF and return ONLY the indices of the most relevant pages (0-based).
|
| 135 |
|
|
@@ -175,7 +175,7 @@ def mcp_test_search(query: str, k: int = 5) -> List[int]:
|
|
| 175 |
return sorted(expanded)
|
| 176 |
|
| 177 |
|
| 178 |
-
def
|
| 179 |
"""
|
| 180 |
Return page images (as data URLs) for the given 0-based indices.
|
| 181 |
|
|
@@ -241,7 +241,7 @@ Final deliverable:
|
|
| 241 |
|
| 242 |
DEFAULT_MCP_SERVER_URL = "https://manu-mcp-test.hf.space/gradio_api/mcp/"
|
| 243 |
DEFAULT_MCP_SERVER_LABEL = "colpali_rag"
|
| 244 |
-
DEFAULT_ALLOWED_TOOLS = "mcp_test_search,
|
| 245 |
|
| 246 |
|
| 247 |
def stream_agent(question: str,
|
|
@@ -431,7 +431,7 @@ def build_ui():
|
|
| 431 |
output_text = gr.Textbox(label="Indices (0-based)", lines=12, placeholder="[0, 1, 2, ...]")
|
| 432 |
|
| 433 |
def run_direct_indices(query: str, k: int) -> str:
|
| 434 |
-
idxs =
|
| 435 |
return str(idxs)
|
| 436 |
|
| 437 |
search_button.click(run_direct_indices, inputs=[query_box, k_slider], outputs=[output_text])
|
|
|
|
| 129 |
# MCP Tools
|
| 130 |
# =============================
|
| 131 |
|
| 132 |
+
def search(query: str, k: int = 5) -> List[int]:
|
| 133 |
"""
|
| 134 |
Search within an indexed PDF and return ONLY the indices of the most relevant pages (0-based).
|
| 135 |
|
|
|
|
| 175 |
return sorted(expanded)
|
| 176 |
|
| 177 |
|
| 178 |
+
def get_pages(indices: List[int]) -> Dict[str, Any]:
|
| 179 |
"""
|
| 180 |
Return page images (as data URLs) for the given 0-based indices.
|
| 181 |
|
|
|
|
| 241 |
|
| 242 |
DEFAULT_MCP_SERVER_URL = "https://manu-mcp-test.hf.space/gradio_api/mcp/"
|
| 243 |
DEFAULT_MCP_SERVER_LABEL = "colpali_rag"
|
| 244 |
+
DEFAULT_ALLOWED_TOOLS = "mcp_test_search,mcp_test_get_pages"
|
| 245 |
|
| 246 |
|
| 247 |
def stream_agent(question: str,
|
|
|
|
| 431 |
output_text = gr.Textbox(label="Indices (0-based)", lines=12, placeholder="[0, 1, 2, ...]")
|
| 432 |
|
| 433 |
def run_direct_indices(query: str, k: int) -> str:
|
| 434 |
+
idxs = search(query=query, k=k)
|
| 435 |
return str(idxs)
|
| 436 |
|
| 437 |
search_button.click(run_direct_indices, inputs=[query_box, k_slider], outputs=[output_text])
|