Skip to content

Commit 1ad9b94

Browse files
authored
Add completions streaming support (foundation-model-stack#457)
Signed-off-by: Mateus Devino <[email protected]>
1 parent 0fc040e commit 1ad9b94

File tree

3 files changed

+565
-34
lines changed

3 files changed

+565
-34
lines changed

src/clients/openai.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@ impl CompletionsRequest {
363363
if self.model.is_empty() {
364364
return Err(ValidationError::Invalid("`model` must not be empty".into()));
365365
}
366-
if self.prompt.is_empty() {
366+
if !self.detectors.input.is_empty() && self.prompt.is_empty() {
367367
return Err(ValidationError::Invalid(
368-
"`prompt` must not be empty".into(),
368+
"`prompt` must not be empty when input detectors are provided".into(),
369369
));
370370
}
371371
Ok(())
@@ -887,7 +887,7 @@ pub struct CompletionChoice {
887887
}
888888

889889
/// Completion logprobs.
890-
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
890+
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Default)]
891891
pub struct CompletionLogprobs {
892892
/// Tokens generated by the model.
893893
pub tokens: Vec<String>,

0 commit comments

Comments
 (0)