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

chatapi/v1/got endpoint returns 200 with empty answer, bad OpenAI key #90

Open
jay-m-dev opened this issue May 15, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@jay-m-dev
Copy link
Collaborator

jay-m-dev commented May 15, 2024

Describe the bug
If the OPEN_AI_API Key is wrong or invalid, the chatapi/v1/got endpoint returns http code 200, but the "answer" is empty.
The DEBUG logs will show an error:

2024-05-15 21:50:32,910 DEBUG openai._base_client Thread-1 (process_request_thread) : HTTP Request: POST https://api.openai.com/v1/chat/completions "401 Unauthorized"
2024-05-15 21:50:32,911 INFO backoff Thread-1 (process_request_thread) : Backing off chat(...) for 0.7s (openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: 03********************5e. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}})

But this error is not being relayed by the chatapi/v1/got endpoint. The Frontend needs this information to display a helpful message to users.

To Reproduce
Steps to reproduce the behavior:

  1. Set an invalid OPENAI_API_KEY in the .env file
  2. Launch the backend server: docker compose up execgpt
  3. Call the POST chatapi/v1/got endpoint with a body similar to:
{
  "chatInput": "what genes are associated with Droperidol?"
}

The response comes back with an empty "answer" key and the DEBUG log shows the error above

Expected behavior
This endpoint needs to relay messages from calls to the OpenAI API.

@jay-m-dev jay-m-dev added the bug Something isn't working label May 22, 2024
@jay-m-dev jay-m-dev assigned jay-m-dev and unassigned jay-m-dev May 22, 2024
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

1 participant