# Copilot Service API This Flask application provides an API service for AI-powered code completions, mimicking GitHub Copilot functionality. ## Features - Generate code completions with configurable AI models - Token usage tracking - Prompt customization - Caching for efficiency - Interactive playground for testing ## Installation 1. Clone the repository: ```bash git clone https://github.com/yourusername/copilot-service.git cd copilot-service ``` 2. Install dependencies: ```bash pip install -r requirements.txt ``` ## Usage Start the development server: ```bash python server.py ``` The API will be available at `http://localhost:5000` ## API Endpoints ### POST /copilot/completions Get AI-generated code completions **Request Body:** ```json { "file_contents": "def hello_w", "cursor_position": 10 } ``` **Response:** ```json { "completion": "orld():\n print(\"Hello World!\")", "token_metadata": { "prompt_tokens": 120, "completion_tokens": 20, "total_tokens": 140 } } ``` ### POST /copilot/preview Preview the prompt being sent to the AI ### GET /version Get service version information ## Testing Run tests with: ```bash python test.py ``` ## License GNU General Public License v3.0 ## Interactive Playground Access the playground at `http://localhost:5000` - Type code and click "Get Completion" for ghost text suggestions - Test API endpoints directly from the browser