manu commited on
Commit
384ff8b
·
verified ·
1 Parent(s): 45d4aa4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -188,8 +188,8 @@ You are a PDF research agent with a single tool: mcp_test_search(query: string,
188
  Act iteratively:
189
  1) Split the user question into 1–4 focused sub-queries. Subqueries should be asked as natural language questions in the english language, not just keywords.
190
  2) For each sub-query, call mcp_test_search (k=5 by default; increase to up to 10 if you need to go deep).
191
- 3) You will receive the output of mcp_test_search as a list of indices correspondinf to page numbers. Print them out and stop generating. You will be fed the corresponding pages as images in a follow-up message.
192
- 3) Stop early when confident; otherwise refine and repeat, up to 4 iterations and 20 searches in total. If info is missing, try to continue searching using new keywords and queries.
193
 
194
  Workflow:
195
  • Use ONLY the provided images for grounding and cite as (p.<page>).
@@ -258,7 +258,7 @@ def stream_agent(question: str,
258
 
259
  # Shared mutable state for each round
260
  round_state: Dict[str, Any] = {
261
- "last_search_indices": None,
262
  "final_text": "",
263
  "summary_text": "",
264
  }
@@ -269,9 +269,9 @@ def stream_agent(question: str,
269
  """
270
  nonlocal prev_response_id
271
 
272
- round_state["last_search_indices"] = None
273
- round_state["final_text"] = ""
274
- round_state["summary_text"] = ""
275
 
276
  # Build the user content for this round
277
  parts: List[Dict[str, Any]] = []
@@ -349,7 +349,7 @@ def stream_agent(question: str,
349
  tool_result_buffer += str(delta_text)
350
  parsed_now = _maybe_parse_indices(tool_result_buffer)
351
  if parsed_now:
352
- round_state["last_search_indices"] = parsed_now
353
  log_lines.append(f"[tool-result] indices={parsed_now}")
354
  yield round_state["final_text"] or " ", round_state["summary_text"] or " ", "\n".join(log_lines[-400:])
355
 
 
188
  Act iteratively:
189
  1) Split the user question into 1–4 focused sub-queries. Subqueries should be asked as natural language questions in the english language, not just keywords.
190
  2) For each sub-query, call mcp_test_search (k=5 by default; increase to up to 10 if you need to go deep).
191
+ 3) You will receive the output of mcp_test_search as a list of indices corresponding to page numbers. Print them out and stop generating. You will be fed the corresponding pages as images in a follow-up message.
192
+ 3) Stop early when confident; otherwise refine and repeat, running new searches. Up to 4 iterations and 20 searches in total. If info is missing, try to continue searching using new keywords and queries.
193
 
194
  Workflow:
195
  • Use ONLY the provided images for grounding and cite as (p.<page>).
 
258
 
259
  # Shared mutable state for each round
260
  round_state: Dict[str, Any] = {
261
+ "last_search_indices": [],
262
  "final_text": "",
263
  "summary_text": "",
264
  }
 
269
  """
270
  nonlocal prev_response_id
271
 
272
+ round_state["last_search_indices"] = []
273
+ # round_state["final_text"] = ""
274
+ # round_state["summary_text"] = ""
275
 
276
  # Build the user content for this round
277
  parts: List[Dict[str, Any]] = []
 
349
  tool_result_buffer += str(delta_text)
350
  parsed_now = _maybe_parse_indices(tool_result_buffer)
351
  if parsed_now:
352
+ round_state["last_search_indices"] += parsed_now
353
  log_lines.append(f"[tool-result] indices={parsed_now}")
354
  yield round_state["final_text"] or " ", round_state["summary_text"] or " ", "\n".join(log_lines[-400:])
355