Skip to content

Commit 39fcae4

Browse files
committed
Add new /prompt-show command
1 parent 80db62b commit 39fcae4

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Add support for auto read `AGENT.md` from workspace root and global eca dir, considering as context for chat prompts.
6+
- Add `/prompt-show` command to show ECA prompt sent to LLM.
67

78
## 0.26.3
89

src/eca/features/chat.clj

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,14 @@
100100

101101
(defn ^:private prompt-messages!
102102
[user-messages
103-
{:keys [db* config chat-id contexts behavior model] :as chat-ctx}]
103+
{:keys [db* config chat-id contexts behavior model instructions] :as chat-ctx}]
104104
(when (seq contexts)
105105
(send-content! chat-ctx :system {:type :progress
106106
:state :running
107107
:text "Parsing given context"}))
108108
(let [db @db*
109109
all-models (models/all)
110110
provider (get-in all-models [model :provider])
111-
rules (f.rules/all config (:workspace-folders db))
112-
refined-contexts (f.context/raw-contexts->refined contexts db config)
113-
repo-map* (delay (f.index/repo-map db {:as-string? true}))
114-
instructions (f.prompt/build-instructions refined-contexts rules repo-map* (or behavior (:chat-default-behavior db)) config)
115111
past-messages (get-in db [:chats chat-id :messages] [])
116112
all-tools (f.tools/all-tools behavior @db* config)
117113
received-msgs* (atom "")
@@ -321,8 +317,8 @@
321317
:external-id (:external-id message-content)
322318
:text (:text message-content)}))
323319

324-
(defn ^:private handle-command! [{:keys [command args]} {:keys [chat-id db* config model] :as chat-ctx}]
325-
(let [{:keys [type] :as result} (f.commands/handle-command! command args chat-id model config db*)]
320+
(defn ^:private handle-command! [{:keys [command args]} {:keys [chat-id db* config model instructions] :as chat-ctx}]
321+
(let [{:keys [type] :as result} (f.commands/handle-command! command args chat-id model instructions config db*)]
326322
(case type
327323
:chat-messages (do
328324
(doseq [[chat-id messages] (:chats result)]
@@ -344,11 +340,17 @@
344340
(let [new-id (str (random-uuid))]
345341
(swap! db* assoc-in [:chats new-id] {:id new-id})
346342
new-id))
347-
chosen-model (or model (default-model @db* config))
343+
db @db*
344+
chosen-model (or model (default-model db config))
345+
rules (f.rules/all config (:workspace-folders db))
346+
refined-contexts (f.context/raw-contexts->refined contexts db config)
347+
repo-map* (delay (f.index/repo-map db {:as-string? true}))
348+
instructions (f.prompt/build-instructions refined-contexts rules repo-map* (or behavior (:chat-default-behavior db)) config)
348349
chat-ctx {:chat-id chat-id
349350
:request-id request-id
350351
:contexts contexts
351352
:behavior behavior
353+
:instructions instructions
352354
:model chosen-model
353355
:db* db*
354356
:config config

src/eca/features/commands.clj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,15 @@
7171
(dissoc :server))))
7272
eca-commands [{:name "costs"
7373
:type :native
74-
:description "Show the total costs of the current chat session."
74+
:description "Total costs of the current chat session."
7575
:arguments []}
7676
{:name "repo-map-show"
7777
:type :native
78-
:description "Show the actual repoMap of current session."
78+
:description "Actual repoMap of current session."
79+
:arguments []}
80+
{:name "prompt-show"
81+
:type :native
82+
:description "Prompt sent to LLM as system instructions."
7983
:arguments []}
8084
{:name "resume"
8185
:type :native
@@ -100,7 +104,7 @@
100104
raw-content
101105
(map-indexed vector args)))))
102106

103-
(defn handle-command! [command args chat-id model config db*]
107+
(defn handle-command! [command args chat-id model instructions config db*]
104108
(let [db @db*
105109
custom-commands (custom-commands config (:workspace-folders db))]
106110
(case command
@@ -119,6 +123,8 @@
119123
:chats {chat-id [{:role "system" :content [{:type :text :text text}]}]}})
120124
"repo-map-show" {:type :chat-messages
121125
:chats {chat-id [{:role "system" :content [{:type :text :text (f.index/repo-map db {:as-string? true})}]}]}}
126+
"prompt-show" {:type :chat-messages
127+
:chats {chat-id [{:role "system" :content [{:type :text :text instructions}]}]}}
122128

123129
"resume" (let [chats (:chats db)]
124130
;; Override current chat with first chat

0 commit comments

Comments
 (0)