(systemPrompt, userPrompt, options)
| 54 | }, |
| 55 | |
| 56 | async llmComplete(systemPrompt, userPrompt, options) { |
| 57 | const fastConfig = getFastModelConfig() |
| 58 | if (!fastConfig) throw new Error(t('llm.notConfigured')) |
| 59 | |
| 60 | const piModel = buildPiModel(fastConfig) |
| 61 | const result = await completeSimple( |
| 62 | piModel, |
| 63 | { systemPrompt, messages: [{ role: 'user', content: userPrompt, timestamp: Date.now() }] }, |
| 64 | { apiKey: fastConfig.apiKey, temperature: options?.temperature, maxTokens: options?.maxTokens } |
| 65 | ) |
| 66 | |
| 67 | if (result.stopReason === 'error' || result.stopReason === 'aborted') { |
| 68 | throw new Error(result.errorMessage || t('llm.callFailed')) |
| 69 | } |
| 70 | |
| 71 | return result.content |
| 72 | .filter((item): item is PiTextContent => item.type === 'text') |
| 73 | .map((item) => item.text) |
| 74 | .join('') |
| 75 | }, |
| 76 | |
| 77 | t, |
| 78 | logger: aiLogger, |
nothing calls this directly
no test coverage detected