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
0edc886f
Unverified
Commit
0edc886f
authored
Jun 24, 2025
by
Paul Hendricks
Committed by
GitHub
Jun 24, 2025
Browse files
refactor: using async_openai::types::Logprobs (#1625)
parent
0b7cdf55
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
15 deletions
+3
-15
lib/llm/src/protocols/openai/completions.rs
lib/llm/src/protocols/openai/completions.rs
+1
-13
lib/llm/src/protocols/openai/completions/aggregator.rs
lib/llm/src/protocols/openai/completions/aggregator.rs
+2
-2
No files found.
lib/llm/src/protocols/openai/completions.rs
View file @
0edc886f
...
@@ -13,8 +13,6 @@
...
@@ -13,8 +13,6 @@
// See the License for the specific language governing permissions and
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
use
std
::
collections
::
HashMap
;
use
derive_builder
::
Builder
;
use
derive_builder
::
Builder
;
use
dynamo_runtime
::
protocols
::
annotated
::
AnnotationsProvider
;
use
dynamo_runtime
::
protocols
::
annotated
::
AnnotationsProvider
;
use
serde
::{
Deserialize
,
Serialize
};
use
serde
::{
Deserialize
,
Serialize
};
...
@@ -92,7 +90,7 @@ pub struct CompletionChoice {
...
@@ -92,7 +90,7 @@ pub struct CompletionChoice {
#[serde(skip_serializing_if
=
"Option::is_none"
)]
#[serde(skip_serializing_if
=
"Option::is_none"
)]
#[builder(default,
setter(strip_option))]
#[builder(default,
setter(strip_option))]
pub
logprobs
:
Option
<
Logprob
Result
>
,
pub
logprobs
:
Option
<
async_openai
::
types
::
Logprob
s
>
,
}
}
impl
ContentProvider
for
CompletionChoice
{
impl
ContentProvider
for
CompletionChoice
{
...
@@ -107,16 +105,6 @@ impl CompletionChoice {
...
@@ -107,16 +105,6 @@ impl CompletionChoice {
}
}
}
}
// TODO: validate this is the correct format
/// Legacy OpenAI LogprobResult component
#[derive(Clone,
Debug,
Deserialize,
Serialize)]
pub
struct
LogprobResult
{
pub
tokens
:
Vec
<
String
>
,
pub
token_logprobs
:
Vec
<
f32
>
,
pub
top_logprobs
:
Vec
<
HashMap
<
String
,
f32
>>
,
pub
text_offset
:
Vec
<
i32
>
,
}
pub
fn
prompt_to_string
(
prompt
:
&
async_openai
::
types
::
Prompt
)
->
String
{
pub
fn
prompt_to_string
(
prompt
:
&
async_openai
::
types
::
Prompt
)
->
String
{
match
prompt
{
match
prompt
{
async_openai
::
types
::
Prompt
::
String
(
s
)
=>
s
.clone
(),
async_openai
::
types
::
Prompt
::
String
(
s
)
=>
s
.clone
(),
...
...
lib/llm/src/protocols/openai/completions/aggregator.rs
View file @
0edc886f
...
@@ -18,7 +18,7 @@ use std::{collections::HashMap, str::FromStr};
...
@@ -18,7 +18,7 @@ use std::{collections::HashMap, str::FromStr};
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
futures
::
StreamExt
;
use
futures
::
StreamExt
;
use
super
::{
CompletionChoice
,
CompletionResponse
,
LogprobResult
};
use
super
::{
CompletionChoice
,
CompletionResponse
};
use
crate
::
protocols
::{
use
crate
::
protocols
::{
codec
::{
Message
,
SseCodecError
},
codec
::{
Message
,
SseCodecError
},
common
::
FinishReason
,
common
::
FinishReason
,
...
@@ -40,7 +40,7 @@ struct DeltaChoice {
...
@@ -40,7 +40,7 @@ struct DeltaChoice {
index
:
u64
,
index
:
u64
,
text
:
String
,
text
:
String
,
finish_reason
:
Option
<
FinishReason
>
,
finish_reason
:
Option
<
FinishReason
>
,
logprobs
:
Option
<
Logprob
Result
>
,
logprobs
:
Option
<
async_openai
::
types
::
Logprob
s
>
,
}
}
impl
Default
for
DeltaAggregator
{
impl
Default
for
DeltaAggregator
{
...
...
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