mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-24 21:41:04 +02:00
fix: drop unrecognized stream_metadata, align sort and page_count
- Remove stream_metadata from chat/completions payloads — the server's ChatCompletionRequest model has no such field; it was silently ignored. - Local list_documents tie-breaker: rowid DESC → doc_id ASC, matching the server's "createdAt" DESC, "id" ASC ordering. - Cloud get_document: skip page_count when pageNum is 0 (server returns 0 for NULL, meaning "not yet computed", not "zero pages").
This commit is contained in:
parent
e94f6d45c8
commit
11ba63debe
3 changed files with 2 additions and 10 deletions
|
|
@ -307,7 +307,7 @@ class CloudBackend:
|
|||
"status": resp.get("status", ""),
|
||||
"structure": self._normalize_tree(raw_tree, max_page=page_num),
|
||||
}
|
||||
if page_num is not None:
|
||||
if page_num:
|
||||
result["page_count"] = page_num
|
||||
return result
|
||||
|
||||
|
|
@ -508,7 +508,6 @@ class CloudBackend:
|
|||
"messages": [{"role": "user", "content": question}],
|
||||
"doc_id": doc_id,
|
||||
"stream": True,
|
||||
"stream_metadata": True,
|
||||
},
|
||||
stream=True,
|
||||
timeout=120,
|
||||
|
|
|
|||
|
|
@ -169,13 +169,6 @@ class LegacyCloudAPI:
|
|||
payload["temperature"] = temperature
|
||||
if enable_citations:
|
||||
payload["enable_citations"] = enable_citations
|
||||
# Forward stream_metadata so the wire request matches the caller's intent
|
||||
# (and stays correct if the server ever gates metadata chunks behind it),
|
||||
# mirroring the modern CloudBackend which always sends it. It only affects
|
||||
# streaming responses, where it selects the raw dict-chunk parser below.
|
||||
if stream_metadata:
|
||||
payload["stream_metadata"] = stream_metadata
|
||||
|
||||
# Non-streaming completions return no bytes until server-side
|
||||
# generation finishes — far longer than the default 30s read timeout.
|
||||
response = self._request(
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ class SQLiteStorage:
|
|||
def list_documents(self, collection: str) -> list[dict]:
|
||||
conn = self._get_conn()
|
||||
rows = conn.execute(
|
||||
"SELECT doc_id, doc_name, doc_description, doc_type FROM documents WHERE collection_name = ? ORDER BY created_at DESC, rowid DESC",
|
||||
"SELECT doc_id, doc_name, doc_description, doc_type FROM documents WHERE collection_name = ? ORDER BY created_at DESC, doc_id ASC",
|
||||
(collection,),
|
||||
).fetchall()
|
||||
return [{"doc_id": r[0], "doc_name": r[1], "doc_description": r[2] or "", "doc_type": r[3]} for r in rows]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue