import { CHAT_PROVIDERS, PROVIDER_URLS, PluginSettings, PostProcessingProvider } from "./SettingsManager"; export interface ResolvedChatProvider { apiKey: string; endpoint: string; provider: PostProcessingProvider; } /** * Resolves the API key + endpoint for a chat-completion provider selection. * Shared by every AI feature that talks to an LLM (Post-Processing, * Proofreading, Title Generation, Property Filler) so they all treat * providers — including "no key configured" — identically. */ export function resolveChatProvider( settings: PluginSettings, provider: PostProcessingProvider ): ResolvedChatProvider | null { const info = CHAT_PROVIDERS.find((p) => p.id === provider); if (!info) return null; const apiKey = settings[info.apiKeyField]; const endpoint = provider === "custom" ? settings.customApiUrl : PROVIDER_URLS[provider]; if (!apiKey || !endpoint) return null; return { apiKey, endpoint, provider }; }