Skip to content

Commit d4b7a60

Browse files
committed
Bring back changes
1 parent 194b574 commit d4b7a60

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/api/providers/openai.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import { convertToR1Format } from "../transform/r1-format"
1313
import { convertToSimpleMessages } from "../transform/simple-format"
1414
import { ApiStream } from "../transform/stream"
1515

16+
export const DEEP_SEEK_DEFAULT_TEMPERATURE = 0.6
17+
const OPENAI_DEFAULT_TEMPERATURE = 0
18+
1619
export class OpenAiHandler implements ApiHandler, SingleCompletionHandler {
1720
protected options: ApiHandlerOptions
1821
private client: OpenAI
@@ -70,7 +73,9 @@ export class OpenAiHandler implements ApiHandler, SingleCompletionHandler {
7073

7174
const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming = {
7275
model: modelId,
73-
temperature: 0,
76+
temperature:
77+
this.options.modelTemperature ??
78+
(deepseekReasoner ? DEEP_SEEK_DEFAULT_TEMPERATURE : OPENAI_DEFAULT_TEMPERATURE),
7479
messages: convertedMessages,
7580
stream: true as const,
7681
stream_options: { include_usage: true },

src/core/webview/ClineProvider.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ type GlobalStateKey =
123123
| "customModes" // Array of custom modes
124124
| "unboundModelId"
125125
| "unboundModelInfo"
126+
| "modelTemperature"
126127

127128
export const GlobalFileNames = {
128129
apiConversationHistory: "api_conversation_history.json",
@@ -1587,6 +1588,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
15871588
unboundApiKey,
15881589
unboundModelId,
15891590
unboundModelInfo,
1591+
modelTemperature,
15901592
} = apiConfiguration
15911593
await this.updateGlobalState("apiProvider", apiProvider)
15921594
await this.updateGlobalState("apiModelId", apiModelId)
@@ -1628,6 +1630,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
16281630
await this.storeSecret("unboundApiKey", unboundApiKey)
16291631
await this.updateGlobalState("unboundModelId", unboundModelId)
16301632
await this.updateGlobalState("unboundModelInfo", unboundModelInfo)
1633+
await this.updateGlobalState("modelTemperature", modelTemperature)
16311634
if (this.cline) {
16321635
this.cline.api = buildApiHandler(apiConfiguration)
16331636
}
@@ -2388,6 +2391,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
23882391
unboundApiKey,
23892392
unboundModelId,
23902393
unboundModelInfo,
2394+
modelTemperature,
23912395
] = await Promise.all([
23922396
this.getGlobalState("apiProvider") as Promise<ApiProvider | undefined>,
23932397
this.getGlobalState("apiModelId") as Promise<string | undefined>,
@@ -2464,6 +2468,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
24642468
this.getSecret("unboundApiKey") as Promise<string | undefined>,
24652469
this.getGlobalState("unboundModelId") as Promise<string | undefined>,
24662470
this.getGlobalState("unboundModelInfo") as Promise<ModelInfo | undefined>,
2471+
this.getGlobalState("modelTemperature") as Promise<number | undefined>,
24672472
])
24682473

24692474
let apiProvider: ApiProvider
@@ -2522,6 +2527,7 @@ export class ClineProvider implements vscode.WebviewViewProvider {
25222527
unboundApiKey,
25232528
unboundModelId,
25242529
unboundModelInfo,
2530+
modelTemperature,
25252531
},
25262532
lastShownAnnouncementId,
25272533
customInstructions,

src/shared/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export interface ApiHandlerOptions {
6161
unboundApiKey?: string
6262
unboundModelId?: string
6363
unboundModelInfo?: ModelInfo
64+
modelTemperature?: number
6465
}
6566

6667
export type ApiConfiguration = ApiHandlerOptions & {

0 commit comments

Comments
 (0)