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
Metadata
Release files for copilot-service 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| copilot-service-1.0.1.tar.gz | 20.6 kB | Without provenance | Details for copilot-service-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| copilot_service-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for copilot_service-1.0.1-py3-none-any.whl |
Total release size: 41.1 kB
Release files / copilot-service-1.0.1.tar.gz
| Download URL | copilot-service-1.0.1.tar.gz |
|---|---|
| Size | 20.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e54827c436ff05dd8fbfc1fea98d73f086f2ed23298faca6e8aee814ca898b5b
|
|
BLAKE2b-256 checksum How to use checksums |
840e361adb7f938f8a82527159335f03707539eea0bfbb9eafc324bc8702abf9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.2
|
Release files / copilot_service-1.0.1-py3-none-any.whl
| Download URL | copilot_service-1.0.1-py3-none-any.whl |
|---|---|
| Size | 20.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c8881452eb02bded4ab11bd8952f7ae51089847ac214a9c970b16ff1db2d767f
|
|
BLAKE2b-256 checksum How to use checksums |
8642ea34b4345d7e821437b63681cc06a2d095f0d251d02c0d9497bc2ee94b82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.2
|
Security for copilot-service 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.