From 4db9b309803796bc5f996d0b3713344eb44207ec Mon Sep 17 00:00:00 2001 From: sigoden Date: Thu, 25 Apr 2024 10:15:54 +0800 Subject: refactor: rewrite list models of all clients (#436) --- src/client/qianwen.rs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/client/qianwen.rs') diff --git a/src/client/qianwen.rs b/src/client/qianwen.rs index c5a72e0..52548d8 100644 --- a/src/client/qianwen.rs +++ b/src/client/qianwen.rs @@ -24,17 +24,6 @@ const API_URL: &str = const API_URL_VL: &str = "https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation"; -const MODELS: [(&str, usize, &str); 6] = [ - // https://help.aliyun.com/zh/dashscope/developer-reference/api-details - ("qwen-turbo", 6000, "text"), - ("qwen-plus", 30000, "text"), - ("qwen-max", 6000, "text"), - ("qwen-max-longcontext", 28000, "text"), - // https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-qianwen-vl-plus-api - ("qwen-vl-plus", 0, "text,vision"), - ("qwen-vl-max", 0, "text,vision"), -]; - #[derive(Debug, Clone, Deserialize, Default)] pub struct QianwenConfig { pub name: Option, @@ -73,7 +62,19 @@ impl Client for QianwenClient { } impl QianwenClient { - list_models_fn!(QianwenConfig, &MODELS); + list_models_fn!( + QianwenConfig, + [ + // https://help.aliyun.com/zh/dashscope/developer-reference/api-details + ("qwen-turbo", "text", 6000), + ("qwen-plus", "text", 30000), + ("qwen-max", "text", 6000), + ("qwen-max-longcontext", "text", 28000), + // https://help.aliyun.com/zh/dashscope/developer-reference/tongyi-qianwen-vl-plus-api + ("qwen-vl-plus", "text,vision", 0), + ("qwen-vl-max", "text,vision", 0), + ] + ); config_get_fn!(api_key, get_api_key); pub const PROMPTS: [PromptType<'static>; 1] = @@ -211,15 +212,14 @@ fn build_body(data: SendData, model: &Model, is_vl: bool) -> Result<(Value, bool parameters["incremental_output"] = true.into(); } - if let Some(max_tokens) = model.max_output_tokens { - parameters["max_tokens"] = max_tokens.into(); + if let Some(v) = model.max_output_tokens { + parameters["max_tokens"] = v.into(); } - - if let Some(temperature) = temperature { - parameters["temperature"] = temperature.into(); + if let Some(v) = temperature { + parameters["temperature"] = v.into(); } - if let Some(top_p) = top_p { - parameters["top_p"] = top_p.into(); + if let Some(v) = top_p { + parameters["top_p"] = v.into(); } let body = json!({ -- cgit v1.2.3