Skip to content

Commit 1c50b15

Browse files
committed
Remove the need to pass requestId on prompt messages.
1 parent 0253514 commit 1c50b15

File tree

12 files changed

+514
-617
lines changed

12 files changed

+514
-617
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Remove the need to pass `requestId` on prompt messages.
6+
57
## 0.45.0
68

79
- Support user configured custom tools via `customTools` config. #92

docs/protocol.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,6 @@ interface ChatPromptParams {
215215
* The chat session identifier. If not provided, a new chat session will be created.
216216
*/
217217
chatId?: string;
218-
219-
/**
220-
* This message unique identifier used to match with next async messages.
221-
*/
222-
requestId: string;
223218

224219
/**
225220
* The message from the user in native language

integration-test/integration/chat/anthropic_test.clj

Lines changed: 119 additions & 131 deletions
Large diffs are not rendered by default.

integration-test/integration/chat/custom_provider_test.clj

Lines changed: 58 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@
3434
(let [chat-id* (atom nil)]
3535
(testing "We send a simple hello message"
3636
(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"
4139
:message "Tell me a joke!"}))
4240
chat-id (reset! chat-id* (:chatId resp))]
4341

@@ -47,27 +45,25 @@
4745
:status "success"}
4846
resp))
4947

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"})
6058
(is (match?
6159
{:input [{:role "user" :content [{:type "input_text" :text "Tell me a joke!"}]}]
6260
:instructions (m/pred string?)}
6361
llm.mocks/*last-req-body*))))
6462

6563
(testing "We reply"
6664
(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
6966
{:chat-id @chat-id*
70-
:request-id req-id
7167
:model "my-provider/foo1"
7268
:message "Who's there?"}))
7369
chat-id @chat-id*]
@@ -78,15 +74,15 @@
7874
:status "success"}
7975
resp))
8076

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"})
9086
(is (match?
9187
{:input [{:role "user" :content [{:type "input_text" :text "Tell me a joke!"}]}
9288
{:role "assistant" :content [{:type "output_text" :text "Knock knock!"}]}
@@ -95,10 +91,8 @@
9591

9692
(testing "model reply again keeping context"
9793
(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
10095
{:chat-id @chat-id*
101-
:request-id req-id
10296
:model "my-provider/foo1"
10397
:message "What foo?"}))
10498
chat-id @chat-id*]
@@ -109,18 +103,18 @@
109103
:status "success"}
110104
resp))
111105

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"})
124118
(is (match?
125119
{:input [{:role "user" :content [{:type "input_text" :text "Tell me a joke!"}]}
126120
{:role "assistant" :content [{:type "output_text" :text "Knock knock!"}]}
@@ -152,10 +146,8 @@
152146
(let [chat-id* (atom nil)]
153147
(testing "We send a simple hello message"
154148
(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"
159151
:message "Tell me a joke!"}))
160152
chat-id (reset! chat-id* (:chatId resp))]
161153

@@ -165,23 +157,21 @@
165157
:status "success"}
166158
resp))
167159

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"})
174166
(is (match?
175167
{:input [{:role "user" :content [{:type "input_text" :text "Tell me a joke!"}]}]
176168
:instructions (m/pred string?)}
177169
llm.mocks/*last-req-body*))))
178170

179171
(testing "We reply"
180172
(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
183174
{:chat-id @chat-id*
184-
:request-id req-id
185175
:model "my-provider/deepseekcoder"
186176
:message "Who's there?"}))
187177
chat-id @chat-id*]
@@ -192,11 +182,11 @@
192182
:status "success"}
193183
resp))
194184

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"})
200190
(is (match?
201191
{:input [{:role "user" :content [{:type "input_text" :text "Tell me a joke!"}]}
202192
{:role "assistant" :content [{:type "output_text" :text "Knock knock!"}]}
@@ -205,10 +195,8 @@
205195

206196
(testing "model reply again keeping context"
207197
(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
210199
{:chat-id @chat-id*
211-
:request-id req-id
212200
:model "my-provider/deepseekcoder"
213201
:message "What foo?"}))
214202
chat-id @chat-id*]
@@ -219,14 +207,14 @@
219207
:status "success"}
220208
resp))
221209

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"})
230218
(is (match?
231219
{:input [{:role "user" :content [{:type "input_text" :text "Tell me a joke!"}]}
232220
{:role "assistant" :content [{:type "output_text" :text "Knock knock!"}]}

0 commit comments

Comments
 (0)