fix: Resolve Token Credit Balance Issues for Instruct Models 🛠️ (#1232)

* Fix: balance update error and add environment variable check

* fix(ChatGPTClient): return promptTokens for instruct/davinci models

* chore: remove unnecessary comments
This commit is contained in:
Danny Avila 2023-11-26 18:12:27 -05:00 committed by GitHub
parent d7ef4590ea
commit f5f5b2bbdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -52,6 +52,13 @@ const Transaction = require('../api/models/Transaction');
// console.purple(`[DEBUG] Args Length: ${process.argv.length}`);
}
if (!process.env.CHECK_BALANCE) {
console.red(
'Error: CHECK_BALANCE environment variable is not set! Configure it to use it: `CHECK_BALANCE=true`',
);
silentExit(1);
}
/**
* If we don't have the right number of arguments, lets prompt the user for them
*/
@ -99,7 +106,7 @@ const Transaction = require('../api/models/Transaction');
}
// Check the result
if (!result.tokenCredits) {
if (!result?.tokenCredits) {
console.red('Error: Something went wrong while updating the balance!');
console.error(result);
silentExit(1);