Add GitHub Copilot API proxy integration to LLM Gateway: * Implement copilot-bridge service: - HTTP wrapper managing copilot-api (GitHub Copilot API proxy) - OpenAI-compatible /v1/chat/completions endpoint (port 3252) - Graceful startup and SIGTERM shutdown handling - Health check endpoint with service diagnostics * Register copilot-bridge in provider fallback chain: - Position: After OpenAI, before free LLM APIs (tier 4) - Rate limit: 60 requests/min (GitHub Copilot API limit) - Models: gpt-4 (reasoning), gpt-3.5-turbo (medium) - Authentication: GitHub Copilot subscription (internal to copilot-api) * Update PM2 ecosystem configuration: - Add copilot-bridge service definition (port 3252) - Configure COPILOT_BRIDGE_URL in gateway environment - Add copilot to LLM_PROVIDERS list * Enhance deployment automation: - Update ensure-bridges.sh with copilot-bridge deployment - Copy service files from repo to /opt/copilot-bridge - Run npm install for copilot-api dependency * Comprehensive documentation: - Expand DEPLOYMENT-BRIDGES.md with copilot-bridge section - Prerequisites: Node.js 20+, GitHub Copilot subscription - Authentication workflow: npm run auth with GitHub OAuth - Troubleshooting: subscription verification, auth cache reset Provider chain now supports: 1. Ollama (local, free) 2. claude-bridge (Claude subscription) 3. openai-bridge (OpenAI subscription) 4. copilot-bridge (GitHub Copilot subscription) ← NEW 5. Free APIs: Cerebras, Groq, Mistral, NVIDIA, Cloudflare Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
116 lines
3.7 KiB
JavaScript
116 lines
3.7 KiB
JavaScript
/**
|
|
* PM2 Ecosystem Config — LLM Gateway on Erik (217.154.82.179)
|
|
*
|
|
* Deploy: pm2 start deploy/ecosystem.config.cjs
|
|
* Reload: pm2 reload llm-gateway llm-learning
|
|
* Logs: pm2 logs llm-gateway
|
|
* Status: pm2 status
|
|
*/
|
|
module.exports = {
|
|
apps: [
|
|
{
|
|
name: 'llm-gateway',
|
|
script: 'packages/gateway/dist/server.js',
|
|
cwd: '/opt/llm-gateway',
|
|
instances: 1,
|
|
exec_mode: 'fork',
|
|
env: {
|
|
NODE_ENV: 'production',
|
|
PORT: 3103,
|
|
DATABASE_URL: 'postgresql://llm:llm_secure_2026@localhost:5432/llm_gateway',
|
|
TIP_DATABASE_URL: 'postgresql://tip:tip_prod_2026@localhost:5432/transceiver_db',
|
|
OLLAMA_URL: 'http://192.168.178.213:11434',
|
|
LOG_LEVEL: 'info',
|
|
GITEA_URL: 'http://192.168.178.196:3000',
|
|
GITEA_TOKEN: '',
|
|
// LLM Provider Configuration
|
|
CLAUDE_BRIDGE_URL: 'http://localhost:3250',
|
|
CLAUDE_BRIDGE_ENABLED: 'true',
|
|
OPENAI_BRIDGE_URL: 'http://localhost:3251',
|
|
CHATGPT_BRIDGE_URL: 'http://localhost:3251',
|
|
COPILOT_BRIDGE_URL: 'http://localhost:3252',
|
|
LLM_PROVIDERS: 'claude,openai,chatgpt,copilot,cerebras,groq,mistral,nvidia',
|
|
// Subscription API Keys (add as needed)
|
|
OPENAI_API_KEY: '',
|
|
// Free LLM APIs (add keys as needed)
|
|
CEREBRAS_API_KEY: '',
|
|
GROQ_API_KEY: '',
|
|
MISTRAL_API_KEY: '',
|
|
NVIDIA_API_KEY: '',
|
|
OPENROUTER_API_KEY: '',
|
|
},
|
|
// Restart on crash, but not on intentional stop
|
|
autorestart: true,
|
|
watch: false,
|
|
max_memory_restart: '512M',
|
|
// Graceful shutdown: wait up to 10s for in-flight requests
|
|
kill_timeout: 10000,
|
|
// Log rotation
|
|
error_file: '/var/log/llm-gateway/error.log',
|
|
out_file: '/var/log/llm-gateway/out.log',
|
|
log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
|
|
merge_logs: true,
|
|
},
|
|
{
|
|
name: 'openai-bridge',
|
|
script: '/opt/openai-bridge/server.js',
|
|
cwd: '/opt/openai-bridge',
|
|
instances: 1,
|
|
exec_mode: 'fork',
|
|
env: {
|
|
NODE_ENV: 'production',
|
|
OPENAI_BRIDGE_PORT: 3251,
|
|
OPENAI_API_KEY: '',
|
|
OPENAI_MODEL: 'gpt-4-turbo',
|
|
},
|
|
autorestart: true,
|
|
watch: false,
|
|
max_memory_restart: '256M',
|
|
kill_timeout: 5000,
|
|
error_file: '/var/log/llm-gateway/openai-bridge-error.log',
|
|
out_file: '/var/log/llm-gateway/openai-bridge-out.log',
|
|
log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
|
|
},
|
|
{
|
|
name: 'copilot-bridge',
|
|
script: '/opt/copilot-bridge/server.js',
|
|
cwd: '/opt/copilot-bridge',
|
|
instances: 1,
|
|
exec_mode: 'fork',
|
|
env: {
|
|
NODE_ENV: 'production',
|
|
COPILOT_BRIDGE_PORT: 3252,
|
|
COPILOT_API_INTERNAL_PORT: 4141,
|
|
},
|
|
autorestart: true,
|
|
watch: false,
|
|
max_memory_restart: '256M',
|
|
kill_timeout: 5000,
|
|
error_file: '/var/log/llm-gateway/copilot-bridge-error.log',
|
|
out_file: '/var/log/llm-gateway/copilot-bridge-out.log',
|
|
log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
|
|
},
|
|
{
|
|
name: 'llm-learning',
|
|
script: 'packages/learning/src/index.ts',
|
|
interpreter: 'node',
|
|
interpreter_args: '--import tsx/esm',
|
|
cwd: '/opt/llm-gateway',
|
|
instances: 1,
|
|
exec_mode: 'fork',
|
|
env: {
|
|
NODE_ENV: 'production',
|
|
DATABASE_URL: 'postgresql://llm:llm_secure_2026@localhost:5432/llm_gateway',
|
|
GATEWAY_URL: 'http://localhost:3103',
|
|
},
|
|
autorestart: true,
|
|
watch: false,
|
|
max_memory_restart: '256M',
|
|
kill_timeout: 5000,
|
|
error_file: '/var/log/llm-gateway/learning-error.log',
|
|
out_file: '/var/log/llm-gateway/learning-out.log',
|
|
log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
|
|
},
|
|
],
|
|
}
|