{"name":"js-tiktoken","version":"1.0.2","license":"MIT","_id":"js-tiktoken@1.0.2","maintainers":[{"name":"davidduong","email":"david@duong.cz"}],"homepage":"https://github.com/dqbd/tiktoken#readme","bugs":{"url":"https://github.com/dqbd/tiktoken/issues"},"dist":{"shasum":"bee47bd906bd104974a71c759f4920523eaae6f6","tarball":"http://registry-npm.ywwl.com/js-tiktoken/download/js-tiktoken-1.0.2.tgz","fileCount":5,"integrity":"sha512-98/YqL17qkolDbmzjeDRXGR0gNlREBjQS2eO4ioHidkNKqW2mnChhoCU2e7Z7BEbO5CrE55xlrasD3Wv/TaoEw==","signatures":[{"sig":"MEUCIQDFqwo4PNiJOK+ErWRYtAEuHbY4NkmfmaoSmvpRAUqevQIgUewVyQ6ZNuSdJn3IgbCwni7LxIc+yhCpjmfyETcqmCA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6562687,"size":2865062,"noattachment":false,"key":"/js-tiktoken/-/js-tiktoken-1.0.2.tgz"},"main":"./dist/index.cjs","tsup":{"dts":true,"clean":true,"entry":["src/index.ts"],"format":["cjs","esm"],"treeshake":true},"type":"module","types":"./dist/index.d.ts","exports":{".":{"node":"./dist/index.cjs","types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"621ae351c2c579b421a5d7cbbda930d96d96a5b6","scripts":{"test":"vitest run","build":"rm -rf dist && tsup"},"_npmUser":{"name":"davidduong","email":"david@duong.cz"},"repository":{"url":"git+https://github.com/dqbd/tiktoken.git","type":"git"},"_npmVersion":"9.6.2","description":"JavaScript port of tiktoken","directories":{},"_nodeVersion":"19.8.1","dependencies":{"base64-js":"^1.5.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tsup":"^6.7.0"},"_npmOperationalInternal":{"tmp":"tmp/js-tiktoken_1.0.2_1684112227438_0.5124719424447755","host":"s3://npm-registry-packages"},"readme":"# ⏳ js-tiktoken\n\ntiktoken is a [BPE](https://en.wikipedia.org/wiki/Byte_pair_encoding) tokeniser for use with\nOpenAI's models. This is a pure JS port of the original tiktoken library.\n\nInstall the library from NPM:\n\n```\nnpm install js-tiktoken\n```\n\n## Lite\n\nYou can only load the ranks you need, which will significantly reduce the bundle size:\n\n```typescript\nimport { Tiktoken } from \"js-tiktoken/lite\";\nimport o200k_base from \"js-tiktoken/ranks/o200k_base\";\n\nconst enc = new Tiktoken(o200k_base);\nassert(enc.decode(enc.encode(\"hello world\")) === \"hello world\");\n```\n\nAlternatively, encodings can be loaded dynamically from our CDN hosted on Cloudflare Pages.\n\n```typescript\nimport { Tiktoken } from \"js-tiktoken/lite\";\n\nconst res = await fetch(`https://tiktoken.pages.dev/js/o200k_base.json`);\nconst o200k_base = await res.json();\n\nconst enc = new Tiktoken(o200k_base);\nassert(enc.decode(enc.encode(\"hello world\")) === \"hello world\");\n```\n\n## Full usage\n\nIf you need all the OpenAI tokenizers, you can import the entire library:\n\n> [!CAUTION]\n> This will include all the OpenAI tokenizers, which may significantly increase the bundle size. See\n\n```typescript\nimport assert from \"node:assert\";\nimport { getEncoding, encodingForModel } from \"js-tiktoken\";\n\nconst enc = getEncoding(\"gpt2\");\nassert(enc.decode(enc.encode(\"hello world\")) === \"hello world\");\n```\n","publish_time":1684112227721,"_cnpm_publish_time":1684112227721,"dist-tags":{"devel":"1.0.7","latest":"1.0.21"}}