Add model-sync script that updates the current model list with the AI-SDKs list#2126
Add model-sync script that updates the current model list with the AI-SDKs list#2126bigfluffycookie wants to merge 23 commits intomainfrom
Conversation
| }, | ||
| }; | ||
|
|
||
| const NON_CHAT_KEYWORDS = [ |
There was a problem hiding this comment.
im sure theres more we dont want, we can add to this whenever
|
There was a problem hiding this comment.
Pull request overview
Adds a developer script to sync the model ID lists in packages/openops/src/lib/ai/providers/*.ts with the model unions defined by the @ai-sdk/* TypeScript type definitions (fetched from unpkg), with optional in-place updates.
Changes:
- Introduces
sync-models.tsto fetch model IDs from@ai-sdk/*.d.tsunion types. - Compares fetched model lists against existing provider model arrays and prints a summary of adds/removals.
- Adds an
--updatemode to rewrite provider files with the fetched model list (after exclusions and filtering).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| const filePath = path.join(__dirname, 'providers', `${providerFile}.ts`); | ||
| const content = fs.readFileSync(filePath, 'utf-8'); | ||
| const match = content.match(/const\s+(\w+Models)\s*=\s*\[([\s\S]*?)\];/); | ||
| if (!match) return; |
| function getCurrentModels(providerFile: string): string[] { | ||
| const filePath = path.join(__dirname, 'providers', `${providerFile}.ts`); | ||
| if (!fs.existsSync(filePath)) return []; | ||
|
|
||
| const content = fs.readFileSync(filePath, 'utf-8'); | ||
| const match = content.match(/const\s+\w+Models\s*=\s*\[([\s\S]*?)\];/); | ||
| if (!match) return []; | ||
|
|
||
| return match[1] | ||
| .split(',') | ||
| .map((line) => line.match(/['"]([^'"]+)['"]/)?.[1]) | ||
| .filter((model): model is string => model != null) | ||
| .sort(); | ||
| } | ||
|
|
||
| function updateProviderFile(providerFile: string, models: string[]): void { | ||
| const filePath = path.join(__dirname, 'providers', `${providerFile}.ts`); | ||
| const content = fs.readFileSync(filePath, 'utf-8'); | ||
| const match = content.match(/const\s+(\w+Models)\s*=\s*\[([\s\S]*?)\];/); | ||
| if (!match) return; | ||
|
|
||
| const arrayName = match[1]; | ||
| const formattedModels = models.map((model) => ` '${model}',`).join('\n'); | ||
| const newArray = `const ${arrayName} = [\n${formattedModels}\n];`; | ||
| const updatedContent = content.replace( | ||
| /const\s+\w+Models\s*=\s*\[([\s\S]*?)\];/, | ||
| newArray, |
There was a problem hiding this comment.
this was fixed in an antoher pr but yes we assume theres only 1
| async function fetchAiSdkModels( | ||
| pkg: string, | ||
| source: TypeSource, | ||
| ): Promise<string[]> { | ||
| const distPath = source.distPath ?? 'dist/index.d.ts'; | ||
| const url = `https://unpkg.com/@ai-sdk/${pkg}@latest/${distPath}`; |
There was a problem hiding this comment.
nah this is correct, we barely update the AI-sdk and it worked so far when adding new models that are not in the package yet



Fixes OPS-3907
Example PR: #2133