From 194b574b02f1947b21838b6898d2d1f322f43deb Mon Sep 17 00:00:00 2001 From: Joe Manley Date: Sun, 9 Feb 2025 20:09:21 -0800 Subject: [PATCH 1/2] Back to main --- src/api/providers/openai.ts | 7 +------ src/core/webview/ClineProvider.ts | 6 ------ src/shared/api.ts | 1 - 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/api/providers/openai.ts b/src/api/providers/openai.ts index 8551d812a3..203eb44040 100644 --- a/src/api/providers/openai.ts +++ b/src/api/providers/openai.ts @@ -13,9 +13,6 @@ import { convertToR1Format } from "../transform/r1-format" import { convertToSimpleMessages } from "../transform/simple-format" import { ApiStream } from "../transform/stream" -export const DEEP_SEEK_DEFAULT_TEMPERATURE = 0.6 -const OPENAI_DEFAULT_TEMPERATURE = 0 - export class OpenAiHandler implements ApiHandler, SingleCompletionHandler { protected options: ApiHandlerOptions private client: OpenAI @@ -73,9 +70,7 @@ export class OpenAiHandler implements ApiHandler, SingleCompletionHandler { const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming = { model: modelId, - temperature: - this.options.modelTemperature ?? - (deepseekReasoner ? DEEP_SEEK_DEFAULT_TEMPERATURE : OPENAI_DEFAULT_TEMPERATURE), + temperature: 0, messages: convertedMessages, stream: true as const, stream_options: { include_usage: true }, diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 1051267c43..74e797e4a1 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -123,7 +123,6 @@ type GlobalStateKey = | "customModes" // Array of custom modes | "unboundModelId" | "unboundModelInfo" - | "modelTemperature" export const GlobalFileNames = { apiConversationHistory: "api_conversation_history.json", @@ -1588,7 +1587,6 @@ export class ClineProvider implements vscode.WebviewViewProvider { unboundApiKey, unboundModelId, unboundModelInfo, - modelTemperature, } = apiConfiguration await this.updateGlobalState("apiProvider", apiProvider) await this.updateGlobalState("apiModelId", apiModelId) @@ -1630,7 +1628,6 @@ export class ClineProvider implements vscode.WebviewViewProvider { await this.storeSecret("unboundApiKey", unboundApiKey) await this.updateGlobalState("unboundModelId", unboundModelId) await this.updateGlobalState("unboundModelInfo", unboundModelInfo) - await this.updateGlobalState("modelTemperature", modelTemperature) if (this.cline) { this.cline.api = buildApiHandler(apiConfiguration) } @@ -2391,7 +2388,6 @@ export class ClineProvider implements vscode.WebviewViewProvider { unboundApiKey, unboundModelId, unboundModelInfo, - modelTemperature, ] = await Promise.all([ this.getGlobalState("apiProvider") as Promise, this.getGlobalState("apiModelId") as Promise, @@ -2468,7 +2464,6 @@ export class ClineProvider implements vscode.WebviewViewProvider { this.getSecret("unboundApiKey") as Promise, this.getGlobalState("unboundModelId") as Promise, this.getGlobalState("unboundModelInfo") as Promise, - this.getGlobalState("modelTemperature") as Promise, ]) let apiProvider: ApiProvider @@ -2527,7 +2522,6 @@ export class ClineProvider implements vscode.WebviewViewProvider { unboundApiKey, unboundModelId, unboundModelInfo, - modelTemperature, }, lastShownAnnouncementId, customInstructions, diff --git a/src/shared/api.ts b/src/shared/api.ts index 5f41130990..77c73a8c36 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -61,7 +61,6 @@ export interface ApiHandlerOptions { unboundApiKey?: string unboundModelId?: string unboundModelInfo?: ModelInfo - modelTemperature?: number } export type ApiConfiguration = ApiHandlerOptions & { From d4b7a60138759922e98126370278dd858aab0ebe Mon Sep 17 00:00:00 2001 From: Joe Manley Date: Sun, 9 Feb 2025 20:09:37 -0800 Subject: [PATCH 2/2] Bring back changes --- src/api/providers/openai.ts | 7 ++++++- src/core/webview/ClineProvider.ts | 6 ++++++ src/shared/api.ts | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/api/providers/openai.ts b/src/api/providers/openai.ts index 203eb44040..8551d812a3 100644 --- a/src/api/providers/openai.ts +++ b/src/api/providers/openai.ts @@ -13,6 +13,9 @@ import { convertToR1Format } from "../transform/r1-format" import { convertToSimpleMessages } from "../transform/simple-format" import { ApiStream } from "../transform/stream" +export const DEEP_SEEK_DEFAULT_TEMPERATURE = 0.6 +const OPENAI_DEFAULT_TEMPERATURE = 0 + export class OpenAiHandler implements ApiHandler, SingleCompletionHandler { protected options: ApiHandlerOptions private client: OpenAI @@ -70,7 +73,9 @@ export class OpenAiHandler implements ApiHandler, SingleCompletionHandler { const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming = { model: modelId, - temperature: 0, + temperature: + this.options.modelTemperature ?? + (deepseekReasoner ? DEEP_SEEK_DEFAULT_TEMPERATURE : OPENAI_DEFAULT_TEMPERATURE), messages: convertedMessages, stream: true as const, stream_options: { include_usage: true }, diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 74e797e4a1..1051267c43 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -123,6 +123,7 @@ type GlobalStateKey = | "customModes" // Array of custom modes | "unboundModelId" | "unboundModelInfo" + | "modelTemperature" export const GlobalFileNames = { apiConversationHistory: "api_conversation_history.json", @@ -1587,6 +1588,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { unboundApiKey, unboundModelId, unboundModelInfo, + modelTemperature, } = apiConfiguration await this.updateGlobalState("apiProvider", apiProvider) await this.updateGlobalState("apiModelId", apiModelId) @@ -1628,6 +1630,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { await this.storeSecret("unboundApiKey", unboundApiKey) await this.updateGlobalState("unboundModelId", unboundModelId) await this.updateGlobalState("unboundModelInfo", unboundModelInfo) + await this.updateGlobalState("modelTemperature", modelTemperature) if (this.cline) { this.cline.api = buildApiHandler(apiConfiguration) } @@ -2388,6 +2391,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { unboundApiKey, unboundModelId, unboundModelInfo, + modelTemperature, ] = await Promise.all([ this.getGlobalState("apiProvider") as Promise, this.getGlobalState("apiModelId") as Promise, @@ -2464,6 +2468,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { this.getSecret("unboundApiKey") as Promise, this.getGlobalState("unboundModelId") as Promise, this.getGlobalState("unboundModelInfo") as Promise, + this.getGlobalState("modelTemperature") as Promise, ]) let apiProvider: ApiProvider @@ -2522,6 +2527,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { unboundApiKey, unboundModelId, unboundModelInfo, + modelTemperature, }, lastShownAnnouncementId, customInstructions, diff --git a/src/shared/api.ts b/src/shared/api.ts index 77c73a8c36..5f41130990 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -61,6 +61,7 @@ export interface ApiHandlerOptions { unboundApiKey?: string unboundModelId?: string unboundModelInfo?: ModelInfo + modelTemperature?: number } export type ApiConfiguration = ApiHandlerOptions & {