From 527da63d18def9cec29c89387de988b43acb7d24 Mon Sep 17 00:00:00 2001 From: sigoden Date: Fri, 22 Mar 2024 19:24:22 +0800 Subject: refactor: do not automatically convert temperature value (#368) --- src/client/qianwen.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/client/qianwen.rs') diff --git a/src/client/qianwen.rs b/src/client/qianwen.rs index 1858030..3e69dae 100644 --- a/src/client/qianwen.rs +++ b/src/client/qianwen.rs @@ -1,4 +1,6 @@ -use super::{message::*, Client, ExtraConfig, Model, PromptType, QianwenClient, SendData}; +use super::{ + message::*, Client, ExtraConfig, Model, PromptType, QianwenClient, SendData, TokensCountFactors, +}; use crate::{ render::ReplyHandler, @@ -35,6 +37,8 @@ const MODELS: [(&str, usize, &str); 6] = [ ("qwen-vl-max", 0, "text,vision"), ]; +const TOKENS_COUNT_FACTORS: TokensCountFactors = (4, 14); + #[derive(Debug, Clone, Deserialize, Default)] pub struct QianwenConfig { pub name: Option, @@ -84,6 +88,7 @@ impl QianwenClient { Model::new(client_name, name) .set_capabilities(capabilities.into()) .set_max_input_tokens(Some(max_input_tokens)) + .set_tokens_count_factors(TOKENS_COUNT_FACTORS) }) .collect() } @@ -221,7 +226,7 @@ fn build_body(data: SendData, model: String, is_vl: bool) -> Result<(Value, bool let mut parameters = json!({}); if let Some(v) = temperature { - parameters["top_k"] = ((v * 50.0).round() as usize).into(); + parameters["temperature"] = v.into(); } (input, parameters) } else { -- cgit v1.2.3