Skip to content

Commit ca1b87f

Browse files
More testing
1 parent 2fe0174 commit ca1b87f

2 files changed

Lines changed: 110 additions & 36 deletions

File tree

.github/workflows/sync-ai-models.yml

Lines changed: 72 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ jobs:
3131
if: steps.node-modules-cache.outputs.cache-hit != 'true'
3232
run: npm ci --no-audit --no-fund
3333

34+
- name: Build shared package
35+
run: npx nx run shared:build
36+
3437
- name: Check for model updates
3538
id: check-models
3639
continue-on-error: true
@@ -43,51 +46,84 @@ jobs:
4346
cat sync-output.txt
4447
exit 0
4548
46-
- name: Create Pull Request
49+
- name: Read warnings
4750
if: steps.check-models.outputs.exit_code == '1'
48-
id: create-pr
49-
uses: peter-evans/create-pull-request@v7
50-
with:
51-
token: ${{ secrets.GITHUB_TOKEN }}
52-
base: main
53-
commit-message: 'Update AI provider models from models.dev'
54-
title: 'Update AI Provider Models'
55-
body: |
56-
## 🤖 Automated Model Sync
57-
58-
This PR updates AI provider model lists based on the latest data from [models.dev](https://models.dev).
59-
60-
**Review the file changes** to see which models were added or removed for each provider.
61-
62-
### What to Check
63-
64-
- ✅ New models are legitimate and available
65-
- ✅ Removed models are actually deprecated/retired
66-
- ✅ Model IDs match provider documentation
67-
68-
### Testing Locally
69-
70-
```bash
71-
npx tsx packages/openops/src/lib/ai/sync-models.ts
72-
```
73-
74-
---
51+
id: warnings
52+
run: |
53+
if [ -f warnings.txt ]; then
54+
echo "HAS_WARNINGS=true" >> $GITHUB_OUTPUT
55+
{
56+
echo 'WARNINGS<<EOF'
57+
cat warnings.txt
58+
echo EOF
59+
} >> $GITHUB_OUTPUT
60+
else
61+
echo "HAS_WARNINGS=false" >> $GITHUB_OUTPUT
62+
fi
7563
76-
🔗 **Source**: https://models.dev/api.json (MIT License)
77-
branch: sync-ai-models-${{ github.run_number }}
78-
delete-branch: true
79-
labels: |
80-
dependencies
81-
automated
64+
- name: Commit and push to branch
65+
if: steps.check-models.outputs.exit_code == '1'
66+
run: |
67+
git config user.name "github-actions[bot]"
68+
git config user.email "github-actions[bot]@users.noreply.github.com"
69+
git checkout -b sync-ai-models-${{ github.run_number }}
70+
git add packages/openops/src/lib/ai/providers/
71+
git commit -m "Update AI provider models from models.dev"
72+
git push origin sync-ai-models-${{ github.run_number }}
73+
74+
# Commented out for testing - uncomment when ready to auto-create PRs
75+
# - name: Create Pull Request
76+
# if: steps.check-models.outputs.exit_code == '1'
77+
# id: create-pr
78+
# uses: peter-evans/create-pull-request@v7
79+
# with:
80+
# token: ${{ secrets.GITHUB_TOKEN }}
81+
# base: main
82+
# commit-message: 'Update AI provider models from models.dev'
83+
# title: 'Update AI Provider Models'
84+
# body: |
85+
# ## 🤖 Automated Model Sync
86+
#
87+
# This PR updates AI provider model lists based on the latest data from [models.dev](https://models.dev).
88+
#
89+
# **Review the file changes** to see which models were added or removed for each provider.
90+
#
91+
# ${{ steps.warnings.outputs.HAS_WARNINGS == 'true' && format('
92+
#
93+
# ---
94+
#
95+
# {0}
96+
#
97+
# ', steps.warnings.outputs.WARNINGS) || '' }}
98+
#
99+
# ### What to Check
100+
#
101+
# - ✅ New models are legitimate and available
102+
# - ✅ Removed models are actually deprecated/retired
103+
# - ✅ Model IDs match provider documentation
104+
#
105+
# ### Testing Locally
106+
#
107+
# ```bash
108+
# npx tsx packages/openops/src/lib/ai/sync-models.ts
109+
# ```
110+
#
111+
# ---
112+
#
113+
# 🔗 **Source**: https://models.dev/api.json (MIT License)
114+
# branch: sync-ai-models-${{ github.run_number }}
115+
# delete-branch: true
116+
# labels: |
117+
# dependencies
118+
# automated
82119

83120
- name: Summary
84121
if: always()
85122
run: |
86123
if [ "${{ steps.check-models.outputs.exit_code }}" == "0" ]; then
87124
echo "✅ All AI provider models are up to date!" >> $GITHUB_STEP_SUMMARY
88125
elif [ "${{ steps.check-models.outputs.exit_code }}" == "1" ]; then
89-
echo "🔄 Model updates detected and PR created" >> $GITHUB_STEP_SUMMARY
90-
cat sync-output.txt >> $GITHUB_STEP_SUMMARY
126+
echo "🔄 Model updates detected and branch created: sync-ai-models-${{ github.run_number }}" >> $GITHUB_STEP_SUMMARY
91127
else
92128
echo "❌ Sync script failed with unexpected error" >> $GITHUB_STEP_SUMMARY
93129
exit 1

packages/openops/src/lib/ai/sync-models.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,49 @@ function compareModels(
207207
return { added, removed, unchanged };
208208
}
209209

210+
function checkForUnmappedProviders(): string[] {
211+
const providerFiles = getProviderFiles();
212+
const mappedKeys = Object.values(MODELS_DEV_KEYS).filter(
213+
(key): key is string => key !== undefined,
214+
);
215+
216+
const unmappedFiles = providerFiles.filter((file) => {
217+
const normalizedFile = normalizeProviderKey(file);
218+
return !mappedKeys.some(
219+
(key) => normalizeProviderKey(key) === normalizedFile,
220+
);
221+
});
222+
223+
return unmappedFiles;
224+
}
225+
210226
async function main() {
211227
const shouldUpdate = process.argv.includes('--update');
212228

213229
console.log('🔄 Fetching models from models.dev...\n');
214230

231+
const unmappedProviders = checkForUnmappedProviders();
232+
if (unmappedProviders.length > 0) {
233+
console.log('⚠️ Warning: Found provider files not in MODELS_DEV_KEYS:');
234+
unmappedProviders.forEach((file) =>
235+
console.log(` - ${file}.ts (not synced)`),
236+
);
237+
console.log(
238+
' Add these to MODELS_DEV_KEYS if they should be synced.\n',
239+
);
240+
241+
if (shouldUpdate) {
242+
const warningMessage = unmappedProviders
243+
.map((file) => `- \`${file}.ts\``)
244+
.join('\n');
245+
fs.writeFileSync(
246+
'warnings.txt',
247+
`⚠️ **Warning**: The following provider files are not in \`MODELS_DEV_KEYS\` and were not synced:\n\n${warningMessage}\n\nIf these should be synced with models.dev, add them to \`MODELS_DEV_KEYS\` in \`sync-models.ts\`.`,
248+
'utf-8',
249+
);
250+
}
251+
}
252+
215253
const modelsDevData = await fetchModelsDevData();
216254

217255
console.log('📊 Comparing models for each provider:\n');

0 commit comments

Comments
 (0)