Skip to content

Commit

Permalink
docs: ✏️ add examples for Copilot Chat scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Nov 17, 2024
1 parent 492110a commit 289f55c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/src/content/docs/reference/scripts/choices.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Choices
description: Specify a list of preferred token choices for a script.
keywords: choices, preferred words, logit bias
sidebar:
order: 20
---

You can specify a list of preferred words (choices) in the script metadata. It will increase the probability of the model generating the specified words.
Expand Down
45 changes: 43 additions & 2 deletions docs/src/content/docs/reference/vscode/github-copilot-chat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,47 @@ The context selected by the user in Copilot Chat is converted to variables and p
- the current editor selection is passed in `env.vars["copilot.selection"]`
- all other file references are passed in `env.files`

### Examples

- `mermaid` will generate a diagram from the user prompt.

```js title="mermaid.genai.mjs" wrap
def("CODE", env.files)
$`Generate a class diagram using mermaid of the code symbols in the CODE.`
```

- `websearcher` will search the web for the user prompt
and use the file in context in the answer.

```js title="websearcher.genai.mjs" wrap
const res = await retrieval.webSearch(env.vars.question)
def("QUESTION", env.vars.question)
def("WEB_SEARCH", res)
def("FILE", env.files, { ignoreEmpty: true})
$`Answer QUESTION using WEB_SEARCH and FILE.`
```

- `dataanalyst` uses the Python code interpreter tools to
resolve a data computation question.

```js title="dataanalyst.genai.mjs" wrap
script({
tools: [
"fs_read_file",
"python_code_interpreter_copy_files_to_container",
"python_code_interpreter_read_file",
"python_code_interpreter_run",
],
})
def("DATA", env.files.map(({ filename }) => filename).join("\n"))
def("QUESTION", env.vars.question)

$`Run python code to answer the data analyst question
in QUESTION using the data in DATA.
Return the python code that was used to compute the answer.
`
```

### History

The history of messages is passed in `env.vars["copilot.history"]`. It is an array of `HistoryMessageUser | HistoryMessageAssistant`:
Expand Down Expand Up @@ -73,5 +114,5 @@ The following script can used as a starter template to create the default script

The following features are currently not supported in the chat participant:

- Tools (`#tool`)
- `Workspace` reference
- Tools (`#tool`)
- `Workspace` reference

0 comments on commit 289f55c

Please sign in to comment.