From 0050daf74647e057713ffddc00478df755982d3a Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Fri, 31 Jan 2025 22:54:35 -0500 Subject: [PATCH 1/2] Make o3-mini work in glama --- src/api/providers/glama.ts | 51 ++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/src/api/providers/glama.ts b/src/api/providers/glama.ts index a2025ea..bfcb535 100644 --- a/src/api/providers/glama.ts +++ b/src/api/providers/glama.ts @@ -72,28 +72,30 @@ export class GlamaHandler implements ApiHandler, SingleCompletionHandler { maxTokens = 8_192 } + const requestOptions: OpenAI.Chat.ChatCompletionCreateParams = { + model: this.getModel().id, + max_tokens: maxTokens, + messages: openAiMessages, + stream: true, + } + + if (this.supportsTemperature()) { + requestOptions.temperature = 0 + } + const { data: completion, response } = await this.client.chat.completions - .create( - { - model: this.getModel().id, - max_tokens: maxTokens, - temperature: 0, - messages: openAiMessages, - stream: true, + .create(requestOptions, { + headers: { + "X-Glama-Metadata": JSON.stringify({ + labels: [ + { + key: "app", + value: "vscode.rooveterinaryinc.roo-cline", + }, + ], + }), }, - { - headers: { - "X-Glama-Metadata": JSON.stringify({ - labels: [ - { - key: "app", - value: "vscode.rooveterinaryinc.roo-cline", - }, - ], - }), - }, - }, - ) + }) .withResponse() const completionRequestId = response.headers.get("x-completion-request-id") @@ -148,6 +150,10 @@ export class GlamaHandler implements ApiHandler, SingleCompletionHandler { } } + private supportsTemperature(): boolean { + return this.getModel().id !== "openai/o3-mini" + } + getModel(): { id: string; info: ModelInfo } { const modelId = this.options.glamaModelId const modelInfo = this.options.glamaModelInfo @@ -164,7 +170,10 @@ export class GlamaHandler implements ApiHandler, SingleCompletionHandler { const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming = { model: this.getModel().id, messages: [{ role: "user", content: prompt }], - temperature: 0, + } + + if (this.supportsTemperature()) { + requestOptions.temperature = 0 } if (this.getModel().id.startsWith("anthropic/")) { From 0cd1642612c3e116644bbb4effbcab3b7479e2cf Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Fri, 31 Jan 2025 23:19:50 -0500 Subject: [PATCH 2/2] PR feedback --- src/api/providers/glama.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/providers/glama.ts b/src/api/providers/glama.ts index bfcb535..1e8c721 100644 --- a/src/api/providers/glama.ts +++ b/src/api/providers/glama.ts @@ -151,7 +151,7 @@ export class GlamaHandler implements ApiHandler, SingleCompletionHandler { } private supportsTemperature(): boolean { - return this.getModel().id !== "openai/o3-mini" + return !this.getModel().id.startsWith("openai/o3-mini") } getModel(): { id: string; info: ModelInfo } {