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
e6de33f8
Unverified
Commit
e6de33f8
authored
Dec 08, 2025
by
Page
Committed by
GitHub
Dec 09, 2025
Browse files
fix: have frontend populate "stop" field in OpenAI request (#4782)
parent
bd4366d0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
1 deletion
+37
-1
lib/llm/src/protocols/openai/completions.rs
lib/llm/src/protocols/openai/completions.rs
+37
-1
No files found.
lib/llm/src/protocols/openai/completions.rs
View file @
e6de33f8
...
@@ -238,7 +238,11 @@ impl OpenAIStopConditionsProvider for NvCreateCompletionRequest {
...
@@ -238,7 +238,11 @@ impl OpenAIStopConditionsProvider for NvCreateCompletionRequest {
}
}
fn
get_stop
(
&
self
)
->
Option
<
Vec
<
String
>>
{
fn
get_stop
(
&
self
)
->
Option
<
Vec
<
String
>>
{
None
use
dynamo_async_openai
::
types
::
Stop
;
self
.inner.stop
.as_ref
()
.map
(|
s
|
match
s
{
Stop
::
String
(
s
)
=>
vec!
[
s
.clone
()],
Stop
::
StringArray
(
arr
)
=>
arr
.clone
(),
})
}
}
fn
nvext
(
&
self
)
->
Option
<&
NvExt
>
{
fn
nvext
(
&
self
)
->
Option
<&
NvExt
>
{
...
@@ -494,4 +498,36 @@ mod tests {
...
@@ -494,4 +498,36 @@ mod tests {
assert_eq!
(
output_options
.skip_special_tokens
,
Some
(
skip_value
));
assert_eq!
(
output_options
.skip_special_tokens
,
Some
(
skip_value
));
}
}
}
}
#[test]
fn
test_stop
()
{
let
null_stop
=
json!
({
"model"
:
"test-model"
,
"prompt"
:
"Hello, world!"
});
let
request
:
NvCreateCompletionRequest
=
serde_json
::
from_value
(
null_stop
)
.expect
(
"Failed to deserialize request"
);
assert_eq!
(
request
.get_stop
(),
None
);
let
one_stop
=
json!
({
"model"
:
"test-model"
,
"prompt"
:
"Hello, world!"
,
"stop"
:
"foo"
});
let
request
:
NvCreateCompletionRequest
=
serde_json
::
from_value
(
one_stop
)
.expect
(
"Failed to deserialize request"
);
assert_eq!
(
request
.get_stop
(),
Some
(
vec!
[
"foo"
.to_string
()]));
let
many_stops
=
json!
({
"model"
:
"test-model"
,
"prompt"
:
"Hello, world!"
,
"stop"
:
[
"foo"
,
"bar"
]
});
let
request
:
NvCreateCompletionRequest
=
serde_json
::
from_value
(
many_stops
)
.expect
(
"Failed to deserialize request"
);
assert_eq!
(
request
.get_stop
(),
Some
(
vec!
[
"foo"
.to_string
(),
"bar"
.to_string
()])
);
}
}
}
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