many fixes in using the temperature parameter. see #571 #572 #573

This commit is contained in:
mic 2025-12-27 22:56:57 +01:00
parent dfa4da5b2e
commit 78b691271f
7 changed files with 9 additions and 5 deletions

View file

@ -80,7 +80,7 @@ switch (llm) {
chatgpt_api_key: prefs_default.chatgpt_api_key,
chatgpt_model: prefs_default.chatgpt_model,
chatgpt_developer_messages: prefs_default.chatgpt_developer_messages,
chatgpt_api_store: prefs_default.chatgpt_api_store,
chatgpt_api_store: prefs_default.chatgpt_api_store, // Keep as boolean
chatgpt_api_temperature: prefs_default.chatgpt_api_temperature,
do_debug: prefs_default.do_debug,
});
@ -263,6 +263,7 @@ switch (llm) {
anthropic_model: prefs_api.anthropic_model,
anthropic_system_prompt: prefs_api.anthropic_system_prompt,
anthropic_version: prefs_api.anthropic_version,
anthropic_temperature: prefs_api.anthropic_temperature,
anthropic_max_tokens: prefs_api.anthropic_max_tokens,
do_debug: prefs_api.do_debug,
i18nStrings: i18nStrings,

View file

@ -99,7 +99,7 @@ export class Anthropic {
stream: this.stream,
};
if(this.temperature != '') claude_body.temperature = this.temperature;
if(parseFloat(this.temperature) != NaN) claude_body.temperature = parseFloat(this.temperature);
const response = await fetch("https://api.anthropic.com/v1/messages", {
method: "POST",

View file

@ -110,8 +110,8 @@ export class GoogleGemini {
};
}
if(this.temperature !== ''){
google_gemini_body.generationConfig.temperature = this.temperature;
if(parseFloat(this.temperature) != NaN){
google_gemini_body.generationConfig.temperature = parseFloat(this.temperature);
}
// console.log("[ThunderAI] Google Gemini API request: " + JSON.stringify(google_gemini_body));

View file

@ -93,7 +93,7 @@ export class OpenAI {
input: input,
stream: this.stream,
store: this.store,
...(this.temperature != '' ? { 'temperature': this.temperature } : {}),
...(parseFloat(this.temperature) != NaN ? { 'temperature': parseFloat(this.temperature) } : {}),
...(maxTokens > 0 ? { 'max_output_tokens': parseInt(maxTokens) } : {}),
...(previous_response_id && this.store ? { 'previous_response_id': previous_response_id } : {})
}

View file

@ -44,6 +44,7 @@ self.onmessage = async function(event) {
version: event.data.anthropic_version,
model: anthropic_model,
system_prompt: event.data.anthropic_system_prompt,
temperature: event.data.anthropic_temperature,
max_tokens: event.data.anthropic_max_tokens,
stream: true
});

View file

@ -42,6 +42,7 @@ self.onmessage = async function(event) {
apiKey: google_gemini_api_key,
model: google_gemini_model,
system_instruction: event.data.google_gemini_system_instruction,
temperature: event.data.google_gemini_temperature,
thinking_budget: event.data.google_gemini_thinking_budget,
stream: true
});

View file

@ -43,6 +43,7 @@ self.onmessage = async function(event) {
apiKey: chatgpt_api_key,
model: chatgpt_model,
developer_messages: event.data.chatgpt_developer_messages,
temperature: event.data.chatgpt_api_temperature,
stream: true,
store: event.data.chatgpt_api_store
});