Cinnamon / kotaemon

An open-source RAG-based tool for chatting with your documents.
https://cinnamon.github.io/kotaemon/
Apache License 2.0
17.7k stars 1.38k forks source link

[BUG] - OpenAI API not working #205

Closed tstanek390 closed 2 months ago

tstanek390 commented 2 months ago

Description

Whenever I put working (checked with other apps) OpenAI API key either to .env or to YAML in the app's interface Im getting the error below. Tried different brackets, quotation marks etc. but Im still unable to use openai api. Thanks for any help

Reproduction steps

1. Go to Resources settings in the app.
2. Click on Specification of the LLM in YAML format
3. Enter openAI API key
4. See error:  Connection failed. Got error: Error code: 401 - {'error': {'message': 'Incorrect API key provided: openai_key. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}.

Screenshots

![DESCRIPTION](LINK.png)

Logs

No response

Browsers

No response

OS

MacOS

Additional information

No response

EjbejaranosAI commented 2 months ago

I export the api key and then I run by terminal the app.py:

export OPENAI_API_KEY=sk- export GRAPHRAG_API_KEY=sk-pr

taprosoft commented 2 months ago

Can you test a quick curl command to see if API key is correct or is there any networking issue:

curl "https://api.openai.com/v1/chat/completions" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $OPENAI_API_KEY" \
    -d '{
        "model": "gpt-4o-mini",
        "messages": [
            {
                "role": "system",
                "content": "You are a helpful assistant."
            },
            {
                "role": "user",
                "content": "Write a haiku that explains the concept of recursion."
            }
        ]
    }'
tstanek390 commented 2 months ago

Something happened, probably the new app update, and it is working now. Thanks anyways!:)

ziudeso commented 2 months ago

Same error here

bytesfromali commented 2 months ago

any updates to this ?