Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ def _build_from_streaming_response(
# this function would not be able to catch the errors, as they are
# raised later, after the generator is returned, and when it is being
# consumed.
span.add_event("llm.content.completion.chunk")
chunk_result = process_stream_chunk(
chunk,
role,
Expand Down Expand Up @@ -435,6 +436,7 @@ async def _abuild_from_streaming_response(
# this function would not be able to catch the errors, as they are
# raised later, after the generator is returned, and when it is being
# consumed.
span.add_event("llm.content.completion.chunk")
chunk_result = process_stream_chunk(
chunk,
role,
Expand Down
4 changes: 4 additions & 0 deletions tests/test_google_genai.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,10 @@ def test_google_genai_streaming(span_exporter: InMemorySpanExporter):
],
)
final_response = ""
chunk_count = 0
for chunk in stream:
final_response += chunk.text or ""
chunk_count += 1

spans = span_exporter.get_finished_spans()
assert len(spans) == 1
Expand Down Expand Up @@ -885,6 +887,8 @@ def test_google_genai_streaming(span_exporter: InMemorySpanExporter):
assert span.attributes["gen_ai.usage.input_tokens"] == 7
assert span.attributes["gen_ai.usage.output_tokens"] == 166
assert span.attributes["llm.usage.total_tokens"] == 175 # 173 + 2 (thinking tokens)
assert len(span.events) == chunk_count
assert all(event.name == "llm.content.completion.chunk" for event in span.events)


@pytest.mark.vcr
Expand Down