|
100 | 100 |
|
101 | 101 | (defn ^:private prompt-messages! |
102 | 102 | [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}] |
104 | 104 | (when (seq contexts) |
105 | 105 | (send-content! chat-ctx :system {:type :progress |
106 | 106 | :state :running |
107 | 107 | :text "Parsing given context"})) |
108 | 108 | (let [db @db* |
109 | 109 | all-models (models/all) |
110 | 110 | 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) |
115 | 111 | past-messages (get-in db [:chats chat-id :messages] []) |
116 | 112 | all-tools (f.tools/all-tools behavior @db* config) |
117 | 113 | received-msgs* (atom "") |
|
321 | 317 | :external-id (:external-id message-content) |
322 | 318 | :text (:text message-content)})) |
323 | 319 |
|
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*)] |
326 | 322 | (case type |
327 | 323 | :chat-messages (do |
328 | 324 | (doseq [[chat-id messages] (:chats result)] |
|
344 | 340 | (let [new-id (str (random-uuid))] |
345 | 341 | (swap! db* assoc-in [:chats new-id] {:id new-id}) |
346 | 342 | 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) |
348 | 349 | chat-ctx {:chat-id chat-id |
349 | 350 | :request-id request-id |
350 | 351 | :contexts contexts |
351 | 352 | :behavior behavior |
| 353 | + :instructions instructions |
352 | 354 | :model chosen-model |
353 | 355 | :db* db* |
354 | 356 | :config config |
|
0 commit comments