brianpetro / obsidian-smart-connections

Chat with your notes & see links to related content with AI embeddings. Use local models or 100+ via APIs like Claude, Gemini, ChatGPT & Llama 3

Home Page:https://smartconnections.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

401 Unauthorized Error when trying to use chat

joshuadanpeterson opened this issue · comments

I'm getting an API error when I try to use the smart connections chat. I have the API key in place, but it won't let me choose a model. I checked the console and saw these errors:

POST https://api.openai.com/v1/chat/completions 401 (Unauthorized)
stream @ plugin:smart-connections:5647
full_text @ plugin:smart-connections:6278
stream @ plugin:smart-connections:6253
complete @ plugin:smart-connections:6115
await in complete (async)
new_user_message @ plugin:smart-connections:8053
await in new_user_message (async)
new_user_message @ plugin:smart-connections:8279
eval @ plugin:smart-connections:6664
plugin:smart-connections:6273 CustomEvent {isTrusted: false, data: '{\n    "error": {\n        "message": "Incorrect API… null,\n        "code": "invalid_api_key"\n    }\n}\n', source: SmartStreamer, detail: null, type: 'error', …}
eval @ plugin:smart-connections:6273
eval @ plugin:smart-connections:5623
dispatchEvent @ plugin:smart-connections:5622
onStreamFailure_fn @ plugin:smart-connections:5672
onStreamProgress_fn @ plugin:smart-connections:5685
XMLHttpRequest.send (async)
stream @ plugin:smart-connections:5647
full_text @ plugin:smart-connections:6278
stream @ plugin:smart-connections:6253
complete @ plugin:smart-connections:6115
await in complete (async)
new_user_message @ plugin:smart-connections:8053
await in new_user_message (async)
new_user_message @ plugin:smart-connections:8279
eval @ plugin:smart-connections:6664
plugin:smart-connections:6155 CustomEvent {isTrusted: false, data: '{\n    "error": {\n        "message": "Incorrect API… null,\n        "code": "invalid_api_key"\n    }\n}\n', source: SmartStreamer, detail: null, type: 'error', …}
complete @ plugin:smart-connections:6155
await in complete (async)
new_user_message @ plugin:smart-connections:8053
await in new_user_message (async)
new_user_message @ plugin:smart-connections:8279
eval @ plugin:smart-connections:6664
plugin:smart-connections:7379 chat_ml
Screenshot 2024-05-11 at 20 16 43

The chat worked for me for a little bit, but then it started giving me that message. I didn't do anything different. I even downloaded the update and restarted my Obsidian to see if that would make a difference and it didn't.

When I press "Refresh Model List", I get:

plugin:smart-connections:5864 
        
        
GET https://api.openai.com/v1/models 401 (Unauthorized)
fetch_openai_models @ plugin:smart-connections:5864
get_models @ plugin:smart-connections:6372
get_view_data @ plugin:smart-connections:7148
render @ plugin:smart-connections:6961
changed_smart_chat_model @ plugin:smart-connections:7123
await in changed_smart_chat_model (async)
eval @ plugin:smart-connections:7049
(anonymous) @ app.js:1
plugin:smart-connections:5887 Failed to fetch model data: Error: Network response was not ok
at Object.fetch_openai_models [as openai] (plugin:smart-connections:5870:17)
at async ScChatModel.get_models (plugin:smart-connections:6372:26)
at async SmartChatSettings.get_view_data (plugin:smart-connections:7148:42)
at async SmartChatSettings.render (plugin:smart-connections:6961:70)
Screenshot 2024-05-11 at 20 16 29

Is this still a problem? It should work if you have an API key connected. When you hit save the API key, does it say it was successful? 🌸

Is this still a problem? It should work if you have an API key connected. When you hit save the API key, does it say it was successful? 🌸

I updated the plugin and created a new API key. It works perfectly now.