https://github.com/rabilrbl/gh_copilot_chat
Unofficial GH Copilot SDK (Reverse Engineered API)
https://github.com/rabilrbl/gh_copilot_chat
copilot copilot-chat reverse-engineering
Last synced: 6 months ago
JSON representation
Unofficial GH Copilot SDK (Reverse Engineered API)
- Host: GitHub
- URL: https://github.com/rabilrbl/gh_copilot_chat
- Owner: rabilrbl
- Created: 2024-05-10T17:30:21.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-11T05:05:29.000Z (over 1 year ago)
- Last Synced: 2025-02-11T17:58:53.663Z (8 months ago)
- Topics: copilot, copilot-chat, reverse-engineering
- Language: Python
- Homepage:
- Size: 45.9 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```python
from gh_copilot_chat import Copilot
import asyncio
import jsonasync 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 Trueasyncio.run(run())
```## Pip Installation
Install the package using pip/any other package manager
```bash
pip install gh_copilot_chat
```Then you can use the package in your code
## Poetry Project
This is a Python project that uses [Poetry](https://python-poetry.org/) for dependency management and packaging.
## Getting Started
1. Install Poetry by following the [official installation guide](https://python-poetry.org/docs/#installation).
2. Clone this repository:
git clone https://github.com/rabilrbl/gh_copilot_sdk.git
3. 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
3. 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.