Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
text-generation-inference
Commits
f8a5b381
Unverified
Commit
f8a5b381
authored
Aug 06, 2024
by
drbh
Committed by
GitHub
Aug 06, 2024
Browse files
feat: prefer stop over eos_token to align with openai finish_reason (#2344)
parent
e11f5f1c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
router/src/lib.rs
router/src/lib.rs
+10
-1
router/src/server.rs
router/src/server.rs
+2
-2
No files found.
router/src/lib.rs
View file @
f8a5b381
...
...
@@ -619,7 +619,7 @@ impl ChatCompletion {
message
,
logprobs
:
return_logprobs
.then
(||
ChatCompletionLogprobs
::
from
((
details
.tokens
,
details
.top_tokens
))),
finish_reason
:
details
.finish_reason
.
to_string
(
),
finish_reason
:
details
.finish_reason
.
format
(
true
),
}],
usage
:
Usage
{
prompt_tokens
:
details
.prefill
.len
()
as
u32
,
...
...
@@ -1117,6 +1117,15 @@ impl std::fmt::Display for FinishReason {
}
}
impl
FinishReason
{
pub
fn
format
(
&
self
,
use_stop
:
bool
)
->
String
{
match
self
{
FinishReason
::
EndOfSequenceToken
if
use_stop
=>
"stop"
.to_string
(),
_
=>
self
.to_string
(),
}
}
}
#[derive(Serialize,
ToSchema)]
pub
(
crate
)
struct
BestOfSequence
{
#[schema(example
=
"test"
)]
...
...
router/src/server.rs
View file @
f8a5b381
...
...
@@ -1021,7 +1021,7 @@ async fn completions(
total_tokens
+=
details
.prefill
.len
()
as
u32
+
details
.generated_tokens
;
Ok
(
CompletionComplete
{
finish_reason
:
details
.finish_reason
.
to_string
(
),
finish_reason
:
details
.finish_reason
.
format
(
true
),
index
:
index
as
u32
,
logprobs
:
None
,
text
:
generation
.generated_text
,
...
...
@@ -1212,7 +1212,7 @@ async fn chat_completions(
tool_calls
,
current_time
,
logprobs
,
stream_token
.details
.map
(|
d
|
d
.finish_reason
.
to_string
(
)),
stream_token
.details
.map
(|
d
|
d
.finish_reason
.
format
(
true
)),
),
))
.unwrap_or_else
(|
e
|
{
...
...
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