📃 feat: add list-balances, remove-user, and improve User scripts (#1418)

* Refactoring opening of DB to config/helpers.js

* Adding two user scripts:

- 'delete-user' to remove a user definitely
- 'list-balances' to show the balances of all the users
This commit is contained in:
Linus Gasser 2023-12-30 19:25:12 +01:00 committed by GitHub
parent 8735db0980
commit 1a95bef677
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 137 additions and 82 deletions

View file

@ -30,6 +30,14 @@ npm run add-balance danny@librechat.ai 1000
This works well to track your own usage for personal use; 1000 credits = $0.001 (1 mill USD)
## Listing of balances
To see the balances of your users, you can run:
```bash
npm run list-balances
```
## Notes
- With summarization enabled, you will be blocked from making an API request if the cost of the content that you need to summarize + your messages payload exceeds the current balance

View file

@ -581,6 +581,7 @@ see: **[Token Usage](../../features/token_usage.md)**
- To manually add balances, run the following command:`npm run add-balance`
- You can also specify the email and token credit amount to add, e.g.:`npm run add-balance example@example.com 1000`
- To list the balance of every user: `npm run list-balances`
> **Note:** 1000 credits = $0.001 (1 mill USD)
@ -602,6 +603,7 @@ see: **[User/Auth System](../configuration/user_auth_system.md)**
- `ALLOW_SOCIAL_REGISTRATION`: Enable or disable registration of new user using various social network. Set to `true` or `false` to enable or disable.
> **Quick Tip:** Even with registration disabled, add users directly to the database using `npm run create-user`.
> **Quick Tip:** With registration disabled, you can delete a user with `npm run delete-user email@domain.com`.
```bash
ALLOW_EMAIL_LOGIN=true

View file

@ -30,6 +30,7 @@ Here's an overview of the general configuration, located in the `.env` file at t
> **Note:** OpenID does not support the ability to disable only registration.
>> **Quick Tip:** Even with registration disabled, add users directly to the database using `npm run create-user`. If you can't get npm to work, try `sudo docker exec -ti LibreChat sh` first to "ssh" into the container.
>> **Quick Tip:** To delete a user, you can run `docker-compose exec api npm run delete-user email@domain.com`
![image](https://github.com/danny-avila/LibreChat/assets/81851188/52a37d1d-7392-4a9a-a79f-90ed2da7f841)