(apiConfiguration: ProviderSettings, promptText: string)
| 7 | * This is a lightweight alternative that only uses the API's completion functionality. |
| 8 | */ |
| 9 | export async function singleCompletionHandler(apiConfiguration: ProviderSettings, promptText: string): Promise<string> { |
| 10 | if (!promptText) { |
| 11 | throw new Error("No prompt text provided") |
| 12 | } |
| 13 | if (!apiConfiguration || !apiConfiguration.apiProvider) { |
| 14 | throw new Error("No valid API configuration provided") |
| 15 | } |
| 16 | |
| 17 | const handler = buildApiHandler(apiConfiguration) |
| 18 | |
| 19 | // Check if handler supports single completions |
| 20 | if (!("completePrompt" in handler)) { |
| 21 | throw new Error("The selected API provider does not support prompt enhancement") |
| 22 | } |
| 23 | |
| 24 | return (handler as SingleCompletionHandler).completePrompt(promptText) |
| 25 | } |
no test coverage detected