Skip to content

Commit 791f034

Browse files
committed
Improve error message
1 parent f89dc73 commit 791f034

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Improve api url error message when not configured.
6+
57
## 0.36.3
68

79
- Fix `anthropic/claude-3-5-haiku-20241022` model.

src/eca/features/commands.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
(update-some :verifier shared/obfuscate)
141141
(update-some :device-code shared/obfuscate)
142142
(update-some :access-token shared/obfuscate)
143+
(update-some :refresh-token shared/obfuscate)
143144
(update-some :api-key shared/obfuscate)) "\n"))
144145
"\n"
145146
(:auth db)))

src/eca/llm_api.clj

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@
109109
provider-config (get-in config [:providers provider])
110110
model-config (get-in provider-config [:models model])
111111
extra-payload (:extraPayload model-config)
112-
provider-api-key (provider-api-key provider provider-auth config)
113-
provider-api-url (provider-api-url provider config)
112+
api-key (provider-api-key provider provider-auth config)
113+
api-url (provider-api-url provider config)
114114
provider-auth-type (:type provider-auth)
115115
callbacks {:on-message-received on-message-received-wrapper
116116
:on-error on-error-wrapper
@@ -119,6 +119,7 @@
119119
:on-reason on-reason-wrapper
120120
:on-usage-updated on-usage-updated}]
121121
(try
122+
(when-not api-url (throw (ex-info (format "API url not found.\nMake sure you have provider '%s' configured properly." provider) {})))
122123
(cond
123124
(= "openai" provider)
124125
(llm-providers.openai/completion!
@@ -131,8 +132,8 @@
131132
:tools tools
132133
:web-search web-search
133134
:extra-payload extra-payload
134-
:api-url provider-api-url
135-
:api-key provider-api-key}
135+
:api-url api-url
136+
:api-key api-key}
136137
callbacks)
137138

138139
(= "anthropic" provider)
@@ -146,8 +147,8 @@
146147
:tools tools
147148
:web-search web-search
148149
:extra-payload extra-payload
149-
:api-url provider-api-url
150-
:api-key provider-api-key
150+
:api-url api-url
151+
:api-key api-key
151152
:auth-type provider-auth-type}
152153
callbacks)
153154

@@ -161,8 +162,8 @@
161162
:past-messages past-messages
162163
:tools tools
163164
:extra-payload extra-payload
164-
:api-url provider-api-url
165-
:api-key provider-api-key
165+
:api-url api-url
166+
:api-key api-key
166167
:extra-headers {"openai-intent" "conversation-panel"
167168
"x-request-id" (str (random-uuid))
168169
"vscode-sessionid" ""
@@ -172,7 +173,7 @@
172173

173174
(= "ollama" provider)
174175
(llm-providers.ollama/completion!
175-
{:api-url provider-api-url
176+
{:api-url api-url
176177
:reason? (:reason? model-capabilities)
177178
:model model
178179
:instructions instructions
@@ -200,8 +201,8 @@
200201
:tools tools
201202
:extra-payload extra-payload
202203
:url-relative-path url-relative-path
203-
:api-url provider-api-url
204-
:api-key provider-api-key}
204+
:api-url api-url
205+
:api-key api-key}
205206
callbacks))
206207

207208
:else

0 commit comments

Comments
 (0)