summaryrefslogtreecommitdiffstats
path: root/src/client/qianwen.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-04-23 18:14:47 +0800
committerGitHub <noreply@github.com>2024-04-23 18:14:47 +0800
commit9c6c9f10a27d0993636b453f39d8934c95c5c2b2 (patch)
tree268598294b234c7eac87fc70d1e2d1b32ac88a78 /src/client/qianwen.rs
parentd1aafa11153ab689c21c2c57c47da52337d8e8d1 (diff)
downloadaichat-9c6c9f10a27d0993636b453f39d8934c95c5c2b2.tar.gz
feat: builtin models can be overwrited by models config (#429)
Diffstat (limited to 'src/client/qianwen.rs')
-rw-r--r--src/client/qianwen.rs18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/client/qianwen.rs b/src/client/qianwen.rs
index 6225b96..a3ee988 100644
--- a/src/client/qianwen.rs
+++ b/src/client/qianwen.rs
@@ -1,5 +1,6 @@
use super::{
- message::*, Client, ExtraConfig, Model, PromptType, QianwenClient, ReplyHandler, SendData,
+ message::*, Client, ExtraConfig, Model, ModelConfig, PromptType, QianwenClient, ReplyHandler,
+ SendData,
};
use crate::utils::{sha256sum, PromptKind};
@@ -38,6 +39,8 @@ const MODELS: [(&str, usize, &str); 6] = [
pub struct QianwenConfig {
pub name: Option<String>,
pub api_key: Option<String>,
+ #[serde(default)]
+ pub models: Vec<ModelConfig>,
pub extra: Option<ExtraConfig>,
}
@@ -70,23 +73,12 @@ impl Client for QianwenClient {
}
impl QianwenClient {
+ list_models_fn!(QianwenConfig, &MODELS);
config_get_fn!(api_key, get_api_key);
pub const PROMPTS: [PromptType<'static>; 1] =
[("api_key", "API Key:", true, PromptKind::String)];
- pub fn list_models(local_config: &QianwenConfig) -> Vec<Model> {
- let client_name = Self::name(local_config);
- MODELS
- .into_iter()
- .map(|(name, max_input_tokens, capabilities)| {
- Model::new(client_name, name)
- .set_capabilities(capabilities.into())
- .set_max_input_tokens(Some(max_input_tokens))
- })
- .collect()
- }
-
fn request_builder(&self, client: &ReqwestClient, data: SendData) -> Result<RequestBuilder> {
let api_key = self.get_api_key()?;