From 81624f7267ba20799a3bbf779abfe41df30d349c Mon Sep 17 00:00:00 2001 From: sigoden Date: Tue, 7 Nov 2023 09:55:06 +0800 Subject: refactor: rename Model.llm_name to name (#216) --- src/client/azure_openai.rs | 4 ++-- src/client/ernie.rs | 4 ++-- src/client/localai.rs | 2 +- src/client/model.rs | 6 +++--- src/client/openai.rs | 2 +- src/client/palm.rs | 4 ++-- src/client/qianwen.rs | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src/client') diff --git a/src/client/azure_openai.rs b/src/client/azure_openai.rs index 815413e..8fa3e10 100644 --- a/src/client/azure_openai.rs +++ b/src/client/azure_openai.rs @@ -59,11 +59,11 @@ impl AzureOpenAIClient { let api_base = self.get_api_base()?; let api_key = self.get_api_key()?; - let body = openai_build_body(data, self.model.llm_name.clone()); + let body = openai_build_body(data, self.model.name.clone()); let url = format!( "{}/openai/deployments/{}/chat/completions?api-version=2023-05-15", - &api_base, self.model.llm_name + &api_base, self.model.name ); let builder = client.post(url).header("api-key", api_key).json(&body); diff --git a/src/client/ernie.rs b/src/client/ernie.rs index 0046658..c871450 100644 --- a/src/client/ernie.rs +++ b/src/client/ernie.rs @@ -73,9 +73,9 @@ impl ErnieClient { } fn request_builder(&self, client: &ReqwestClient, data: SendData) -> Result { - let body = build_body(data, self.model.llm_name.clone()); + let body = build_body(data, self.model.name.clone()); - let model = self.model.llm_name.clone(); + let model = self.model.name.clone(); let (_, chat_endpoint) = MODELS .iter() .find(|(v, _)| v == &model) diff --git a/src/client/localai.rs b/src/client/localai.rs index eb4de65..ecb0e63 100644 --- a/src/client/localai.rs +++ b/src/client/localai.rs @@ -58,7 +58,7 @@ impl LocalAIClient { fn request_builder(&self, client: &ReqwestClient, data: SendData) -> Result { let api_key = self.get_api_key().ok(); - let body = openai_build_body(data, self.model.llm_name.clone()); + let body = openai_build_body(data, self.model.name.clone()); let chat_endpoint = self .config diff --git a/src/client/model.rs b/src/client/model.rs index d00ad46..dc30dcf 100644 --- a/src/client/model.rs +++ b/src/client/model.rs @@ -10,7 +10,7 @@ pub type TokensCountFactors = (usize, usize); // (per-messages, bias) pub struct Model { pub client_index: usize, pub client_name: String, - pub llm_name: String, + pub name: String, pub max_tokens: Option, pub tokens_count_factors: TokensCountFactors, } @@ -26,14 +26,14 @@ impl Model { Self { client_index, client_name: client_name.into(), - llm_name: name.into(), + name: name.into(), max_tokens: None, tokens_count_factors: Default::default(), } } pub fn id(&self) -> String { - format!("{}:{}", self.client_name, self.llm_name) + format!("{}:{}", self.client_name, self.name) } pub fn set_max_tokens(mut self, max_tokens: Option) -> Self { diff --git a/src/client/openai.rs b/src/client/openai.rs index f1243f0..7c10a4d 100644 --- a/src/client/openai.rs +++ b/src/client/openai.rs @@ -59,7 +59,7 @@ impl OpenAIClient { fn request_builder(&self, client: &ReqwestClient, data: SendData) -> Result { let api_key = self.get_api_key()?; - let body = openai_build_body(data, self.model.llm_name.clone()); + let body = openai_build_body(data, self.model.name.clone()); let env_prefix = Self::name(&self.config).to_uppercase(); let api_base = env::var(format!("{env_prefix}_API_BASE")) diff --git a/src/client/palm.rs b/src/client/palm.rs index c59b269..3720796 100644 --- a/src/client/palm.rs +++ b/src/client/palm.rs @@ -64,9 +64,9 @@ impl PaLMClient { fn request_builder(&self, client: &ReqwestClient, data: SendData) -> Result { let api_key = self.get_api_key()?; - let body = build_body(data, self.model.llm_name.clone()); + let body = build_body(data, self.model.name.clone()); - let model = self.model.llm_name.clone(); + let model = self.model.name.clone(); let (_, _, endpoint) = MODELS .iter() .find(|(v, _, _)| v == &model) diff --git a/src/client/qianwen.rs b/src/client/qianwen.rs index d5145c2..162fcc2 100644 --- a/src/client/qianwen.rs +++ b/src/client/qianwen.rs @@ -66,7 +66,7 @@ impl QianwenClient { let api_key = self.get_api_key()?; let stream = data.stream; - let body = build_body(data, self.model.llm_name.clone()); + let body = build_body(data, self.model.name.clone()); let mut builder = client.post(API_URL).bearer_auth(api_key).json(&body); if stream { -- cgit v1.2.3