|
201 | 201 | ; ============================================================
|
202 | 202 |
|
203 | 203 | (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]]])) |
227 | 214 |
|
228 | 215 | (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"]]])) |
249 | 224 |
|
250 | 225 | ; 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 |
259 | 227 | (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"]]])) |
261 | 235 |
|
0 commit comments