From be00fb7fc06bc27abf7b6d68c9be1cf04f1966a2 Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Tue, 24 Sep 2024 11:37:58 +0200 Subject: [PATCH] Parameters are optional --- router/src/vertex.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/router/src/vertex.rs b/router/src/vertex.rs index a8f7804e..5741658b 100644 --- a/router/src/vertex.rs +++ b/router/src/vertex.rs @@ -26,11 +26,12 @@ pub(crate) struct GenerateVertexInstance { pub(crate) struct VertexChat { messages: Vec, // Messages is ignored there. + #[serde(default)] parameters: VertexParameters, } -#[derive(Clone, Deserialize, ToSchema, Serialize)] -#[cfg_attr(test, derive(Debug, PartialEq, Default))] +#[derive(Clone, Deserialize, ToSchema, Serialize, Default)] +#[cfg_attr(test, derive(Debug, PartialEq))] pub(crate) struct VertexParameters { #[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. @@ -316,6 +317,12 @@ mod tests { 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!({ "instances": [