From 40907a3d5fd00dcbafa69baa50aa3ddabc08483f Mon Sep 17 00:00:00 2001 From: Alexandru Dima Date: Wed, 18 Sep 2024 11:26:29 +0200 Subject: [PATCH] Fixes #85 (#88) --- package-lock.json | 4 ++-- package.json | 2 +- src/base/promptRenderer.ts | 8 ++++---- src/base/test/renderer.test.tsx | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 230c81d..c89fdc9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@vscode/prompt-tsx", - "version": "0.2.9-alpha", + "version": "0.2.10-alpha", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@vscode/prompt-tsx", - "version": "0.2.9-alpha", + "version": "0.2.10-alpha", "license": "SEE LICENSE IN LICENSE", "devDependencies": { "@microsoft/tiktokenizer": "^1.0.6", diff --git a/package.json b/package.json index 7e5ed52..a051960 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vscode/prompt-tsx", - "version": "0.2.9-alpha", + "version": "0.2.10-alpha", "description": "Declare LLM prompts with TSX", "main": "./dist/base/index.js", "types": "./dist/base/index.d.ts", diff --git a/src/base/promptRenderer.ts b/src/base/promptRenderer.ts index 1440573..a7243cb 100644 --- a/src/base/promptRenderer.ts +++ b/src/base/promptRenderer.ts @@ -511,11 +511,11 @@ async function computeTokensConsumedByLiterals(tokenizer: ITokenizer, element: Q if (isChatMessagePromptElement(instance)) { tokensConsumed += await tokenizer.countMessageTokens({ role: element.props.role, content: '', ...(element.props.name ? { name: element.props.name } : undefined) }); + } - for (const piece of pieces) { - if (piece.kind === 'literal') { - tokensConsumed += await tokenizer.tokenLength(piece.value); - } + for (const piece of pieces) { + if (piece.kind === 'literal') { + tokensConsumed += await tokenizer.tokenLength(piece.value); } } diff --git a/src/base/test/renderer.test.tsx b/src/base/test/renderer.test.tsx index f988542..07c7f7a 100644 --- a/src/base/test/renderer.test.tsx +++ b/src/base/test/renderer.test.tsx @@ -1129,7 +1129,7 @@ LOW MED 00 01 02 03 04 05 06 07 08 09 ); }) - test.skip('none-grow, greedy-grow, grow elements, nested', async () => { + test('none-grow, greedy-grow, grow elements, nested', async () => { class StringEchoBudget extends PromptElement { prepare(sizing: PromptSizing): Promise {