Merge branch 'dev'
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
import { build } from 'esbuild'
|
||||||
|
import fs from 'fs'
|
||||||
|
|
||||||
|
await build({
|
||||||
|
entryPoints: ['./src/cli.ts'],
|
||||||
|
bundle: true,
|
||||||
|
platform: 'node',
|
||||||
|
format: 'cjs',
|
||||||
|
outfile: './out/cli.cjs',
|
||||||
|
});
|
||||||
|
|
||||||
|
const wasmFile = fs.readFileSync('./node_modules/@dqbd/tiktoken/lite/tiktoken_bg.wasm')
|
||||||
|
|
||||||
|
fs.writeFileSync('./out/tiktoken_bg.wasm', wasmFile)
|
||||||
+2
-1
@@ -40,7 +40,7 @@
|
|||||||
"watch": "npm run -S build -- --sourcemap --watch",
|
"watch": "npm run -S build -- --sourcemap --watch",
|
||||||
"start": "node ./out/cli.cjs",
|
"start": "node ./out/cli.cjs",
|
||||||
"dev": "ts-node ./src/cli.ts",
|
"dev": "ts-node ./src/cli.ts",
|
||||||
"build": "rimraf out && esbuild ./src/cli.ts --bundle --outfile=out/cli.cjs --format=cjs --platform=node",
|
"build": "rimraf out && node esbuild.config.js",
|
||||||
"deploy": "npm run build && npm version patch && npm publish --tag latest",
|
"deploy": "npm run build && npm version patch && npm publish --tag latest",
|
||||||
"lint": "eslint src --ext ts && tsc --noEmit",
|
"lint": "eslint src --ext ts && tsc --noEmit",
|
||||||
"format": "prettier --write src"
|
"format": "prettier --write src"
|
||||||
@@ -60,6 +60,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@clack/prompts": "^0.6.1",
|
"@clack/prompts": "^0.6.1",
|
||||||
|
"@dqbd/tiktoken": "^1.0.2",
|
||||||
"axios": "^1.3.4",
|
"axios": "^1.3.4",
|
||||||
"chalk": "^5.2.0",
|
"chalk": "^5.2.0",
|
||||||
"cleye": "^1.3.2",
|
"cleye": "^1.3.2",
|
||||||
|
|||||||
+11
-10
@@ -1,14 +1,15 @@
|
|||||||
// import { Tiktoken } from '@dqbd/tiktoken/lite';
|
import { Tiktoken } from '@dqbd/tiktoken/lite';
|
||||||
// import cl100k_base from '@dqbd/tiktoken/encoders/cl100k_base.json' assert { type: 'json' };
|
import cl100k_base from '@dqbd/tiktoken/encoders/cl100k_base.json' assert { type: 'json' };
|
||||||
|
|
||||||
export function tokenCount(content: string): number {
|
export function tokenCount(content: string): number {
|
||||||
// const encoding = new Tiktoken(
|
const encoding = new Tiktoken(
|
||||||
// cl100k_base.bpe_ranks,
|
cl100k_base.bpe_ranks,
|
||||||
// cl100k_base.special_tokens,
|
cl100k_base.special_tokens,
|
||||||
// cl100k_base.pat_str
|
cl100k_base.pat_str
|
||||||
// );
|
);
|
||||||
// const tokens = encoding.encode(content);
|
const tokens = encoding.encode(content);
|
||||||
// encoding.free();
|
encoding.free();
|
||||||
|
return tokens.length;
|
||||||
|
|
||||||
return content.length / 2.7;
|
//return content.length / 2.7;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user