From 9c6c9f10a27d0993636b453f39d8934c95c5c2b2 Mon Sep 17 00:00:00 2001 From: sigoden Date: Tue, 23 Apr 2024 18:14:47 +0800 Subject: feat: builtin models can be overwrited by models config (#429) --- src/client/vertexai.rs | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'src/client/vertexai.rs') diff --git a/src/client/vertexai.rs b/src/client/vertexai.rs index eceeb2c..66bb098 100644 --- a/src/client/vertexai.rs +++ b/src/client/vertexai.rs @@ -1,6 +1,6 @@ use super::{ - json_stream, message::*, patch_system_message, Client, ExtraConfig, Model, PromptType, - ReplyHandler, SendData, VertexAIClient, + json_stream, message::*, patch_system_message, Client, ExtraConfig, Model, ModelConfig, + PromptType, ReplyHandler, SendData, VertexAIClient, }; use crate::utils::PromptKind; @@ -28,6 +28,8 @@ pub struct VertexAIConfig { pub api_base: Option, pub adc_file: Option, pub block_threshold: Option, + #[serde(default)] + pub models: Vec, pub extra: Option, } @@ -54,23 +56,12 @@ impl Client for VertexAIClient { } impl VertexAIClient { + list_models_fn!(VertexAIConfig, &MODELS); config_get_fn!(api_base, get_api_base); pub const PROMPTS: [PromptType<'static>; 1] = [("api_base", "API Base:", true, PromptKind::String)]; - pub fn list_models(local_config: &VertexAIConfig) -> Vec { - let client_name = Self::name(local_config); - MODELS - .into_iter() - .map(|(name, max_input_tokens, capabilities)| { - Model::new(client_name, name) - .set_capabilities(capabilities.into()) - .set_max_input_tokens(Some(max_input_tokens)) - }) - .collect() - } - fn request_builder(&self, client: &ReqwestClient, data: SendData) -> Result { let api_base = self.get_api_base()?; -- cgit v1.2.3