Skip to content

Commit

Permalink
Interpolate into prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
slimslenderslacks committed Dec 12, 2024
1 parent c5ad31a commit 91121bc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
8 changes: 7 additions & 1 deletion prompts/examples/explain_dockerfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@ tools:
parameters:
type: object
properties:
project:
type: string
description: absolute path in the project root
path:
type: string
description: Path of the folder to delete
container:
image: vonwig/bash_alpine
mounts:
- "{{project|safe}}:/workdir:ro"
workdir: /workdir
command:
- "cat {{path|safe}}"
prompt-format: "django"
---

# prompt user

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

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

Expand Down
38 changes: 21 additions & 17 deletions src/tools.clj
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,28 @@
(try
(if (:container definition) ;; synchronous call to container function
(let [function-call (cond-> (merge
(:container definition)
(dissoc defaults :functions)
{:command (interpolate-coll
(-> definition :container :command)
arg-context)}
;; workdirs in a container definition will always override ones
;; set in the metadata
(when-let [wd (or
(-> definition :container :workdir)
(:workdir defaults))]
{:workdir (first (interpolate arg-context wd))}))
(:container definition)
(dissoc defaults :functions)
{:command (interpolate-coll
(-> definition :container :command)
arg-context)}
(when (-> definition :container :mounts)
{:mounts (->> (-> definition :container :mounts)
(map (fn [s] (first (interpolate arg-context s))))
(into []))})
;; workdirs in a container definition will always override ones
;; set in the metadata
(when-let [wd (or
(-> definition :container :workdir)
(:workdir defaults))]
{:workdir (first (interpolate arg-context wd))}))
(-> definition :stdin :file) (update-in [:stdin :file] (fn [s] (first (interpolate arg-context s)))))]
(jsonrpc/notify
:message
{:debug (format "function call %s"
(with-out-str
(pp/pprint (-> function-call
(update :jwt (fn [s] (if s "xxxxxxx" "not-set")))))))})
(jsonrpc/notify
:message
{:debug (format "function call %s"
(with-out-str
(pp/pprint (-> function-call
(update :jwt (fn [s] (if s "xxxxxxx" "not-set")))))))})
(trace/container-call (update function-call :jwt (fn [s] (if s "xxxxxxx" "not-set"))))
(let [{:keys [pty-output exit-code done] :as result} (docker/run-container function-call)
exit-code-fail? (if (false? (:check-exit-code definition))
Expand Down

0 comments on commit 91121bc

Please sign in to comment.