Chat UI answers section-specific questions correctly, but Chat API ignores indexed nodes and falls back to generic assistant #94
Replies: 1 comment
-
|
Hi @parthpaliwal-49 , The Chat UI and Chat API are different surfaces. The Chat API (beta) is an agentic loop over PageIndex's name-based MCP tools — it discovers a document, then reads it. Your Q1 & Q2 (expected? hidden orchestration?): Yes. The hosted UI binds the open document into the agent's scope so discovery can't wander off; the API exposes the raw agent and leaves that to you. Same primitives underneath. Q3 (force document-only answers?): No single "grounded-only" flag, but combine:
Q4 (use retrieval instead for section Q&A?): Yes — for deterministic lookups like "OPERATING TIPS," skip the agent and retrieve directly: import time
if pi_client.is_retrieval_ready(doc_id):
r = pi_client.submit_query(doc_id, "OPERATING TIPS", thinking=True)
res = pi_client.get_retrieval(r["retrieval_id"])
while res.get("status") != "completed": # retrieval is async
time.sleep(1); res = pi_client.get_retrieval(r["retrieval_id"])
for node in res["retrieved_nodes"]:
for c in node["relevant_contents"]: # note: nested array
print(node["title"], c["page_index"], c["relevant_content"])Or just pick the node from Rule of thumb: agentic Chat API for open-ended multi-doc chat; Retrieval API / tree-node selection for precise, must-be-grounded sections. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi PageIndex team,
I’m integrating PageIndex via the Python SDK and I’m seeing a consistent difference between the Chat UI and the Chat API (chat_completions) behavior.
What works in the UI:
Upload a PDF (e.g., an air-conditioner operating manual)
Ask a section-specific question like “Give me OPERATING TIPS from the document”
The UI correctly retrieves and summarizes the exact section
What fails via the API:
The same document is uploaded and fully processed (status=completed)
get_tree() shows nodes with titles, page indexes, and extracted text (e.g., OPERATING TIPS)
Calling chat_completions(messages, doc_id=...) with the same question
The model calls recent_documents, claims the document is missing, and answers generically
From MCP traces, it appears that when retrieval confidence is low, the Chat API silently falls back to a generic assistant and ignores the document — even though the node content exists and is retrievable via get_tree().
Questions:
Is this difference between the Chat UI and Chat API expected behavior?
Does the UI use additional retrieval orchestration (retries, node/page binding, forced grounding) that is not exposed via the API?
Is there a documented or recommended way to force the Chat API to answer only from indexed document content or specific nodes?
If not, should section-level or procedural Q&A be implemented using the retrieval endpoints instead of chat_completions?
I’m trying to understand the intended usage boundaries here
Thanks in advance for clarification.
Beta Was this translation helpful? Give feedback.
All reactions