Repository navigation
serving-endpoints: make query --stream work - #7660
Open
anshul0713 wants to merge 3 commits into
Open
anshul0713 wants to merge 3 commits into
anshul0713 wants to merge 3 commits into
Conversation
The generated query command decodes the response as one JSON object, so a streamed (server-sent events) response always failed with "failed to unmarshal response body". When --stream or "stream": true is set, read the event stream and print each chunk's JSON on its own line. Non-streaming queries still run the generated code. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Anshul Gupta <anshul.gupta@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Anshul Gupta <anshul.gupta@databricks.com>
Contributor
|
Commit: Regression test reportSelected 1 changed tests (limit=20, 0 not selected) 1 tests: regression=1 unreleased=0 coverage=0 failing=0
TestAccept/cmd/workspace/serving-endpoints/query-stream: branch ✅ | main (620ea05) ❌ | latest (v1.26.0) ❌main (620ea05): latest (v1.26.0): same output as main (620ea05) |
Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Anshul Gupta <anshul.gupta@databricks.com>
Collaborator
✅ Integration test reportCommit: 1fd8e82
Top 3 slowest tests (at least 2 minutes):
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
databricks serving-endpoints query --stream, or"stream": truein--json, now prints the streamed response as it arrives, one JSON chunk per line, without the server-sent events framing (data:prefixes, blank lines, the[DONE]sentinel). For a chat endpoint, the reply text is thenjq -rj '.choices[0].delta.content'away.Non-streaming queries are unchanged: they still run the generated code.
Why
The generated command decodes the whole response as a single JSON object. A streamed response is an event stream, so
--streamalways failed:The
--streamflag exists and is documented in--help, but there was no way to use it. In agent trials of shell-only LLM usage, agents tried it, hit this error, and fell back tocurlwith a hand-fetched token.Backward compatibility
stream: true). Only the response handling is new, and that path previously always errored.stream) are printed as is.Tests
[DONE], comments and other fields, plain JSON bodies, 1 MiB lines) and for detecting stream mode from the flag or from--json.acceptance/cmd/workspace/serving-endpoints/query-stream. It stubs the invocations route, which the test server doesn't model.databricks-gpt-5-4pay-per-token endpoint on a staging workspace: chunks arrive one per line and end at[DONE]../task lintpasses.This pull request and its description were written by Isaac.