summaryrefslogtreecommitdiffstats
path: root/src/client/localai.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-01-13 19:52:07 +0800
committerGitHub <noreply@github.com>2024-01-13 19:52:07 +0800
commitfe35cfd9419302f01baf9672493c0b0a4b41d889 (patch)
tree94e763745fb7989c97af39cc1dfb44250440a5eb /src/client/localai.rs
parent4e99df4c1bd4028a77251bdb00ff23c664372b5f (diff)
downloadaichat-fe35cfd9419302f01baf9672493c0b0a4b41d889.tar.gz
feat: supports model capabilities (#297)
1. automatically switch to the model that has the necessary capabilities. 2. throw an error if the client does not have a model with the necessary capabilities
Diffstat (limited to 'src/client/localai.rs')
-rw-r--r--src/client/localai.rs11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/client/localai.rs b/src/client/localai.rs
index 9325e0f..3bc0670 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, Model};
+use super::{ExtraConfig, LocalAIClient, Model, ModelConfig, PromptType, SendData};
use crate::utils::PromptKind;
@@ -14,16 +14,10 @@ pub struct LocalAIConfig {
pub api_base: String,
pub api_key: Option<String>,
pub chat_endpoint: Option<String>,
- pub models: Vec<LocalAIModel>,
+ pub models: Vec<ModelConfig>,
pub extra: Option<ExtraConfig>,
}
-#[derive(Debug, Clone, Deserialize)]
-pub struct LocalAIModel {
- name: String,
- max_tokens: Option<usize>,
-}
-
openai_compatible_client!(LocalAIClient);
impl LocalAIClient {
@@ -49,6 +43,7 @@ impl LocalAIClient {
.iter()
.map(|v| {
Model::new(client_name, &v.name)
+ .set_capabilities(v.capabilities)
.set_max_tokens(v.max_tokens)
.set_tokens_count_factors(OPENAI_TOKENS_COUNT_FACTORS)
})