Verify GitHub Copilot outputs for Python with this VSCode Extension and accompanying Docker container.
The docker container depends on being run with docker run --rm -p 8000:8000 ghcr.io/lukvonstrom/copilot-verification:latest
please be aware that currently only amd64 architectures are supported.
For ARM based Macs, intel emulation via rosetta needs to be used, as microsoft provides only z3-solver
binaries for macos arm, but not for linux arm via pip.
Building Z3 from source is quite expensive, therefore emulation can be used like this (given that you manage docker via colima https://github.com/abiosoft/colima and have rosetta installed already https://support.apple.com/en-gb/102527):
colima start --profile amd64 -a x86_64 -c 4 -m 6
Now that everything is setup we can conduct a basic test as shown below:
The steps shown in the video are:
- Open the cloned repository in vscode.
- Open the folder containing the extension in vscode via
code code-extractor-extension
- Click on
Run & Debug
- and there on the Play icon next toRun Extension
- In the newly spawned VsCode instance with the extension in debug mode, open a new python file
- Open the Command Bar with
CMD-SHIFT-P
- Select
copilot-verifier: Start Verification Session
- A notification should appear and the Github Copilot Inline Chat Window should open itself.
- Prompt Copilot
- After a short delay, the verification will start, which is signified by a loading notification
- Next, a markdown with the verification results from the backend will open.
The extension automatically validates in the background that two assert
statements are present in any method in the code.
If this is not the case, a syntax error will be displayed in the Editor at the specific method.
The error is verbose on purpose to facilitate an easier fix with Copilot.
To now prompt copilot to fix this error, one simply has to invoke it inline by clicking on the impacted line and executing CMD-I
.
Copilot subsequently will attempt to generate sensible pre- and postconditions to fix the error.
The extension exposes the following settings:
With these settings, the URI of the Docker container is controllable, as well as the debounce time after which the LLM Verifier asks whether to verify the completion. When enabling save, results from the verification run are saved as markdown files in the same file.