mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-21 21:50:49 +02:00
🧮 feat: Improve structured token spending and testing; fix: Anthropic Cache Spend (#3766)
* chore: update jest and mongodb-memory-server dependencies * fix: Anthropic edge case of increasing balance * refactor: Update token calculations in Transaction model/spec * refactor: `spendTokens` always record transactions, add Tx related tests * feat: Add error handling for CHECK_BALANCE environment variable * feat: Update import path for Balance model in Balance controller * chore: remove logging * refactor: Improve structured token spend logging in spendTokens.js * ci: add unit tests for spend token * ci: Improve structured token spend unit testing * chore: improve logging phrase for no tx spent from balance
This commit is contained in:
parent
ea5140ff0f
commit
d54458b3a6
8 changed files with 850 additions and 82 deletions
|
@ -1,6 +1,7 @@
|
|||
const path = require('path');
|
||||
require('module-alias')({ base: path.resolve(__dirname, '..', 'api') });
|
||||
const { askQuestion, silentExit } = require('./helpers');
|
||||
const { isEnabled } = require('~/server/utils/handleText');
|
||||
const { Transaction } = require('~/models/Transaction');
|
||||
const User = require('~/models/User');
|
||||
const connect = require('./connect');
|
||||
|
@ -36,6 +37,12 @@ const connect = require('./connect');
|
|||
);
|
||||
silentExit(1);
|
||||
}
|
||||
if (isEnabled(process.env.CHECK_BALANCE) === false) {
|
||||
console.red(
|
||||
'Error: CHECK_BALANCE environment variable is set to `false`! Please configure: `CHECK_BALANCE=true`',
|
||||
);
|
||||
silentExit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* If we don't have the right number of arguments, lets prompt the user for them
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue