|
15 | 15 | (def base-url "https://api.openai.com") |
16 | 16 |
|
17 | 17 | (defn ^:private base-completion-request! [{:keys [rid body api-url api-key on-error on-response]}] |
18 | | - (let [url (str api-url responses-path) |
19 | | - reason-id (str (random-uuid))] |
| 18 | + (let [url (str api-url responses-path)] |
20 | 19 | (llm-util/log-request logger-tag rid url body) |
21 | 20 | (http/post |
22 | 21 | url |
|
35 | 34 | (with-open [rdr (io/reader body)] |
36 | 35 | (doseq [[event data] (llm-util/event-data-seq rdr)] |
37 | 36 | (llm-util/log-response logger-tag rid event data) |
38 | | - (on-response event data reason-id)))) |
| 37 | + (on-response event data)))) |
39 | 38 | (catch Exception e |
40 | 39 | (on-error {:exception e})))) |
41 | 40 | (fn [e] |
|
83 | 82 | :max_output_tokens max-output-tokens} |
84 | 83 | mcp-call-by-item-id* (atom {}) |
85 | 84 | on-response-fn |
86 | | - (fn handle-response [event data reason-id] |
| 85 | + (fn handle-response [event data] |
87 | 86 | (case event |
88 | 87 | ;; text |
89 | 88 | "response.output_text.delta" |
|
112 | 111 | :on-response handle-response}) |
113 | 112 | (swap! mcp-call-by-item-id* dissoc (-> data :item :id))) |
114 | 113 | "reasoning" (on-reason {:status :finished |
115 | | - :id reason-id}) |
| 114 | + :id (-> data :item :id)}) |
116 | 115 | nil) |
117 | 116 |
|
118 | 117 | ;; URL mentioned |
|
128 | 127 | "response.output_item.added" |
129 | 128 | (case (-> data :item :type) |
130 | 129 | "reasoning" (on-reason {:status :started |
131 | | - :id reason-id}) |
| 130 | + :id (-> data :item :id)}) |
132 | 131 | "function_call" (let [call-id (-> data :item :call_id) |
133 | 132 | item-id (-> data :item :id) |
134 | 133 | name (-> data :item :name)] |
|
0 commit comments