Skip to content

Commit 1e110af

Browse files
committed
env var controlled
1 parent 1906b70 commit 1e110af

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/llm/src/http/service/openai.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,10 @@ fn process_event_converter<T: Serialize>(
506506
response_collector.observe_current_osl(metrics.output_tokens);
507507
response_collector.observe_response(metrics.input_tokens, metrics.chunk_tokens);
508508

509-
// Chomp the LLMMetricAnnotation so it's not returned in the response stream
510-
// TODO: add a flag to control what is returned in the SSE stream
511-
if annotated.event.as_deref() == Some(crate::preprocessor::ANNOTATION_LLM_METRICS) {
509+
// Only filter out metrics if DYN_RICH_EVENT_STREAM is not set
510+
if std::env::var("DYN_RICH_EVENT_STREAM").is_err()
511+
&& annotated.event.as_deref() == Some(crate::preprocessor::ANNOTATION_LLM_METRICS)
512+
{
512513
annotated.event = None;
513514
annotated.comment = None;
514515
}

0 commit comments

Comments
 (0)