mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
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:
parent
d7ef4590ea
commit
f5f5b2bbdb
2 changed files with 9 additions and 2 deletions
|
|
@ -548,7 +548,7 @@ ${botMessage.message}
|
||||||
if (isChatGptModel) {
|
if (isChatGptModel) {
|
||||||
return { prompt: [instructionsPayload, messagePayload], context };
|
return { prompt: [instructionsPayload, messagePayload], context };
|
||||||
}
|
}
|
||||||
return { prompt, context };
|
return { prompt, context, promptTokens: currentTokenCount };
|
||||||
}
|
}
|
||||||
|
|
||||||
getTokenCount(text) {
|
getTokenCount(text) {
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,13 @@ const Transaction = require('../api/models/Transaction');
|
||||||
// console.purple(`[DEBUG] Args Length: ${process.argv.length}`);
|
// 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
|
* 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
|
// Check the result
|
||||||
if (!result.tokenCredits) {
|
if (!result?.tokenCredits) {
|
||||||
console.red('Error: Something went wrong while updating the balance!');
|
console.red('Error: Something went wrong while updating the balance!');
|
||||||
console.error(result);
|
console.error(result);
|
||||||
silentExit(1);
|
silentExit(1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue