Skip to content

Conversation

@AlexisAyalaS
Copy link
Owner

🔧 feat: Add real AI API integration with smart fallback system

📝 Description

This PR implements real AI API integration for ChatGPT, DeepSeek, and Gemini platforms, replacing the previous simulated responses. The system includes a smart fallback mechanism that uses clipboard and browser when API keys are not available.

🔧 Technical Implementation

Real API Integration

  • OpenAI ChatGPT: Uses official OpenAI API with GPT-3.5-turbo
  • DeepSeek: Integrates with DeepSeek Chat API
  • Google Gemini: Connects to Gemini Pro via Google AI Studio API
  • Proper error handling with fallback to clipboard system

Smart Fallback System

  • Clipboard integration: Automatically copies prompts when API keys are missing
  • Browser automation: Opens corresponding AI chat platforms
  • User instructions: Clear guidance for manual prompt usage
  • Multiple process fallback: Combined prompts for batch operations

Dynamic Menu System

  • API key detection: Automatically detects configured API keys
  • Adaptive options: Shows/hides multiple processes based on API availability
  • Placeholder validation: Prevents using example API keys from env.example

Enhanced Configuration

  • Environment variables: Proper .env file support with dotenv
  • Node.js v18+ requirement: Updated engine requirements for all dependencies
  • API key validation: Checks for valid, non-placeholder keys

🎬 Demo

With API Keys

# Configure API keys in .env
OPENAI_API_KEY=sk-your-real-key
DEEPSEEK_API_KEY=sk-your-real-key  
GEMINI_API_KEY=your-real-key

# Use all features including multiple processes
git-ai
# Select: 🔄 Perform multiple processes
# Result: Direct AI responses via API

Without API Keys

# No API keys configured
git-ai
# Select: 📝 Generate Pull Request message  
# Result: Prompt copied to clipboard + browser opens
# Instructions: Paste in AI chat and copy response

Smart Menu Adaptation

🎯 What process do you want to perform?

✅ Available with API keys:
  🔄 Perform multiple processes
  📝 Generate Pull Request message
  💬 Suggest commit message
  🌿 Suggest branch name

⚠️ Available without API keys (clipboard fallback):
  📝 Generate Pull Request message  
  💬 Suggest commit message
  🌿 Suggest branch name

📋 Changes Made

Core Features

  • Added real API calls to OpenAI, DeepSeek, and Gemini
  • Implemented smart fallback system for missing API keys
  • Created dynamic menu that adapts to available API keys
  • Added clipboard integration for manual AI usage
  • Enhanced error handling with graceful degradation

Configuration Updates

  • Updated README with comprehensive API setup instructions
  • Added environment variable validation
  • Increased Node.js requirement to v18+ for compatibility
  • Improved documentation for fallback system

Technical Improvements

  • Added proper API response formatting
  • Implemented branch name extraction from AI responses
  • Enhanced multiple process handling with combined prompts
  • Added platform availability detection

The system now provides a seamless experience whether users have API keys configured or prefer manual interaction with AI platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants