From fe35cfd9419302f01baf9672493c0b0a4b41d889 Mon Sep 17 00:00:00 2001 From: sigoden Date: Sat, 13 Jan 2024 19:52:07 +0800 Subject: 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 --- src/client/localai.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/client/localai.rs') 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, pub chat_endpoint: Option, - pub models: Vec, + pub models: Vec, pub extra: Option, } -#[derive(Debug, Clone, Deserialize)] -pub struct LocalAIModel { - name: String, - max_tokens: Option, -} - 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) }) -- cgit v1.2.3