CodeGPT icon indicating copy to clipboard operation
CodeGPT copied to clipboard

can't use groq

Open dss99911 opened this issue 1 year ago • 10 comments

What happened?

Connection failed.

Incorrect API key provided: $CUSTOM_***********_KEY. You can find your API key at https://platform.openai.com/account/api-keys.

Relevant log output or stack trace

No response

Steps to reproduce

  1. get api key from https://groq.com/

  2. on codegpt setting,

  • select custom openai service
  • select 'Groq' on preset template
  • input api key
  • click test connection

the error below occurred

Connection failed.

Incorrect API key provided: $CUSTOM_***********_KEY. You can find your API key at
https://platform.openai.com/account/api-keys.

when I tested on curl below, it's working fine.

curl -X POST "https://api.groq.com/openai/v1/chat/completions" \
     -H "Authorization: Bearer $GROQ_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{"messages": [{"role": "user", "content": "Explain the importance of fast language models"}], "model": "mixtral-8x7b-32768"}'

CodeGPT version

2.6.3-241

Operating System

macOS

dss99911 avatar Apr 24 '24 19:04 dss99911

The error message indicates that 1) you're talking to openai.com, and 2) you're sending the literal string $CUSTOM_SERVICE_API_KEY as your api-key.

Can you verify that you have configured an custom URL and api-key in your CodeGPT plugin settings?

sisve avatar Apr 25 '24 03:04 sisve

when I select 'Groq' on preset template. it changes the URL to https://api.groq.com/openai/v1/chat/completions automatically. I used the url

dss99911 avatar Apr 25 '24 04:04 dss99911

image

dss99911 avatar Apr 25 '24 04:04 dss99911

Did you apply the settings before testing the connection? There's a small bug around that.

carlrobertoh avatar Apr 25 '24 05:04 carlrobertoh

the settings I mentioned above is applied before testing the connection

dss99911 avatar Apr 25 '24 05:04 dss99911

Same here since #476 has been merged, the wrong settings are being used for Custom OpenAI, depending on your application state. If you switch presets, the default settings are being applied (Ollama has no code completions, tab is disabled). If you reopen the settings dialog again, code completions becomes active with default settings for OpenAI (first FIM template autoselected), hence the Incorrect API key provided response for platform.openai.com (Ollama runs on localhost). So the user settings are being overwritten sometimes with "default values" or empty values depending on Preset template change, FIM template change, open settings dialog (init forms)... This feature is very flaky, I would suggest writing tests first for all supported services, models and FIM templates (success and errors like missing API key, unexpected API key, unexpected response). And especially changing user settings without the user knowing it, initializing forms shouldn't change persisted users settings but instead load them, but many more settings are changed/deleted/added depending on the selected Preset and FIM. Maybe it would be helpful if the listener would be usable with checked exceptions instead of RuntimeExceptions, so the application would have to handle all errors explicitly.

Incorrect API key provided: $CUSTOM_***********_KEY. You can find your API key at https://platform.openai.com/account/api-keys.

java.lang.RuntimeException
	at ee.carlrobert.llm.completion.CompletionEventSourceListener.onFailure(CompletionEventSourceListener.java:114)
	at okhttp3.internal.sse.RealEventSource.processResponse(RealEventSource.kt:52)

reneleonhardt avatar Apr 25 '24 05:04 reneleonhardt

thanks for the solution. but, I couldn't understand the detail.

  1. can it be fixed?
  2. is there workaround before it's fixed?

dss99911 avatar Apr 25 '24 06:04 dss99911

Never open settings again before the next CodeGPT release 😅 Before closing settings, make sure to switch the Preset template first and check all settings to be correct.

reneleonhardt avatar Apr 25 '24 06:04 reneleonhardt

@dss99911

is there workaround before it's fixed?

Delete CodeGPT_CustomServiceSettings.xml settings file from the options folder and restart your IDE.

https://intellij-support.jetbrains.com/hc/en-us/articles/206544519-Directories-used-by-the-IDE-to-store-settings-caches-plugins-and-logs

carlrobertoh avatar Apr 25 '24 11:04 carlrobertoh

This is fixed by https://github.com/carlrobertoh/CodeGPT/pull/531

Crustack avatar May 08 '24 10:05 Crustack