Skip to content

Commit

Permalink
update parser builder
Browse files Browse the repository at this point in the history
  • Loading branch information
rhys101 committed Oct 29, 2024
1 parent c7fd2f0 commit 28ba6f3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/extension/background/APIHandler/AILanguageModelHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,22 @@ class AILanguageModelHandler {
let tokenCount = systemPrompt
? await AIPrompter.countTokens(systemPrompt, manifest.tokens.method)
: 0
const messagesWindow = [
...systemPrompt
? [{ content: systemPrompt, role: 'system' }]
: []
]

const history = [...initialPrompts, ...messages]
const countedMessages=[]

Check failure on line 80 in src/extension/background/APIHandler/AILanguageModelHandler.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Operator '=' must be spaced
for (let i = history.length - 1; i >= 0; i--) {
const message = history[i]
tokenCount += await AIPrompter.countTokens(message.content, manifest.tokens.method)
if (tokenCount > manifest.tokens.max) {
break
}
messagesWindow.unshift(message)
countedMessages.unshift(message)
}
messagesWindow.reverse()
const messagesWindow = [
...systemPrompt
? [{ content: systemPrompt, role: 'system' }, ...countedMessages]
: countedMessages
]

// Send to the template
const template = new Template(promptConfig.template)
Expand Down

0 comments on commit 28ba6f3

Please sign in to comment.