Skip to main content

API Wrapper for GitHub Copilot Chat

Project description

GitHub Copilot Chat

This is a Python SDK that provides a simple interface to interact with the GitHub Copilot API. It uses reverse engineered API, unofficial, use at your own risk. This SDK is not affiliated with GitHub. It was created for educational purposes only.

To run this project, you need to set the following environment variables:

  • GH_TOKEN: Generated by Official GitHub Client. You need to find this yourself and use it at your own risk. If you know what you are doing, you will know how to get this token. The developer of this project won't provide any support for this.

Example Usage

from gh_copilot_chat import Copilot
import asyncio
import json


async def run():
    async with Copilot() as cp:
        thread_id = await cp.new_chat()
        print("-----")
        while True:
            question = input("You: ")
            if question == "exit":
                break
            print("Copilot: ", end="")
            async for line in cp.ask_stream(thread_id, question):
                response = line.replace("data: ", "")
                try:
                    response = json.loads(response)
                except json.decoder.JSONDecodeError:
                    continue
                if response["type"] == "content":
                    print(response["body"], end="")
                elif response["type"] == "complete":
                    print()
                    break
            print("-----")
        await cp.generate_title(thread_id)
    return True


asyncio.run(run())

Pip Installation

Install the package using pip/any other package manager

pip install gh_copilot_chat

Then you can use the package in your code

Poetry Project

This is a Python project that uses Poetry for dependency management and packaging.

Getting Started

  1. Install Poetry by following the official installation guide.

  2. Clone this repository:

git clone https://github.com/rabilrbl/gh_copilot_sdk.git

  1. Navigate to the project directory:

cd gh_copilot_sdk

  1. Set required environment variables from the .env.example file.

  2. Install the project dependencies:

poetry install

  1. Activate the virtual environment (if required)

poetry shell

You're now ready to work on the project!

Running the Project

To run the project, use the following command:

poetry run python gh_copilot_sdk/main.py

This will execute the main.py file within the virtual environment.

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

gh_copilot_chat-2024.5.11.441.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gh_copilot_chat-2024.5.11.441-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file gh_copilot_chat-2024.5.11.441.tar.gz.

File metadata

  • Download URL: gh_copilot_chat-2024.5.11.441.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1018-azure

File hashes

Hashes for gh_copilot_chat-2024.5.11.441.tar.gz
Algorithm Hash digest
SHA256 8c6a7f5c7ad470452a850a04f07970f5d953b3e2cca69f953129c8a8ae62841e
MD5 8974a2f81d15ede24dcef86b2745bc54
BLAKE2b-256 0ae5e681e47b896227a6f626c8fd97ebfd4b5440ab9c7041733a9607227af6cb

See more details on using hashes here.

File details

Details for the file gh_copilot_chat-2024.5.11.441-py3-none-any.whl.

File metadata

File hashes

Hashes for gh_copilot_chat-2024.5.11.441-py3-none-any.whl
Algorithm Hash digest
SHA256 f2ef202cac75a36e6de202b56a0cfebb3f167a1dbf1c6ae6cac33aa4a7f4a447
MD5 99faf6cc5bb2e7787cde59d3b7eeda6b
BLAKE2b-256 90684f0de061a5cb9bd663ed2e9914e58693519a383af16c2d0c276a651ba86e

See more details on using hashes here.

Supported by

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