Skip to content

Commit 8387689

Browse files
Merge pull request #1581 from jasonrandrews/new-content
New GitHub Copilot Extension Learning Path
2 parents f39c36d + 00ac6e5 commit 8387689

File tree

12 files changed

+392
-0
lines changed

12 files changed

+392
-0
lines changed
28.9 KB
Loading
19.4 KB
Loading
58.4 KB
Loading
33.9 KB
Loading
68.6 KB
Loading
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Build a GitHub Copilot Extension in Python
3+
4+
draft: true
5+
cascade:
6+
draft: true
7+
8+
minutes_to_complete: 20
9+
10+
who_is_this_for: This is an introductory topic for software developers who want to learn how to build a simple GitHub Copilot Extension.
11+
12+
learning_objectives:
13+
- Create a simple GitHub Copilot Extension in Python.
14+
- Use ngrok to expose the extension to Copilot.
15+
- Add a GitHub App to your GitHub account and use your Copilot Extension.
16+
17+
prerequisites:
18+
- A GitHub account.
19+
- A Linux computer with Python installed.
20+
21+
author_primary: Jason Andrews
22+
23+
### Tags
24+
skilllevels: Introductory
25+
subjects: ML
26+
armips:
27+
- Neoverse
28+
tools_software_languages:
29+
- Python
30+
- GitHub
31+
operatingsystems:
32+
- Linux
33+
34+
35+
### FIXED, DO NOT MODIFY
36+
# ================================================================================
37+
weight: 1 # _index.md always has weight of 1 to order correctly
38+
layout: "learningpathall" # All files under learning paths have this same wrapper
39+
learning_path_main_page: "yes" # This should be surfaced when looking for related content. Only set for _index.md of learning path content.
40+
---
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
3+
further_reading:
4+
- resource:
5+
title: GitHub Marketplace for Copilot extensions
6+
link: https://github.com/marketplace?type=apps&copilot_app=true/
7+
type: website
8+
- resource:
9+
title: About building Copilot Extensions
10+
link: https://docs.github.com/en/copilot/building-copilot-extensions/about-building-copilot-extensions/
11+
type: documentation
12+
- resource:
13+
title: Copilot Extensions repository
14+
link: https://github.com/copilot-extensions/
15+
type: documentation
16+
17+
18+
# ================================================================================
19+
# FIXED, DO NOT MODIFY
20+
# ================================================================================
21+
weight: 21 # set to always be larger than the content in this path, and one more than 'review'
22+
title: "Next Steps" # Always the same
23+
layout: "learningpathall" # All files under learning paths have this same wrapper
24+
---
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Learn about GitHub Copilot Extensions
3+
weight: 2
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## What are GitHub Copilot Extensions?
10+
11+
Copilot Extensions provide an integration point to expand the functionality of Copilot chat, allowing developers to introduce external tools, services, and custom behaviors into the chat experience.
12+
13+
You can use an extension to customize the capabilities of Copilot in a variety of ways. Some examples include targeting Copilot for a specific type of user, such as an Arm software developer, by querying specific documentation or prioritizing responses for the developers environment. Copilot Extensions can also integrate additional LLMs, use different APIs, and connect to other AI tools that are not used by Copilot.
14+
15+
A Copilot Extension allows you to build curated experiences that are targeted for specific developer topics.
16+
17+
Think about what you want to offer, or build for yourself, that is beyond or better than what Copilot can already do. If you have ideas, you can try them using a Copilot Extension.
18+
19+
Extensions can be private, public, or shared in the GitHub Marketplace.
20+
21+
This Learning Path is a "hello world" tutorial for a simple extension in Python. It explains how to create a private extension by running Python on a Linux computer, using ngrok to expose the endpoint, and creating a GitHub App to configure the extension in your GitHub account. After this, you can invoke your private extension from GitHub chat.
22+
23+
## How do I get started with GitHub Copilot?
24+
25+
Before building an extension, make sure Copilot is configured and working in your GitHub account.
26+
27+
Refer to the [Quickstart for GitHub Copilot](https://docs.github.com/en/copilot/quickstart) to get started.
28+
29+
You can use [GitHub Copilot free](https://github.com/features/copilot?utm_source=topcopilotfree&utm_medium=blog&utm_campaign=launch) with no cost (subject to usage limits).
30+
31+
## How do I invoke GitHub Copilot Extensions?
32+
33+
You can use extensions on any platform where Copilot chat can be used. This includes the GitHub website, various IDEs, and the command line.
34+
35+
Extensions are invoked using `@` followed by the name of the extension. For example, the [Arm extension for GitHub Copilot](https://github.com/marketplace/arm-for-github-copilot) is invoked using `@arm` in the chat.
36+
37+
You can install the Arm extension from the GitHub marketplace and practice using `@arm` to invoke it. Information about how to use it is in the [Arm for GitHub Copilot repository](https://github.com/arm/copilot-extension).
38+
39+
Continue to learn how to create your own extension using Python.
40+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: Test your Copilot Extension
3+
weight: 6
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
You are now ready to test your GitHub Copilot extension.
10+
11+
Go to any of the Copilot chat interfaces you are currently using, such as browser or VS Code.
12+
13+
Enter `@your-extension` and a test prompt such as:
14+
15+
```console
16+
tell me about Java vs Python
17+
```
18+
19+
On the first prompt, you get an authorization dialog to enable your extension.
20+
21+
Confirming the authorization takes you to an ngrok page in the browser, click the button and you will see the message from the GET request from your Python server in the browser:
22+
23+
```output
24+
Hello! Welcome to the example GitHub Copilot Extension in Python!
25+
```
26+
27+
You see the extension invoked in the terminal where Python is running and information about the chat printed:
28+
29+
```output
30+
127.0.0.1 - - [31/Jan/2025 23:33:18] "POST / HTTP/1.1" 200 -
31+
User: jasonrandrews
32+
Payload: {'copilot_thread_id': 'eceb9ea8-70a1-4a75-93b6-9096db87c4c6', 'messages': [{'role': 'user', 'content': '@jasonrandrews-cp tell me about Java vs Python', 'copilot_references': [], 'copilot_confirmations': None}, {'role': 'assistant', 'content': "@jasonrandrews Java and Python are both popular programming languages used for different purposes. Here are some key differences between the two:\n\n1. Syntax: Java has a more verbose syntax with strict rules, whereas Python has a more concise and readable syntax. Python's syntax is considered more beginner-friendly.\n\n2. Typing: Java is a statically-typed language, which means you need to declare the type of a variable before using it. Python, on the other hand, is dynamically-typed, allowing you to change the type of a variable during runtime.\n\n3. Performance: Java is typically faster than Python because it is a compiled language, while Python is an interpreted language. However, Python has many libraries and frameworks that leverage lower-level languages like C to improve performance.\n\n4. Application domains: Java is commonly used for building enterprise-level applications, Android apps, and large-scale systems due to its performance and robustness. Python is often used for web development, data analysis, scientific computing, and scripting due to its simplicity and extensive libraries.\n\n5. Community and ecosystem: Both Java and Python have vibrant communities and extensive libraries and frameworks. However, Java has been around longer, resulting in a larger ecosystem and support for enterprise development.\n\nUltimately, the choice between Java and Python depends on your specific needs, the type of application you are building, and personal preference. Both languages have their strengths and weaknesses, and it's worth considering the requirements of your project and your familiarity with each language.", 'copilot_references': [], 'copilot_confirmations': None}, {'role': 'user', 'content': "Current Date and Time (UTC - YYYY-MM-DD HH:MM:SS formatted): 2025-01-31 23:33:54\nCurrent User's Login: jasonrandrews\n", 'name': '_session', 'copilot_references': [{'type': 'github.current-url', 'data': {'url': 'https://github.com/jasonrandrews/arm-learning-paths'}, 'id': 'https://github.com/jasonrandrews/arm-learning-paths', 'is_implicit': True, 'metadata': {'display_name': 'https://github.com/jasonrandrews/arm-learning-paths', 'display_icon': '', 'display_url': ''}}], 'copilot_confirmations': None}, {'role': 'user', 'content': 'how do I install the aws cli on Arm Linux?', 'copilot_references': [], 'copilot_confirmations': []}], 'stop': None, 'top_p': 0, 'temperature': 0, 'max_tokens': 0, 'presence_penalty': 0, 'frequency_penalty': 0, 'response_format': None, 'copilot_skills': None, 'agent': 'jasonrandrews-cp', 'client_id': 'Iv23liSj0dAnWIBmCjzi', 'tools': [], 'functions': None, 'model': ''}
33+
```
34+
35+
You also see HTTP requests on the terminal where ngrok is running.
36+
37+
```output
38+
23:33:18.042 UTC POST / 200 OK
39+
23:33:00.991 UTC GET / 200 OK
40+
```
41+
42+
Lastly, the chat output from your extension is printed. Here it is in VS Code:
43+
44+
![#Copilot output](_images/output.png)
45+
46+
Your GitHub Copilot Extension is now responding to chat prompts. You have the basic structure to build more interesting Copilot Extensions.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: Configure GitHub app
3+
weight: 5
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## How do I connect my Copilot extension to my GitHub account?
10+
11+
Create a GitHub App to connect your Python extension to your GitHub account.
12+
13+
Click on your photo in the upper-right corner of GitHub and select `Settings`.
14+
15+
Scroll to the bottom left and select `Developer settings`.
16+
17+
### Create a new GitHub App
18+
19+
Select the `GitHub Apps` on the left slide and click `New GitHub App`.
20+
21+
![#New GitHub App](_images/gh-cp1.png)
22+
23+
The important fields to complete or modify are listed below.
24+
25+
| Field | Description |
26+
|------|-------------|
27+
| GitHub App Name | This can be any name, but it must be unique across all of GitHub. This is also the name you will use to invoke your extension in Copilot using the `@name` syntax. One way to avoid conflicts is to use your GitHub handle as the name or add some text to your handle, such as `@jasonrandrews-cp`. |
28+
| Homepage URL | This needs to be filled in but is not used for a private extension, any URL can be entered such as https://learn.arm.com |
29+
| Callback URL | Enter the URL of your ngrok domain such as `https://your-domain.ngrok-free.app` (substitute your domain). |
30+
| Webhook | Uncheck the `Active` box. |
31+
| Permissions | Select `Account permissions` and set the `GitHub Copilot Chat` and `GitHub Copilot Chat` to `Read-only`. |
32+
| Where can this GitHub App be installed? | Confirm `Only this account` is selected to make the GitHub App only for your use. |
33+
34+
Click the `Create GitHub App` to save the configuration.
35+
36+
![#Create GitHub App](_images/gh-cp2.png)
37+
38+
### Configure the Copilot settings
39+
40+
### Configure the Copilot settings
41+
42+
Click on the left side Copilot sidebar.
43+
44+
Modify and update the following fields:
45+
46+
| Step | Description |
47+
|------|-------------|
48+
| 1. Set the App Type | Set the `App Type` to `Agent`. |
49+
| 2. Agent Definition | Enter your ngrok URL in the URL box, such as `https://your-domain.ngrok-free.app`. |
50+
| 3. Interface Description | Any text can be added. |
51+
52+
53+
The Copilot settings are shown below:
54+
55+
![#Copilot configuration](_images/gh-cp3.png)
56+
57+
Click the `Save` button when the information is entered.
58+
59+
### Install your GitHub App
60+
61+
When the GitHub App has been configured and save, install it into your account using the `Install App` tab on the left site and the `Install` button.
62+
63+
You may need to agree to install the GitHub App in your account.
64+
65+
Once installed, you see the App in your account's [Applications](https://github.com/settings/installations)
66+
67+
Your GitHub App is now ready to use with Copilot.

0 commit comments

Comments
 (0)