feat: implement token counter (#3)

This commit is contained in:
boojack
2023-03-29 00:11:39 +08:00
committed by GitHub
parent f94a273d78
commit 0a878caf4f
5 changed files with 43 additions and 13 deletions

View File

@ -1 +1,7 @@
import { encode } from "@nem035/gpt-3-encoder";
export const openAIApiKey = process.env.OPENAI_API_KEY;
export const countTextTokens = (text: string) => {
return encode(text).length;
};