|
8 | 8 | [eca.llm-api :as llm-api] |
9 | 9 | [eca.test-helper :as h] |
10 | 10 | [matcher-combinators.matchers :as m] |
11 | | - [matcher-combinators.test :refer [match?]])) |
| 11 | + [matcher-combinators.test :refer [match?]] |
| 12 | + [babashka.fs :as fs] |
| 13 | + [clojure.string :as string])) |
12 | 14 |
|
13 | 15 | (h/reset-components-before-test) |
14 | 16 |
|
|
181 | 183 | :role :system}]} |
182 | 184 | (h/messages))))))) |
183 | 185 |
|
| 186 | +(deftest contexts-in-prompt-test |
| 187 | + (testing "When prompt contains @file we add a user message" |
| 188 | + (h/reset-components!) |
| 189 | + (let [{:keys [chat-id]} |
| 190 | + (complete! |
| 191 | + {:message "Check @/path/to/file please"} |
| 192 | + {:api-mock |
| 193 | + (fn [{:keys [on-first-response-received |
| 194 | + on-message-received]}] |
| 195 | + (on-first-response-received {:type :text :text "On it..."}) |
| 196 | + (on-message-received {:type :text :text "On it..."}) |
| 197 | + (on-message-received {:type :finish}))})] |
| 198 | + (is (match? |
| 199 | + {chat-id {:id chat-id |
| 200 | + :messages [{:role "user" :content [{:type :text :text "Check @/path/to/file please"} |
| 201 | + {:type :text :text (m/pred #(string/includes? % "<file path"))}]} |
| 202 | + {:role "assistant" :content [{:type :text :text "On it..."}]}]}} |
| 203 | + (:chats (h/db)))) |
| 204 | + (is (match? |
| 205 | + {:chat-content-received |
| 206 | + [{:chat-id chat-id |
| 207 | + :content {:type :text :text "Check @/path/to/file please\n"} |
| 208 | + :role :user} |
| 209 | + {:chat-id chat-id |
| 210 | + :content {:type :progress :state :running :text "Waiting model"} |
| 211 | + :role :system} |
| 212 | + {:chat-id chat-id |
| 213 | + :content {:type :progress :state :running :text "Generating"} |
| 214 | + :role :system} |
| 215 | + {:chat-id chat-id |
| 216 | + :content {:type :text :text "On it..."} |
| 217 | + :role :assistant} |
| 218 | + {:chat-id chat-id |
| 219 | + :content {:state :finished :type :progress} |
| 220 | + :role :system}]} |
| 221 | + (h/messages)))))) |
| 222 | + |
184 | 223 | (deftest basic-tool-calling-prompt-test |
185 | 224 | (testing "Asking to list directories, LLM will check for allowed directories and then list files" |
186 | 225 | (h/reset-components!) |
|
0 commit comments