Skip to content

Commit db47bc5

Browse files
committed
refactor: using async_openai::types::Logprobs
1 parent 0c9ae4d commit db47bc5

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

lib/llm/src/protocols/openai/completions.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
// See the License for the specific language governing permissions and
1414
// limitations under the License.
1515

16-
use std::collections::HashMap;
17-
1816
use derive_builder::Builder;
1917
use dynamo_runtime::protocols::annotated::AnnotationsProvider;
2018
use serde::{Deserialize, Serialize};
@@ -92,7 +90,7 @@ pub struct CompletionChoice {
9290

9391
#[serde(skip_serializing_if = "Option::is_none")]
9492
#[builder(default, setter(strip_option))]
95-
pub logprobs: Option<LogprobResult>,
93+
pub logprobs: Option<async_openai::types::Logprobs>,
9694
}
9795

9896
impl ContentProvider for CompletionChoice {
@@ -107,16 +105,6 @@ impl CompletionChoice {
107105
}
108106
}
109107

110-
// TODO: validate this is the correct format
111-
/// Legacy OpenAI LogprobResult component
112-
#[derive(Clone, Debug, Deserialize, Serialize)]
113-
pub struct LogprobResult {
114-
pub tokens: Vec<String>,
115-
pub token_logprobs: Vec<f32>,
116-
pub top_logprobs: Vec<HashMap<String, f32>>,
117-
pub text_offset: Vec<i32>,
118-
}
119-
120108
pub fn prompt_to_string(prompt: &async_openai::types::Prompt) -> String {
121109
match prompt {
122110
async_openai::types::Prompt::String(s) => s.clone(),

lib/llm/src/protocols/openai/completions/aggregator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::{collections::HashMap, str::FromStr};
1818
use anyhow::Result;
1919
use futures::StreamExt;
2020

21-
use super::{CompletionChoice, CompletionResponse, LogprobResult};
21+
use super::{CompletionChoice, CompletionResponse};
2222
use crate::protocols::{
2323
codec::{Message, SseCodecError},
2424
common::FinishReason,
@@ -40,7 +40,7 @@ struct DeltaChoice {
4040
index: u64,
4141
text: String,
4242
finish_reason: Option<FinishReason>,
43-
logprobs: Option<LogprobResult>,
43+
logprobs: Option<async_openai::types::Logprobs>,
4444
}
4545

4646
impl Default for DeltaAggregator {

0 commit comments

Comments
 (0)