Skip to content

Commit f72ef41

Browse files
committed
Merge remote-tracking branch 'origin/streaming-first-byte' into ai-proxy-updates
2 parents 32a2b13 + 78b4e7d commit f72ef41

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

guardrails/telemetry/guard_tracing.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,11 @@ def trace_guard_execution(
188188
if isinstance(result, Iterator) and not isinstance(
189189
result, ValidationOutcome
190190
):
191-
return trace_stream_guard(guard_span, result, history)
192-
add_guard_attributes(guard_span, history, result)
193-
add_user_attributes(guard_span)
194-
return result
191+
for res in trace_stream_guard(guard_span, result, history):
192+
yield res
193+
else:
194+
add_guard_attributes(guard_span, history, result)
195+
add_user_attributes(guard_span)
195196
except Exception as e:
196197
guard_span.set_status(status=StatusCode.ERROR, description=str(e))
197198
raise e

guardrails/telemetry/runner_tracing.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ def trace_call_wrapper(*args, **kwargs):
265265
) as call_span:
266266
try:
267267
response = fn(*args, **kwargs)
268+
if isinstance(response, LLMResponse) and (
269+
response.async_stream_output or response.stream_output
270+
):
271+
# TODO: Iterate, add a call attr each time
272+
return response
268273
add_call_attributes(call_span, response, *args, **kwargs)
269274
return response
270275
except Exception as e:

0 commit comments

Comments
 (0)