summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-11-07 09:55:06 +0800
committerGitHub <noreply@github.com>2023-11-07 09:55:06 +0800
commit81624f7267ba20799a3bbf779abfe41df30d349c (patch)
tree5484737923446cf8bffc2d6e9d0b80062ce421c9 /src
parent399ed3337f1c4edaab39a534b63cc9d00c09dd07 (diff)
downloadaichat-81624f7267ba20799a3bbf779abfe41df30d349c.tar.gz
refactor: rename Model.llm_name to name (#216)
Diffstat (limited to 'src')
-rw-r--r--src/client/azure_openai.rs4
-rw-r--r--src/client/ernie.rs4
-rw-r--r--src/client/localai.rs2
-rw-r--r--src/client/model.rs6
-rw-r--r--src/client/openai.rs2
-rw-r--r--src/client/palm.rs4
-rw-r--r--src/client/qianwen.rs2
7 files changed, 12 insertions, 12 deletions
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<RequestBuilder> {
- 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<RequestBuilder> {
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<usize>,
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<usize>) -> 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<RequestBuilder> {
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<RequestBuilder> {
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 {