| 13 | import { get, post, put, del } from '../utils/http' |
| 14 | |
| 15 | export class FetchLLMAdapter implements LLMServiceAdapter { |
| 16 | async hasConfig(): Promise<boolean> { |
| 17 | return get<boolean>('/ai/llm/has-config') |
| 18 | } |
| 19 | |
| 20 | async getConfigStore(): Promise<LLMConfigStore> { |
| 21 | return get<LLMConfigStore>('/ai/llm/configs') |
| 22 | } |
| 23 | |
| 24 | async getAllConfigs(): Promise<AIServiceConfigDisplay[]> { |
| 25 | const store = await this.getConfigStore() |
| 26 | return store.configs |
| 27 | } |
| 28 | |
| 29 | async getDefaultAssistantSlot(): Promise<ModelSlot | null> { |
| 30 | return get<ModelSlot | null>('/ai/llm/default-assistant-slot') |
| 31 | } |
| 32 | |
| 33 | async getFastModelSlot(): Promise<ModelSlot | null> { |
| 34 | return get<ModelSlot | null>('/ai/llm/fast-model-slot') |
| 35 | } |
| 36 | |
| 37 | async setDefaultAssistantModel(configId: string, modelId: string) { |
| 38 | return put<{ success: boolean; error?: string }>('/ai/llm/default-assistant-slot', { configId, modelId }) |
| 39 | } |
| 40 | |
| 41 | async setFastModel(slot: ModelSlot | null) { |
| 42 | return put<{ success: boolean; error?: string }>('/ai/llm/fast-model-slot', slot) |
| 43 | } |
| 44 | |
| 45 | async getProviders(): Promise<LLMProvider[]> { |
| 46 | return get<LLMProvider[]>('/ai/llm/providers') |
| 47 | } |
| 48 | |
| 49 | async getProviderRegistry(): Promise<ProviderRegistryItem[]> { |
| 50 | return get<ProviderRegistryItem[]>('/ai/llm/provider-registry') |
| 51 | } |
| 52 | |
| 53 | async getModelCatalog(): Promise<ModelCatalogItem[]> { |
| 54 | return get<ModelCatalogItem[]>('/ai/llm/model-catalog') |
| 55 | } |
| 56 | |
| 57 | async addConfig(config: AIServiceConfigInput) { |
| 58 | return post<{ success: boolean; config?: AIServiceConfigDisplay; error?: string }>('/ai/llm/configs', config) |
| 59 | } |
| 60 | |
| 61 | async updateConfig(id: string, updates: Partial<AIServiceConfigInput>) { |
| 62 | return put<{ success: boolean; error?: string }>(`/ai/llm/configs/${id}`, updates) |
| 63 | } |
| 64 | |
| 65 | async deleteConfig(id: string) { |
| 66 | return del<{ success: boolean; error?: string }>(`/ai/llm/configs/${id}`) |
| 67 | } |
| 68 | |
| 69 | async validateApiKey( |
| 70 | provider: string, |
| 71 | apiKey: string, |
| 72 | baseUrl?: string, |
nothing calls this directly
no outgoing calls
no test coverage detected