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
-
Install Poetry by following the official installation guide.
-
Clone this repository:
git clone https://github.com/rabilrbl/gh_copilot_sdk.git
- Navigate to the project directory:
cd gh_copilot_sdk
-
Set required environment variables from the
.env.examplefile. -
Install the project dependencies:
poetry install
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gh_copilot_chat-2024.5.11.505.tar.gz.
File metadata
- Download URL: gh_copilot_chat-2024.5.11.505.tar.gz
- Upload date:
- Size: 3.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b41689a80a79418987bdaf6553767214869b77896f5500a172ea46bf08effcf7
|
|
| MD5 |
bbfdfc4da3a28c14b12e02806226cf48
|
|
| BLAKE2b-256 |
d40249d859fb958ae546aed06e3c4978a0d71fa01cd9a66dc8093497b6a35f20
|
File details
Details for the file gh_copilot_chat-2024.5.11.505-py3-none-any.whl.
File metadata
- Download URL: gh_copilot_chat-2024.5.11.505-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8883ac5144d6b04b67c894a73038dfe4cc4561d32949e4a7ae03211f7fb82d7
|
|
| MD5 |
ec6ac7d47cba1579cffb0ae884ddc9c9
|
|
| BLAKE2b-256 |
3af8395d7ce6c8b4514f02a4aa79ca94ca58fa14f74b586168a8067cb859419f
|