-
Notifications
You must be signed in to change notification settings - Fork 92
221 lines (194 loc) · 8.64 KB
/
update-models.yml
File metadata and controls
221 lines (194 loc) · 8.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
name: Update AI Models
on:
schedule:
# Run every day at 00:00 UTC
- cron: '0 0 * * *'
workflow_dispatch: # Allow manual triggering
jobs:
update-models:
runs-on: ubuntu-latest
environment: Production
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
cache-dependency-glob: 'scripts/requirements*.txt'
- name: Install dependencies
run: uv pip sync scripts/requirements.txt --system
- name: Verify installation
run: |
python --version
python -c "import ruamel.yaml; print('ruamel.yaml:', ruamel.yaml.version_info)"
python -c "import httpx; print('httpx:', httpx.__version__)"
- name: Run automated model update
id: update
env:
AI302_API_KEY: ${{ secrets.AI302_API_KEY }}
APIPIE_API_KEY: ${{ secrets.APIPIE_API_KEY }}
COHERE_API_KEY: ${{ secrets.COHERE_API_KEY }}
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
FIREWORKS_API_KEY: ${{ secrets.FIREWORKS_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GLHF_API_KEY: ${{ secrets.GLHF_API_KEY }}
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
HUGGINGFACE_TOKEN: ${{ secrets.HUGGINGFACE_TOKEN }}
HYPERBOLIC_API_KEY: ${{ secrets.HYPERBOLIC_API_KEY }}
KLUSTER_API_KEY: ${{ secrets.KLUSTER_API_KEY }}
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}
NANOGPT_API_KEY: ${{ secrets.NANOGPT_API_KEY }}
NVIDIA_API_KEY: ${{ secrets.NVIDIA_API_KEY }}
OPENROUTER_KEY: ${{ secrets.OPENROUTER_KEY }}
PERPLEXITY_API_KEY: ${{ secrets.PERPLEXITY_API_KEY }}
SAMBANOVA_API_KEY: ${{ secrets.SAMBANOVA_API_KEY }}
TOGETHERAI_API_KEY: ${{ secrets.TOGETHERAI_API_KEY }}
UNIFY_API_KEY: ${{ secrets.UNIFY_API_KEY }}
XAI_API_KEY: ${{ secrets.XAI_API_KEY }}
run: |
cd scripts
python automated_update.py
- name: Check for changes
id: changes
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "HAS_CHANGES=true" >> $GITHUB_OUTPUT
echo "Changes detected in YAML files"
else
echo "HAS_CHANGES=false" >> $GITHUB_OUTPUT
echo "No changes detected"
fi
- name: Get current date
id: date
run: echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Commit and push changes (if validation passed)
if: steps.changes.outputs.HAS_CHANGES == 'true' && env.YAML_VALIDATION_FAILED != 'true'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add librechat-*.yaml
if [ -s .commit_msg ]; then
git commit -F .commit_msg
else
git commit -m "chore: update AI models (${{ steps.date.outputs.DATE }})"
fi
git push
- name: Trigger deploy webhook
if: steps.changes.outputs.HAS_CHANGES == 'true' && env.YAML_VALIDATION_FAILED != 'true'
env:
DEPLOY_WEBHOOK_URL: ${{ secrets.DEPLOY_WEBHOOK_URL }}
run: |
if [ -z "$DEPLOY_WEBHOOK_URL" ]; then
echo "DEPLOY_WEBHOOK_URL is not configured. Skipping deploy webhook."
exit 0
fi
echo "Triggering deploy webhook..."
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
-X POST "$DEPLOY_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{"event": "models_updated", "date": "${{ steps.date.outputs.DATE }}", "repository": "${{ github.repository }}", "run_id": "${{ github.run_id }}"}' \
--max-time 30)
if [ "$HTTP_STATUS" -ge 200 ] && [ "$HTTP_STATUS" -lt 300 ]; then
echo "Deploy webhook triggered successfully (HTTP $HTTP_STATUS)"
else
echo "Warning: Deploy webhook returned HTTP $HTTP_STATUS (non-fatal)"
fi
- name: Create Pull Request (if validation failed)
if: steps.changes.outputs.HAS_CHANGES == 'true' && env.YAML_VALIDATION_FAILED == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: update AI models (${{ steps.date.outputs.DATE }}) [YAML VALIDATION FAILED]"
branch: automated-update-${{ steps.date.outputs.DATE }}
delete-branch: true
title: '⚠️ AI Models Update - YAML Validation Failed (${{ steps.date.outputs.DATE }})'
body: |
## ⚠️ YAML Validation Failed
This automated update encountered YAML parsing errors and requires manual review.
### Validation Errors
```
${{ env.VALIDATION_ERRORS }}
```
### What to do
1. Review the changes in `librechat-test.yaml`
2. Fix any YAML syntax errors
3. Test the configuration locally
4. Merge this PR once validated
### Details
- **Date**: ${{ steps.date.outputs.DATE }}
- **Triggered by**: Automated workflow
- **Exit code**: Non-zero (validation failure)
@Berry-13 Please review this update.
labels: |
automated
needs-review
yaml-error
assignees: Berry-13
reviewers: Berry-13
- name: Notify on success
if: steps.changes.outputs.HAS_CHANGES == 'true' && env.YAML_VALIDATION_FAILED != 'true' && success()
env:
WEBHOOK_URL: ${{ secrets.NOTIFICATION_WEBHOOK }}
uses: actions/github-script@v7
with:
script: |
const files = 'all librechat-*.yaml files';
const message = `✅ **AI Models Updated Successfully**\n\nDate: ${{ steps.date.outputs.DATE }}\nFiles: ${files}\n\nChanges have been committed to the main branch.`;
console.log(message);
// Optional: Send to webhook if configured
if (process.env.WEBHOOK_URL) {
await fetch(process.env.WEBHOOK_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: message })
});
}
- name: Notify on validation failure
if: steps.changes.outputs.HAS_CHANGES == 'true' && env.YAML_VALIDATION_FAILED == 'true'
uses: actions/github-script@v7
with:
script: |
const message = `⚠️ **AI Models Update - Validation Failed**\n\nDate: ${{ steps.date.outputs.DATE }}\n\nYAML validation failed. A pull request has been created for manual review.\n\nErrors:\n${process.env.VALIDATION_ERRORS}\n\n@Berry-13`;
console.log(message);
// Optional: Send to webhook if configured
if (process.env.WEBHOOK_URL) {
await fetch(process.env.WEBHOOK_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: message })
});
}
env:
WEBHOOK_URL: ${{ secrets.NOTIFICATION_WEBHOOK }}
VALIDATION_ERRORS: ${{ env.VALIDATION_ERRORS }}
- name: Notify on failure
if: failure()
uses: actions/github-script@v7
with:
script: |
const message = `❌ **AI Models Update Failed**\n\nDate: ${{ steps.date.outputs.DATE }}\n\nThe automated update process encountered an error. Please check the workflow logs.\n\n@Berry-13`;
console.log(message);
// Optional: Send to webhook if configured
if (process.env.WEBHOOK_URL) {
await fetch(process.env.WEBHOOK_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: message })
});
}
env:
WEBHOOK_URL: ${{ secrets.NOTIFICATION_WEBHOOK }}
- name: No changes notification
if: steps.changes.outputs.HAS_CHANGES != 'true' && success()
run: |
echo "✅ Update check completed - no model changes detected"