File tree Expand file tree Collapse file tree 5 files changed +45
-13
lines changed Expand file tree Collapse file tree 5 files changed +45
-13
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ tools :
3
+ - name : ls
4
+ description : list files in a directory
5
+ container :
6
+ image : alpine:latest
7
+ command :
8
+ - ls
9
+ - /project
10
+ - name : echo
11
+ description : echo the current host dir
12
+ container :
13
+ image : vonwig/bash_alpine
14
+ command :
15
+ - -c
16
+ - " echo {{hostDir}}"
17
+ ---
18
+
19
+ # Background
20
+
21
+ The ` host-dir ` for the prompt-engine run is mounted at ` /project ` in the container.
22
+ So in the tool above, you'll see that the tool can only access your host-dir from this ` /project ` path.
23
+ However, the tools can be passed the _ value_ of the hostDir even if they can only access it via the ` /project ` mount.
24
+ See the ` echo ` tool for an example of how this value becomes accessible (the ` {{hostDir}} `
25
+ can also be used directly in prompt templates.
26
+
27
+ # Prompt user
28
+
29
+ Start by listing the files in my host-dir and then run echo. Summarize by writing the output of the echo command and then
30
+ write a poem using the file names from that directory.
31
+
Original file line number Diff line number Diff line change 274
274
[" tools-query" tools-query]
275
275
[" completion" completion]
276
276
[:edge tool-or-end]]
277
- [[" sub-graph" (sub-graph-node nil )]
277
+ [[" sub-graph" (sub-graph-node {} )]
278
278
[" tools-query" ]]
279
- [[" tool" (tool-node nil )]
279
+ [[" tool" (tool-node {} )]
280
280
[" tools-query" ]]
281
281
[[" end" end]]])
282
282
283
283
(defn one-tool-call [_]
284
284
(-> {}
285
285
(add-node " start" start)
286
286
(add-node " completion" completion)
287
- (add-node " tool" (tool-node nil ))
287
+ (add-node " tool" (tool-node {} ))
288
288
(add-node " end" end)
289
- (add-node " sub-graph" (sub-graph-node nil ))
289
+ (add-node " sub-graph" (sub-graph-node {} ))
290
290
(add-edge " start" " completion" )
291
291
(add-edge " sub-graph" " end" )
292
292
(add-edge " tool" " end" )
296
296
[[[" start" start]
297
297
[" completion" completion]
298
298
[:edge tool-or-end]]
299
- [[" sub-graph" (sub-graph-node nil )]
299
+ [[" sub-graph" (sub-graph-node {} )]
300
300
[" completion" ]]
301
- [[" tool" (tool-node nil )]
301
+ [[" tool" (tool-node {} )]
302
302
[" completion" ]]
303
303
[[" end" end]]])
304
304
Original file line number Diff line number Diff line change 90
90
; add the schema tool
91
91
(-> state
92
92
(update-in [:opts :level ] (fnil inc 0 ))
93
- (update-in [:opts :parameters ] (constantly {:database " ./Chinook.db" }))
94
93
(update-in [:functions ] (fnil concat []) (:tools model-get-schema))))
95
94
96
95
(defn seed-correct-query-conversation
101
100
(dissoc :messages )
102
101
(update-in [:opts :level ] (fnil inc 0 ))
103
102
(update-in [:opts :prompts ] (constantly (fs/file " prompts/sql/query-check.md" )))
104
- (update-in [:opts :parameters ] (constantly {:database " ./Chinook.db" }))
105
103
(graph/construct-initial-state-from-prompts )
106
104
(update-in [:messages ] concat [(last (:messages state))])))
107
105
Original file line number Diff line number Diff line change 22
22
23
23
(defn- facts
24
24
" fix up facts before sending to templates"
25
- [project-facts user platform]
25
+ [project-facts user platform host-dir ]
26
26
(medley/deep-merge
27
27
{:platform platform
28
28
:username user
29
+ :hostDir host-dir
29
30
:project-facts {:files (-> project-facts :project-facts :project/files )
30
31
:dockerfiles (-> project-facts :project-facts :project/dockerfiles )
31
32
:composefiles (-> project-facts :project-facts :project/composefiles )
187
188
(defn get-prompts
188
189
" run extractors and then render prompt templates
189
190
returns ordered collection of chat messages"
190
- [{:keys [parameters prompts user platform] :as opts}]
191
+ [{:keys [parameters prompts user platform host-dir ] :as opts}]
191
192
(let [; ; TODO the docker default no longer makes sense here
192
193
m (merge (run-extractors opts) parameters)
193
- renderer (partial selma-render prompts (facts m user platform))
194
+ renderer (partial selma-render prompts (facts m user platform host-dir ))
194
195
prompts (if (fs/directory? prompts)
195
196
; ; directory based prompts
196
197
(->> (fs/list-dir prompts)
Original file line number Diff line number Diff line change 45
45
does not stream - calls resolve or fail only once
46
46
should not throw exceptions
47
47
params
48
- opts - options map for the engine
48
+ opts - options map for the engine (partially bound))
49
49
function-name - the name of the function that the LLM has selected
50
50
json-arg-string - the JSON arg string that the LLM has generated
51
51
resolve fail - callbacks"
54
54
(->> (filter #(= function-name (-> % :function :name )) functions)
55
55
first)
56
56
:function )]
57
- (let [arg-context (arg-context json-arg-string)]
57
+ (let [arg-context (merge
58
+ {:hostDir (:host-dir opts)}
59
+ (arg-context json-arg-string))]
58
60
(try
59
61
(if (:container definition ) ; ; synchronous call to container function
60
62
(let [function-call (merge
You can’t perform that action at this time.
0 commit comments