mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-15 21:11:05 +02:00
fix: prompt guidance referenced fields get_document doesn't return
OPEN_SYSTEM_PROMPT and SCOPED_SYSTEM_PROMPT told the agent to call
get_document(doc_id) "to confirm status and page/line count", but neither
backend returns a page/line count and the local backend has no status field
(get_document returns doc_name/doc_type/doc_description). The agent would
hunt for fields that don't exist, degrading QA. Align both prompts with the
demo's wording ("confirm the document's name and type"). Regression test
asserts the prompts no longer reference the non-existent page/line count.
This commit is contained in:
parent
9ad7c687e0
commit
e18ccdeaf8
2 changed files with 12 additions and 2 deletions
|
|
@ -20,7 +20,7 @@ OPEN_SYSTEM_PROMPT = """
|
|||
You are PageIndex, a document QA assistant.
|
||||
TOOL USE:
|
||||
- Call list_documents() to see available documents; use doc_name and doc_description to pick which doc(s) are relevant.
|
||||
- Call get_document(doc_id) to confirm status and page/line count.
|
||||
- Call get_document(doc_id) to confirm the document's name and type.
|
||||
- Call get_document_structure(doc_id) to identify relevant page ranges.
|
||||
- Call get_page_content(doc_id, pages="5-7") with tight ranges; never fetch the whole document.
|
||||
- Before each tool call, output one short sentence explaining the reason.
|
||||
|
|
@ -33,7 +33,7 @@ Answer based only on tool output. Be concise.
|
|||
SCOPED_SYSTEM_PROMPT = """
|
||||
You are PageIndex, a document QA assistant.
|
||||
TOOL USE:
|
||||
- Call get_document(doc_id) to confirm status and page/line count.
|
||||
- Call get_document(doc_id) to confirm the document's name and type.
|
||||
- Call get_document_structure(doc_id) to identify relevant page ranges.
|
||||
- Call get_page_content(doc_id, pages="5-7") with tight ranges; never fetch the whole document.
|
||||
- Before each tool call, output one short sentence explaining the reason.
|
||||
|
|
|
|||
|
|
@ -20,6 +20,16 @@ def test_scoped_prompt_omits_list_documents():
|
|||
assert "get_page_content" in SCOPED_SYSTEM_PROMPT
|
||||
|
||||
|
||||
def test_prompts_get_document_guidance_matches_returned_fields():
|
||||
# Regression: get_document returns doc_name/doc_type/doc_description — neither
|
||||
# backend returns a page/line count, and the local backend has no status
|
||||
# field. The prompt must not send the agent hunting for fields that don't
|
||||
# exist (degrades QA), so it references only name and type (like the demo).
|
||||
for prompt in (OPEN_SYSTEM_PROMPT, SCOPED_SYSTEM_PROMPT):
|
||||
assert "page/line count" not in prompt
|
||||
assert "get_document(doc_id) to confirm the document's name and type" in prompt
|
||||
|
||||
|
||||
def test_wrap_with_doc_context_cannot_be_escaped_by_untrusted_content():
|
||||
"""doc_name/doc_description are untrusted (doc_name is an unsanitized
|
||||
filename; doc_description is LLM-generated from document content). Neither
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue