|
83 | 83 | ;; how many times should we try to correct because correct-query will always end up back here
|
84 | 84 | :else "correct-query")))
|
85 | 85 |
|
86 |
| -(defn seed-list-tables-conversation [state] |
87 |
| - (-> state |
88 |
| - (assoc :finish-reason "tool_calls") |
89 |
| - (update-in [:functions] (constantly (:tools first-tool-call))) |
90 |
| - (update-in [:messages] concat (:messages first-tool-call)))) |
91 |
| - |
92 |
| -(defn seed-get-schema-conversation [state] |
93 |
| - ; inherit full conversation |
94 |
| - ; no prompts |
95 |
| - ; add the schema tool |
96 |
| - (-> state |
97 |
| - (update-in [:functions] (fnil concat []) (:tools model-get-schema)))) |
98 |
| - |
99 | 86 | (defn seed-correct-query-conversation
|
100 | 87 | [state]
|
101 | 88 | ; make one LLM call with the last message (which should be a user query containing the SQL we want to check)
|
|
106 | 93 | (state/construct-initial-state-from-prompts)
|
107 | 94 | (update-in [:messages] concat [(last (:messages state))])))
|
108 | 95 |
|
| 96 | +(comment |
| 97 | + [state/messages-reset |
| 98 | + (state/messages-from-prompt "prompts/sql/query-check.md") |
| 99 | + (state/messages-take-last 1)]) |
| 100 | + |
109 | 101 | ;; query-gen has a prompt
|
110 | 102 | ;; seed-correct-query-conversation has a prompt
|
111 | 103 | ;; prompts/sql/query-gen.md has a hard-coded db file
|
112 | 104 | (defn graph [_]
|
113 | 105 | (graph/construct-graph
|
114 | 106 | [[["start" graph/start]
|
115 |
| - ["list-tables-tool" (graph/sub-graph-node |
116 |
| - {:init-state seed-list-tables-conversation |
117 |
| - :construct-graph graph/generate-start-with-tool |
118 |
| - :next-state (state/take-last-messages 2)})] |
| 107 | + ["list-tables-tool" (graph/sub-graph-node |
| 108 | + {:init-state |
| 109 | + [#(assoc % :finish-reason "tool_calls") |
| 110 | + (state/tools-set (:tools first-tool-call)) |
| 111 | + (state/messages-append (:messages first-tool-call))] |
| 112 | + :construct-graph graph/generate-start-with-tool |
| 113 | + :next-state (state/take-last-messages 2)})] |
119 | 114 | ["model-get-schema" (graph/sub-graph-node
|
120 |
| - {:init-state seed-get-schema-conversation |
| 115 | + {:init-state |
| 116 | + [(state/tools-append (:tools model-get-schema))] |
121 | 117 | :next-state state/append-new-messages})]
|
122 | 118 | ["query-gen" query-gen]
|
123 | 119 | [:edge should-continue]]
|
|
0 commit comments