Skip to content

Commit ff70d2e

Browse files
committed
Tests
1 parent 70b8313 commit ff70d2e

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

integration-test/integration/chat/commands_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
{:name "config" :arguments []}
3030
{:name "doctor" :arguments []}
3131
{:name "repo-map-show" :arguments []}
32-
{:name "prompt-show" :arguments []}]}
32+
{:name "prompt-show" :arguments [{:name "optional-prompt"}]}]}
3333
resp))))
3434

3535
(testing "We query specific commands"

src/eca/features/context.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
(mapcat #(parse-agents-file (str %))))))
7676

7777
(defn ^:private file->refined-context [path lines-range]
78-
(let [ext (string/lower-case (fs/extension path))]
78+
(let [ext (string/lower-case (or (fs/extension path) ""))]
7979
(if (contains? #{"png" "jpg" "jpeg" "gif" "webp"} ext)
8080
{:type :image
8181
:media-type (case ext

test/eca/features/chat_test.clj

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
[eca.llm-api :as llm-api]
99
[eca.test-helper :as h]
1010
[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]))
1214

1315
(h/reset-components-before-test)
1416

@@ -181,6 +183,43 @@
181183
:role :system}]}
182184
(h/messages)))))))
183185

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+
184223
(deftest basic-tool-calling-prompt-test
185224
(testing "Asking to list directories, LLM will check for allowed directories and then list files"
186225
(h/reset-components!)

0 commit comments

Comments
 (0)