()
| 296 | }; |
| 297 | }, [builtLines]); |
| 298 | const askAi = (): void => { |
| 299 | if (!props.aiAvailable || builtLines.length === 0) return; |
| 300 | setAiState('running'); |
| 301 | void askModel({ |
| 302 | origin: SIDECAR_ORIGIN, |
| 303 | system: READER_SYSTEM_PROMPT, |
| 304 | user: buildReaderPrompt('chat reader', readerSubjectText(builtLines)), |
| 305 | chatTemplateKwargs: nonThinkingFor(props.requestModel ?? props.modelName ?? '').chatTemplateKwargs, |
| 306 | maxTokens: readerMaxTokens(builtLines), |
| 307 | fetch: (url, init) => window.fetch(url, init), |
| 308 | ...(props.requestModel === undefined ? {} : { model: props.requestModel }), |
| 309 | }).then((reply) => { |
| 310 | const checked = applyReaderRewrite(builtLines, reply.content); |
| 311 | if (checked.kind === 'applied') { |
| 312 | setAiLines(checked.lines.map((line) => line.text)); |
| 313 | setAiState('applied'); |
| 314 | setAiReason(''); |
| 315 | } else { |
| 316 | setAiState('refused'); |
| 317 | setAiReason(checked.reason); |
| 318 | } |
| 319 | }).catch((error: unknown) => { |
| 320 | setAiState('refused'); |
| 321 | setAiReason(error instanceof Error ? error.message : String(error)); |
| 322 | }); |
| 323 | }; |
| 324 | |
| 325 | return ( |
| 326 | <article |
nothing calls this directly
no test coverage detected