This documentation covers the integration between the changelog system, GitHub repository, and Custom GPT models.
Overview
The system consists of three main components:
Local changelog management script
GitHub repository integration
Custom GPT model integration
Backend API Endpoints
1. Get Repository Changes
GET /api/repository/changes
Response:
{
"changes": [
{
"type": "Added" | "Changed" | "Removed",
"path": string,
"category": "Documentation" | "Security" | "Tests" | "Configuration" | "Feature"
}
]
}
2. Update Changelog
POST /api/changelog/update
Request:
{
"changes": [
{
"type": "Added" | "Changed" | "Removed",
"description": string
}
]
}
Response:
{
"success": boolean,
"message": string
}
3. Create Release
POST /api/changelog/release
Request:
{
"version_bump": "MAJOR" | "MINOR" | "PATCH"
}
Response:
{
"success": boolean,
"version": string,
"message": string
}
Custom GPT Function Definitions
Add these function definitions to your Custom GPT model configuration:
{
"functions": [
{
"name": "get_repository_changes",
"description": "Get list of changes in the repository",
"parameters": {
"type": "object",
"properties": {},
"required": []
}
},
{
"name": "update_changelog",
"description": "Update changelog with new changes",
"parameters": {
"type": "object",
"properties": {
"changes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["Added", "Changed", "Removed"]
},
"description": {
"type": "string"
}
},
"required": ["type", "description"]
}
}
},
"required": ["changes"]
}
},
{
"name": "create_release",
"description": "Create a new release in the changelog",
"parameters": {
"type": "object",
"properties": {
"version_bump": {
"type": "string",
"enum": ["MAJOR", "MINOR", "PATCH"]
}
},
"required": ["version_bump"]
}
}
]
}
Implementation Example
Here's how to use these functions in your Custom GPT model:
// Get repository changes
const changes = await get_repository_changes();
// Analyze changes and update changelog
if (changes.length > 0) {
const formattedChanges = changes.map(change => ({
type: change.type,
description: `${change.category}: ${change.path}`
}));
await update_changelog({ changes: formattedChanges });
}
// Create a new release
await create_release({ version_bump: "PATCH" });
Backend Implementation
The backend should implement these endpoints using the existing changelog script:
from flask import Flask, jsonify, request
from changelog_manager import ChangelogManager
app = Flask(__name__)
manager = ChangelogManager()
@app.route('/api/repository/changes', methods=['GET'])
def get_changes():
changes = manager.git_analyzer.get_changes()
return jsonify({
'changes': [
{
'type': change[0],
'path': change[1],
'category': change[2]
}
for change in changes
]
})
@app.route('/api/changelog/update', methods=['POST'])
def update_changelog():
changes = request.json.get('changes', [])
success = all(
manager.add_entry(change['type'], change['description'])
for change in changes
)
return jsonify({
'success': success,
'message': 'Changelog updated successfully' if success else 'Failed to update changelog'
})
@app.route('/api/changelog/release', methods=['POST'])
def create_release():
version_bump = request.json.get('version_bump', 'PATCH')
success = manager.create_release(version_bump)
return jsonify({
'success': success,
'version': str(manager.get_current_version()),
'message': 'Release created successfully' if success else 'Failed to create release'
})
GitBook Integration
To integrate with GitBook:
Ensure the changelog file is in the GitBook documentation directory
Use GitBook's API to update the documentation when changes are made:
import requests
def update_gitbook(changelog_content, api_key):
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
# Update GitBook page content
response = requests.post(
'https://api.gitbook.com/v1/spaces/{space_id}/content',
headers=headers,
json={
'path': '/changelog.md',
'content': changelog_content
}
)
return response.status_code == 200
Security Considerations
API Authentication: Implement JWT or API key authentication for all endpoints
Input Validation: Validate all input parameters before processing
Rate Limiting: Implement rate limiting to prevent abuse
Access Control: Restrict access to release creation to authorized users
Secure Storage: Store API keys and credentials securely using environment variables
Error Handling
Implement proper error handling for common scenarios:
class ChangelogError(Exception):
pass
def handle_changelog_error(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except ChangelogError as e:
return jsonify({
'success': False,
'error': str(e)
}), 400
except Exception as e:
return jsonify({
'success': False,
'error': 'Internal server error'
}), 500
return wrapper