File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323 (map (comp shared/uri->filename :uri ) (:workspace-folders db))))))
2424
2525(defn ^:private list-directory [arguments db]
26- (let [path (fs/canonicalize (:path arguments))]
26+ (let [path (fs/canonicalize (get arguments " path " ))]
2727 (or (not-allowed-path path db)
2828 (single-text-content
2929 (reduce
Original file line number Diff line number Diff line change 2828 :name " web_search"
2929 :max_uses 10 })))
3030
31- (defn ^:private base-request! [{:keys [rid body api-key on-error on-response]}]
31+ (defn ^:private base-request! [{:keys [rid body api-key content-block* on-error on-response]}]
3232 (let [api-key (or api-key
3333 (System/getenv " ANTHROPIC_API_KEY" ))
3434 url (url messages-path)]
5151 (with-open [rdr (io/reader body)]
5252 (doseq [[event data] (llm-util/event-data-seq rdr)]
5353 (llm-util/log-response logger-tag rid event data)
54- (on-response event data))))
54+ (on-response event data content-block* ))))
5555 (catch Exception e
5656 (on-error {:exception e}))))
5757 (fn [e]
9090 :stream true
9191 :tools (->tools tools web-search)
9292 :system context}
93- content-block* (atom nil )
9493 on-response-fn
95- (fn handle-response [event data]
94+ (fn handle-response [event data content-block* ]
9695 (case event
9796 " content_block_start" (case (-> data :content_block :type )
9897 " tool_use" (do
140139 {:rid (llm-util/gen-rid )
141140 :body (assoc body :messages messages)
142141 :api-key api-key
142+ :content-block* (atom nil )
143143 :on-error on-error
144144 :on-response handle-response}))))
145145 " end_turn" (on-message-received {:type :finish
150150 {:rid (llm-util/gen-rid )
151151 :body body
152152 :api-key api-key
153+ :content-block* (atom nil )
153154 :on-error on-error
154155 :on-response on-response-fn})))
Original file line number Diff line number Diff line change 5252 (case role
5353 " tool_call" {:type " function_call"
5454 :name (:name content)
55- :call-id (:id content)
55+ :call_id (:id content)
5656 :arguments (:arguments content)}
5757 " tool_call_output"
5858 {:type " function_call_output"
5959 :name (:name content)
60- :call-id (:id content)
60+ :call_id (:id content)
6161 :output (llm-util/stringfy-tool-result content)}
6262 msg))
6363 past-messages)
Original file line number Diff line number Diff line change 2323 [{:role " user" :content " List the files you are allowed" }
2424 {:role " assistant" :content " Ok!" }
2525 {:type " function_call"
26- :call-id " call-1"
26+ :call_id " call-1"
2727 :name " list_allowed_directories"
2828 :arguments {}}
2929 {:type " function_call_output"
30- :call-id " call-1"
30+ :call_id " call-1"
3131 :output " Allowed directories: /foo/bar\n " }
3232 {:role " assistant" :content " I see /foo/bar" }
3333 {:role " user" :content " Thanks" }]
You can’t perform that action at this time.
0 commit comments