summaryrefslogtreecommitdiffstats
path: root/src/client/localai.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-11-03 06:52:57 +0800
committerGitHub <noreply@github.com>2023-11-03 06:52:57 +0800
commitf9c40e52dabda7b037805c0635b84ccb6d75f5a8 (patch)
tree73fda138c432ed18c5f95b7be571f8298f6284c8 /src/client/localai.rs
parentdce6877f5de297803a737387fef7f672593904cf (diff)
downloadaichat-f9c40e52dabda7b037805c0635b84ccb6d75f5a8.tar.gz
refactor: improve code quanity (#203)
- update field name of ModelInfo - rename ModelInfo to Model
Diffstat (limited to 'src/client/localai.rs')
-rw-r--r--src/client/localai.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/client/localai.rs b/src/client/localai.rs
index 5cc12cc..eb4de65 100644
--- a/src/client/localai.rs
+++ b/src/client/localai.rs
@@ -1,5 +1,5 @@
use super::openai::{openai_build_body, OPENAI_TOKENS_COUNT_FACTORS};
-use super::{ExtraConfig, LocalAIClient, PromptType, SendData, ModelInfo};
+use super::{ExtraConfig, LocalAIClient, PromptType, SendData, Model};
use crate::utils::PromptKind;
@@ -41,14 +41,14 @@ impl LocalAIClient {
),
];
- pub fn list_models(local_config: &LocalAIConfig, index: usize) -> Vec<ModelInfo> {
- let client = Self::name(local_config);
+ pub fn list_models(local_config: &LocalAIConfig, client_index: usize) -> Vec<Model> {
+ let client_name = Self::name(local_config);
local_config
.models
.iter()
.map(|v| {
- ModelInfo::new(index, client, &v.name)
+ Model::new(client_index, client_name, &v.name)
.set_max_tokens(v.max_tokens)
.set_tokens_count_factors(OPENAI_TOKENS_COUNT_FACTORS)
})
@@ -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_info.name.clone());
+ let body = openai_build_body(data, self.model.llm_name.clone());
let chat_endpoint = self
.config