Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/guidellm/backends/response_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def add_streaming_line(self, line: str) -> int | None:
updated = False
choices, usage = self.extract_choices_and_usage(data)

if text := choices[0].get("text"):
if text := choices[0].get("text") if choices else None:
self.streaming_texts.append(text)
updated = True

Expand Down Expand Up @@ -180,7 +180,7 @@ def extract_line_data(self, line: str) -> dict[str, Any] | None:

line = line[len("data:") :].strip()

return json.loads(line)
return json.loads(line) if line else {}

def extract_choices_and_usage(
self, response: dict
Expand Down Expand Up @@ -393,7 +393,7 @@ def add_streaming_line(self, line: str) -> int | None:
if not line or not (line := line.strip()) or not line.startswith("{"):
return 0

data: dict[str, Any] = json.loads(line)
data: dict[str, Any] = json.loads(line) if line else {}
text: str
usage: dict[str, int | dict[str, int]]
updated = False
Expand Down
Loading
Loading