do you know to say if that this make the counts before the api answers ? I’m very confused , if i pay for usage i wouldn’t like to pay after the answers of the users from my app.
her part ofthe code : //Send messages to the OpenAI API and get a response
I’m having a difficult time understanding your objective. Can you have ChatGPT translate your native language?
It seems like you are denying users the answer after you sent it to the API. Instead, check the criteria first: are they paid up? Are they over their quota? Have they been suspended?
The size of the response generation shouldn’t affect whether the user can get their answer. If they use too much (of whatever you measure), it should affect the next time they use the service.
Sorry for my English, in the application I am sending the request to the api and I have the total values of the tokens, the values are added to the database and then I check if the maximum limit has exceeded the limits. There is the pro account and the test account.
To obtain the total token values, I need to make a call to the API that generates the values. Using Tiktokens, is it possible to estimate the values without consuming the API? as a kind of simulator?
Tiktoken can count the AI language encoding tokens of text. It can count and measure the language before you send it to the API, using local code.
Token counting is useful for managing the size of past conversation that you send, for example.
While you can measure the user input, you can’t anticipate the length of the AI response output. AI could just say “hi”, or it could write Shakespeare.
Therefore, it is far more practical to tell the user that they are out of tokens or requests BEFORE they waste their time typing a chatbot input.