Skip to content

Commit 4be31ef

Browse files
committed
Fix models with slash on custom provider
1 parent b4c7a3c commit 4be31ef

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

src/eca/config.clj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@
140140
models' (when models
141141
(into {}
142142
(map (fn [[k v]]
143-
[(if (or (keyword? k) (symbol? k)) (name k) (str k)) v])
143+
[(if (or (keyword? k) (symbol? k))
144+
(string/replace-first (str k) ":" "")
145+
(str k))
146+
v])
144147
models)))
145148
provider' (dissoc provider "models")]
146149
(if models'

src/eca/handlers.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
full-model (str provider "/" model)
2626
model-capabilities (merge
2727
(or (get all-models full-model)
28-
;; we guess the capabilities from
29-
;; the first model with same name
28+
;; we guess the capabilities from
29+
;; the first model with same name
3030
(when-let [found-full-model (first (filter #(= model (second (string/split % #"/" 2)))
3131
(keys all-models)))]
3232
(get all-models found-full-model))

test/eca/config_test.clj

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
(testing "providers and models are updated correctly"
2727
(reset! config/initialization-config* {:pureConfig true
2828
:providers {"customProvider" {:key "123"
29-
:models {:gpt-5 {}}}}})
29+
:models {:gpt-5 {}}}
30+
"openrouter" {:models {"openai/o4-mini" {}}}}})
3031
(is (match?
3132
{:pureConfig true
3233
:providers {"custom-provider" {:key "123"
33-
:models {"gpt-5" {}}}}}
34+
:models {"gpt-5" {}}}
35+
"openrouter" {:models {"openai/o4-mini" {}}}}}
3436
(config/all {})))))
3537

3638
(deftest deep-merge-test
@@ -69,3 +71,23 @@
6971
(#'config/deep-merge {:providers {"github-copilot" {:models {"gpt-5" {}}}}}
7072
{:pureConfig true
7173
:providers {"github-copilot" {:key "123"}}})))))
74+
75+
(deftest normalize-fields-test
76+
(is (match?
77+
{:pureConfig true
78+
:providers {"custom-provider" {:key "123"
79+
:models {"gpt-5" {}}}
80+
"openrouter" {:models {"openai/o4-mini" {}}}}}
81+
(#'config/normalize-fields {:pureConfig true
82+
:providers {"custom-provider" {:key "123"
83+
:models {"gpt-5" {}}}
84+
"openrouter" {:models {"openai/o4-mini" {}}}}})))
85+
(is (match?
86+
{:pureConfig true
87+
:providers {"custom-provider" {:key "123"
88+
:models {"gpt-5" {}}}
89+
"openrouter" {:models {"openai/o4-mini" {}}}}}
90+
(#'config/normalize-fields {:pureConfig true
91+
:providers {:customProvider {:key "123"
92+
:models {"gpt-5" {}}}
93+
:openrouter {:models {:openai/o4-mini {}}}}}))))

test/eca/test_helper.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747
(defn config! [config]
4848
(swap! components* update :config shared/deep-merge config))
4949

50-
(defn reset-components! [] (reset! components* (make-components)))
50+
(defn reset-components! []
51+
(reset! config/initialization-config* {})
52+
(reset! components* (make-components)))
5153
(defn reset-components-before-test []
5254
(use-fixtures :each (fn [f] (reset-components!) (f))))
5355
(defn reset-messenger! [] (swap! components* assoc :messenger (:messenger (make-components))))

0 commit comments

Comments
 (0)