Outline
GitHub Copilot is a useful way to integrate LLM’s into our coding process. These tools should be used with some care, so see our ‘Using GitHub Copilot and other LLM’s in our Coding workflows’ presentation for more information and guidance.
This walkthrough will provide the necessary steps to add Copilot to RStudio and VScode/Positron.
Prerequisites
To access Copilot for free, you will need to request GitHub education benefits using the following steps:
- Sign up for a GitHub account (ideally using your university account)
- From your new GitHub account, apply for free GitHub Education benefits (i.e., upload photo of your Unicard)
- Once GitHub Education email to say your application is approved, head to https://github.com/settings/copilot and click the
Start free trial
button - The next screen will have a green button to
Get access to GitHub Copilot
- Finally, you just have to check policies (for additional details see here) and click
Save and complete setup
- You’re now ready to set up GitHub copilot!
Setting up Copilot in RStudio
- To set up the GitHub Copilot for RStudio, we navigate to
Tools
>Global Options
>Copilot
(see image below) - From the Copilot tab, check the
Enable Copilot
box and hitApply
- You should then see a
You are not currently signed in
message below the checkbox. Click theSign in
button. - Copy the 8-digit code, click the link, select
Continue
and paste the code - Copilot should show as activated (if not click the
Activate
button in Copilot options) - Copilot will now provide suggestions for code as you type (you can see status in bottom right of the code window)
Setting up Copilot for Visual Studio Code
- On VS Code we just have to install the GitHub Copilot extension
- Once installed, we open the Copilot extension and use it to sign into our GitHub account
- Copilot will now give you suggestions as you type, and you can also use the additional
Copilot chat
feature (messages icon on left of window) to open a dialogue
General Copilot usage and pointers
Now we have Copilot ready to provide suggestions for our code in our chosen software!
- To approve Copilot suggestions that appear, press
Tab
- To give Copilot guidance on code suggestions, provide
#code comments
that describe steps required - Make sure to check both the generated code itself and sense-check outputs to ensure that it is doing what is expected
- The Copilot chat extension (installed automatically alongside Copilot) can be used for a broader range of tasks – see examples here
Additional Resources
Acknowledgements
We did not create this content alone! Inspiration, tips, and resources have been borrowed from multiple sources.