Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Google Endpoint Balance Issues #4408

Open
1 task done
mattj2332 opened this issue Oct 15, 2024 · 2 comments
Open
1 task done

[Bug]: Google Endpoint Balance Issues #4408

mattj2332 opened this issue Oct 15, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@mattj2332
Copy link

mattj2332 commented Oct 15, 2024

What happened?

When CHECK_BALANCE is set to true, users are able to bypass the lack of tokens assigned to their account by switching to Google. OpenAI, Anthropic and all other providers honour the CHECK_BALANCE setting.

Currently running 0.7.5-rc2

Steps to Reproduce

  1. Set CHECK_BALANCE=true in .env
  2. Ensure that a valid API Key is present for Google and any other providers that will be tested.
  3. Start LibreChat
  4. Login with a user who has no balance assigned or insufficient balance
  5. Change the provider to Google
  6. Send a message

Step 6 should respond with insufficient funds.

Repeating steps 5 and 6 with OpenAI results in Insufficient Funds message as per screenshot

What browsers are you seeing the problem on?

No response

Relevant log output

No response

Screenshots

image

Code of Conduct

  • I agree to follow this project's Code of Conduct
@mattj2332 mattj2332 added the bug Something isn't working label Oct 15, 2024
@mattj2332 mattj2332 changed the title [Bug]: Google bypasses the LibreChat CHECK_BALANCE and allows chat despite the user having insufficient balance. [Bug]: CHECK_BALANCE not honoured by Google LLMS and allows chat despite the user having insufficient balance. Oct 15, 2024
@chihebIA
Copy link

chihebIA commented Oct 24, 2024


Issue: Balance Check Not Triggered for Google Endpoint

Problem:
The balance check functionality wasn't triggered for the Google endpoint due to the default configuration in supportsBalanceCheck not including Google.

Affected Code Snippet (api/app/clients/BaseClient.js):

if ( isEnabled(process.env.CHECK_BALANCE) && supportsBalanceCheck[this.options.endpointType ?? this.options.endpoint] ) { await checkBalance({ req: this.options.req, res: this.options.res, txData: { user: this.user, tokenType: 'prompt', amount: promptTokens, model: this.modelOptions.model, endpoint: this.options.endpoint, endpointTokenConfig: this.options.endpointTokenConfig, }, }); }

By default, the supportsBalanceCheck object didn't include Google as an endpoint for balance checking.

Solution:
To resolve this, I modified the supportsBalanceCheck configuration in packages/data-provider/src/config.ts to include Google. The change looks like this:

typescript

export const supportsBalanceCheck = { [EModelEndpoint.custom]: true, [EModelEndpoint.openAI]: true, [EModelEndpoint.anthropic]: true, [EModelEndpoint.gptPlugins]: true, [EModelEndpoint.assistants]: true, [EModelEndpoint.agents]: true, [EModelEndpoint.azureAssistants]: true, [EModelEndpoint.azureOpenAI]: true, [EModelEndpoint.bedrock]: true, [EModelEndpoint.google]: true, // Added Google endpoint };

With this addition, the balance check now works for the Google endpoint as expected.


@danny-avila danny-avila changed the title [Bug]: CHECK_BALANCE not honoured by Google LLMS and allows chat despite the user having insufficient balance. [Bug]: Google Endpoint Balance Issues Oct 30, 2024
@danny-avila
Copy link
Owner

Also #4580

The root cause of these issues is that Google had not published their prices for a long time when it was implemented, as their models were in "free trial."

I have a series of changes planned for the Google Endpoint that should address this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants