Skip to content

Commit 91121bc

Browse files
Interpolate into prompts
1 parent c5ad31a commit 91121bc

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

prompts/examples/explain_dockerfile.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,25 @@ tools:
1313
parameters:
1414
type: object
1515
properties:
16+
project:
17+
type: string
18+
description: absolute path in the project root
1619
path:
1720
type: string
1821
description: Path of the folder to delete
1922
container:
2023
image: vonwig/bash_alpine
24+
mounts:
25+
- "{{project|safe}}:/workdir:ro"
26+
workdir: /workdir
2127
command:
2228
- "cat {{path|safe}}"
2329
prompt-format: "django"
2430
---
2531

2632
# prompt user
2733

28-
Start by fetching the ./Dockerfile in the project root.
34+
Start by fetching the ./Dockerfile in the project root at /Users/slim/docker/labs-ai-tools-for-devs.
2935

3036
After fetching the Dockerfile contents, explain the Dockerfile line by line.
3137

src/tools.clj

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,28 @@
6262
(try
6363
(if (:container definition) ;; synchronous call to container function
6464
(let [function-call (cond-> (merge
65-
(:container definition)
66-
(dissoc defaults :functions)
67-
{:command (interpolate-coll
68-
(-> definition :container :command)
69-
arg-context)}
70-
;; workdirs in a container definition will always override ones
71-
;; set in the metadata
72-
(when-let [wd (or
73-
(-> definition :container :workdir)
74-
(:workdir defaults))]
75-
{:workdir (first (interpolate arg-context wd))}))
65+
(:container definition)
66+
(dissoc defaults :functions)
67+
{:command (interpolate-coll
68+
(-> definition :container :command)
69+
arg-context)}
70+
(when (-> definition :container :mounts)
71+
{:mounts (->> (-> definition :container :mounts)
72+
(map (fn [s] (first (interpolate arg-context s))))
73+
(into []))})
74+
;; workdirs in a container definition will always override ones
75+
;; set in the metadata
76+
(when-let [wd (or
77+
(-> definition :container :workdir)
78+
(:workdir defaults))]
79+
{:workdir (first (interpolate arg-context wd))}))
7680
(-> definition :stdin :file) (update-in [:stdin :file] (fn [s] (first (interpolate arg-context s)))))]
77-
(jsonrpc/notify
78-
:message
79-
{:debug (format "function call %s"
80-
(with-out-str
81-
(pp/pprint (-> function-call
82-
(update :jwt (fn [s] (if s "xxxxxxx" "not-set")))))))})
81+
(jsonrpc/notify
82+
:message
83+
{:debug (format "function call %s"
84+
(with-out-str
85+
(pp/pprint (-> function-call
86+
(update :jwt (fn [s] (if s "xxxxxxx" "not-set")))))))})
8387
(trace/container-call (update function-call :jwt (fn [s] (if s "xxxxxxx" "not-set"))))
8488
(let [{:keys [pty-output exit-code done] :as result} (docker/run-container function-call)
8589
exit-code-fail? (if (false? (:check-exit-code definition))

0 commit comments

Comments
 (0)