mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-05-19 18:35:16 +02:00
- Collection.query and Backend.query/query_stream accept doc_ids as str, list[str] or None. Single str is normalized to [str] inside each backend; bare [] is rejected with ValueError at both layers. - wrap_with_doc_context wraps the scoped doc list in <docs>...</docs> and SCOPED_SYSTEM_PROMPT instructs the agent to treat that block as data, not instructions (defense against prompt injection via auto-generated doc_description). - _require_cloud_api now distinguishes api_key="" from api_key=None; the former gives a targeted error pointing at the empty-string vs fall-back-to-local situation when legacy SDK methods are called. - Legacy PageIndexClient.list_documents docstring spells out the return-shape difference vs collection.list_documents() to flag a silent migration footgun (paginated dict with id/name keys vs plain list[dict] with doc_id/doc_name keys). - Remove dead CloudBackend.get_agent_tools stub (not on the Backend protocol; only ever returned an empty AgentTools()) and the SYSTEM_PROMPT alias (OPEN_/SCOPED_SYSTEM_PROMPT are the explicit names now). - README quick start and streaming example now pass doc_ids; new multi-document section shows both str and list forms. - examples/demo_query_modes.py exercises all five query-mode cases (single-doc, multi-doc with/without env var, scoped single, scoped multi) for manual verification.
20 lines
735 B
Python
20 lines
735 B
Python
from pageindex.agent import AgentRunner, OPEN_SYSTEM_PROMPT, SCOPED_SYSTEM_PROMPT
|
|
from pageindex.backend.protocol import AgentTools
|
|
|
|
|
|
def test_agent_runner_init():
|
|
tools = AgentTools(function_tools=["mock_tool"])
|
|
runner = AgentRunner(tools=tools, model="gpt-4o")
|
|
assert runner._model == "gpt-4o"
|
|
|
|
|
|
def test_open_prompt_has_tool_instructions():
|
|
assert "list_documents" in OPEN_SYSTEM_PROMPT
|
|
assert "get_document_structure" in OPEN_SYSTEM_PROMPT
|
|
assert "get_page_content" in OPEN_SYSTEM_PROMPT
|
|
|
|
|
|
def test_scoped_prompt_omits_list_documents():
|
|
assert "list_documents" not in SCOPED_SYSTEM_PROMPT
|
|
assert "get_document_structure" in SCOPED_SYSTEM_PROMPT
|
|
assert "get_page_content" in SCOPED_SYSTEM_PROMPT
|