(input: {
id: string
providerId: string
name: string
description?: string
contextWindow?: number
capabilities?: string[]
recommendedFor?: string[]
status?: string
})
| 72 | } |
| 73 | |
| 74 | add(input: { |
| 75 | id: string |
| 76 | providerId: string |
| 77 | name: string |
| 78 | description?: string |
| 79 | contextWindow?: number |
| 80 | capabilities?: string[] |
| 81 | recommendedFor?: string[] |
| 82 | status?: string |
| 83 | }): { success: boolean; model?: ModelDefinition; error?: string } { |
| 84 | const models = this.getAll() |
| 85 | if (models.find((m) => m.id === input.id && m.providerId === input.providerId)) { |
| 86 | return { |
| 87 | success: false, |
| 88 | error: `Model "${input.id}" already exists under provider "${input.providerId}"`, |
| 89 | } |
| 90 | } |
| 91 | const newModel: ModelDefinition = { |
| 92 | id: input.id, |
| 93 | providerId: input.providerId, |
| 94 | name: input.name, |
| 95 | description: input.description, |
| 96 | contextWindow: input.contextWindow, |
| 97 | capabilities: (input.capabilities ?? ['chat']) as ModelDefinition['capabilities'], |
| 98 | recommendedFor: (input.recommendedFor ?? ['chat']) as ModelDefinition['recommendedFor'], |
| 99 | status: (input.status ?? 'stable') as ModelDefinition['status'], |
| 100 | builtin: false, |
| 101 | editable: true, |
| 102 | } |
| 103 | models.push(newModel) |
| 104 | this.storage.writeJson('custom-models', models) |
| 105 | return { success: true, model: newModel } |
| 106 | } |
| 107 | |
| 108 | update(providerId: string, modelId: string, updates: Partial<ModelDefinition>): { success: boolean; error?: string } { |
| 109 | const models = this.getAll() |
no test coverage detected