Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -243,6 +243,7 @@ def search_synthetize(query: str, k: int = 5) -> List[int]:
|
|
243 |
results.append((images[idx], f"Page {page_num}"))
|
244 |
|
245 |
# Generate grounded response
|
|
|
246 |
ai_response = query_gpt(query, results)
|
247 |
print("[search_synthetize]", ai_response)
|
248 |
return ai_response
|
@@ -308,7 +309,6 @@ Final deliverable (must be clear and standalone):
|
|
308 |
# =============================
|
309 |
# MCP config (search-only)
|
310 |
# =============================
|
311 |
-
VISUAL_REASONING = True
|
312 |
DEFAULT_MCP_SERVER_URL = "https://manu-mcp-test.hf.space/gradio_api/mcp/"
|
313 |
DEFAULT_MCP_SERVER_LABEL = "colpali_rag"
|
314 |
|
@@ -448,7 +448,7 @@ def stream_agent(question: str,
|
|
448 |
yield round_state["final_text"] or " ", round_state["summary_text"] or " ", "\n".join(log_lines[-400:])
|
449 |
|
450 |
# Capture tool RESULT text and try to parse indices
|
451 |
-
elif etype.startswith("response.output_item.done"):
|
452 |
delta_text = getattr(event.item, "output", "")
|
453 |
if delta_text:
|
454 |
tool_result_buffer += str(delta_text)
|
@@ -487,7 +487,7 @@ def stream_agent(question: str,
|
|
487 |
|
488 |
# If the model returned indices via the tool, use them in a fresh call
|
489 |
next_indices = round_state.get("last_search_indices") or []
|
490 |
-
if next_indices:
|
491 |
# Neighbor expansion for context
|
492 |
base = set(next_indices)
|
493 |
expanded = set(base)
|
|
|
243 |
results.append((images[idx], f"Page {page_num}"))
|
244 |
|
245 |
# Generate grounded response
|
246 |
+
print("[waiting for ai response]", query)
|
247 |
ai_response = query_gpt(query, results)
|
248 |
print("[search_synthetize]", ai_response)
|
249 |
return ai_response
|
|
|
309 |
# =============================
|
310 |
# MCP config (search-only)
|
311 |
# =============================
|
|
|
312 |
DEFAULT_MCP_SERVER_URL = "https://manu-mcp-test.hf.space/gradio_api/mcp/"
|
313 |
DEFAULT_MCP_SERVER_LABEL = "colpali_rag"
|
314 |
|
|
|
448 |
yield round_state["final_text"] or " ", round_state["summary_text"] or " ", "\n".join(log_lines[-400:])
|
449 |
|
450 |
# Capture tool RESULT text and try to parse indices
|
451 |
+
elif etype.startswith("response.output_item.done") and visual_reasoning:
|
452 |
delta_text = getattr(event.item, "output", "")
|
453 |
if delta_text:
|
454 |
tool_result_buffer += str(delta_text)
|
|
|
487 |
|
488 |
# If the model returned indices via the tool, use them in a fresh call
|
489 |
next_indices = round_state.get("last_search_indices") or []
|
490 |
+
if next_indices and visual_reasoning:
|
491 |
# Neighbor expansion for context
|
492 |
base = set(next_indices)
|
493 |
expanded = set(base)
|