Skip to main content

Copilot Importer

Why write code when you can import it directly from GitHub Copilot?

What is Copilot Importer?

The copilot python module will dynamically generate any function imported by leveraging the GitHub Copilot service.

How do I use Copilot Importer?

You can install copilot-importer via pip (e.g. pip install copilot-importer).

Additionally and importantly, you need a GitHub Copilot API token. If you have access to GitHub Copilot, you can find your token from (TODO: ADD TOKEN INSTRUCTIONS).

Once you have your token, set it to the environment variable GITHUB_COPILOT_TOKEN.

export GITHUB_COPILOT_TOKEN=xxxxxxxxxxxxxxxxxxxx

Finally, before the dynamic importing feature is enabled, you must run the copilot.install method.

# Enable copilot importer
from copilot import install
install()

After all of the above has been taken care of, you should be able to import anything you want directly from GitHub Copilot:

>>> from copilot import install
>>> install()

>>> from copilot import base64_encode
>>> base64_encode(b"test")
b'dGVzdA=='

>>> from copilot import base64_decode
>>> base64_decode(base64_encode(b"test"))
b'test'

>>> from copilot import quicksort
>>> quicksort([5,2,3,4])
[2, 3, 4, 5]

You can also output the code of imported functions like so:

>>> from copilot import say_hello
>>> print(say_hello._code)
def say_hello():
    print("Hello, World!")

Credits

  • Inspiration taken from stack-overflow-import
  • GitHub for providing GitHub Copilot
  • molenzwiebel for working out the copilot API and most of the code
  • akx for giving a quick review of the code

Release files for copilot-import 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for copilot-import 0.1.0
File Size Uploaded
copilot-import-0.1.0.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for copilot-import 0.1.0
File Interpreter ABI Platform
copilot_import-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.4 kB

Release files / copilot-import-0.1.0.tar.gz

Download URL copilot-import-0.1.0.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f85ca2613440c49b04022a379b5d6ce666833a18b8124a941c811df07e749dce
BLAKE2b-256 checksum
How to use checksums
3474413443bce769ba472e577f6f12ab1dcb271f29886ac1bf6ee036e2d5e1b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.6 Windows/10

Release files / copilot_import-0.1.0-py3-none-any.whl

Download URL copilot_import-0.1.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3c335f7077e9eacf05832160afd26da264a0d29bed0b8327f7eceea1941dcf8
BLAKE2b-256 checksum
How to use checksums
7fc28df4cab680a54ed912967e3428934c1b3f5ebbf4c695a526a51446559d13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.8.6 Windows/10

Release history Release notifications | RSS feed

1.0.0

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page