MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / add

Method add

packages/node-runtime/src/ai/custom-store.ts:74–106  ·  view source on GitHub ↗
(input: {
    id: string
    providerId: string
    name: string
    description?: string
    contextWindow?: number
    capabilities?: string[]
    recommendedFor?: string[]
    status?: string
  })

Source from the content-addressed store, hash-verified

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()

Callers 15

analyzeNewImportFunction · 0.45
streamParseFileInfoFunction · 0.45
loadExistingDedupFunction · 0.45
isDuplicateFunction · 0.45
cleanupExpiredMethod · 0.45
getActiveRecordMethod · 0.45
detectMethod · 0.45
ensureVecTableMethod · 0.45
buildMethod · 0.45
rebuildMethod · 0.45
getActivePathRowsMethod · 0.45

Calls 2

getAllMethod · 0.95
writeJsonMethod · 0.80

Tested by

no test coverage detected