mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-07 02:58:15 +00:00
Add OpenRouter middle out transform to avoid context limit errors
This commit is contained in:
parent
ed99fb0a42
commit
7386e3db2b
1 changed files with 6 additions and 0 deletions
|
|
@ -95,12 +95,18 @@ export class OpenRouterHandler implements ApiHandler {
|
|||
maxTokens = 8_192
|
||||
break
|
||||
}
|
||||
|
||||
// Removes messages in the middle when close to context window limit. Should not be applied to models that support prompt caching since it would continuously break the cache.
|
||||
const shouldApplyMiddleOutTransform = !this.getModel().info.supportsPromptCache
|
||||
|
||||
// @ts-ignore-next-line
|
||||
const stream = await this.client.chat.completions.create({
|
||||
model: this.getModel().id,
|
||||
max_tokens: maxTokens,
|
||||
temperature: 0,
|
||||
messages: openAiMessages,
|
||||
stream: true,
|
||||
transforms: shouldApplyMiddleOutTransform ? ["middle-out"] : undefined,
|
||||
})
|
||||
|
||||
let genId: string | undefined
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue