-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathupdate_models.js
More file actions
24 lines (19 loc) · 1002 Bytes
/
update_models.js
File metadata and controls
24 lines (19 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const fs = require('fs');
const path = require('path');
const providersDir = path.join(__dirname, 'src/core/api/providers');
const files = fs.readdirSync(providersDir).filter(f => f.endsWith('.ts'));
for (const file of files) {
const filePath = path.join(providersDir, file);
let content = fs.readFileSync(filePath, 'utf8');
// Pattern to match:
// if (modelId in someModels) {
// const id = modelId as SomeModelId
// return { id, info: someModels[id] }
// }
// throw new Error(...)
// We want to replace it with:
// return { id: modelId as SomeModelId, info: someModels[modelId as SomeModelId] || someModels[someDefaultModelId] }
// Wait, the default model info is usually returned at the end of the function.
// If we just remove the `if (modelId in someModels)` and the `throw new Error`, we can just return the modelId and its info (or default info).
// Let's just use sed or a simple string replacement for each file.
}