fix: avoid default message

This commit is contained in:
drbh 2024-02-20 15:22:19 +00:00
parent df23062574
commit e0c9441a86
2 changed files with 5 additions and 12 deletions

View File

@ -469,23 +469,14 @@ impl ChatCompletionChunk {
} }
} }
fn default_request_messages() -> Vec<Message> {
vec![Message {
role: "user".to_string(),
content: "My name is David and I".to_string(),
name: None,
}]
}
#[derive(Clone, Deserialize, ToSchema, Serialize)] #[derive(Clone, Deserialize, ToSchema, Serialize)]
pub(crate) struct ChatRequest { pub(crate) struct ChatRequest {
/// UNUSED
#[schema(example = "mistralai/Mistral-7B-Instruct-v0.2")] #[schema(example = "mistralai/Mistral-7B-Instruct-v0.2")]
/// ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API. /// [UNUSED] ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API.
pub model: String, pub model: String,
/* NOTE: UNUSED */
/// A list of messages comprising the conversation so far. /// A list of messages comprising the conversation so far.
#[serde(default = "default_request_messages")] #[schema(example = "[{\"role\": \"user\", \"content\": \"What is Deep Learning?\"}]")]
pub messages: Vec<Message>, pub messages: Vec<Message>,
/// Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, /// Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far,
@ -568,6 +559,7 @@ pub(crate) struct Message {
pub role: String, pub role: String,
#[schema(example = "My name is David and I")] #[schema(example = "My name is David and I")]
pub content: String, pub content: String,
#[serde(default)]
#[schema(example = "\"David\"")] #[schema(example = "\"David\"")]
pub name: Option<String>, pub name: Option<String>,
} }

View File

@ -594,6 +594,7 @@ async fn chat_completions(
)); ));
} }
}; };
tracing::debug!("Templated input: {}", inputs);
// build the request passing some parameters // build the request passing some parameters
let generate_request = GenerateRequest { let generate_request = GenerateRequest {