-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathAIModelRegistry.ts
More file actions
59 lines (47 loc) · 1.28 KB
/
AIModelRegistry.ts
File metadata and controls
59 lines (47 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// src/api/ai/core/AIModelRegistry.ts
import { AICapability } from './types'
export type AIModel = {
id: string
provider: string
capabilities: AICapability[]
}
class AIModelRegistry {
private models: AIModel[] = []
// --------------------
// Model management
// --------------------
register(model: AIModel) {
if (this.models.some(m => m.id === model.id && m.provider === model.provider)) {
throw new Error(
`Model "${model.id}" from provider "${model.provider}" is already registered.`
)
}
this.models.push(model)
}
listProviders(): string[] {
return [...new Set(this.models.map(m => m.provider))]
}
listModelsByProvider(provider: string): AIModel[] {
return this.models.filter(m => m.provider === provider)
}
getModel(provider: string, modelId: string): AIModel | undefined {
return this.models.find(
m => m.provider === provider && m.id === modelId
)
}
listAll(): AIModel[] {
return [...this.models]
}
}
export const aiModelRegistry = new AIModelRegistry()
// Register default models
aiModelRegistry.register({
id: 'gemini-pro',
provider: 'gemini',
capabilities: ['cloud'],
})
aiModelRegistry.register({
id: 'gemini-pro-vision',
provider: 'gemini',
capabilities: ['cloud', 'multimodal'],
})