The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: get tokenizer working again for Supabase AI (#20844)
Charisd29771a6305a
diff --git a/supabase/functions/common/tokenizer.ts b/supabase/functions/common/tokenizer.tsindex 7ae2417b7b1..0096c389864 100644--- a/supabase/functions/common/tokenizer.ts+++ b/supabase/functions/common/tokenizer.ts@@ -1,19 +1,7 @@-import { init, Tiktoken } from 'https://esm.sh/@dqbd/[email protected]/lite/init'+import { getEncoding } from 'https://esm.sh/[email protected]'import { ChatCompletionRequestMessage } from 'https://esm.sh/v113/[email protected]'-const encoderResponse = await fetch('https://esm.sh/@dqbd/[email protected]/encoders/cl100k_base.json')-const cl100kBase = await encoderResponse.json()--await init(async (imports) => {- const req = await fetch('https://esm.sh/@dqbd/tiktoken/lite/tiktoken_bg.wasm')- return WebAssembly.instantiate(await req.arrayBuffer(), imports)-})--export const tokenizer = new Tiktoken(- cl100kBase.bpe_ranks,- cl100kBase.special_tokens,- cl100kBase.pat_str-)+export const tokenizer = getEncoding('cl100k_base')/*** Count the tokens for multi-message chat completion requests