Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ who_is_this_for: This is an introductory topic for software developers who want
learning_objectives:
- Create a simple GitHub Copilot Extension in Python.
- Use ngrok to expose the extension to Copilot.
- Add a GitHub App to your GitHub account and use your Copilot Extension.
- Add a GitHub App to your GitHub account and deploy the Copilot Extension.

prerequisites:
- A GitHub account.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@ layout: learningpathall

## What are GitHub Copilot Extensions?

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.
GitHub Copilot Extensions provide an integration point to expand the functionality of GitHub Copilot Chat, allowing developers to introduce external tools, services, and custom behaviors into the chat experience.

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.

A Copilot Extension allows you to build curated experiences that are targeted for specific developer topics.
You can use Copilot Extensions to customize the capabilities of Copilot in multiple ways. For example, you can target the needs of a specific type of user, such as an Arm software developer, by querying specific documentation or prioritizing responses related to that specific developer's environment. Copilot Extensions also benefit users by facilitating the integration of additional LLMs, and offering different APIs and AI tools, which broadens the reach of the resources. In short, a Copilot Extension allows you to build a more curated experience.

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.

Extensions can be private, public, or shared in the GitHub Marketplace.

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.
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.

## How do I get started with GitHub Copilot?

Before building an extension, make sure Copilot is configured and working in your GitHub account.

Refer to the [Quickstart for GitHub Copilot](https://docs.github.com/en/copilot/quickstart) to get started.

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).
You can use [GitHub Copilot Free](https://github.com/features/copilot?utm_source=topcopilotfree&utm_medium=blog&utm_campaign=launch) at no cost, subject to a usage allowance.

## How do I invoke GitHub Copilot Extensions?

You can use extensions on any platform where Copilot chat can be used. This includes the GitHub website, various IDEs, and the command line.
You can use extensions on any platform where you can use Copilot chat. This includes the GitHub website, various IDEs, and the command line.

Extensions are invoked using `@` followed by the name of the extension.

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.
For example, you can invoke the [Arm extension for GitHub Copilot](https://github.com/marketplace/arm-for-github-copilot) using `@arm` in the chat.

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).
You can install the Arm extension from the GitHub Marketplace and practice using `@arm` to invoke it. For information on how to use it, see the [Arm for GitHub Copilot repository](https://github.com/arm/copilot-extension).

Continue to learn how to create your own extension using Python.

Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@ layout: learningpathall

You are now ready to test your GitHub Copilot extension.

Go to any of the Copilot chat interfaces you are currently using, such as browser or VS Code.
Go to any of the Copilot Chat interfaces that you are currently using, such as your browser or VS Code.

Enter `@your-extension` and a test prompt such as:
Enter `@your-extension` and a test prompt, such as:

```console
tell me about Java vs Python
```

On the first prompt, you get an authorization dialog to enable your extension.
The first time you enter a prompt, you will receive an authorization dialog asking you if you wish to enable your extension.

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:
Confirming the authorization takes you to an ngrok page in the browser.

Click the button and in the browser you will see the following message from the GET request from your Python server:

```output
Hello! Welcome to the example GitHub Copilot Extension in Python!
```

You see the extension invoked in the terminal where Python is running and information about the chat printed:
You will see the extension invoked in the terminal where Python is running and information about the chat printed:

```output
127.0.0.1 - - [31/Jan/2025 23:33:18] "POST / HTTP/1.1" 200 -
Expand All @@ -39,8 +41,12 @@ You also see HTTP requests on the terminal where ngrok is running.
23:33:00.991 UTC GET / 200 OK
```

Lastly, the chat output from your extension is printed. Here it is in VS Code:
Lastly, the chat output from your extension is printed.

Here it is in VS Code:

![#Copilot output](_images/output.png)

Your GitHub Copilot Extension is now responding to chat prompts. You have the basic structure to build more interesting Copilot Extensions.
Your GitHub Copilot Extension is now responding to chat prompts.

You can now use what you have learned to build different, and more complex, Copilot Extensions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Scroll to the bottom left and select `Developer settings`.

### Create a new GitHub App

Select the `GitHub Apps` on the left slide and click `New GitHub App`.
Select the `GitHub Apps` on the left side and click `New GitHub App`.

![#New GitHub App](_images/gh-cp1.png)

Expand All @@ -28,7 +28,7 @@ The important fields to complete or modify are listed below.
| 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 |
| Callback URL | Enter the URL of your ngrok domain such as `https://your-domain.ngrok-free.app` (substitute your domain). |
| Webhook | Uncheck the `Active` box. |
| Permissions | Select `Account permissions` and set the `GitHub Copilot Chat` and `GitHub Copilot Chat` to `Read-only`. |
| Permissions | Select `Account permissions` and set the `GitHub Copilot Chat` to `Read-only`. |
| Where can this GitHub App be installed? | Confirm `Only this account` is selected to make the GitHub App only for your use. |

Click the `Create GitHub App` to save the configuration.
Expand All @@ -37,8 +37,6 @@ Click the `Create GitHub App` to save the configuration.

### Configure the Copilot settings

### Configure the Copilot settings

Click on the left side Copilot sidebar.

Modify and update the following fields:
Expand All @@ -58,10 +56,10 @@ Click the `Save` button when the information is entered.

### Install your GitHub App

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.
When the GitHub App has been configured and saved, install it into your account using the `Install App` tab on the left side and click the `Install` button.

You may need to agree to install the GitHub App in your account.
You might need to agree to install the GitHub App in your account.

Once installed, you see the App in your account's [Applications](https://github.com/settings/installations)
Once installed, you see the App in your account's [Applications](https://github.com/settings/installations).

Your GitHub App is now ready to use with Copilot.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Follow the steps below to set up ngrok.

### Download and install ngrok

If needed, create a new account.
If required, create a new account.

Refer to the [Setup & installation](https://dashboard.ngrok.com/get-started/setup/linux) section for installation details.

If you are using a Debian based Linux system, run the command:
If you are using a Debian-based Linux system, run the command:

```console
curl -sSL https://ngrok-agent.s3.amazonaws.com/ngrok.asc \
Expand All @@ -35,17 +35,19 @@ curl -sSL https://ngrok-agent.s3.amazonaws.com/ngrok.asc \

### Configure your ngrok account

Before starting the ngrok server, you need an Authtoken. If you don't currently have one, create a new Authtoken from the [Authtoken](https://dashboard.ngrok.com/get-started/your-authtoken) settings.
Before you can start the ngrok server, you need an Authtoken.

If you don't currently have one, create a new Authtoken from the [Authtoken Get Started section](https://dashboard.ngrok.com/get-started/your-authtoken).

Once you have the token, add it to the Linux computer where you are running your Python extension.

Substitute your token in the command below:
Substitute your token in the command below where it states **\<your-authtoken\>**:

```console
ngrok config add-authtoken <your-authtoken>
```

ngrok is easier to use if you create a domain name. Go to the [Domains](https://dashboard.ngrok.com/domains) section and add a new randomly generated domain name. You can create 1 domain name in a free account.
ngrok is easier to use if you create a domain name. Go to the [Domains](https://dashboard.ngrok.com/domains) section and add a new randomly generated domain name. You can create one domain name in a free account.

Use the domain name in the next section to start the server.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if __name__ == "__main__":

```

You may need to install the following Python packages:
You might need to install the following Python packages:

```console
sudo apt update
Expand All @@ -84,7 +84,7 @@ python -m venv venv
source venv/bin/activate
```

Your shell prompt now includes `(venv)` indicating the virtual environment is active.
Your shell prompt now includes `(venv)` indicating that the virtual environment is active.

Install the required Python packages:

Expand All @@ -108,4 +108,6 @@ WARNING: This is a development server. Do not use it in a production deployment.
Press CTRL+C to quit
```

Your extension is running, but needs to be connected to Copilot. Continue to learn how to share it with Copilot.
Your extension is running, but it needs to be connected to Copilot.

Continue to learn how to share your extension with Copilot.