Skip to content

Commit eb1b838

Browse files
committed
Include total cost to costs command
1 parent 10ce3fe commit eb1b838

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/eca/features/chat.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@
293293
{:keys [messages]} (f.mcp/get-prompt! prompt args-vals @db*)]
294294
(prompt-messages! messages false chat-ctx)))
295295

296-
(defn ^:private handle-command! [{:keys [command]} {:keys [chat-id db*] :as chat-ctx}]
296+
(defn ^:private handle-command! [{:keys [command]} {:keys [chat-id db* model] :as chat-ctx}]
297297
(case command
298298
"costs" (let [db @db*
299299
total-input-tokens (get-in db [:chats chat-id :total-input-tokens] 0)
@@ -305,7 +305,8 @@
305305
(str "Total input cache creation tokens: " total-input-cache-creation-tokens))
306306
(when total-input-cache-read-tokens
307307
(str "Total input cache read tokens: " total-input-cache-read-tokens))
308-
(str "Total output tokens: " total-output-tokens))]
308+
(str "Total output tokens: " total-output-tokens)
309+
(str "Total cost: $" (tokens->cost total-input-tokens total-input-cache-creation-tokens total-input-cache-read-tokens total-output-tokens model db)))]
309310
(send-content! chat-ctx :system {:type :text
310311
:text text}))
311312
(send-content! chat-ctx :system {:type :text

0 commit comments

Comments
 (0)