( request: APIRequestContext, baseURL: string, options: SummarizeOptions, )
| 271 | * Call the summarize API directly (non-streaming) |
| 272 | */ |
| 273 | export async function callSummarizeAPI( |
| 274 | request: APIRequestContext, |
| 275 | baseURL: string, |
| 276 | options: SummarizeOptions, |
| 277 | ): Promise<{ summary: string; provider: string; model: string }> { |
| 278 | const response = await request.post(`${baseURL}/api/summarize`, { |
| 279 | data: { |
| 280 | text: options.text, |
| 281 | provider: options.provider, |
| 282 | model: options.model, |
| 283 | maxLength: options.maxLength || 100, |
| 284 | style: options.style || 'concise', |
| 285 | stream: false, |
| 286 | }, |
| 287 | }) |
| 288 | |
| 289 | if (!response.ok()) { |
| 290 | const errorBody = await response.text() |
| 291 | throw new Error(`Summarize API failed: ${response.status()} - ${errorBody}`) |
| 292 | } |
| 293 | |
| 294 | return response.json() |
| 295 | } |
| 296 | |
| 297 | /** |
| 298 | * Call the summarize API with streaming |
no test coverage detected