Skip to content

Commit

Permalink
more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Nov 19, 2024
1 parent 9a78374 commit 18db390
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ sidebar:
order: 4
---

import copilotSrc from "../../../assets/chat-participant.png"
import copilotAlt from "../../../assets/chat-participant.png.txt?raw"
import { Image } from "astro:assets"

:::caution

Script are executed in the context of your environment.
Expand Down Expand Up @@ -42,6 +46,12 @@ To run the script on the root folder, right click under the files.

:::

### GitHub Copilot Chat

You can run scripts in the [GitHub Copilot Chat](https://code.visualstudio.com/docs/copilot/getting-started-chat) through the [**@genaiscript**](/genaiscript/reference/vscode/github-copilot-chat) participant.

<Image src={copilotSrc} alt={copilotAlt} loading="lazy" />

### Default files

You can specify default file or files to run the script on.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The `@genaiscript` [chat participant](https://code.visualstudio.com/api/extensio
of a [GitHub Copilot Chat](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot-chat) conversation.
This is useful for leverage existing scripts in an interactive chat session.

<Image src={src} alt={alt} />
<Image src={src} alt={alt} loading="lazy" />

## Choosing which script to run

Expand Down
14 changes: 13 additions & 1 deletion packages/vscode/src/chatparticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,24 @@ export async function activateChatParticipant(state: ExtensionState) {
prompt = prompt.slice(scriptid.length).trim()
template = templates.find((t) => t.id === scriptid)
if (!template) {
md(`$(error) Oops, I could not find any genaiscript matching \`${scriptid}\`. Try one of the following:
if (state.project.templates.length === 0) {
md(
`$(error) Oops, I could not find any genaiscript. Try **GenAIScript: Create new script...** to create one.`
)
} else {
if (scriptid === "")
md(`$(error) Please specify a genaiscript to run.`)
else
md(
`$(error) Oops, I could not find any genaiscript matching \`${scriptid}\`.`
)
md(`Try one of the following:
${state.project.templates
.filter((s) => !s.system && !s.unlisted)
.map((s) => `- \`${s.id}\`: ${s.title}`)
.join("\n")}
`)
}
return
}
} else {
Expand Down

0 comments on commit 18db390

Please sign in to comment.