File tree Expand file tree Collapse file tree 3 files changed +16
-12
lines changed Expand file tree Collapse file tree 3 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 1
1
(ns graph
2
2
(:require
3
- [babashka.fs :as fs]
4
3
[clojure.core.async :as async]
5
4
[clojure.core.match :refer [match]]
5
+ [clojure.pprint :as pprint]
6
6
git
7
7
jsonrpc
8
8
openai
155
155
[state m
156
156
node " start" ]
157
157
(jsonrpc/notify :message {:debug (format " \n -> entering %s\n\n " node)})
158
- #_ (jsonrpc/notify :message {:debug (with-out-str (pprint (state/summarize (dissoc state :opts ))))})
158
+ (jsonrpc/notify :message {:debug (with-out-str (pprint/ pprint (state/summarize (dissoc state :opts ))))})
159
159
; ; TODO handling bad graphs with missing nodes
160
160
(let [enter-node (get-in graph [:nodes node])
161
161
new-state (state-reducer state (async/<! (enter-node state)))]
256
256
[[" tool" (tool-node {})]
257
257
[" end" ]]])
258
258
259
+ (defn generate-start-with-tool [_]
260
+ (construct-graph start-with-tool))
261
+
Original file line number Diff line number Diff line change 114
114
[[[" start" graph/start]
115
115
[" list-tables-tool" (graph/sub-graph-node
116
116
{:init-state seed-list-tables-conversation
117
- :construct-graph ( fn [_] ( graph/construct-graph graph/ start-with-tool))
118
- :next-state state/take-last-two- messages})]
117
+ :construct-graph graph/generate- start-with-tool
118
+ :next-state ( state/take-last-messages 2 ) })]
119
119
[" model-get-schema" (graph/sub-graph-node
120
120
{:init-state seed-get-schema-conversation
121
121
:next-state state/append-new-messages})]
Original file line number Diff line number Diff line change 1
- (ns state
1
+ (ns state
2
2
(:require
3
3
git
4
4
jsonrpc
22
22
23
23
(defn summarize [state]
24
24
(-> state
25
- (update :messages (each
25
+ (update :messages (each
26
26
; summarize-content
27
27
; summarize-tool-calls
28
- ))))
28
+ ))))
29
29
30
30
(defn prompt? [m]
31
31
(= " prompt" (-> m :function :type )))
75
75
(update-in [:opts :prompts ] (constantly (git/prompt-file (-> definition :function :ref ))))
76
76
(update-in [:opts :parameters ] (constantly arg-context)))))
77
77
78
-
79
78
(defn add-last-message-as-tool-call
80
79
[state sub-graph-state]
81
80
{:messages [(-> sub-graph-state
88
87
{:messages (->> (:messages sub-graph-state)
89
88
(filter (complement (fn [m] (some #(= m %) (:messages state))))))})
90
89
91
- (defn take-last-two-messages
92
- [_ sub-graph-state]
93
- {:messages (->> (:messages sub-graph-state)
94
- (take-last 2 ))})
90
+ (defn take-last-messages
91
+ [n]
92
+ (fn
93
+ [_ sub-graph-state]
94
+ {:messages (->> (:messages sub-graph-state)
95
+ (take-last n))}))
95
96
96
97
You can’t perform that action at this time.
0 commit comments