Skip to content

Commit

Permalink
Fix countMessageTokens (#124)
Browse files Browse the repository at this point in the history
* Fix countMessageTokens

* Version bump
  • Loading branch information
roblourens authored Oct 22, 2024
1 parent 071e399 commit f734669
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vscode/prompt-tsx",
"version": "0.3.0-alpha.10",
"version": "0.3.0-alpha.11",
"description": "Declare LLM prompts with TSX",
"main": "./dist/base/index.js",
"types": "./dist/base/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/base/tokenizer/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export class AnyTokenizer implements ITokenizer {
}

async countMessageTokens(message: ChatMessage): Promise<number> {
const vscode = require('vscode');
const vscode = await import('vscode');
return this.countTokens({
role: this.toChatRole(message.role),
content: new vscode.LanguageModelTextPart(message.content),
content: [new vscode.LanguageModelTextPart(message.content)],
name: 'name' in message ? message.name : undefined,
});
}
Expand Down

0 comments on commit f734669

Please sign in to comment.