Skip to content

Commit 96082d3

Browse files
toslali-ibmmarkurtz
authored andcommitted
Add response id to streaming
Signed-off-by: Mert Toslali <[email protected]>
1 parent 33e027a commit 96082d3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/guidellm/backends/response_handlers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def __init__(self):
124124
"""
125125
self.streaming_texts: list[str] = []
126126
self.streaming_usage: dict[str, int | dict[str, int]] | None = None
127+
self.streaming_response_id: str | None = None
127128

128129
def compile_non_streaming(
129130
self, request: GenerationRequest, response: dict
@@ -163,6 +164,9 @@ def add_streaming_line(self, line: str) -> int | None:
163164
"""
164165
if not (data := self.extract_line_data(line)):
165166
return None if data is None else 0
167+
168+
if "id" in data and self.streaming_response_id is None:
169+
self.streaming_response_id = data["id"]
166170

167171
updated = False
168172
choices, usage = self.extract_choices_and_usage(data)
@@ -192,6 +196,7 @@ def compile_streaming(self, request: GenerationRequest) -> GenerationResponse:
192196
request_args=str(
193197
request.arguments.model_dump() if request.arguments else None
194198
),
199+
response_id=self.streaming_response_id, # use vLLM ID if available
195200
text=text,
196201
input_metrics=input_metrics,
197202
output_metrics=output_metrics,

0 commit comments

Comments
 (0)