(key)
| 175 | * @returns {{ name: string, baseUrl: string, apiKey: string, models: string[] }|null} |
| 176 | */ |
| 177 | export function getCustomProvider(key) { |
| 178 | const db = getDb(); |
| 179 | const row = db |
| 180 | .select() |
| 181 | .from(settings) |
| 182 | .where(and(eq(settings.type, 'llm_provider'), eq(settings.key, key))) |
| 183 | .get(); |
| 184 | if (!row) return null; |
| 185 | const config = JSON.parse(decrypt(JSON.parse(row.value))); |
| 186 | if (!config.models) config.models = []; |
| 187 | return config; |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * Create or update a custom provider (encrypted JSON). |
no test coverage detected