|
166 | 166 |
|
167 | 167 | Handles the full conversation flow including tool calls, streaming responses, |
168 | 168 | and message normalization. Supports both single and parallel tool execution. |
169 | | - Compatible with OpenRouter and other OpenAI-compatible providers. |
170 | | -
|
171 | | - Parameters: |
172 | | - - model: Model ID (e.g., 'gpt-4', 'gpt-3.5-turbo', 'o1-preview') |
173 | | - - user-messages: Current user input messages |
174 | | - - instructions: System-level instructions for the model |
175 | | - - temperature: Sampling temperature (default 1.0) |
176 | | - - api-key: API key for the provider |
177 | | - - api-url: Base URL for the provider's API |
178 | | - - max-output-tokens: Maximum tokens in response |
179 | | - - past-messages: Previous conversation history |
180 | | - - tools: Available tools for function calling |
181 | | - - extra-payload: Additional request parameters |
182 | | -
|
183 | | - Callbacks: |
184 | | - - on-message-received: Called for each streaming text chunk and finish events |
185 | | - Format: {:type :text :text \"chunk\"} or {:type :finish :finish-reason \"reason\"} |
186 | | - - on-error: Called for any errors during processing |
187 | | - - on-prepare-tool-call: Called as tool calls are being prepared/accumulated |
188 | | - - on-tools-called: Called when tools need execution, expects {:new-messages [...]} |
189 | | - - on-reason: Called for reasoning/thinking events (o1 models and compatible) |
190 | | - Format: {:status :started/:thinking/:finished :id \"uuid\" :text \"reasoning chunk\"} |
191 | | -
|
192 | | - The function handles the OpenAI streaming protocol, accumulates partial tool call |
193 | | - arguments across chunks, executes tools when complete, and manages the conversation |
194 | | - flow including recursive API calls for tool result processing." |
| 169 | + Compatible with OpenRouter and other OpenAI-compatible providers." |
195 | 170 | [{:keys [model user-messages instructions temperature api-key api-url max-output-tokens |
196 | 171 | past-messages tools extra-payload] |
197 | 172 | :or {temperature 1.0}} |
|
0 commit comments