Quickstart
Getting started with Patchwork in 5 minutes
Patchwork is a command-line interface. It can be used in your local terminal, IDE or as part of a CI/CD pipeline.
Installation
Using Pip
PatchWork is available on PyPI and can be installed using pip:
The following optional dependency groups are available.
- security: installs semgrep and depscan with
pip install 'patchwork-cli[security]'
and is required for AutoFix and DependencyUpgrade patchflows. - rag: installs chromadb with
pip install 'patchwork-cli[rag]'
and is required for the ResolveIssue patchflow. - notifications: Used by steps sending notifications, e.g. slack messages.
- all: installs everything.
- not specifying any dependency group (
pip install patchwork-cli
) will install a core set of dependencies that are sufficient to run the GenerateDocstring, PRReview and GenerateREADME patchflows.
Using Poetry
PatchWork is built using Poetry, a dependency management and packaging tool for Python. To install PatchWork using Poetry, follow these steps:
-
Make sure you have Poetry installed. If you don’t have it installed, you can install it by running:
-
Clone the PatchWork repository:
-
Navigate to the project directory:
-
Activate a shell using virtual environment:
-
Install the dependencies using Poetry:
PatchWork CLI
The CLI runs Patchflows, as follows:
Where
- Arguments: Allow for overriding default/optional attributes of the Patchflow in the format of
key=value
. Ifkey
does not have any value, it is considered a booleanTrue
flag.
Example
For an AutoFix patchflow which patches vulnerabilities based on a scan using Semgrep:
The above command will default to patching code in the current directory, by running Semgrep to identify the vulnerabilities.
You can take a look at the default.yml
file for the list of configurations you can set to manage the AutoFix patchflow. For more details on how you can use a personal access token from GitHub on CLI you can read this.
You will need to pass your own openai_api_key
to call the LLM. Otherwise, to get started, you can get a patched_api_key
for free by
by signing in at https://app.patched.codes/signin and generating an API key from the integrations tab. You can then call the patchflow with the key as follows:
Similarly, to use Google’s models you can set the google_api_key
and model
, this is useful if you want to work with large contexts as the gemini-pro-1.5
model supports a input context length of 1 million tokens.
The patchwork-configs repository contains the default configuration and prompts for all the patchflows. You can clone that repo and pass it as a flag to the CLI:
Using open source models
Patchwork supports any OpenAI compatible endpoint, you can use that to use any LLM from various providers like Groq, Together AI, or Hugging Face.
E.g. to use Llama 3.1 405B from Groq.com run:
You can also use a config file to do the same, e.g. if you want to use Llama 3.1 405B from Hugging Face you can create a config.yml file:
And run as:
This also allows you to run local models via llama.cpp, ollama, vllm or tgi. For instance, you can run Llama 3.1 8B locally using llama_cpp.server as follows:
Then run your patchflow: