mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
refactor: cache buildProviderOptions() result to avoid redundant calls
This commit is contained in:
parent
42089d8b71
commit
3690b887e3
1 changed files with 4 additions and 2 deletions
|
|
@ -309,6 +309,7 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
|
|||
}
|
||||
|
||||
// https://openrouter.ai/docs/transforms
|
||||
const providerOptions = this.buildProviderOptions()
|
||||
const completionParams: OpenRouterChatCompletionParams = {
|
||||
model: modelId,
|
||||
...(maxTokens && maxTokens > 0 && { max_tokens: maxTokens }),
|
||||
|
|
@ -317,7 +318,7 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
|
|||
messages: openAiMessages,
|
||||
stream: true,
|
||||
stream_options: { include_usage: true },
|
||||
...(this.buildProviderOptions() && { provider: this.buildProviderOptions() }),
|
||||
...(providerOptions && { provider: providerOptions }),
|
||||
...(reasoning && { reasoning }),
|
||||
tools: this.convertToolsForOpenAI(metadata?.tools),
|
||||
tool_choice: metadata?.tool_choice,
|
||||
|
|
@ -610,13 +611,14 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
|
|||
async completePrompt(prompt: string) {
|
||||
let { id: modelId, maxTokens, temperature, reasoning } = await this.fetchModel()
|
||||
|
||||
const providerOptions = this.buildProviderOptions()
|
||||
const completionParams: OpenRouterChatCompletionParams = {
|
||||
model: modelId,
|
||||
max_tokens: maxTokens,
|
||||
temperature,
|
||||
messages: [{ role: "user", content: prompt }],
|
||||
stream: false,
|
||||
...(this.buildProviderOptions() && { provider: this.buildProviderOptions() }),
|
||||
...(providerOptions && { provider: providerOptions }),
|
||||
...(reasoning && { reasoning }),
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue