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
053041e6
"vscode:/vscode.git/clone" did not exist on "c12c25787fcda62d012af61e9dcb202578a7f84f"
Unverified
Commit
053041e6
authored
Jul 15, 2025
by
Jorge António
Committed by
GitHub
Jul 14, 2025
Browse files
fix: resolve incorrect finish reason propagation (#1857)
parent
3733f585
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
lib/llm/src/backend.rs
lib/llm/src/backend.rs
+12
-2
No files found.
lib/llm/src/backend.rs
View file @
053041e6
...
...
@@ -164,7 +164,9 @@ impl
let
result
=
state
.decoder
.process_token_ids
(
&
data
.token_ids
)
.unwrap
();
// todo - propagate finish reason details - possibly an annotation
// NOTE: the `finish_reason` is computed from the generated `token_ids` alone.
// The `data` field can have a `finish_reason` set, coming from the underlying
// LLM inference `Engine`, and empty `token_ids`. See comment below for more details.
let
finish_reason
=
match
&
result
.stop_trigger
{
Some
(
StopTrigger
::
MaxTokensLimit
)
=>
Some
(
FinishReason
::
Length
),
Some
(
StopTrigger
::
HiddenStopTokenDetected
(
_
))
=>
Some
(
FinishReason
::
Stop
),
...
...
@@ -203,7 +205,15 @@ impl
let
mut
output
=
output
;
let
mut
data
=
output
.data
.take
()
.unwrap
();
// NOTE: If `finish_reason.is_some()`, then one of the stop conditions was triggered
// by the token generation. We should update the `data.finish_reason` in that case.
// However, if `finish_reason.is_none()`, it is possible that we are in the case where
// `data.token_ids` is empty, and `data.finish_reason` is already correctly set.
// In that case, `process_token_ids` above will rewrite `finish_reason` to `None`,
// which we don't want to propagate to `data.finish_reason`.
if
finish_reason
.is_some
()
{
data
.finish_reason
=
finish_reason
;
}
data
.text
=
text
;
data
.tokens
=
Some
(
tokens
);
...
...
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