|
34 | 34 | (let [chat-id* (atom nil)] |
35 | 35 | (testing "We send a simple hello message" |
36 | 36 | (llm.mocks/set-case! :simple-text-0) |
37 | | - (let [req-id 0 |
38 | | - resp (eca/request! (fixture/chat-prompt-request |
39 | | - {:request-id req-id |
40 | | - :model "my-provider/foo1" |
| 37 | + (let [resp (eca/request! (fixture/chat-prompt-request |
| 38 | + {:model "my-provider/foo1" |
41 | 39 | :message "Tell me a joke!"})) |
42 | 40 | chat-id (reset! chat-id* (:chatId resp))] |
43 | 41 |
|
|
47 | 45 | :status "success"} |
48 | 46 | resp)) |
49 | 47 |
|
50 | | - (match-content chat-id req-id "user" {:type "text" :text "Tell me a joke!\n"}) |
51 | | - (match-content chat-id req-id "system" {:type "progress" :state "running" :text "Waiting model"}) |
52 | | - (match-content chat-id req-id "system" {:type "progress" :state "running" :text "Generating"}) |
53 | | - (match-content chat-id req-id "assistant" {:type "text" :text "Knock"}) |
54 | | - (match-content chat-id req-id "assistant" {:type "text" :text " knock!"}) |
55 | | - (match-content chat-id req-id "system" {:type "usage" |
56 | | - :sessionTokens 30 |
57 | | - :lastMessageCost m/absent |
58 | | - :sessionCost m/absent}) |
59 | | - (match-content chat-id req-id "system" {:type "progress" :state "finished"}) |
| 48 | + (match-content chat-id "user" {:type "text" :text "Tell me a joke!\n"}) |
| 49 | + (match-content chat-id "system" {:type "progress" :state "running" :text "Waiting model"}) |
| 50 | + (match-content chat-id "system" {:type "progress" :state "running" :text "Generating"}) |
| 51 | + (match-content chat-id "assistant" {:type "text" :text "Knock"}) |
| 52 | + (match-content chat-id "assistant" {:type "text" :text " knock!"}) |
| 53 | + (match-content chat-id "system" {:type "usage" |
| 54 | + :sessionTokens 30 |
| 55 | + :lastMessageCost m/absent |
| 56 | + :sessionCost m/absent}) |
| 57 | + (match-content chat-id "system" {:type "progress" :state "finished"}) |
60 | 58 | (is (match? |
61 | 59 | {:input [{:role "user" :content [{:type "input_text" :text "Tell me a joke!"}]}] |
62 | 60 | :instructions (m/pred string?)} |
63 | 61 | llm.mocks/*last-req-body*)))) |
64 | 62 |
|
65 | 63 | (testing "We reply" |
66 | 64 | (llm.mocks/set-case! :simple-text-1) |
67 | | - (let [req-id 1 |
68 | | - resp (eca/request! (fixture/chat-prompt-request |
| 65 | + (let [resp (eca/request! (fixture/chat-prompt-request |
69 | 66 | {:chat-id @chat-id* |
70 | | - :request-id req-id |
71 | 67 | :model "my-provider/foo1" |
72 | 68 | :message "Who's there?"})) |
73 | 69 | chat-id @chat-id*] |
|
78 | 74 | :status "success"} |
79 | 75 | resp)) |
80 | 76 |
|
81 | | - (match-content chat-id req-id "user" {:type "text" :text "Who's there?\n"}) |
82 | | - (match-content chat-id req-id "system" {:type "progress" :state "running" :text "Waiting model"}) |
83 | | - (match-content chat-id req-id "system" {:type "progress" :state "running" :text "Generating"}) |
84 | | - (match-content chat-id req-id "assistant" {:type "text" :text "Foo"}) |
85 | | - (match-content chat-id req-id "system" {:type "usage" |
86 | | - :sessionTokens 15 |
87 | | - :lastMessageCost m/absent |
88 | | - :sessionCost m/absent}) |
89 | | - (match-content chat-id req-id "system" {:type "progress" :state "finished"}) |
| 77 | + (match-content chat-id "user" {:type "text" :text "Who's there?\n"}) |
| 78 | + (match-content chat-id "system" {:type "progress" :state "running" :text "Waiting model"}) |
| 79 | + (match-content chat-id "system" {:type "progress" :state "running" :text "Generating"}) |
| 80 | + (match-content chat-id "assistant" {:type "text" :text "Foo"}) |
| 81 | + (match-content chat-id "system" {:type "usage" |
| 82 | + :sessionTokens 15 |
| 83 | + :lastMessageCost m/absent |
| 84 | + :sessionCost m/absent}) |
| 85 | + (match-content chat-id "system" {:type "progress" :state "finished"}) |
90 | 86 | (is (match? |
91 | 87 | {:input [{:role "user" :content [{:type "input_text" :text "Tell me a joke!"}]} |
92 | 88 | {:role "assistant" :content [{:type "output_text" :text "Knock knock!"}]} |
|
95 | 91 |
|
96 | 92 | (testing "model reply again keeping context" |
97 | 93 | (llm.mocks/set-case! :simple-text-2) |
98 | | - (let [req-id 2 |
99 | | - resp (eca/request! (fixture/chat-prompt-request |
| 94 | + (let [resp (eca/request! (fixture/chat-prompt-request |
100 | 95 | {:chat-id @chat-id* |
101 | | - :request-id req-id |
102 | 96 | :model "my-provider/foo1" |
103 | 97 | :message "What foo?"})) |
104 | 98 | chat-id @chat-id*] |
|
109 | 103 | :status "success"} |
110 | 104 | resp)) |
111 | 105 |
|
112 | | - (match-content chat-id req-id "user" {:type "text" :text "What foo?\n"}) |
113 | | - (match-content chat-id req-id "system" {:type "progress" :state "running" :text "Waiting model"}) |
114 | | - (match-content chat-id req-id "system" {:type "progress" :state "running" :text "Generating"}) |
115 | | - (match-content chat-id req-id "assistant" {:type "text" :text "Foo"}) |
116 | | - (match-content chat-id req-id "assistant" {:type "text" :text " bar!"}) |
117 | | - (match-content chat-id req-id "assistant" {:type "text" :text "\n\n"}) |
118 | | - (match-content chat-id req-id "assistant" {:type "text" :text "Ha!"}) |
119 | | - (match-content chat-id req-id "system" {:type "usage" |
120 | | - :sessionTokens 20 |
121 | | - :lastMessageCost m/absent |
122 | | - :sessionCost m/absent}) |
123 | | - (match-content chat-id req-id "system" {:type "progress" :state "finished"}) |
| 106 | + (match-content chat-id "user" {:type "text" :text "What foo?\n"}) |
| 107 | + (match-content chat-id "system" {:type "progress" :state "running" :text "Waiting model"}) |
| 108 | + (match-content chat-id "system" {:type "progress" :state "running" :text "Generating"}) |
| 109 | + (match-content chat-id "assistant" {:type "text" :text "Foo"}) |
| 110 | + (match-content chat-id "assistant" {:type "text" :text " bar!"}) |
| 111 | + (match-content chat-id "assistant" {:type "text" :text "\n\n"}) |
| 112 | + (match-content chat-id "assistant" {:type "text" :text "Ha!"}) |
| 113 | + (match-content chat-id "system" {:type "usage" |
| 114 | + :sessionTokens 20 |
| 115 | + :lastMessageCost m/absent |
| 116 | + :sessionCost m/absent}) |
| 117 | + (match-content chat-id "system" {:type "progress" :state "finished"}) |
124 | 118 | (is (match? |
125 | 119 | {:input [{:role "user" :content [{:type "input_text" :text "Tell me a joke!"}]} |
126 | 120 | {:role "assistant" :content [{:type "output_text" :text "Knock knock!"}]} |
|
152 | 146 | (let [chat-id* (atom nil)] |
153 | 147 | (testing "We send a simple hello message" |
154 | 148 | (llm.mocks/set-case! :simple-text-0) |
155 | | - (let [req-id 0 |
156 | | - resp (eca/request! (fixture/chat-prompt-request |
157 | | - {:request-id req-id |
158 | | - :model "my-provider/deepseekcoder" |
| 149 | + (let [resp (eca/request! (fixture/chat-prompt-request |
| 150 | + {:model "my-provider/deepseekcoder" |
159 | 151 | :message "Tell me a joke!"})) |
160 | 152 | chat-id (reset! chat-id* (:chatId resp))] |
161 | 153 |
|
|
165 | 157 | :status "success"} |
166 | 158 | resp)) |
167 | 159 |
|
168 | | - (match-content chat-id req-id "user" {:type "text" :text "Tell me a joke!\n"}) |
169 | | - (match-content chat-id req-id "system" {:type "progress" :state "running" :text "Waiting model"}) |
170 | | - (match-content chat-id req-id "system" {:type "progress" :state "running" :text "Generating"}) |
171 | | - (match-content chat-id req-id "assistant" {:type "text" :text "Knock"}) |
172 | | - (match-content chat-id req-id "assistant" {:type "text" :text " knock!"}) |
173 | | - (match-content chat-id req-id "system" {:type "progress" :state "finished"}) |
| 160 | + (match-content chat-id "user" {:type "text" :text "Tell me a joke!\n"}) |
| 161 | + (match-content chat-id "system" {:type "progress" :state "running" :text "Waiting model"}) |
| 162 | + (match-content chat-id "system" {:type "progress" :state "running" :text "Generating"}) |
| 163 | + (match-content chat-id "assistant" {:type "text" :text "Knock"}) |
| 164 | + (match-content chat-id "assistant" {:type "text" :text " knock!"}) |
| 165 | + (match-content chat-id "system" {:type "progress" :state "finished"}) |
174 | 166 | (is (match? |
175 | 167 | {:input [{:role "user" :content [{:type "input_text" :text "Tell me a joke!"}]}] |
176 | 168 | :instructions (m/pred string?)} |
177 | 169 | llm.mocks/*last-req-body*)))) |
178 | 170 |
|
179 | 171 | (testing "We reply" |
180 | 172 | (llm.mocks/set-case! :simple-text-1) |
181 | | - (let [req-id 1 |
182 | | - resp (eca/request! (fixture/chat-prompt-request |
| 173 | + (let [resp (eca/request! (fixture/chat-prompt-request |
183 | 174 | {:chat-id @chat-id* |
184 | | - :request-id req-id |
185 | 175 | :model "my-provider/deepseekcoder" |
186 | 176 | :message "Who's there?"})) |
187 | 177 | chat-id @chat-id*] |
|
192 | 182 | :status "success"} |
193 | 183 | resp)) |
194 | 184 |
|
195 | | - (match-content chat-id req-id "user" {:type "text" :text "Who's there?\n"}) |
196 | | - (match-content chat-id req-id "system" {:type "progress" :state "running" :text "Waiting model"}) |
197 | | - (match-content chat-id req-id "system" {:type "progress" :state "running" :text "Generating"}) |
198 | | - (match-content chat-id req-id "assistant" {:type "text" :text "Foo"}) |
199 | | - (match-content chat-id req-id "system" {:type "progress" :state "finished"}) |
| 185 | + (match-content chat-id "user" {:type "text" :text "Who's there?\n"}) |
| 186 | + (match-content chat-id "system" {:type "progress" :state "running" :text "Waiting model"}) |
| 187 | + (match-content chat-id "system" {:type "progress" :state "running" :text "Generating"}) |
| 188 | + (match-content chat-id "assistant" {:type "text" :text "Foo"}) |
| 189 | + (match-content chat-id "system" {:type "progress" :state "finished"}) |
200 | 190 | (is (match? |
201 | 191 | {:input [{:role "user" :content [{:type "input_text" :text "Tell me a joke!"}]} |
202 | 192 | {:role "assistant" :content [{:type "output_text" :text "Knock knock!"}]} |
|
205 | 195 |
|
206 | 196 | (testing "model reply again keeping context" |
207 | 197 | (llm.mocks/set-case! :simple-text-2) |
208 | | - (let [req-id 2 |
209 | | - resp (eca/request! (fixture/chat-prompt-request |
| 198 | + (let [resp (eca/request! (fixture/chat-prompt-request |
210 | 199 | {:chat-id @chat-id* |
211 | | - :request-id req-id |
212 | 200 | :model "my-provider/deepseekcoder" |
213 | 201 | :message "What foo?"})) |
214 | 202 | chat-id @chat-id*] |
|
219 | 207 | :status "success"} |
220 | 208 | resp)) |
221 | 209 |
|
222 | | - (match-content chat-id req-id "user" {:type "text" :text "What foo?\n"}) |
223 | | - (match-content chat-id req-id "system" {:type "progress" :state "running" :text "Waiting model"}) |
224 | | - (match-content chat-id req-id "system" {:type "progress" :state "running" :text "Generating"}) |
225 | | - (match-content chat-id req-id "assistant" {:type "text" :text "Foo"}) |
226 | | - (match-content chat-id req-id "assistant" {:type "text" :text " bar!"}) |
227 | | - (match-content chat-id req-id "assistant" {:type "text" :text "\n\n"}) |
228 | | - (match-content chat-id req-id "assistant" {:type "text" :text "Ha!"}) |
229 | | - (match-content chat-id req-id "system" {:type "progress" :state "finished"}) |
| 210 | + (match-content chat-id "user" {:type "text" :text "What foo?\n"}) |
| 211 | + (match-content chat-id "system" {:type "progress" :state "running" :text "Waiting model"}) |
| 212 | + (match-content chat-id "system" {:type "progress" :state "running" :text "Generating"}) |
| 213 | + (match-content chat-id "assistant" {:type "text" :text "Foo"}) |
| 214 | + (match-content chat-id "assistant" {:type "text" :text " bar!"}) |
| 215 | + (match-content chat-id "assistant" {:type "text" :text "\n\n"}) |
| 216 | + (match-content chat-id "assistant" {:type "text" :text "Ha!"}) |
| 217 | + (match-content chat-id "system" {:type "progress" :state "finished"}) |
230 | 218 | (is (match? |
231 | 219 | {:input [{:role "user" :content [{:type "input_text" :text "Tell me a joke!"}]} |
232 | 220 | {:role "assistant" :content [{:type "output_text" :text "Knock knock!"}]} |
|
0 commit comments