Skip to content

Add model-sync script that updates the current model list with the AI-SDKs list#2126

Open
bigfluffycookie wants to merge 23 commits intomainfrom
lb/models
Open

Add model-sync script that updates the current model list with the AI-SDKs list#2126
bigfluffycookie wants to merge 23 commits intomainfrom
lb/models

Conversation

@bigfluffycookie
Copy link
Contributor

@bigfluffycookie bigfluffycookie commented Mar 13, 2026

Fixes OPS-3907

Example PR: #2133

@linear
Copy link

linear bot commented Mar 13, 2026

@bigfluffycookie bigfluffycookie changed the title Add github action to update model list dynamically Add model-sync script that updates the current model list with the AI-SDKs list Mar 14, 2026
},
};

const NON_CHAT_KEYWORDS = [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im sure theres more we dont want, we can add to this whenever

@sonarqubecloud
Copy link

@bigfluffycookie bigfluffycookie marked this pull request as ready for review March 18, 2026 08:29
Copilot AI review requested due to automatic review settings March 18, 2026 08:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts to fetch model IDs from @ai-sdk/* .d.ts union types.
  • Compares fetched model lists against existing provider model arrays and prints a summary of adds/removals.
  • Adds an --update mode 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;
Comment on lines +295 to +321
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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was fixed in an antoher pr but yes we assume theres only 1

Comment on lines +265 to +270
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}`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants