A Copilot-like API service for code completions
Project description
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
PyPI Installation
pip install copilot-service
GitHub Installation
pip install git+https://github.com/yourusername/copilot-service.git
Usage
Set API Keys
The service uses LiteLLM for model access. To declare API keys, use LiteLLM's standard format. For example:
export OPENAI_API_KEY=your-api-key-here
# Or for other providers
export COHERE_API_KEY=your-api-key-here
export ANTHROPIC_API_KEY=your-api-key-here
Start the Service
copilot-service
Configuration
You can also configure the default model and token limits:
export DEFAULT_MODEL="gpt-3.5-turbo"
export DEFAULT_MAX_TOKENS=100
copilot-service
API Endpoints
POST /copilot/completions
Get AI-generated code completions
Request Body:
{
"file_contents": "def hello_w",
"cursor_position": 10
}
Response:
{
"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:
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file copilot-service-1.0.1.tar.gz.
File metadata
- Download URL: copilot-service-1.0.1.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e54827c436ff05dd8fbfc1fea98d73f086f2ed23298faca6e8aee814ca898b5b
|
|
| MD5 |
d165ea330fe930cb6ab128e781291211
|
|
| BLAKE2b-256 |
840e361adb7f938f8a82527159335f03707539eea0bfbb9eafc324bc8702abf9
|
File details
Details for the file copilot_service-1.0.1-py3-none-any.whl.
File metadata
- Download URL: copilot_service-1.0.1-py3-none-any.whl
- Upload date:
- Size: 20.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8881452eb02bded4ab11bd8952f7ae51089847ac214a9c970b16ff1db2d767f
|
|
| MD5 |
25a450d671d779958c34d8ae54367559
|
|
| BLAKE2b-256 |
8642ea34b4345d7e821437b63681cc06a2d095f0d251d02c0d9497bc2ee94b82
|