Skip to content

Commit b4fb25a

Browse files
committed
Fix prePrompt hook.
1 parent 7c6b250 commit b4fb25a

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Fix prePrompt hook.
6+
57
## 0.70.0
68

79
- Add hooks support. #43

src/eca/features/chat.clj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -945,9 +945,9 @@
945945
seq
946946
(f.prompt/contexts-str repo-map*))]
947947
[{:type :text :text contexts-str}])
948-
user-messages [{:role "user" :content (concat [{:type :text :text message}]
949-
expanded-prompt-contexts
950-
image-contents)}]
948+
user-messages [{:role "user" :content (vec (concat [{:type :text :text message}]
949+
expanded-prompt-contexts
950+
image-contents))}]
951951
chat-ctx {:chat-id chat-id
952952
:message message
953953
:contexts contexts
@@ -967,13 +967,14 @@
967967
:prompt message}
968968
{:on-before-action (partial notify-before-hook-action! chat-ctx)
969969
:on-after-action (fn [result]
970-
(when (= 0 (:status result))
971-
(reset! hook-outputs* (:outputs result)))
970+
(when (and (= 0 (:status result))
971+
(:output result))
972+
(swap! hook-outputs* conj (:output result)))
972973
(notify-after-hook-action! chat-ctx result))}
973974
db
974975
config)
975976
user-messages (if (seq @hook-outputs*)
976-
(update-in user-messages [0 :content 0 :text] str " " (string/join "\n" @hook-outputs*))
977+
(update-in user-messages [0 :content 0 :text] #(str % " " (string/join "\n" @hook-outputs*)))
977978
user-messages)]
978979
(swap! db* assoc-in [:chats chat-id :status] :running)
979980
(send-content! chat-ctx :user {:type :text

0 commit comments

Comments
 (0)