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.447.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.447-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gh_copilot_chat-2024.5.11.447.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.447.tar.gz
Algorithm Hash digest
SHA256 09c20b87c900cad813afd398cd7a7d2b19c730e232d15f8083899056651df9d3
MD5 3373123203c981256bdd295dd33aab1f
BLAKE2b-256 6d312c62e1cb2526387c18be8ce41341ba89556fc2625ff466569818528c2550

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gh_copilot_chat-2024.5.11.447-py3-none-any.whl
Algorithm Hash digest
SHA256 e25ef52121ab64cb2dc7b69498a57a951b44d2a236bc4cb2cf5448014a8adee7
MD5 a6caa17014e1378c8b17eb7932b53393
BLAKE2b-256 144e56364f6095153b172b088b37a046b4c3818c8d3b7d511985c32a587b1eb0

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