feat(ai): add Ollama integration for AI release notes

- Install Ollama in GitHub Actions workflow
- Pull configurable AI model (default: gemma2:9b)
- Add AI model input to workflow parameters
- Implement fallback to OpenAI if Ollama fails
- Add comprehensive error handling and testing
- Update documentation with AI model configuration

This enables intelligent AI-powered release notes generation
using your existing changelog system with Ollama models.
This commit is contained in:
Vijay Janapa Reddi
2025-08-02 11:23:45 -04:00
parent a3f57518c8
commit a623867919
2 changed files with 75 additions and 11 deletions

View File

@@ -25,6 +25,10 @@ on:
description: 'Type "PUBLISH" to confirm'
required: true
default: ''
ai_model:
description: 'AI model for release notes (default: gemma2:9b)'
required: false
default: 'gemma2:9b'
permissions:
contents: write
@@ -336,16 +340,41 @@ jobs:
run: |
echo "📝 Generating AI-powered release notes..."
# Install Python dependencies if needed
# Install Python dependencies
python -m pip install --upgrade pip
python -m pip install openai requests
# Install Ollama
echo "🤖 Installing Ollama..."
curl -fsSL https://ollama.ai/install.sh | sh
# Start Ollama service
echo "🚀 Starting Ollama service..."
ollama serve &
sleep 10 # Wait for service to start
# Pull the model (configurable via workflow input)
MODEL="${{ github.event.inputs.ai_model || 'gemma2:9b' }}"
echo "📦 Pulling AI model: $MODEL"
ollama pull $MODEL
# Test Ollama connection
echo "🧪 Testing Ollama connection..."
if ollama list | grep -q "$MODEL"; then
echo "✅ Ollama model ready: $MODEL"
else
echo "❌ Failed to pull model: $MODEL"
exit 1
fi
# Generate release notes using your existing AI system
echo "📝 Generating release notes with AI..."
python tools/scripts/maintenance/update_changelog.py \
--release-notes \
--version ${{ steps.version.outputs.new_version }} \
--previous-version ${{ steps.version.outputs.previous_version }} \
--description "${{ github.event.inputs.description }}" \
--model $MODEL \
--verbose
# Check if release notes were generated
@@ -353,9 +382,20 @@ jobs:
echo "✅ AI release notes generated successfully"
cat "release_notes_${{ steps.version.outputs.new_version }}.md"
else
echo "⚠️ AI release notes generation failed, using fallback"
# Fallback to basic release notes
cat > "release_notes_${{ steps.version.outputs.new_version }}.md" << EOF
echo "⚠️ AI release notes generation failed, trying fallback..."
# Try without AI (basic analysis)
echo "🔄 Attempting basic release notes generation..."
python tools/scripts/maintenance/update_changelog.py \
--release-notes \
--version ${{ steps.version.outputs.new_version }} \
--previous-version ${{ steps.version.outputs.previous_version }} \
--description "${{ github.event.inputs.description }}" \
--openai \
--verbose || {
echo "⚠️ Basic generation also failed, using template"
# Fallback to basic release notes template
cat > "release_notes_${{ steps.version.outputs.new_version }}.md" << EOF
## 📚 Release ${{ steps.version.outputs.new_version }}
**${{ github.event.inputs.description }}**
@@ -379,7 +419,11 @@ jobs:
- 🌐 [Read Online](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }})
- 📄 [Download PDF](https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.new_version }}/Machine-Learning-Systems.pdf)
- 📄 [Direct PDF Link](https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/assets/Machine-Learning-Systems.pdf)
---
*Note: AI analysis was unavailable, using template release notes*
EOF
}
fi
- name: 📦 Create GitHub Release with PDF

View File

@@ -93,24 +93,44 @@ The workflow now creates **draft releases** that you can edit manually on GitHub
### Generate Release Notes Script
Use the release notes generator for comprehensive analysis:
The workflow automatically generates AI-powered release notes using your existing changelog system:
```bash
python tools/scripts/generate_release_notes.py v1.2.0 "Add new chapter on TinyML" v1.1.0
# Manual usage (for testing)
python tools/scripts/maintenance/update_changelog.py \
--release-notes \
--version v1.2.0 \
--previous-version v1.1.0 \
--description "Add new chapter on TinyML" \
--model gemma2:9b
```
This script analyzes:
This analyzes:
- 📊 Git commits since last release
- 📁 Changed files and directories
- 📖 Content updates and improvements
- 🔧 Technical changes and infrastructure updates
- 🎯 Impact assessment with visual bars
### AI Model Configuration
The workflow uses Ollama with configurable AI models:
- **Default**: `gemma2:9b` (fast, good quality)
- **Alternative**: `gemma2:27b` (better quality, slower)
- **Other options**: `llama3.1:8b`, `llama3.1:70b`
You can specify the model in the workflow inputs:
- Go to GitHub Actions → "🚀 Publish Live"
- Set "AI model" field to your preferred model
- Leave empty for default (`gemma2:9b`)
### Manual Release Notes Workflow
1. **Run publish-live workflow** → Creates draft release
2. **Generate release notes** → Use the script above
3. **Edit on GitHub** → Go to the draft release and edit
4. **Publish release** → Click "Publish release" when ready
1. **Run publish-live workflow** → Creates draft release with AI notes
2. **AI analyzes changes** → Uses your existing changelog system
3. **Edit on GitHub** → Go to the draft release and edit if needed
4. **Publish when ready** → Click "Publish release" when satisfied
## 📋 Usage Instructions