Skip to content

Commit c4eb943

Browse files
Add unmerged changes from previous repo
* complete the conversation loop when using prompts
1 parent 76b41dc commit c4eb943

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ a GitHub ref. For example, to test some local prompts in a directory named `my_
2727
docker run --rm \
2828
-v /var/run/docker.sock:/var/run/docker.sock \
2929
--mount type=bind,source=$PWD,target=/app/my_prompts \
30-
--workdir /app
30+
--workdir /app \
3131
vonwig/prompts:latest $PWD \
3232
jimclark106 \
3333
darwin \
@@ -61,7 +61,7 @@ docker run --rm \
6161
-it \
6262
-v /var/run/docker.sock:/var/run/docker.sock \
6363
--mount type=bind,source=$PROMPTS_DIR,target=/app/my_prompts \
64-
--workdir /app
64+
--workdir /app \
6565
--mount type=volume,source=docker-prompts,target=/prompts \
6666
--mount type=bind,source=$HOME/.openai-api-key,target=/root/.openai-api-key \
6767
vonwig/prompts:latest \

prompts/dockerfiles/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ functions:
1111
- name: analyze_project
1212
description: Analyze a project to determine how it should be built
1313
type: prompt
14-
ref: project_type
14+
ref: github:docker/labs-ai-tools-for-devs?ref=main&path=prompts/project_type
1515
- name: write_files
1616
description: Write a set of files to my project
1717
parameters:

src/prompts.clj

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@
178178
(into []))]
179179
(map (comp merge-role renderer fs/file) prompts)))
180180

181+
(declare conversation-loop)
182+
181183
(defn function-handler
182184
"call function
183185
params
@@ -207,9 +209,17 @@
207209
(resolve pty-output)
208210
(fail (format "call exited with non-zero code (%d): %s" exit-code pty-output))))
209211
(= "prompt" (:type definition)) ;; asynchronous call to another agent
210-
(do
211-
;; TODO use the assistant here
212-
(resolve "This is an NPM project.")))
212+
(let [{:keys [messages _finish-reason] :as m}
213+
(async/<!! (conversation-loop
214+
(:host-dir opts)
215+
user
216+
(:host-dir opts)
217+
(:ref definition)))]
218+
(jsonrpc/notify :message {:debug (with-out-str (pprint m))})
219+
(resolve (->> messages
220+
(filter #(= "assistant" (:role %)))
221+
(last)
222+
:content))))
213223
(catch Throwable t
214224
(fail (format "system failure %s" t))))
215225
(fail "no function found")))
@@ -240,14 +250,15 @@
240250
[& args]
241251
(async/go-loop
242252
[prompts (apply get-prompts args)]
243-
(let [{:keys [messages finish-reason] :as m} (async/<!! (apply run-prompts prompts args))]
253+
(let [{:keys [messages finish-reason] :as m}
254+
(async/<!! (apply run-prompts prompts args))]
244255
(if (= "tool_calls" finish-reason)
245256
(do
246257
(jsonrpc/notify :message {:debug (with-out-str (pprint m))})
247258
(recur (concat prompts messages)))
248259
(do
249260
(jsonrpc/notify :message {:debug (with-out-str (pprint m))})
250-
{:done finish-reason})))))
261+
{:messages (concat prompts messages) :done finish-reason})))))
251262

252263
(defn- -run-command
253264
[& args]
@@ -276,7 +287,9 @@
276287
(update-in m [:prompts] (fn [coll] (remove (fn [{:keys [type]}] (= type (second args))) coll)))))
277288

278289
(= "run" (first args))
279-
(async/<!! (apply conversation-loop (rest args)))
290+
(select-keys
291+
(async/<!! (apply conversation-loop (rest args)))
292+
[:done])
280293

281294
:else
282295
(apply get-prompts args)))

0 commit comments

Comments
 (0)