Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
b051a213
Unverified
Commit
b051a213
authored
Jun 13, 2025
by
Hongkuan Zhou
Committed by
GitHub
Jun 13, 2025
Browse files
fix: remove LLMMetricAnnotation from response stream (#1499)
Signed-off-by:
Hongkuan Zhou
<
tedzhouhk@gmail.com
>
parent
fcfc21f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
lib/llm/src/http/service/openai.rs
lib/llm/src/http/service/openai.rs
+8
-1
No files found.
lib/llm/src/http/service/openai.rs
View file @
b051a213
...
@@ -499,12 +499,19 @@ fn process_event_converter<T: Serialize>(
...
@@ -499,12 +499,19 @@ fn process_event_converter<T: Serialize>(
annotated
:
EventConverter
<
T
>
,
annotated
:
EventConverter
<
T
>
,
response_collector
:
&
mut
ResponseMetricCollector
,
response_collector
:
&
mut
ResponseMetricCollector
,
)
->
Result
<
Event
,
axum
::
Error
>
{
)
->
Result
<
Event
,
axum
::
Error
>
{
let
annotated
=
annotated
.0
;
let
mut
annotated
=
annotated
.0
;
// update metrics
// update metrics
if
let
Ok
(
Some
(
metrics
))
=
LLMMetricAnnotation
::
from_annotation
(
&
annotated
)
{
if
let
Ok
(
Some
(
metrics
))
=
LLMMetricAnnotation
::
from_annotation
(
&
annotated
)
{
response_collector
.observe_current_osl
(
metrics
.output_tokens
);
response_collector
.observe_current_osl
(
metrics
.output_tokens
);
response_collector
.observe_response
(
metrics
.input_tokens
,
metrics
.chunk_tokens
);
response_collector
.observe_response
(
metrics
.input_tokens
,
metrics
.chunk_tokens
);
// Chomp the LLMMetricAnnotation so it's not returned in the response stream
// TODO: add a flag to control what is returned in the SSE stream
if
annotated
.event
.as_deref
()
==
Some
(
crate
::
preprocessor
::
ANNOTATION_LLM_METRICS
)
{
annotated
.event
=
None
;
annotated
.comment
=
None
;
}
}
}
let
mut
event
=
Event
::
default
();
let
mut
event
=
Event
::
default
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment