Skip to content

Commit 521f7e5

Browse files
author
Bruce Hauman
committed
Bump langchain4j to 1.12.2 and add new model configurations
- Update langchain4j deps from 1.8.0 to 1.12.2 - Add Anthropic models: claude-opus-4-6, claude-sonnet-4-6, claude-haiku-4-5 - Add OpenAI models: gpt-5-pro, gpt-5-codex, gpt-5.1 variants, gpt-5.2, gpt-5.4, o1-pro, and codex variants - Add model alias resolution for short names (sonnet, opus, haiku, flash, codex, etc.) usable from CLI and config - Replace removed CLAUDE_3_5_HAIKU_20241022 enum with CLAUDE_HAIKU_4_5_20251001 - Update tests and documentation for 44 total built-in models
1 parent f4c8872 commit 521f7e5

File tree

4 files changed

+181
-27
lines changed

4 files changed

+181
-27
lines changed

deps.edn

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
org.apache.tika/tika-core {:mvn/version "3.2.0"}
2626
io.modelcontextprotocol.sdk/mcp {:mvn/version "0.17.2"}
2727

28-
dev.langchain4j/langchain4j {:mvn/version "1.8.0"}
29-
dev.langchain4j/langchain4j-open-ai {:mvn/version "1.8.0"}
30-
dev.langchain4j/langchain4j-anthropic {:mvn/version "1.8.0"}
31-
dev.langchain4j/langchain4j-google-ai-gemini {:mvn/version "1.8.0"}
28+
dev.langchain4j/langchain4j {:mvn/version "1.12.2"}
29+
dev.langchain4j/langchain4j-open-ai {:mvn/version "1.12.2"}
30+
dev.langchain4j/langchain4j-anthropic {:mvn/version "1.12.2"}
31+
dev.langchain4j/langchain4j-google-ai-gemini {:mvn/version "1.12.2"}
3232

3333
com.taoensso/timbre {:mvn/version "6.8.0"}
3434

doc/model-configuration.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,16 @@ If a model key is not found in your custom configuration, the system automatical
230230

231231
## Built-in Models
232232

233-
The system includes 21 pre-configured models that can be used without configuration:
233+
The system includes 44 pre-configured models that can be used without configuration:
234234

235235
### OpenAI
236236
- `:openai/gpt-4o`
237-
- `:openai/gpt-4-1`
238-
- `:openai/gpt-4-1-mini`
239-
- `:openai/gpt-4-1-nano`
240-
- `:openai/o1`, `:openai/o1-mini`
237+
- `:openai/gpt-4-1`, `:openai/gpt-4-1-mini`, `:openai/gpt-4-1-nano`
238+
- `:openai/gpt-5`, `:openai/gpt-5-mini`, `:openai/gpt-5-nano`, `:openai/gpt-5-pro`, `:openai/gpt-5-codex`
239+
- `:openai/gpt-5-1`, `:openai/gpt-5-1-codex`, `:openai/gpt-5-1-codex-max`, `:openai/gpt-5-1-codex-mini`
240+
- `:openai/gpt-5-2`, `:openai/gpt-5-2-pro`, `:openai/gpt-5-2-codex`
241+
- `:openai/gpt-5-4`, `:openai/gpt-5-4-pro`
242+
- `:openai/o1`, `:openai/o1-mini`, `:openai/o1-pro`
241243
- `:openai/o3`, `:openai/o3-mini`, `:openai/o3-pro`
242244
- `:openai/o4-mini`, `:openai/o4-mini-reasoning`
243245

@@ -249,11 +251,13 @@ The system includes 21 pre-configured models that can be used without configurat
249251
- `:google/gemini-2-5-pro-reasoning`
250252

251253
### Anthropic
252-
- `:anthropic/claude-opus-4`
253-
- `:anthropic/claude-opus-4-reasoning`
254-
- `:anthropic/claude-3-5-haiku`
255-
- `:anthropic/claude-sonnet-4`
256-
- `:anthropic/claude-sonnet-4-reasoning`
254+
- `:anthropic/claude-opus-4-6`, `:anthropic/claude-opus-4-6-reasoning`
255+
- `:anthropic/claude-sonnet-4-6`, `:anthropic/claude-sonnet-4-6-reasoning`
256+
- `:anthropic/claude-opus-4-1`, `:anthropic/claude-opus-4-1-reasoning`
257+
- `:anthropic/claude-opus-4`, `:anthropic/claude-opus-4-reasoning`
258+
- `:anthropic/claude-sonnet-4-5`, `:anthropic/claude-sonnet-4-5-reasoning`
259+
- `:anthropic/claude-sonnet-4`, `:anthropic/claude-sonnet-4-reasoning`
260+
- `:anthropic/claude-haiku-4-5`
257261

258262
## API Keys
259263

src/clojure_mcp/agent/langchain/model.clj

Lines changed: 136 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,72 @@
5555

5656
:openai/gpt-5
5757
(merge model-base
58-
{:model-name "gpt-5-2025-08-07"
58+
{:model-name "gpt-5"
5959
:thinking {:effort :medium}})
6060

6161
:openai/gpt-5-mini
6262
(merge model-base
63-
{:model-name "gpt-5-mini-2025-08-07"
63+
{:model-name "gpt-5-mini"
6464
:thinking {:effort :medium}})
6565

6666
:openai/gpt-5-nano
6767
(merge model-base
68-
{:model-name "gpt-5-nano-2025-08-07"
68+
{:model-name "gpt-5-nano"
69+
:thinking {:effort :medium}})
70+
71+
:openai/gpt-5-pro
72+
(merge model-base
73+
{:model-name "gpt-5-pro"
74+
:thinking {:effort :medium}})
75+
76+
:openai/gpt-5-codex
77+
(merge model-base
78+
{:model-name "gpt-5-codex"
79+
:thinking {:effort :medium}})
80+
81+
:openai/gpt-5-1
82+
(merge model-base
83+
{:model-name "gpt-5.1"
84+
:thinking {:effort :medium}})
85+
86+
:openai/gpt-5-1-codex
87+
(merge model-base
88+
{:model-name "gpt-5.1-codex"
89+
:thinking {:effort :medium}})
90+
91+
:openai/gpt-5-1-codex-max
92+
(merge model-base
93+
{:model-name "gpt-5.1-codex-max"
94+
:thinking {:effort :medium}})
95+
96+
:openai/gpt-5-1-codex-mini
97+
(merge model-base
98+
{:model-name "gpt-5.1-codex-mini"
99+
:thinking {:effort :medium}})
100+
101+
:openai/gpt-5-2
102+
(merge model-base
103+
{:model-name "gpt-5.2"
104+
:thinking {:effort :medium}})
105+
106+
:openai/gpt-5-2-pro
107+
(merge model-base
108+
{:model-name "gpt-5.2-pro"
109+
:thinking {:effort :medium}})
110+
111+
:openai/gpt-5-2-codex
112+
(merge model-base
113+
{:model-name "gpt-5.2-codex"
114+
:thinking {:effort :medium}})
115+
116+
:openai/gpt-5-4
117+
(merge model-base
118+
{:model-name "gpt-5.4"
119+
:thinking {:effort :medium}})
120+
121+
:openai/gpt-5-4-pro
122+
(merge model-base
123+
{:model-name "gpt-5.4-pro"
69124
:thinking {:effort :medium}})
70125

71126
:openai/o1
@@ -78,6 +133,11 @@
78133
{:model-name "o1-mini"
79134
:thinking {:effort :medium}})
80135

136+
:openai/o1-pro
137+
(merge reasoning-model-base
138+
{:model-name "o1-pro"
139+
:thinking {:effort :medium}})
140+
81141
:openai/o3
82142
(merge reasoning-model-base
83143
{:model-name "o3"
@@ -90,7 +150,7 @@
90150

91151
:openai/o3-pro
92152
(merge reasoning-model-base
93-
{:model-name "o3-pro-2025-06-10"
153+
{:model-name "o3-pro"
94154
:thinking {:effort :medium}})
95155

96156
:openai/o4-mini
@@ -146,10 +206,30 @@
146206
:thinking (merge thinking-base
147207
{:budget-tokens 4096})})
148208

149-
:anthropic/claude-3-5-haiku
209+
:anthropic/claude-opus-4-6
210+
(merge model-base
211+
{:model-name AnthropicChatModelName/CLAUDE_OPUS_4_6})
212+
213+
:anthropic/claude-opus-4-6-reasoning
214+
(merge reasoning-model-base
215+
{:model-name AnthropicChatModelName/CLAUDE_OPUS_4_6
216+
:thinking (merge thinking-base
217+
{:budget-tokens 4096})})
218+
219+
:anthropic/claude-sonnet-4-6
220+
(merge model-base
221+
{:model-name AnthropicChatModelName/CLAUDE_SONNET_4_6})
222+
223+
:anthropic/claude-sonnet-4-6-reasoning
224+
(merge reasoning-model-base
225+
{:model-name AnthropicChatModelName/CLAUDE_SONNET_4_6
226+
:thinking (merge thinking-base
227+
{:budget-tokens 4096})})
228+
229+
:anthropic/claude-haiku-4-5
150230
(merge model-base
151-
{:model-name AnthropicChatModelName/CLAUDE_3_5_HAIKU_20241022
152-
:max-tokens 2048}) ; Haiku has lower default max tokens
231+
{:model-name AnthropicChatModelName/CLAUDE_HAIKU_4_5_20251001
232+
:max-tokens 2048})
153233

154234
:anthropic/claude-sonnet-4
155235
(merge model-base
@@ -171,6 +251,51 @@
171251
:thinking (merge thinking-base
172252
{:budget-tokens 4096})})})
173253

254+
(def model-aliases
255+
"Short aliases for commonly used models. Aliases are unnamespaced keywords
256+
that resolve to full model keys."
257+
{;; Anthropic aliases
258+
:sonnet :anthropic/claude-sonnet-4-6
259+
:opus :anthropic/claude-opus-4-6
260+
:haiku :anthropic/claude-haiku-4-5
261+
:sonnet-4-6 :anthropic/claude-sonnet-4-6
262+
:opus-4-6 :anthropic/claude-opus-4-6
263+
:sonnet-4-5 :anthropic/claude-sonnet-4-5
264+
:opus-4-1 :anthropic/claude-opus-4-1
265+
:opus-4 :anthropic/claude-opus-4
266+
:sonnet-4 :anthropic/claude-sonnet-4
267+
;; Anthropic reasoning aliases
268+
:sonnet-reasoning :anthropic/claude-sonnet-4-6-reasoning
269+
:opus-reasoning :anthropic/claude-opus-4-6-reasoning
270+
;; Google aliases
271+
:flash :google/gemini-2-5-flash
272+
:flash-lite :google/gemini-2-5-flash-lite
273+
:gemini-pro :google/gemini-2-5-pro
274+
:flash-reasoning :google/gemini-2-5-flash-reasoning
275+
:gemini-pro-reasoning :google/gemini-2-5-pro-reasoning
276+
;; OpenAI aliases
277+
:gpt-5-4 :openai/gpt-5-4
278+
:gpt-5-4-pro :openai/gpt-5-4-pro
279+
:gpt-5-2 :openai/gpt-5-2
280+
:gpt-5-1 :openai/gpt-5-1
281+
:gpt-5 :openai/gpt-5
282+
:o4-mini :openai/o4-mini
283+
:o3 :openai/o3
284+
:o3-pro :openai/o3-pro
285+
;; Codex aliases
286+
:codex :openai/gpt-5-4-pro
287+
:gpt-5-1-codex :openai/gpt-5-1-codex
288+
:gpt-5-1-codex-max :openai/gpt-5-1-codex-max
289+
:gpt-5-2-codex :openai/gpt-5-2-codex})
290+
291+
(defn resolve-model-alias
292+
"Resolves a model key, checking aliases for unnamespaced keywords.
293+
Returns the resolved key (which may be the same as the input)."
294+
[model-key]
295+
(if (and (keyword? model-key) (nil? (namespace model-key)))
296+
(get model-aliases model-key model-key)
297+
model-key))
298+
174299
(defn get-provider [model-key]
175300
(-> model-key namespace keyword))
176301

@@ -405,7 +530,8 @@
405530
([model-key config-overrides]
406531
(create-model-builder model-key config-overrides {:validate? true}))
407532
([model-key config-overrides {:keys [validate?] :or {validate? true}}]
408-
(let [;; Resolve env refs in config overrides
533+
(let [model-key (resolve-model-alias model-key)
534+
;; Resolve env refs in config overrides
409535
resolved-overrides (resolve-env-refs config-overrides)
410536
base-config (merge-with-defaults model-key resolved-overrides)
411537
config (-> base-config
@@ -499,7 +625,8 @@
499625
([nrepl-client-map model-key config-overrides]
500626
(create-model-builder-from-config nrepl-client-map model-key config-overrides {:validate? true}))
501627
([nrepl-client-map model-key config-overrides {:keys [validate?] :or {validate? true} :as _options}]
502-
(let [user-models (config/get-models nrepl-client-map)
628+
(let [model-key (resolve-model-alias model-key)
629+
user-models (config/get-models nrepl-client-map)
503630
;; Look in user config first, then defaults
504631
base-config (or (get user-models model-key)
505632
(get default-configs model-key))

test/clojure_mcp/agent/langchain/model_test.clj

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,23 @@
2020
(is (contains? (set models) :openai/gpt-4-1))
2121
(is (contains? (set models) :openai/gpt-4-1-mini))
2222
(is (contains? (set models) :openai/gpt-4-1-nano))
23+
(is (contains? (set models) :openai/gpt-5))
24+
(is (contains? (set models) :openai/gpt-5-mini))
25+
(is (contains? (set models) :openai/gpt-5-nano))
26+
(is (contains? (set models) :openai/gpt-5-pro))
27+
(is (contains? (set models) :openai/gpt-5-codex))
28+
(is (contains? (set models) :openai/gpt-5-1))
29+
(is (contains? (set models) :openai/gpt-5-1-codex))
30+
(is (contains? (set models) :openai/gpt-5-1-codex-max))
31+
(is (contains? (set models) :openai/gpt-5-1-codex-mini))
32+
(is (contains? (set models) :openai/gpt-5-2))
33+
(is (contains? (set models) :openai/gpt-5-2-pro))
34+
(is (contains? (set models) :openai/gpt-5-2-codex))
35+
(is (contains? (set models) :openai/gpt-5-4))
36+
(is (contains? (set models) :openai/gpt-5-4-pro))
2337
(is (contains? (set models) :openai/o1))
2438
(is (contains? (set models) :openai/o1-mini))
39+
(is (contains? (set models) :openai/o1-pro))
2540
(is (contains? (set models) :openai/o3))
2641
(is (contains? (set models) :openai/o3-mini))
2742
(is (contains? (set models) :openai/o3-pro))
@@ -36,10 +51,18 @@
3651
;; Anthropic models
3752
(is (contains? (set models) :anthropic/claude-opus-4))
3853
(is (contains? (set models) :anthropic/claude-opus-4-reasoning))
39-
(is (contains? (set models) :anthropic/claude-3-5-haiku))
54+
(is (contains? (set models) :anthropic/claude-opus-4-1))
55+
(is (contains? (set models) :anthropic/claude-opus-4-1-reasoning))
56+
(is (contains? (set models) :anthropic/claude-opus-4-6))
57+
(is (contains? (set models) :anthropic/claude-opus-4-6-reasoning))
4058
(is (contains? (set models) :anthropic/claude-sonnet-4))
4159
(is (contains? (set models) :anthropic/claude-sonnet-4-reasoning))
42-
(is (= 28 (count models))))))
60+
(is (contains? (set models) :anthropic/claude-sonnet-4-5))
61+
(is (contains? (set models) :anthropic/claude-sonnet-4-5-reasoning))
62+
(is (contains? (set models) :anthropic/claude-sonnet-4-6))
63+
(is (contains? (set models) :anthropic/claude-sonnet-4-6-reasoning))
64+
(is (contains? (set models) :anthropic/claude-haiku-4-5))
65+
(is (= 44 (count models))))))
4366

4467
(deftest test-get-provider
4568
(testing "Provider extraction from model keys"
@@ -96,7 +119,7 @@
96119

97120
(testing "New Anthropic models"
98121
(let [opus (model/create-model-builder :anthropic/claude-opus-4 {})
99-
haiku (model/create-model-builder :anthropic/claude-3-5-haiku {})]
122+
haiku (model/create-model-builder :anthropic/claude-haiku-4-5 {})]
100123
(is (instance? AnthropicChatModel$AnthropicChatModelBuilder opus))
101124
(is (instance? AnthropicChatModel$AnthropicChatModelBuilder haiku))))
102125

@@ -107,7 +130,7 @@
107130
(is (= :medium (get-in o3-pro-config [:thinking :effort])))))
108131

109132
(testing "Haiku has lower max tokens"
110-
(let [haiku-config (model/merge-with-defaults :anthropic/claude-3-5-haiku {})]
133+
(let [haiku-config (model/merge-with-defaults :anthropic/claude-haiku-4-5 {})]
111134
(is (= 2048 (:max-tokens haiku-config)))))
112135

113136
(testing "Opus reasoning has budget tokens configured"

0 commit comments

Comments
 (0)