import { anthropic, completePrompt, fireworksai, logCompletePrompt, openai } from '../models'; import { getModelEntry, loadSettings } from '../settings'; import { PROVIDERS } from '../models'; import { SynthOSConfig } from '../init'; export async function createCompletePrompt(config: SynthOSConfig, use: 'builder' | 'chat', modelOverride?: string): Promise { // Get configuration settings const settings = await loadSettings(config); const entry = getModelEntry(settings, use); // ClaudeCode provider uses its own CLI subprocess — no API key or completePrompt needed. // Return a no-op stub; the ClaudeCode builder ignores it entirely. if (entry.provider === 'ClaudeCode') { return async () => ({ completed: false, error: new Error('ClaudeCode provider does not use completePrompt') }); } if (!entry.configuration.apiKey) { throw new Error('API key not configured'); } // Validate model const model = modelOverride || entry.configuration.model; if (!model) { throw new Error('Model not configured'); } // Create completion functions let modelInstance: completePrompt; const apiKey = entry.configuration.apiKey; if (entry.provider === 'Anthropic') { modelInstance = anthropic({apiKey, model}); } else if (entry.provider === 'FireworksAI') { modelInstance = fireworksai({apiKey, model}); } else { modelInstance = openai({apiKey, model}); } // Return new model instance if (entry.logCompletions) { return logCompletePrompt(modelInstance, true); } else { return modelInstance; } } export { PROVIDERS };