GitHub Copilot Chat
The @genaiscript
chat participant lets your run scripts without the context
of a GitHub Copilot Chat conversation.
This is useful for leverage existing scripts in an interactive chat session.
Choosing which script to run
The /run
command expects a script id as the first argument (e.g., /run poem
). The rest of the query is
passed to the script as the env.vars.question
variable.
If you omit the /run
command, GenAIScript will look for a script named copilotchat
. If it finds one, it will run it.
Otherwise, it will ask you to pick a script from the list of available scripts.
Context
The context selected by the user in Copilot Chat is converted to variables and passed to the script:
- the prompt content is passed in
env.vars.question
. The script id is removed in the case of/run
. - the current editor text is passed in
env.vars["copilot.editor"]
- 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.
websearcher
will search the web for the user prompt and use the file in context in the answer.
dataanalyst
uses the Python code interpreter tools to resolve a data computation question.
History
The history of messages is passed in env.vars["copilot.history"]
. It is an array of HistoryMessageUser | HistoryMessageAssistant
:
Default script
The following script can used as a starter template to create the default script when the user does not use the /run
command.
Unsupported features
The following features are currently not supported in the chat participant:
- Tools (
#tool
) Workspace
reference