This is a WIP (work-in-progress) project π§π·ββοΈ
codypy
is a Python wrapper binding to Cody Agent through establishing a connection to the Cody-Agent server from Sourcegraph Cody using JSON-RPC (Remote Procedure Call) protocol over a TCP/stdio connection. It allows sending and receiving JSON-RPC messages asynchronously. π¨π₯
Note 1: You need to register an account at Sourcegraph and create an API key.
Note 2: This project is currently in an experimental alpha stage. The API and functionality may change and break in future versions. β οΈπ§
asyncio
libraryasyncio
libraryClone the repository:
git clone https://github.com/PriNova/codypy.git
Navigate to the project directory:
cd codypy
Ensure you have Python 3.7 or higher installed:
python --version
The asyncio
library is included in the Python standard library, so no additional installation is required.
Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate
Install the dependencies from the requirements.txt
file:
pip install -r requirements.txt
Rename the provided env.example
file to .env
and set the SRC_ACCESS_TOKEN
value to your API key and the path BINARY_PATH
to where the cody agent binary should be downloaded and accessed. Use the following command in Linux to rename your file:
mv env.example .env
Run the script using python main.py
.
You are now ready to use codypy!
You can also install the package in dev mode via pip install -e .
python main.py
.is_debugging
is set to True
./quit
. The server closes then the connection.If installed as a package like mentioned above, you can also use codypy as a CLI tool. Simply export SRC_ACCESS_TOKEN
and BINARY_PATH
to your environment and in the terminal execute codypy-cli --help
to see the available options and flags.
For an example of initializing and chatting, look at main.py file
This example demonstrates how to use a complete cycle to establish a connection to the server and process JSON-RPC messages.
receive_jsonrpc_messages()
function.initializing_message()
function to include additional client information.codypy
.codypy
client library.Copyright notices for third-party code included are licensed under their respective licenses.
This project is licensed under the MIT License.