|
252 | 252 | :type :text}]})}) |
253 | 253 | (send-content! chat-ctx :assistant |
254 | 254 | (assoc-some |
255 | | - {:type :toolCallRejected |
256 | | - :origin (tool-name->origin name all-tools) |
257 | | - :name name |
258 | | - :arguments arguments |
259 | | - :reason :user |
260 | | - :id id} |
261 | | - :details details)))) |
| 255 | + {:type :toolCallRejected |
| 256 | + :origin (tool-name->origin name all-tools) |
| 257 | + :name name |
| 258 | + :arguments arguments |
| 259 | + :reason :user |
| 260 | + :id id} |
| 261 | + :details details)))) |
262 | 262 | (swap! tool-call-by-id* dissoc id) |
263 | 263 | (send-content! chat-ctx :system {:type :progress :state :running :text "Generating"}) |
264 | 264 | {:new-messages (get-in @db* [:chats chat-id :messages])})) |
|
296 | 296 | (prompt-messages! messages false chat-ctx))) |
297 | 297 |
|
298 | 298 | (defn ^:private handle-command! [{:keys [command]} {:keys [chat-id db* model] :as chat-ctx}] |
299 | | - (case command |
300 | | - "costs" (let [db @db* |
301 | | - total-input-tokens (get-in db [:chats chat-id :total-input-tokens] 0) |
302 | | - total-input-cache-creation-tokens (get-in db [:chats chat-id :total-input-cache-creation-tokens] nil) |
303 | | - total-input-cache-read-tokens (get-in db [:chats chat-id :total-input-cache-read-tokens] nil) |
304 | | - total-output-tokens (get-in db [:chats chat-id :total-output-tokens] 0) |
305 | | - text (multi-str (str "Total input tokens: " total-input-tokens) |
306 | | - (when total-input-cache-creation-tokens |
307 | | - (str "Total input cache creation tokens: " total-input-cache-creation-tokens)) |
308 | | - (when total-input-cache-read-tokens |
309 | | - (str "Total input cache read tokens: " total-input-cache-read-tokens)) |
310 | | - (str "Total output tokens: " total-output-tokens) |
311 | | - (str "Total cost: $" (tokens->cost total-input-tokens total-input-cache-creation-tokens total-input-cache-read-tokens total-output-tokens model db)))] |
312 | | - (send-content! chat-ctx :system {:type :text |
313 | | - :text text})) |
314 | | - (send-content! chat-ctx :system {:type :text |
315 | | - :text (str "Unknown command: " command)})) |
| 299 | + (let [db @db*] |
| 300 | + (case command |
| 301 | + "costs" (let [total-input-tokens (get-in db [:chats chat-id :total-input-tokens] 0) |
| 302 | + total-input-cache-creation-tokens (get-in db [:chats chat-id :total-input-cache-creation-tokens] nil) |
| 303 | + total-input-cache-read-tokens (get-in db [:chats chat-id :total-input-cache-read-tokens] nil) |
| 304 | + total-output-tokens (get-in db [:chats chat-id :total-output-tokens] 0) |
| 305 | + text (multi-str (str "Total input tokens: " total-input-tokens) |
| 306 | + (when total-input-cache-creation-tokens |
| 307 | + (str "Total input cache creation tokens: " total-input-cache-creation-tokens)) |
| 308 | + (when total-input-cache-read-tokens |
| 309 | + (str "Total input cache read tokens: " total-input-cache-read-tokens)) |
| 310 | + (str "Total output tokens: " total-output-tokens) |
| 311 | + (str "Total cost: $" (tokens->cost total-input-tokens total-input-cache-creation-tokens total-input-cache-read-tokens total-output-tokens model db)))] |
| 312 | + (send-content! chat-ctx :system {:type :text |
| 313 | + :text text})) |
| 314 | + "repo-map-show" (send-content! chat-ctx :system {:type :text |
| 315 | + :text (f.index/repo-map db {:as-string? true})}) |
| 316 | + (send-content! chat-ctx :system {:type :text |
| 317 | + :text (str "Unknown command: " command)}))) |
316 | 318 | (finish-chat-prompt! :idle chat-ctx)) |
317 | 319 |
|
318 | 320 | (defn prompt |
|
398 | 400 | eca-commands [{:name "costs" |
399 | 401 | :type :native |
400 | 402 | :description "Show the total costs of the current chat session." |
| 403 | + :arguments []} |
| 404 | + {:name "repo-map-show" |
| 405 | + :type :native |
| 406 | + :description "Show the actual repoMap of current session." |
401 | 407 | :arguments []}] |
402 | 408 | commands (concat mcp-prompts |
403 | 409 | eca-commands) |
|
0 commit comments