{"name":"js-tiktoken","version":"1.0.0","license":"MIT","_id":"js-tiktoken@1.0.0","maintainers":[{"name":"davidduong","email":"david@duong.cz"}],"homepage":"https://github.com/dqbd/tiktoken#readme","bugs":{"url":"https://github.com/dqbd/tiktoken/issues"},"dist":{"shasum":"474720b4fdd0ebb722dae48d1c9bd88bc97c8ff0","tarball":"http://registry-npm.ywwl.com/js-tiktoken/download/js-tiktoken-1.0.0.tgz","fileCount":5,"integrity":"sha512-scwc28vcv/8emEAIc1ow1I2rKINIvZDL2JfpUP6kU9RjzThE8Pg6xqjvn/teMgqWbX4LDLnSngl7uL40jQZzIw==","signatures":[{"sig":"MEUCIBlZZ2Wr+xAumKN2mgQp0nCiItMKOT9Xh1AmgGI2PgV4AiEAm6sj5dKOefD3Lrm5aujsDQWdbd8AkONN+JWmjMEI33k=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9483,"size":2648,"noattachment":false,"key":"/js-tiktoken/-/js-tiktoken-1.0.0.tgz"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"gitHead":"7c6a304792c8612639bf5b79b328060656be2d64","scripts":{"test":"vitest run","build":"tsc"},"_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,"devDependencies":{},"_npmOperationalInternal":{"tmp":"tmp/js-tiktoken_1.0.0_1683978526324_0.03961127880024162","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":1683978526582,"_cnpm_publish_time":1683978526582,"dist-tags":{"devel":"1.0.7","latest":"1.0.21"}}