Skip to content

Commit 7be2b6e

Browse files
committed
Add support for azure for /login
1 parent bec6afd commit 7be2b6e

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- openai
77
- openrouter
88
- deepseek
9+
- azure
910

1011
## 0.46.0
1112

src/eca/db.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
;; cacheable, bump cache when changing
3232
:chats {}
3333
:auth {"anthropic" {}
34+
"azure" {}
35+
"deepseek" {}
3436
"github-copilot" {}
3537
"openai" {}
36-
"openrouter" {}
37-
"deepseek" {}}})
38+
"openrouter" {}}})
3839

3940
(defonce db* (atom initial-db))
4041

src/eca/llm_api.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
[clojure.string :as string]
55
[eca.config :as config]
66
[eca.llm-providers.anthropic :as llm-providers.anthropic]
7+
[eca.llm-providers.azure]
78
[eca.llm-providers.copilot]
9+
[eca.llm-providers.deepseek]
810
[eca.llm-providers.ollama :as llm-providers.ollama]
911
[eca.llm-providers.openai :as llm-providers.openai]
1012
[eca.llm-providers.openai-chat :as llm-providers.openai-chat]
1113
[eca.llm-providers.openrouter]
12-
[eca.llm-providers.deepseek]
1314
[eca.llm-util :as llm-util]
1415
[eca.logger :as logger]))
1516

src/eca/llm_providers/azure.clj

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
(ns eca.llm-providers.azure
2+
(:require
3+
[clojure.string :as string]
4+
[eca.config :as config]
5+
[eca.features.login :as f.login]))
6+
7+
(defmethod f.login/login-step ["azure" :login/start] [{:keys [db* chat-id provider send-msg!]}]
8+
(swap! db* assoc-in [:chats chat-id :login-provider] provider)
9+
(swap! db* assoc-in [:auth provider] {:step :login/waiting-api-key})
10+
(send-msg! "Paste your API Key"))
11+
12+
(defmethod f.login/login-step ["azure" :login/waiting-api-key] [{:keys [input db* provider send-msg!]}]
13+
(swap! db* assoc-in [:auth provider] {:step :login/waiting-api-url
14+
:api-key input})
15+
(send-msg! "Inform the API URL (ex: 'https://your-resource-name.openai.azure.com'):"))
16+
17+
(defmethod f.login/login-step ["azure" :login/waiting-api-url] [{:keys [input db* provider send-msg!]}]
18+
(swap! db* update-in [:auth provider] merge {:step :login/waiting-models
19+
:url input})
20+
(send-msg! "Inform one or more models (separated by `,`):"))
21+
22+
(defmethod f.login/login-step ["azure" :login/waiting-models] [{:keys [input db* provider send-msg!] :as ctx}]
23+
(let [{:keys [api-url api-key]} (get-in @db* [:auth provider])]
24+
(config/update-global-config! {:providers {"azure" {:api "openai-responses"
25+
:url api-url
26+
:completionUrlRelativePath "/openai/responses?api-version=2025-04-01-preview"
27+
:models (reduce
28+
(fn [models model-str]
29+
(assoc models (string/trim model-str) {}))
30+
{}
31+
(string/split input #","))
32+
:key api-key}}}))
33+
(swap! db* assoc-in [:auth provider] nil)
34+
(send-msg! (format "API key, url and models saved to %s" (.getCanonicalPath (config/global-config-file))))
35+
(f.login/login-done! ctx))

0 commit comments

Comments
 (0)