↧
Answer by EL MAHDI Bouzkoura for how can I count tokens before making api call?
Question is old but it may help someone. There is a node.js library called tiktoken wish is a fork form the original tiktoken library.All the examples on the official tiktoken repo are valid with a...
View ArticleAnswer by Schroeder for how can I count tokens before making api call?
Exact MethodA precise way is to use tiktoken, which is a python library. Taken from the openAI cookbook: import tiktoken encoding = tiktoken.encoding_for_model("gpt-3.5-turbo") num_tokens =...
View Articlehow can I count tokens before making api call?
import { Configuration, OpenAIApi } from "openai"import { readFile } from './readFile.js'// Config OpenAI APIconst configuration = new Configuration({ organization: "xyx......", apiKey:...
View Article