Skip to content

Commit dd9b88c

Browse files
committed
Fix integration tests
1 parent ea083cc commit dd9b88c

File tree

6 files changed

+54
-97
lines changed

6 files changed

+54
-97
lines changed

integration-test/integration/chat/anthropic_test.clj

Lines changed: 37 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@
3737
(match-content chat-id req-id "assistant" {:type "text" :text "Knock"})
3838
(match-content chat-id req-id "assistant" {:type "text" :text " knock!"})
3939
(match-content chat-id req-id "system" {:type "usage"
40-
:messageInputTokens 10
41-
:messageOutputTokens 20
4240
:sessionTokens 30
43-
:messageCost (m/pred string?)
41+
:lastMessageCost (m/pred string?)
4442
:sessionCost (m/pred string?)})
4543
(match-content chat-id req-id "system" {:type "progress" :state "finished"})
4644
(is (match?
@@ -69,16 +67,14 @@
6967
(match-content chat-id req-id "system" {:type "progress" :state "running" :text "Generating"})
7068
(match-content chat-id req-id "assistant" {:type "text" :text "Foo"})
7169
(match-content chat-id req-id "system" {:type "usage"
72-
:messageInputTokens 10
73-
:messageOutputTokens 5
74-
:sessionTokens 45
75-
:messageCost (m/pred string?)
70+
:sessionTokens 15
71+
:lastMessageCost (m/pred string?)
7672
:sessionCost (m/pred string?)})
7773
(match-content chat-id req-id "system" {:type "progress" :state "finished"})
7874
(is (match?
7975
{:messages [{:role "user" :content [{:type "text" :text "Tell me a joke!"}]}
80-
{:role "assistant" :content [{:type "text" :text "Knock knock!"}]}
81-
{:role "user" :content [{:type "text" :text "Who's there?"}]}]}
76+
{:role "assistant" :content [{:type "text" :text "Knock knock!"}]}
77+
{:role "user" :content [{:type "text" :text "Who's there?"}]}]}
8278
llm.mocks/*last-req-body*))))
8379

8480
(testing "model reply again keeping context"
@@ -105,18 +101,16 @@
105101
(match-content chat-id req-id "assistant" {:type "text" :text "\n\n"})
106102
(match-content chat-id req-id "assistant" {:type "text" :text "Ha!"})
107103
(match-content chat-id req-id "system" {:type "usage"
108-
:messageInputTokens 5
109-
:messageOutputTokens 15
110-
:sessionTokens 65
111-
:messageCost (m/pred string?)
104+
:sessionTokens 20
105+
:lastMessageCost (m/pred string?)
112106
:sessionCost (m/pred string?)})
113107
(match-content chat-id req-id "system" {:type "progress" :state "finished"})
114108
(is (match?
115109
{:messages [{:role "user" :content [{:type "text" :text "Tell me a joke!"}]}
116-
{:role "assistant" :content [{:type "text" :text "Knock knock!"}]}
117-
{:role "user" :content [{:type "text" :text "Who's there?"}]}
118-
{:role "assistant" :content [{:type "text" :text "Foo"}]}
119-
{:role "user" :content [{:type "text" :text "What foo?"}]}]}
110+
{:role "assistant" :content [{:type "text" :text "Knock knock!"}]}
111+
{:role "user" :content [{:type "text" :text "Who's there?"}]}
112+
{:role "assistant" :content [{:type "text" :text "Foo"}]}
113+
{:role "user" :content [{:type "text" :text "What foo?"}]}]}
120114
llm.mocks/*last-req-body*))))))
121115

122116
(deftest reasoning-text
@@ -150,10 +144,8 @@
150144
(match-content chat-id req-id "assistant" {:type "text" :text "hello"})
151145
(match-content chat-id req-id "assistant" {:type "text" :text " there!"})
152146
(match-content chat-id req-id "system" {:type "usage"
153-
:messageInputTokens 5
154-
:messageOutputTokens 30
155147
:sessionTokens 35
156-
:messageCost (m/pred string?)
148+
:lastMessageCost (m/pred string?)
157149
:sessionCost (m/pred string?)})
158150
(match-content chat-id req-id "system" {:type "progress" :state "finished"})
159151
(is (match?
@@ -187,20 +179,18 @@
187179
(match-content chat-id req-id "assistant" {:type "text" :text "I'm "})
188180
(match-content chat-id req-id "assistant" {:type "text" :text " fine"})
189181
(match-content chat-id req-id "system" {:type "usage"
190-
:messageInputTokens 10
191-
:messageOutputTokens 20
192-
:sessionTokens 65
193-
:messageCost (m/pred string?)
182+
:sessionTokens 30
183+
:lastMessageCost (m/pred string?)
194184
:sessionCost (m/pred string?)})
195185
(match-content chat-id req-id "system" {:type "progress" :state "finished"})
196186
(is (match?
197187
{:messages [{:role "user" :content [{:type "text" :text "hello!"}]}
198-
{:role "assistant"
199-
:content [{:type "thinking"
200-
:signature "enc-123"
201-
:thinking "I should say hello"}]}
202-
{:role "assistant" :content [{:type "text" :text "hello there!"}]}
203-
{:role "user" :content [{:type "text" :text "how are you?"}]}]
188+
{:role "assistant"
189+
:content [{:type "thinking"
190+
:signature "enc-123"
191+
:thinking "I should say hello"}]}
192+
{:role "assistant" :content [{:type "text" :text "hello there!"}]}
193+
{:role "user" :content [{:type "text" :text "how are you?"}]}]
204194
:system (m/pred vector?)}
205195
llm.mocks/*last-req-body*))))))
206196

@@ -255,10 +245,8 @@
255245
:manualApproval false
256246
:summary "Listing file tree"})
257247
(match-content chat-id req-id "system" {:type "usage"
258-
:messageInputTokens 5
259-
:messageOutputTokens 30
260248
:sessionTokens 35
261-
:messageCost (m/pred string?)
249+
:lastMessageCost (m/pred string?)
262250
:sessionCost (m/pred string?)})
263251
(match-content chat-id req-id "assistant" {:type "toolCallRun"
264252
:origin "native"
@@ -279,31 +267,25 @@
279267
"0 directories, 2 files")}]})
280268
(match-content chat-id req-id "assistant" {:type "text" :text "The files I see:\n"})
281269
(match-content chat-id req-id "assistant" {:type "text" :text "file1\nfile2\n"})
282-
(match-content chat-id req-id "system" {:type "usage"
283-
:messageInputTokens 5
284-
:messageOutputTokens 30
285-
:sessionTokens 70
286-
:messageCost (m/pred string?)
287-
:sessionCost (m/pred string?)})
288270
(match-content chat-id req-id "system" {:type "progress" :state "finished"})
289271
(is (match?
290272
{:messages [{:role "user" :content [{:type "text" :text "What files you see?"}]}
291-
{:role "assistant"
292-
:content [{:type "thinking"
293-
:signature "enc-123"
294-
:thinking "I should call tool eca_directory_tree"}]}
295-
{:role "assistant" :content [{:type "text" :text "I will list files"}]}
296-
{:role "assistant"
297-
:content [{:type "tool_use"
298-
:id "tool-1"
299-
:name "eca_directory_tree"
300-
:input {:path (h/project-path->canon-path "resources")}}]}
301-
{:role "user"
302-
:content [{:type "tool_result"
303-
:tool_use_id "tool-1"
304-
:content (str "├── file1.md\n"
305-
"└── file2.md\n\n"
306-
"0 directories, 2 files\n")}]}]
273+
{:role "assistant"
274+
:content [{:type "thinking"
275+
:signature "enc-123"
276+
:thinking "I should call tool eca_directory_tree"}]}
277+
{:role "assistant" :content [{:type "text" :text "I will list files"}]}
278+
{:role "assistant"
279+
:content [{:type "tool_use"
280+
:id "tool-1"
281+
:name "eca_directory_tree"
282+
:input {:path (h/project-path->canon-path "resources")}}]}
283+
{:role "user"
284+
:content [{:type "tool_result"
285+
:tool_use_id "tool-1"
286+
:content (str "├── file1.md\n"
287+
"└── file2.md\n\n"
288+
"0 directories, 2 files\n")}]}]
307289
:tools (m/embeds
308290
[{:name "eca_directory_tree"}])
309291
:system (m/pred vector?)}

integration-test/integration/chat/custom_provider_test.clj

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@
5353
(match-content chat-id req-id "assistant" {:type "text" :text "Knock"})
5454
(match-content chat-id req-id "assistant" {:type "text" :text " knock!"})
5555
(match-content chat-id req-id "system" {:type "usage"
56-
:messageInputTokens 10
57-
:messageOutputTokens 20
5856
:sessionTokens 30
59-
:messageCost m/absent
57+
:lastMessageCost m/absent
6058
:sessionCost m/absent})
6159
(match-content chat-id req-id "system" {:type "progress" :state "finished"})
6260
(is (match?
@@ -85,10 +83,8 @@
8583
(match-content chat-id req-id "system" {:type "progress" :state "running" :text "Generating"})
8684
(match-content chat-id req-id "assistant" {:type "text" :text "Foo"})
8785
(match-content chat-id req-id "system" {:type "usage"
88-
:messageInputTokens 10
89-
:messageOutputTokens 5
90-
:sessionTokens 45
91-
:messageCost m/absent
86+
:sessionTokens 15
87+
:lastMessageCost m/absent
9288
:sessionCost m/absent})
9389
(match-content chat-id req-id "system" {:type "progress" :state "finished"})
9490
(is (match?
@@ -121,10 +117,8 @@
121117
(match-content chat-id req-id "assistant" {:type "text" :text "\n\n"})
122118
(match-content chat-id req-id "assistant" {:type "text" :text "Ha!"})
123119
(match-content chat-id req-id "system" {:type "usage"
124-
:messageInputTokens 5
125-
:messageOutputTokens 15
126-
:sessionTokens 65
127-
:messageCost m/absent
120+
:sessionTokens 20
121+
:lastMessageCost m/absent
128122
:sessionCost m/absent})
129123
(match-content chat-id req-id "system" {:type "progress" :state "finished"})
130124
(is (match?

integration-test/integration/chat/ollama_test.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@
257257
:arguments {:path (h/project-path->canon-path "resources")}
258258
:summary "Listing file tree"
259259
:origin "native"}}]}
260-
{:role "tool" :content (str "├── file1.md\n"
261-
"└── file2.md\n\n"
260+
{:role "tool" :content (str "├── file1.md\n"
261+
"└── file2.md\n\n"
262262
"0 directories, 2 files\n")}]
263263
:tools (m/embeds [{:type "function" :function {:name "eca_directory_tree"}}])}
264264
llm.mocks/*last-req-body*))))))

integration-test/integration/chat/openai_test.clj

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@
3737
(match-content chat-id req-id "assistant" {:type "text" :text "Knock"})
3838
(match-content chat-id req-id "assistant" {:type "text" :text " knock!"})
3939
(match-content chat-id req-id "system" {:type "usage"
40-
:messageInputTokens 10
41-
:messageOutputTokens 20
4240
:sessionTokens 30
43-
:messageCost (m/pred string?)
41+
:lastMessageCost (m/pred string?)
4442
:sessionCost (m/pred string?)})
4543
(match-content chat-id req-id "system" {:type "progress" :state "finished"})
4644
(is (match?
@@ -69,10 +67,8 @@
6967
(match-content chat-id req-id "system" {:type "progress" :state "running" :text "Generating"})
7068
(match-content chat-id req-id "assistant" {:type "text" :text "Foo"})
7169
(match-content chat-id req-id "system" {:type "usage"
72-
:messageInputTokens 10
73-
:messageOutputTokens 5
74-
:sessionTokens 45
75-
:messageCost (m/pred string?)
70+
:sessionTokens 15
71+
:lastMessageCost (m/pred string?)
7672
:sessionCost (m/pred string?)})
7773
(match-content chat-id req-id "system" {:type "progress" :state "finished"})
7874
(is (match?
@@ -105,10 +101,8 @@
105101
(match-content chat-id req-id "assistant" {:type "text" :text "\n\n"})
106102
(match-content chat-id req-id "assistant" {:type "text" :text "Ha!"})
107103
(match-content chat-id req-id "system" {:type "usage"
108-
:messageInputTokens 5
109-
:messageOutputTokens 15
110-
:sessionTokens 65
111-
:messageCost (m/pred string?)
104+
:sessionTokens 20
105+
:lastMessageCost (m/pred string?)
112106
:sessionCost (m/pred string?)})
113107
(match-content chat-id req-id "system" {:type "progress" :state "finished"})
114108
(is (match?
@@ -150,10 +144,8 @@
150144
(match-content chat-id req-id "assistant" {:type "text" :text "hello"})
151145
(match-content chat-id req-id "assistant" {:type "text" :text " there!"})
152146
(match-content chat-id req-id "system" {:type "usage"
153-
:messageInputTokens 5
154-
:messageOutputTokens 30
155147
:sessionTokens 35
156-
:messageCost (m/pred string?)
148+
:lastMessageCost (m/pred string?)
157149
:sessionCost (m/pred string?)})
158150
(match-content chat-id req-id "system" {:type "progress" :state "finished"})
159151
(is (match?
@@ -187,10 +179,8 @@
187179
(match-content chat-id req-id "assistant" {:type "text" :text "I'm "})
188180
(match-content chat-id req-id "assistant" {:type "text" :text " fine"})
189181
(match-content chat-id req-id "system" {:type "usage"
190-
:messageInputTokens 10
191-
:messageOutputTokens 20
192-
:sessionTokens 65
193-
:messageCost (m/pred string?)
182+
:sessionTokens 30
183+
:lastMessageCost (m/pred string?)
194184
:sessionCost (m/pred string?)})
195185
(match-content chat-id req-id "system" {:type "progress" :state "finished"})
196186
(is (match?
@@ -255,10 +245,8 @@
255245
:manualApproval false
256246
:summary "Listing file tree"})
257247
(match-content chat-id req-id "system" {:type "usage"
258-
:messageInputTokens 5
259-
:messageOutputTokens 30
260248
:sessionTokens 35
261-
:messageCost (m/pred string?)
249+
:lastMessageCost (m/pred string?)
262250
:sessionCost (m/pred string?)})
263251
(match-content chat-id req-id "assistant" {:type "toolCallRun"
264252
:origin "native"
@@ -279,12 +267,6 @@
279267
"0 directories, 2 files")}]})
280268
(match-content chat-id req-id "assistant" {:type "text" :text "The files I see:\n"})
281269
(match-content chat-id req-id "assistant" {:type "text" :text "file1\nfile2\n"})
282-
(match-content chat-id req-id "system" {:type "usage"
283-
:messageInputTokens 5
284-
:messageOutputTokens 30
285-
:sessionTokens 70
286-
:messageCost (m/pred string?)
287-
:sessionCost (m/pred string?)})
288270
(match-content chat-id req-id "system" {:type "progress" :state "finished"})
289271
(is (match?
290272
{:input [{:role "user" :content [{:type "input_text" :text "What files you see?"}]}

src/eca/config.clj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
[cheshire.core :as json]
1111
[cheshire.factory :as json.factory]
1212
[clojure.core.memoize :as memoize]
13-
[clojure.data :as data]
1413
[clojure.java.io :as io]
1514
[clojure.string :as string]
1615
[eca.logger :as logger]

0 commit comments

Comments
 (0)