From cef922779852108d0fe4e37b40f1492e4f59b30f Mon Sep 17 00:00:00 2001 From: Greg Van Liew Date: Tue, 21 Nov 2023 16:15:57 -0800 Subject: [PATCH] Add section on getting the best out of Copilot Chat (#6848) * initial content * add section on iterating * tune the first image --- docs/editor/github-copilot.md | 37 ++++++++++++++++++- .../fibonacci-better-var-names.png | 3 ++ .../fibonacci-first.png | 3 ++ .../fibonacci-second.png | 3 ++ .../fibonacci-third.png | 3 ++ 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 docs/editor/images/artificial-intelligence/fibonacci-better-var-names.png create mode 100644 docs/editor/images/artificial-intelligence/fibonacci-first.png create mode 100644 docs/editor/images/artificial-intelligence/fibonacci-second.png create mode 100644 docs/editor/images/artificial-intelligence/fibonacci-third.png diff --git a/docs/editor/github-copilot.md b/docs/editor/github-copilot.md index 504ac1c3d3..9081c28dfd 100644 --- a/docs/editor/github-copilot.md +++ b/docs/editor/github-copilot.md @@ -117,7 +117,7 @@ A function name can only be so descriptive without being overly long so function #### Prime Copilot with sample code -One trick to get Copilot on the right page is to copy and paste sample code that is close to what you are looking for. Providing a small example can help Copilot generate suggestions that match the language and tasks you want to achieve. Once Copilot begins providing you with the code you want and will actually use, you can delete the sample code from the file. This can be especially helpful to jump start Copilot to a newer library version when it defaults to the providing older code suggestions. +One trick to get Copilot on the right page is to copy and paste sample code into your open editor that is close to what you are looking for. Providing a small example can help Copilot generate suggestions that match the language and tasks you want to achieve. Once Copilot begins providing you with the code you want and will actually use, you can delete the sample code from the file. This can be especially helpful to jump start Copilot to a newer library version when it defaults to the providing older code suggestions. ### Be consistent and keep the quality bar high @@ -336,6 +336,41 @@ The **Ask GitHub Copilot** command will open the Chat view and input your search ![Chat view with answer to "hide editor overview"](images/artificial-intelligence/copilot-answer-hide-editor-overview.png) +## Getting the most of of Copilot Chat + +This section is similar to the earlier [Getting the most out of Copilot](#getting-the-most-out-of-copilot), which had recommendations for getting the best editor inline completions from Copilot. Here we'll cover tips to effectively use Copilot Chat (Chat view, inline chat, Quick Chat). + +### Use agents and slash commands + +[Agents](#agents-and-slash-commands) are designed to collect extra context either about a code base or a specific domain or technology. By using the appropriate agent, Copilot Chat can find and provide better information to send to the Copilot backend. + +* Use `@workspace` if you want to ask questions about your open project. +* Use `@vscode` if you want to know about VS Code features and APIs. + +Slash commands help Copilot Chat understand your **intent** when you ask a question. Are you learning about a code base (`/explain`) or do you want help fixing an issue (`/fix`) or creating test cases (`/test`)? By letting Copilot Chat know what you're trying to do, it can tune its reply to your task and provide helpful commands, settings, and code snippets. + +You could write out your project scope or current task with a natural language query but using agents and slash commands is more concise and explicit. + +### Iterate on your solution + +When asking Copilot Chat for help, you aren't stuck with the first response. You can iterate and prompt Copilot to improve the solution. Copilot has both the context of the generated code and also your current conversation. + +Here's an example using inline chat to create a function to calculate Fibonacci numbers: + +![First response from Copilot for a function to calculate Fibonacci numbers](images/artificial-intelligence/fibonacci-first.png) + +Maybe you're prefer a solution that doesn't use recursion: + +![Ask Copilot to not use recursion and new result](images/artificial-intelligence/fibonacci-second.png) + +You can even ask Copilot to follow coding conventions or improve variable names: + +![Ask Copilot to use better variable names and new result](images/artificial-intelligence/fibonacci-third.png) + +Even if you've already accepted a result, you can always ask Copilot to iterate on the code later: + +![Ask inline chat to use better variable names on existing code](images/artificial-intelligence/fibonacci-better-var-names.png) + ## Additional resources Congratulations, you've now used artificial intelligence to enhance your coding! diff --git a/docs/editor/images/artificial-intelligence/fibonacci-better-var-names.png b/docs/editor/images/artificial-intelligence/fibonacci-better-var-names.png new file mode 100644 index 0000000000..7f51bf9fbd --- /dev/null +++ b/docs/editor/images/artificial-intelligence/fibonacci-better-var-names.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:78b87dab3ca6e7e457705f38cdc6a7d5d5656b31ed02f28633f4d938cd53e203 +size 97115 diff --git a/docs/editor/images/artificial-intelligence/fibonacci-first.png b/docs/editor/images/artificial-intelligence/fibonacci-first.png new file mode 100644 index 0000000000..aa092d3152 --- /dev/null +++ b/docs/editor/images/artificial-intelligence/fibonacci-first.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d870a7d16c7252ed4ecb1b03e3f92e27bf27bc4c735f0150924b52159f0c7062 +size 63860 diff --git a/docs/editor/images/artificial-intelligence/fibonacci-second.png b/docs/editor/images/artificial-intelligence/fibonacci-second.png new file mode 100644 index 0000000000..2039f40652 --- /dev/null +++ b/docs/editor/images/artificial-intelligence/fibonacci-second.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:360b98a6c5449e9cbe7dae95f12af0b5283f313e6af53361bc4fc9ae690b9b31 +size 67939 diff --git a/docs/editor/images/artificial-intelligence/fibonacci-third.png b/docs/editor/images/artificial-intelligence/fibonacci-third.png new file mode 100644 index 0000000000..a21c4141cb --- /dev/null +++ b/docs/editor/images/artificial-intelligence/fibonacci-third.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b66272aaf4d73fde3a9310651ca361ad8ec3f2fd193c8e50dbc48f04572b7a76 +size 72469