forked from stitionai/devika
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement TicToken library in frontend (stitionai#283)
- Loading branch information
1 parent
edd99a7
commit 7474541
Showing
5 changed files
with
34 additions
and
32 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Tiktoken } from "tiktoken/lite"; | ||
import cl100k_base from "tiktoken/encoders/cl100k_base.json"; | ||
|
||
const encoding = new Tiktoken( | ||
cl100k_base.bpe_ranks, | ||
cl100k_base.special_tokens, | ||
cl100k_base.pat_str | ||
); | ||
|
||
export function calculateTokens(text) { | ||
const tokens = encoding.encode(text); | ||
return tokens.length; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { sveltekit } from '@sveltejs/kit/vite'; | ||
import { defineConfig } from 'vite'; | ||
import { sveltekit } from "@sveltejs/kit/vite"; | ||
import { defineConfig } from "vite"; | ||
import wasm from "vite-plugin-wasm"; | ||
|
||
export default defineConfig({ | ||
plugins: [sveltekit()], | ||
server: { | ||
port: 3000, | ||
}, | ||
plugins: [sveltekit(), wasm()], | ||
server: { | ||
port: 3000, | ||
}, | ||
}); |