You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: api/extension-guides/chat.md
+57-3Lines changed: 57 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -94,7 +94,8 @@ The `isSticky` property controls whether the chat participant is persistent, whi
94
94
95
95
We suggest using a lowercase `name` and using title case for the `fullName` to align with existing chat participants. Get more info about the [naming conventions for chat participants](#chat-participant-naming-conventions).
96
96
97
-
> **Note**: Some participant names are reserved, and in case you use a reserved name VS Code will display the fully qualified name of your participant (including the extension ID).
97
+
> [!NOTE]
98
+
> Some participant names are reserved, and in case you use a reserved name VS Code will display the fully qualified name of your participant (including the extension ID).
98
99
99
100
Up-front registration of participants and [commands](#register-commands) in `package.json` is required, so that VS Code can activate your extension at the right time, and not before it is needed.
100
101
@@ -267,7 +268,59 @@ cat.followupProvider = {
267
268
};
268
269
```
269
270
270
-
> **Tip:** Follow-ups should be written as questions or directions, not just concise commands.
271
+
> [!TIP]
272
+
> Follow-ups should be written as questions or directions, not just concise commands.
273
+
274
+
### Implement participant detection
275
+
276
+
To make it easier to use chat participants with natural language, you can implement participant detection. Participant detection is a way to automatically route the user's question to a suitable participant, without having to explicitly mention the participant in the prompt. For example, if the user asks "How do I add a login page to my project?", the question would be automatically routed to the `@workspace` participant because it can answer questions about the user's project.
277
+
278
+
VS Code uses the chat participant description and examples to determine which participant to route a chat prompt to. You can specify this information in the `disambiguation` property in the extension `package.json` file. The `disambiguation` property contains a list of detection categories, each with a description and examples.
279
+
280
+
| Property | Description | Examples |
281
+
|----------|-------------|----------|
282
+
|`category`| The detection category. If the participant serves different purposes, you can have a category for each. | <ul><li>`cat`</li><li>`workspace_questions`</li><li>`web_questions`</li></ul> |
283
+
|`description`| A detailed description of the kinds of questions that are suitable for this participant. | <ul><li>`The user wants to learn a specific computer science topic in an informal way.`</li><li>`The user just wants to relax and see the cat play.`</li></ul> |
284
+
|`examples`| A list of representative example questions. | <ul><li>`Teach me C++ pointers using metaphors`</li><li>`Explain to me what is a linked list in a simple way`</li><li>`Can you show me a cat playing with a laser pointer?`</li></ul> |
285
+
286
+
You can define participant detection for the overall chat participant, for specific commands, or a combination of both.
287
+
288
+
The following code snippet shows how to implement participant detection at the participant level.
289
+
290
+
```json
291
+
"contributes": {
292
+
"chatParticipants": [
293
+
"id": "chat-sample.cat",
294
+
"fullName": "Cat",
295
+
"name": "cat",
296
+
"description": "Meow! What can I teach you?",
297
+
298
+
"disambiguation": [
299
+
{
300
+
"category": "cat",
301
+
"description": "The user wants to learn a specific computer science topic in an informal way.",
302
+
"examples": [
303
+
"Teach me C++ pointers using metaphors",
304
+
"Explain to me what is a linked list in a simple way",
305
+
"Can you explain to me what is a function in programming?"
306
+
]
307
+
}
308
+
]
309
+
]
310
+
}
311
+
```
312
+
313
+
Similarly, you can also configure participant detection at the command level by adding a `disambiguation` property for one or more items in the `commands` property.
314
+
315
+
Apply the following guidelines to improve the accuracy of participant detection for your extension:
316
+
317
+
-**Be specific**: The description and examples should be as specific as possible to avoid conflicts with other participants. Avoid using generic terminology in the participant and command information.
318
+
-**Use examples**: The examples should be representative of the kinds of questions that are suitable for the participant. Use synonyms and variations to cover a wide range of user queries.
319
+
-**Use natural language**: The description and examples should be written in natural language, as if you were explaining the participant to a user.
320
+
-**Test the detection**: Test the participant detection with a variation of example questions and verify there's no conflict with built-in chat participants.
321
+
322
+
> [!NOTE]
323
+
> Built-in chat participants take precedence for participant detection. For example, a chat participant that operates on workspace files might conflict with the built-in `@workspace` participant.
271
324
272
325
## Supported chat response output types
273
326
@@ -414,7 +467,8 @@ The following list provides the output types for a chat response in the Chat vie
0 commit comments