Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -163,6 +163,7 @@ def search(query: str, k: int = 5) -> List[int]:
|
|
| 163 |
# Score and select top-k
|
| 164 |
scores = processor.score(q_vecs, ds, device=device)
|
| 165 |
top_k_indices = scores[0].topk(k).indices.tolist()
|
|
|
|
| 166 |
|
| 167 |
# Neighbor expansion for context
|
| 168 |
base = set(top_k_indices)
|
|
@@ -180,7 +181,7 @@ def get_pages(indices: List[int]) -> Dict[str, Any]:
|
|
| 180 |
Return page images (as data URLs) for the given 0-based indices.
|
| 181 |
|
| 182 |
MCP tool description:
|
| 183 |
-
- name:
|
| 184 |
- description: Given 0-based indices from mcp_test_search, return the corresponding page images as data URLs for vision reasoning.
|
| 185 |
- input_schema:
|
| 186 |
type: object
|
|
@@ -196,6 +197,7 @@ def get_pages(indices: List[int]) -> Dict[str, Any]:
|
|
| 196 |
{"images": [{"index": int, "page": int, "image_url": str}], "count": int}
|
| 197 |
"""
|
| 198 |
global images
|
|
|
|
| 199 |
|
| 200 |
if not images:
|
| 201 |
return {"images": [], "count": 0}
|
|
|
|
| 163 |
# Score and select top-k
|
| 164 |
scores = processor.score(q_vecs, ds, device=device)
|
| 165 |
top_k_indices = scores[0].topk(k).indices.tolist()
|
| 166 |
+
print(query, top_k_indices)
|
| 167 |
|
| 168 |
# Neighbor expansion for context
|
| 169 |
base = set(top_k_indices)
|
|
|
|
| 181 |
Return page images (as data URLs) for the given 0-based indices.
|
| 182 |
|
| 183 |
MCP tool description:
|
| 184 |
+
- name: mcp_test_get_pages
|
| 185 |
- description: Given 0-based indices from mcp_test_search, return the corresponding page images as data URLs for vision reasoning.
|
| 186 |
- input_schema:
|
| 187 |
type: object
|
|
|
|
| 197 |
{"images": [{"index": int, "page": int, "image_url": str}], "count": int}
|
| 198 |
"""
|
| 199 |
global images
|
| 200 |
+
print("indices to get", indices)
|
| 201 |
|
| 202 |
if not images:
|
| 203 |
return {"images": [], "count": 0}
|