|
84 | 84 |
|
85 | 85 | (defn collect-extractors [f]
|
86 | 86 | (let [extractors (->>
|
87 |
| - (-> (markdown/parse-metadata (metadata-file f)) first :extractors) |
| 87 | + (-> (try |
| 88 | + (markdown/parse-metadata (metadata-file f)) |
| 89 | + (catch Throwable _ |
| 90 | + ;; files with empty strings will throw assertion failures |
| 91 | + nil)) |
| 92 | + first |
| 93 | + :extractors) |
88 | 94 | (map (fn [m] (merge (registry/get-extractor m) m))))]
|
89 | 95 | (if (seq extractors)
|
90 | 96 | extractors
|
|
95 | 101 | "--vs-machine-id" "none"
|
96 | 102 | "--workspace" "/project"]}])))
|
97 | 103 |
|
98 |
| -(defn collect-functions |
| 104 | +(defn collect-functions |
99 | 105 | "get either :functions or :tools collection
|
100 | 106 | returns collection of openai compatiable tool definitions augmented with container info"
|
101 | 107 | [f]
|
102 | 108 | (->>
|
103 |
| - (-> (markdown/parse-metadata (metadata-file f)) first (select-keys [:tools :functions]) seq first second) |
| 109 | + (-> (markdown/parse-metadata (metadata-file f)) first (select-keys [:tools :functions]) seq first second) |
104 | 110 | (mapcat (fn [m] (if-let [tool (#{"curl" "qrencode" "toilet" "figlet" "gh" "typos" "fzf" "jq" "fmpeg"} (:name m))]
|
105 | 111 | [{:type "function"
|
106 | 112 | :function
|
|
210 | 216 | (when pat {:pat pat})
|
211 | 217 | (when timeout {:timeout timeout}))
|
212 | 218 | {:keys [pty-output exit-code done] :as result} (docker/run-function function-call)]
|
213 |
| - (cond |
| 219 | + (cond |
214 | 220 | (and (= :exited done) (= 0 exit-code))
|
215 | 221 | (resolve pty-output)
|
216 | 222 | (and (= :exited done) (not= 0 exit-code))
|
|
298 | 304 | (async/>! c {:messages [] :done "error"})
|
299 | 305 | c))))
|
300 | 306 |
|
| 307 | +(comment |
| 308 | + ;; for testing conversation-loop in repl |
| 309 | + (def x {:stream true, |
| 310 | + :host-dir "/Users/slim/docker/labs-make-runbook", |
| 311 | + :prompts "/Users/slim/docker/labs-ai-tools-for-devs/prompts/hub/default.md" |
| 312 | + :platform "darwin", :user "jimclark106", |
| 313 | + :thread-id "3e61ffe7-840e-4177-b84a-f6f7db58b24d"}) |
| 314 | + (get-prompts x) |
| 315 | + (run-extractors x) |
| 316 | + (collect-extractors (:prompts x)) |
| 317 | + (async/<!! (conversation-loop |
| 318 | + x))) |
| 319 | + |
301 | 320 | (defn- with-volume [f & {:keys [thread-id save-thread-volume]}]
|
302 | 321 | (let [thread-id (or thread-id (str (random-uuid)))]
|
303 | 322 | (try
|
|
0 commit comments