|
1 |
| -# Skillset Example |
2 |
| - |
3 | 1 | > [!NOTE]
|
4 |
| -> Copilot Extensions are in public preview and may be subject to change. Pre-release terms apply. |
5 |
| -> You must have a GitHub Copilot license of any type to use Copilot Extensions. |
| 2 | +> Copilot Extensions are in public preview and may be subject to change. Pre-release terms apply. You must have a GitHub Copilot license of any type to use Copilot Extensions. |
6 | 3 |
|
7 |
| -## Description |
8 |
| - |
9 |
| -This code sample demonstrates building a Copilot Extension using the skillsets approach rather than a traditional agent. This extension is designed to generate random test and example data for a number of development purposes, by calling publicly available APIs. |
| 4 | +# Skillset Example |
| 5 | +Learn to build a Copilot Extension as a skillset. Just define your API endpoints and let Copilot handle the complex AI logic. This sample demonstrates the lighter, faster alternative to building a traditional agent. |
10 | 6 |
|
11 |
| -### Architectural Model |
| 7 | +### Architecture |
12 | 8 | - **Skillsets**: Define up to 5 API endpoints that Copilot can call directly. Copilot handles all AI interactions, prompt engineering, and response formatting.
|
13 | 9 | - **Agents**: Provide full control over the interaction flow, including custom prompt crafting and specific LLM model selection.
|
14 | 10 |
|
15 | 11 | 
|
16 | 12 |
|
| 13 | +### Key Differences |
| 14 | +| | Skillsets | Agents | |
| 15 | +|--------|-----------|--------| |
| 16 | +| **Development Time** | Minutes to hours | Several days to weeks | |
| 17 | +| **Implementation** | Configure API endpoints only. Quicker if you have existing APIs. | Custom AI logic, prompt engineering, interaction handling. | |
| 18 | +| **Best For** | • Quick API integrations<br>• Basic service functionality<br>• Standard Copilot interactions<br>• Minimal infrastructure needs | • Complex interaction flows<br>• Custom LLM model control<br>• Custom prompt crafting<br>• Advanced state management | |
| 19 | +| **Control Level** | Copilot platform handles AI interactions | Full control over entire workflow | |
| 20 | +| **Data Volume** | Good for any volume, if the API handles efficient search/retrieval | Good for any volume, but requires robust search/retrieval at larger sizes | |
| 21 | + |
| 22 | +## Example Prompts |
| 23 | + |
| 24 | +This extension turns three public APIs into functions that can be used in Copilot Chat": |
| 25 | +```typescript |
| 26 | +@extension generate a commit message |
| 27 | +→ "Whatever will be, will be 8{)" |
| 28 | + |
| 29 | +@extension generate 2 short lorem ipsum paragraphs |
| 30 | +→ [HTML-formatted Lorem Ipsum text] |
| 31 | + |
| 32 | +@extension generate random user data |
| 33 | +→ { |
| 34 | + "name": "Miss Mona", |
| 35 | + "email": "mona.lisa@github.com", |
| 36 | + ... |
| 37 | +} |
| 38 | +``` |
17 | 39 |
|
18 |
| -### When to Choose Skillsets |
19 |
| -Skillsets are ideal when you want to: |
20 |
| -- Quickly integrate existing APIs or services without managing AI logic |
21 |
| -- Focus purely on your service's core functionality |
22 |
| -- Maintain consistent Copilot-style interactions without extensive development |
23 |
| -- Get started with minimal infrastructure and setup |
24 |
| - |
25 |
| -Use agents instead if you need: |
26 |
| -- Complex custom interaction flows |
27 |
| -- Specific LLM model control (using LLMs that aren't provided by the Copilot API) |
28 |
| -- Custom prompt crafting |
29 |
| -- Advanced state management |
30 |
| - |
31 |
| -## Example Implementation |
32 |
| - |
33 |
| -This extension showcases the skillset approach by providing three simple endpoints that generate random development data: |
34 |
| -- Random commit messages |
35 |
| -- Lorem ipsum text generation |
36 |
| -- Random user data |
37 |
| - |
38 |
| -## Getting Started |
39 |
| -1. Clone the repository: |
40 |
| - |
| 40 | +## Quick Start |
| 41 | +### 1. Set Up Repository |
41 | 42 | ```
|
42 | 43 | git clone git@github.com:copilot-extensions/skillset-example.git
|
43 | 44 | cd skillset-example
|
44 |
| -``` |
45 |
| - |
46 |
| -2. Install dependencies: |
47 |
| - |
48 |
| -``` |
49 | 45 | go mod tidy
|
50 | 46 | ```
|
51 | 47 |
|
52 |
| -## Usage |
53 |
| - |
54 |
| -1. Start up ngrok with the port provided: |
55 |
| - |
56 |
| -``` |
57 |
| -ngrok http http://localhost:8080 |
58 |
| -``` |
59 |
| - |
60 |
| -2. Set the environment variables (use the ngrok generated url for the `FDQN`) |
61 |
| -3. Run the application: |
62 |
| - |
| 48 | +### 2. Make It Accessible |
| 49 | +1. Run your app: |
63 | 50 | ```
|
64 | 51 | go run .
|
65 | 52 | ```
|
66 | 53 |
|
67 |
| -## Accessing the Extension in Chat: |
68 |
| - |
69 |
| -1. In the `Copilot` tab of your Application settings (`https://github.com/settings/apps/<app_name>/agent`) |
70 |
| -- Set the app type to "Skillset" |
71 |
| -- Specify the following skills |
| 54 | +2. Then choose one method to expose it and copy the URL for your GitHub App config: |
| 55 | +* **VS Code**: Set port 8080 public, copy Local Address |
| 56 | +* **Codespaces**: Set port 8080 public, copy URL |
| 57 | +* **Local with ngrok**: |
| 58 | + 1. Install ngrok from ngrok.com |
| 59 | + 2. Start tunnel: `ngrok http 8080` |
| 60 | + 3. Copy the Forwarding URL |
| 61 | + |
| 62 | +> Note: This step is for development and testing only. For production use, deploy your extension to a public server with proper infrastructure and security. |
| 63 | +
|
| 64 | +### 3. Configure GitHub App |
| 65 | +1. Create a new GitHub App at `github.com/settings/apps/new` or go to an existing one |
| 66 | +2. In the Copilot tab: |
| 67 | + - Set type to "Skillset" |
| 68 | + - Define the three skills below, using your URL from step 2: |
72 | 69 | ```
|
73 | 70 | Name: random_commit_message
|
74 | 71 | Inference description: Generates a random commit message
|
@@ -101,31 +98,16 @@ URL: https://<your ngrok domain>/random-user
|
101 | 98 | Parameters: { "type": "object" }
|
102 | 99 | Return type: String
|
103 | 100 | ```
|
104 |
| - |
105 |
| -2. In the `General` tab of your application settings (`https://github.com/settings/apps/<app_name>`) |
106 |
| -- Set the `Callback URL` to anything (`https://github.com` works well for testing, in a real environment, this would be a URL you control) |
107 |
| -- Set the `Homepage URL` to anything as above |
108 |
| -3. Ensure your permissions are enabled in `Permissions & events` > |
109 |
| -- `Account Permissions` > `Copilot Chat` > `Access: Read Only` |
110 |
| -4. Ensure you install your application at (`https://github.com/apps/<app_name>`) |
111 |
| -5. Now if you go to `https://github.com/copilot` you can `@` your skillset extension using the name of your app. |
112 |
| - |
113 |
| -## What can the bot do? |
114 |
| - |
115 |
| -Here's some example things: |
116 |
| - |
117 |
| -* `@skillset-example please create a random commit message` |
118 |
| -* `@skillset-example generate a lorem ipsum` |
119 |
| -* `@skillset-example generate a short lorem ipsum with 3 paragraphs` |
120 |
| -* `@skillset-example generate random user data` |
121 |
| - |
122 |
| -## Implementation |
123 |
| - |
124 |
| -This bot provides a passthrough to a couple of other APIs: |
125 |
| - |
126 |
| -* For commit messages, https://whatthecommit.com/ |
127 |
| -* For Lorem Ipsum, https://loripsum.net/ |
128 |
| -* For user data, https://randomuser.me/ |
| 101 | +3. In the `General` tab of your GitHub App settings (`https://github.com/settings/apps/<app_name>`) |
| 102 | + - **Homepage URL**: You can set to any URL for quick testing (like `https://github.com`). |
| 103 | + - **Callback URL**: Only needed if your extension uses OAuth for authentication. Since this example doesn't use OAuth, set to any URL (like `https://github.com`) |
| 104 | +4. Ensure your permissions are enabled in `Permissions & events` > `Account Permissions` > `Copilot Chat` > `Access: Read Only` |
| 105 | +5. Install your app at `https://github.com/apps/<app_name>` |
| 106 | + |
| 107 | +### 4. Try It Out |
| 108 | +1. Open Copilot Chat on github.com or in any supported IDE |
| 109 | +3. Send a test prompt like `@test-data-bot generate a commit message` |
| 110 | +> Note: It may take a few seconds for your extension to appear. Try refreshing if needed. |
129 | 111 |
|
130 | 112 | ## Documentation
|
131 | 113 | - [Using Copilot Extensions](https://docs.github.com/en/copilot/using-github-copilot/using-extensions-to-integrate-external-tools-with-copilot-chat)
|
|
0 commit comments