Skip to main content

Inspired by https://github.com/drathier/stack-overflow-import

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

copilot-import-0.1.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

copilot_import-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file copilot-import-0.1.0.tar.gz.

File metadata

  • Download URL: copilot-import-0.1.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.6 Windows/10

File hashes

Hashes for copilot-import-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f85ca2613440c49b04022a379b5d6ce666833a18b8124a941c811df07e749dce
MD5 12ca240aabb6a4927bb2f00d66bca16f
BLAKE2b-256 3474413443bce769ba472e577f6f12ab1dcb271f29886ac1bf6ee036e2d5e1b6

See more details on using hashes here.

File details

Details for the file copilot_import-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: copilot_import-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.6 Windows/10

File hashes

Hashes for copilot_import-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3c335f7077e9eacf05832160afd26da264a0d29bed0b8327f7eceea1941dcf8
MD5 ab70cad8437f9385641d533b2b888a23
BLAKE2b-256 7fc28df4cab680a54ed912967e3428934c1b3f5ebbf4c695a526a51446559d13

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page