summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2025-02-10 16:19:18 +0800
committerGitHub <noreply@github.com>2025-02-10 16:19:18 +0800
commit4fab4c54b2916931bf5705b5aa5e560e57f7f289 (patch)
tree1b35844aebc157bfcefad7f61e41c873a98fecdc
parent69974365ee786af5b643c335e2a12dd7817b84be (diff)
downloadaichat-4fab4c54b2916931bf5705b5aa5e560e57f7f289.tar.gz
feat: add model field `no_temperature` (#1164)
-rw-r--r--models.yaml13
-rw-r--r--src/client/model.rs6
-rw-r--r--src/config/input.rs7
-rw-r--r--src/serve.rs11
4 files changed, 33 insertions, 4 deletions
diff --git a/models.yaml b/models.yaml
index bce8990..a2e8e97 100644
--- a/models.yaml
+++ b/models.yaml
@@ -53,6 +53,7 @@
supports_vision: true
supports_function_calling: true
supports_reasoning: true
+ no_temperature: true
system_prompt_prefix: Formatting re-enabled
- name: o1
max_input_tokens: 200000
@@ -61,6 +62,7 @@
supports_vision: true
supports_function_calling: true
supports_reasoning: true
+ no_temperature: true
system_prompt_prefix: Formatting re-enabled
- name: o1-preview
max_input_tokens: 128000
@@ -69,6 +71,7 @@
output_price: 60
supports_reasoning: true
no_system_message: true
+ no_temperature: true
- name: o1-mini
max_input_tokens: 128000
max_output_tokens: 65536
@@ -76,6 +79,7 @@
output_price: 12
supports_reasoning: true
no_system_message: true
+ no_temperature: true
- name: gpt-3.5-turbo
max_input_tokens: 16385
max_output_tokens: 4096
@@ -1044,6 +1048,7 @@
input_price: 0.55
output_price: 2.19
supports_reasoning: true
+ no_temperature: true
# Links:
# - https://open.bigmodel.cn/pricing
@@ -1174,6 +1179,7 @@
supports_vision: true
supports_function_calling: true
supports_reasoning: true
+ no_temperature: true
system_prompt_prefix: Formatting re-enabled
- name: openai/o1
max_input_tokens: 128000
@@ -1182,6 +1188,7 @@
supports_vision: true
supports_function_calling: true
supports_reasoning: true
+ no_temperature: true
system_prompt_prefix: Formatting re-enabled
- name: openai/o1-preview
max_input_tokens: 128000
@@ -1189,12 +1196,14 @@
output_price: 60
supports_reasoning: true
no_system_message: true
+ no_temperature: true
- name: openai/o1-mini
max_input_tokens: 128000
input_price: 3
output_price: 12
supports_reasoning: true
no_system_message: true
+ no_temperature: true
- name: openai/gpt-3.5-turbo
max_input_tokens: 16385
input_price: 0.5
@@ -1481,23 +1490,27 @@
supports_function_calling: true
supports_vision: true
supports_reasoning: true
+ no_temperature: true
system_prompt_prefix: Formatting re-enabled
- name: o1
max_input_tokens: 200000
supports_function_calling: true
supports_vision: true
supports_reasoning: true
+ no_temperature: true
system_prompt_prefix: Formatting re-enabled
- name: o1-preview
max_input_tokens: 128000
supports_reasoning: true
no_stream: true
no_system_message: true
+ no_temperature: true
- name: o1-mini
max_input_tokens: 128000
supports_reasoning: true
no_stream: true
no_system_message: true
+ no_temperature: true
- name: text-embedding-3-large
type: embedding
max_tokens_per_chunk: 8191
diff --git a/src/client/model.rs b/src/client/model.rs
index 8fcc6db..6681856 100644
--- a/src/client/model.rs
+++ b/src/client/model.rs
@@ -198,6 +198,10 @@ impl Model {
self.data.no_system_message
}
+ pub fn no_temperature(&self) -> bool {
+ self.data.no_temperature
+ }
+
pub fn system_prompt_prefix(&self) -> Option<&str> {
self.data.system_prompt_prefix.as_deref()
}
@@ -325,6 +329,8 @@ pub struct ModelData {
no_stream: bool,
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
no_system_message: bool,
+ #[serde(default, skip_serializing_if = "std::ops::Not::not")]
+ no_temperature: bool,
#[serde(skip_serializing_if = "Option::is_none")]
system_prompt_prefix: Option<String>,
diff --git a/src/config/input.rs b/src/config/input.rs
index 1067b2c..a63e9a6 100644
--- a/src/config/input.rs
+++ b/src/config/input.rs
@@ -240,8 +240,11 @@ impl Input {
let mut messages = self.build_messages()?;
patch_messages(&mut messages, model);
model.guard_max_input_tokens(&messages)?;
- let temperature = self.role().temperature();
- let top_p = self.role().top_p();
+ let (temperature, top_p) = if model.no_temperature() {
+ (None, None)
+ } else {
+ (self.role().temperature(), self.role().top_p())
+ };
let functions = self.config.read().select_functions(self.role());
Ok(ChatCompletionsData {
messages,
diff --git a/src/serve.rs b/src/serve.rs
index f51e56f..4c1a741 100644
--- a/src/serve.rs
+++ b/src/serve.rs
@@ -270,8 +270,8 @@ impl Server {
let ChatCompletionsReqBody {
model,
messages,
- temperature,
- top_p,
+ mut temperature,
+ mut top_p,
max_tokens,
stream,
tools,
@@ -309,7 +309,14 @@ impl Server {
let completion_id = generate_completion_id();
let created = Utc::now().timestamp();
+
patch_messages(&mut messages, client.model());
+
+ if client.model().no_temperature() {
+ temperature = None;
+ top_p = None;
+ }
+
let data: ChatCompletionsData = ChatCompletionsData {
messages,
temperature,