Parameters are optional

This commit is contained in:
Nicolas Patry 2024-09-24 11:37:58 +02:00
parent 507ecae147
commit be00fb7fc0
No known key found for this signature in database
GPG Key ID: 64AF4752B2967863

View File

@ -26,11 +26,12 @@ pub(crate) struct GenerateVertexInstance {
pub(crate) struct VertexChat { pub(crate) struct VertexChat {
messages: Vec<Message>, messages: Vec<Message>,
// Messages is ignored there. // Messages is ignored there.
#[serde(default)]
parameters: VertexParameters, parameters: VertexParameters,
} }
#[derive(Clone, Deserialize, ToSchema, Serialize)] #[derive(Clone, Deserialize, ToSchema, Serialize, Default)]
#[cfg_attr(test, derive(Debug, PartialEq, Default))] #[cfg_attr(test, derive(Debug, PartialEq))]
pub(crate) struct VertexParameters { pub(crate) struct VertexParameters {
#[schema(example = "mistralai/Mistral-7B-Instruct-v0.2")] #[schema(example = "mistralai/Mistral-7B-Instruct-v0.2")]
/// [UNUSED] 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.
@ -316,6 +317,12 @@ mod tests {
let _request: VertexChat = serde_json::from_value(string).expect("Can deserialize"); let _request: VertexChat = serde_json::from_value(string).expect("Can deserialize");
let string = serde_json::json!({
"messages": [{"role": "user", "content": "What's Deep Learning?"}],
});
let _request: VertexChat = serde_json::from_value(string).expect("Can deserialize");
let string = serde_json::json!({ let string = serde_json::json!({
"instances": [ "instances": [