Skip to main content

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.

Metadata

Release files for gh_copilot_chat 2024.5.11.505

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

Source distribution (sdist)

Source distribution for gh_copilot_chat 2024.5.11.505
File Size Uploaded
gh_copilot_chat-2024.5.11.505.tar.gz 3.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gh_copilot_chat 2024.5.11.505
File Interpreter ABI Platform
gh_copilot_chat-2024.5.11.505-py3-none-any.whl Python 3 none any Details

Total release size: 7.6 kB

Release files / gh_copilot_chat-2024.5.11.505.tar.gz

Download URL gh_copilot_chat-2024.5.11.505.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b41689a80a79418987bdaf6553767214869b77896f5500a172ea46bf08effcf7
BLAKE2b-256 checksum
How to use checksums
d40249d859fb958ae546aed06e3c4978a0d71fa01cd9a66dc8093497b6a35f20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1018-azure

Release files / gh_copilot_chat-2024.5.11.505-py3-none-any.whl

Download URL gh_copilot_chat-2024.5.11.505-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e8883ac5144d6b04b67c894a73038dfe4cc4561d32949e4a7ae03211f7fb82d7
BLAKE2b-256 checksum
How to use checksums
3af8395d7ce6c8b4514f02a4aa79ca94ca58fa14f74b586168a8067cb859419f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1018-azure

Release history Release notifications | RSS feed

This release

2024.5.11.505 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