Skip to content

Commit ba844ec

Browse files
Consolidate on new graph representations
1 parent e68c0ae commit ba844ec

File tree

1 file changed

+26
-52
lines changed

1 file changed

+26
-52
lines changed

src/graph.clj

Lines changed: 26 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -201,61 +201,35 @@
201201
; ============================================================
202202

203203
(defn chat-with-tools [_]
204-
(-> {}
205-
(add-node "start" start)
206-
(add-node "completion" completion)
207-
(add-node "tool" (tool-node nil))
208-
(add-node "end" end)
209-
(add-node "sub-graph" (sub-graph-node nil))
210-
(add-node "tools-query" tools-query)
211-
(add-edge "start" "tools-query")
212-
(add-edge "tool" "tools-query")
213-
(add-edge "sub-graph" "tools-query")
214-
(add-edge "tools-query" "completion")
215-
(add-conditional-edges "completion" tool-or-end)))
216-
217-
(def chat-with-tools-representation
218-
[[["start" start]
219-
["tools-query" tools-query]
220-
["completion" completion]
221-
[:edge tool-or-end]]
222-
[["sub-graph" (sub-graph-node {})]
223-
["tools-query"]]
224-
[["tool" (tool-node {})]
225-
["tools-query"]]
226-
[["end" end]]])
204+
(construct-graph
205+
[[["start" start]
206+
["tools-query" tools-query]
207+
["completion" completion]
208+
[:edge tool-or-end]]
209+
[["sub-graph" (sub-graph-node {})]
210+
["tools-query"]]
211+
[["tool" (tool-node {})]
212+
["tools-query"]]
213+
[["end" end]]]))
227214

228215
(defn generate-one-tool-call [_]
229-
(-> {}
230-
(add-node "start" start)
231-
(add-node "completion" completion)
232-
(add-node "tool" (tool-node {}))
233-
(add-node "end" end)
234-
(add-node "sub-graph" (sub-graph-node {}))
235-
(add-edge "start" "completion")
236-
(add-edge "sub-graph" "end")
237-
(add-edge "tool" "end")
238-
(add-conditional-edges "completion" tool-or-end)))
239-
240-
(def one-tool-call-representation
241-
[[["start" start]
242-
["completion" completion]
243-
[:edge tool-or-end]]
244-
[["sub-graph" (sub-graph-node {})]
245-
["completion"]]
246-
[["tool" (tool-node {})]
247-
["completion"]]
248-
[["end" end]]])
216+
(construct-graph
217+
[[["start" start]
218+
["completion" completion]
219+
[:edge tool-or-end]]
220+
[["sub-graph" (sub-graph-node {})]
221+
["end" end]]
222+
[["tool" (tool-node {})]
223+
["end"]]]))
249224

250225
; requires finish-reason to be set to tool_calls
251-
(def start-with-tool
252-
[[["start" start]
253-
[:edge tool-or-end]]
254-
[["sub-graph" (sub-graph-node {})]
255-
["end" end]]
256-
[["tool" (tool-node {})]
257-
["end"]]])
258-
226+
; runs either a tool or sub-graph and then ends
259227
(defn generate-start-with-tool [_]
260-
(construct-graph start-with-tool))
228+
(construct-graph
229+
[[["start" start]
230+
[:edge tool-or-end]]
231+
[["sub-graph" (sub-graph-node {})]
232+
["end" end]]
233+
[["tool" (tool-node {})]
234+
["end"]]]))
261235

0 commit comments

Comments
 (0)