Skip to content

Commit 0b7fe3f

Browse files
committed
Add prompt_logprobs to ChatCompletion, drop from ChatCompletionChunk
Signed-off-by: declark1 <44146800+declark1@users.noreply.github.com>
1 parent 8e9a0b1 commit 0b7fe3f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/clients/openai.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,8 @@ pub struct ChatCompletion {
519519
pub choices: Vec<ChatCompletionChoice>,
520520
/// Usage statistics for the completion request.
521521
pub usage: Usage,
522+
/// Prompt logprobs.
523+
pub prompt_logprobs: Option<Vec<Option<HashMap<String, Logprob>>>>,
522524
/// This fingerprint represents the backend configuration that the model runs with.
523525
#[serde(skip_serializing_if = "Option::is_none")]
524526
pub system_fingerprint: Option<String>,
@@ -617,8 +619,6 @@ pub struct ChatCompletionChunk {
617619
pub service_tier: Option<String>,
618620
#[serde(skip_serializing_if = "Option::is_none")]
619621
pub usage: Option<Usage>,
620-
/// Prompt logprobs.
621-
pub prompt_logprobs: Option<Vec<Option<HashMap<String, Logprob>>>>, // Option<serde_json::Value>,
622622
/// Detections
623623
#[serde(skip_serializing_if = "Option::is_none")]
624624
pub detections: Option<ChatDetections>,

tests/chat_completions_detection.rs

+4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ async fn no_detections() -> Result<(), anyhow::Error> {
9393
index: 0,
9494
logprobs: None,
9595
finish_reason: "NOT_FINISHED".to_string(),
96+
stop_reason: None,
9697
},
9798
ChatCompletionChoice {
9899
message: ChatCompletionMessage {
@@ -104,6 +105,7 @@ async fn no_detections() -> Result<(), anyhow::Error> {
104105
index: 1,
105106
logprobs: None,
106107
finish_reason: "EOS_TOKEN".to_string(),
108+
stop_reason: None,
107109
},
108110
];
109111
let chat_completions_response = ChatCompletion {
@@ -552,6 +554,7 @@ async fn output_detections() -> Result<(), anyhow::Error> {
552554
index: 0,
553555
logprobs: None,
554556
finish_reason: "NOT_FINISHED".to_string(),
557+
stop_reason: None,
555558
},
556559
ChatCompletionChoice {
557560
message: ChatCompletionMessage {
@@ -563,6 +566,7 @@ async fn output_detections() -> Result<(), anyhow::Error> {
563566
index: 1,
564567
logprobs: None,
565568
finish_reason: "EOS_TOKEN".to_string(),
569+
stop_reason: None,
566570
},
567571
];
568572

0 commit comments

Comments
 (0)