Skip to content

Update AI Models

Update AI Models #170

Workflow file for this run

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"