File tree Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change 1010 [git.registry :as registry]
1111 graph
1212 jsonrpc
13+ [jsonrpc.db :as db]
14+ [jsonrpc.logger :as logger]
1315 jsonrpc.producer
1416 jsonrpc.server
1517 [logging :refer [warn]]
169171 (constantly
170172 (fn [method params]
171173 (jsonrpc.producer/publish-docker-notify producer method params))))
174+ (when (:prompts opts)
175+ (try
176+ (db/add opts)
177+ (catch Throwable t
178+ (logger/error t))))
172179 (let [finished @server-promise]
173180 {:result-code (if (= :done finished) 0 1 )})))
174181 (fn []
Original file line number Diff line number Diff line change 11(ns jsonrpc
22 (:require
3+ [babashka.process :as process]
34 [cheshire.core :as json]
45 [clojure.core.async :as async]
56 [clojure.java.io :as io]
143144(comment
144145 (notify :message {:content " message" }))
145146
147+ (comment
148+ (def mcp
149+ (process/process {:err :string }
150+ " docker"
151+ " run"
152+ " -i"
153+ " -v" " /var/run/docker.sock:/var/run/docker.sock"
154+ " --mount" " type=volume,source=docker-prompts,target=/prompts"
155+ " vonwig/prompts:local"
156+ " serve"
157+ " --host-dir" " /Users/slim/docker/labs-ai-tools-for-devs"
158+ " --prompts" " github:docker/labs-ai-tools-for-devs?path=prompts/examples/explain_dockerfile.md" ))
159+ (async/thread
160+ (with-open [rdr (io/reader (:out mcp))]
161+ (binding [*in* rdr]
162+ (loop []
163+ (when-let [line (read-line )]
164+ (println :mcp line)
165+ (recur ))))))
166+ (write-message (:in mcp) (request " ping" {} (constantly 1 )))
167+ (-> @mcp :err )
168+ (-> @mcp :out slurp)
169+ )
170+
146171(comment
147172 " tool module
148173 :start for container runs or failures
163188 :message :debug when entering a new node of the state machine
164189 main
165190 :messsage :content for the final output
166- "
167- )
191+ " )
Original file line number Diff line number Diff line change 11(ns jsonrpc.db
22 (:require
33 git
4+ [jsonrpc.logger :as logger]
45 prompts))
56
67(def db* (atom {}))
78
89(defn get-prompt-data [{:keys [prompts] :as opts}]
9- (let [f (git/prompt-file prompts)
10+ (let [f (if ( string? prompts) ( git/prompt-file prompts) prompts)
1011 {:keys [messages metadata functions] :as entry} (prompts/get-prompts (assoc opts :prompts f))]
1112 entry))
1213
1314(defn add [opts]
15+ (logger/info " adding prompts" (:prompts opts))
1416 (swap! db* update-in [:mcp.prompts/registry ] (fnil assoc {}) (:prompts opts) (get-prompt-data opts)))
1517
1618(comment
You can’t perform that action at this time.
0 commit comments