mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-07-15 21:11:05 +02:00
fix: forward stream_metadata to the chat API in legacy client
chat_completions(stream=True, stream_metadata=True) used stream_metadata only to pick the raw dict-chunk parser locally, never adding it to the request payload. The wire request didn't match the caller's intent and relied on the server sending metadata chunks unconditionally. Forward the flag (mirroring the modern CloudBackend, which always sends it) so the request is correct and robust if the server ever gates metadata behind it. Verified against the real API that the server currently emits block_metadata regardless, so this is a latent-correctness fix, not a behavior change today.
This commit is contained in:
parent
4456b92968
commit
4c7d1088ba
2 changed files with 10 additions and 1 deletions
|
|
@ -147,6 +147,12 @@ 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
|
||||
|
||||
response = self._request(
|
||||
"POST",
|
||||
|
|
|
|||
|
|
@ -238,7 +238,10 @@ def test_chat_completions_stream_metadata_returns_raw_chunks(monkeypatch):
|
|||
))
|
||||
|
||||
assert chunks == [{"object": "chat.completion.chunk"}]
|
||||
assert "stream_metadata" not in calls[0]["json"]
|
||||
# stream_metadata must be forwarded to the server so the wire request matches
|
||||
# the caller's intent (and mirrors the modern CloudBackend), not kept as a
|
||||
# client-only parser switch.
|
||||
assert calls[0]["json"]["stream_metadata"] is True
|
||||
|
||||
|
||||
def test_chat_completions_stream_errors_are_pageindex_api_error(monkeypatch):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue