diff --git a/docs/genaisrc/genaiscript.d.ts b/docs/genaisrc/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/docs/genaisrc/genaiscript.d.ts +++ b/docs/genaisrc/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/docs/src/content/docs/reference/cli/commands.md b/docs/src/content/docs/reference/cli/commands.md index 0497de539b..3d778fa2b5 100644 --- a/docs/src/content/docs/reference/cli/commands.md +++ b/docs/src/content/docs/reference/cli/commands.md @@ -18,7 +18,6 @@ Runs a GenAIScript against files. Options: -ef, --excluded-files excluded files -egi, --exclude-git-ignore exclude files that are ignored through the .gitignore file in the workspace root - -fcs, --file-chunk-size file chunk size -o, --out output folder. Extra markdown fields for output and trace will also be generated -rmo, --remove-out remove output folder if it exists -ot, --out-trace output file for trace @@ -236,9 +235,9 @@ Options: ## `retrieval` -``` Usage: genaiscript retrieval|retreival [options] [command] +RAG support RAG support Options: diff --git a/docs/src/content/docs/samples/gai.mdx b/docs/src/content/docs/samples/gai.mdx index 18f0a269d4..f4c93a236a 100644 --- a/docs/src/content/docs/samples/gai.mdx +++ b/docs/src/content/docs/samples/gai.mdx @@ -2,7 +2,16 @@ title: GitHub Action Investigator description: Investigate GitHub Actions failures sidebar: - order: 20 + order: 100 --- +import { Code } from "@astrojs/starlight/components" +import source from "../../../../../packages/sample/genaisrc/gai.genai.mts?raw" +import gasource from "../../../../../.github/workflows/genai-investigator.yml?raw" This is an in-depth guide to build a script that interactively investigates GitHub Actions failures. + +## Full source ([GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/sample/genaisrc/gai.genai.mts)) + + + + diff --git a/docs/src/content/docs/samples/sc.mdx b/docs/src/content/docs/samples/sc.mdx new file mode 100644 index 0000000000..07ba6a2994 --- /dev/null +++ b/docs/src/content/docs/samples/sc.mdx @@ -0,0 +1,13 @@ +--- +title: Spell Check +description: Spell check a document +sidebar: + order: 101 +--- + +import { Code } from "@astrojs/starlight/components" +import source from "../../../../../packages/sample/genaisrc/sc.genai.mts?raw" + +## Full source ([GitHub](https://github.com/microsoft/genaiscript/blob/main/packages/sample/genaisrc/sc.genai.mts)) + + diff --git a/genaisrc/genaiscript.d.ts b/genaisrc/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/genaisrc/genaiscript.d.ts +++ b/genaisrc/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/auto/genaiscript.d.ts b/packages/auto/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/packages/auto/genaiscript.d.ts +++ b/packages/auto/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/core/src/genaisrc/genaiscript.d.ts b/packages/core/src/genaisrc/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/packages/core/src/genaisrc/genaiscript.d.ts +++ b/packages/core/src/genaisrc/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/core/src/runpromptcontext.ts b/packages/core/src/runpromptcontext.ts index 39929596cb..33592f4c1e 100644 --- a/packages/core/src/runpromptcontext.ts +++ b/packages/core/src/runpromptcontext.ts @@ -318,7 +318,7 @@ export function createChatGenerationContext( } const defFileOutput = ( - pattern: string, + pattern: ElementOrArray, description: string, options?: FileOutputOptions ): void => { @@ -326,7 +326,9 @@ export function createChatGenerationContext( appendChild( node, createFileOutput({ - pattern: arrayify(pattern), + pattern: arrayify(pattern).map((p) => + typeof p === "string" ? p : p.filename + ), description, options, }) diff --git a/packages/core/src/types/prompt_template.d.ts b/packages/core/src/types/prompt_template.d.ts index 5bf54dd708..f86b5649cb 100644 --- a/packages/core/src/types/prompt_template.d.ts +++ b/packages/core/src/types/prompt_template.d.ts @@ -1875,7 +1875,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/core/src/types/prompt_type.d.ts b/packages/core/src/types/prompt_type.d.ts index e68f36323d..fa5cfd7e77 100644 --- a/packages/core/src/types/prompt_type.d.ts +++ b/packages/core/src/types/prompt_type.d.ts @@ -83,7 +83,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/sample/genaisrc/blog/genaiscript.d.ts b/packages/sample/genaisrc/blog/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/packages/sample/genaisrc/blog/genaiscript.d.ts +++ b/packages/sample/genaisrc/blog/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/sample/genaisrc/genaiscript.d.ts b/packages/sample/genaisrc/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/packages/sample/genaisrc/genaiscript.d.ts +++ b/packages/sample/genaisrc/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/sample/genaisrc/node/genaiscript.d.ts b/packages/sample/genaisrc/node/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/packages/sample/genaisrc/node/genaiscript.d.ts +++ b/packages/sample/genaisrc/node/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/sample/genaisrc/python/genaiscript.d.ts b/packages/sample/genaisrc/python/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/packages/sample/genaisrc/python/genaiscript.d.ts +++ b/packages/sample/genaisrc/python/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/sample/genaisrc/sc.genai.mts b/packages/sample/genaisrc/sc.genai.mts index 2e3ad27036..8e33b914d0 100644 --- a/packages/sample/genaisrc/sc.genai.mts +++ b/packages/sample/genaisrc/sc.genai.mts @@ -1,14 +1,34 @@ script({ title: "Spell checker", - system: ["system", "system.files"], + system: ["system", "system.files", "system.diff"], + temperature: 0.1, }) -const files = def("FILES", env.files, { endsWith: [".md", ".mdx"] }) +// Get files from environment or modified files from Git if none provided +let files = env.files +if (files.length === 0) { + // If no files are provided, read all modified files + const gitStatus = await host.exec("git status --porcelain") + const rx = /^\s+[M|U]\s+/ // modified or untracked + files = await Promise.all( + gitStatus.stdout + .split(/\r?\n/g) + .filter((filename) => rx.test(filename)) + .filter((filename) => /\.(md|mdx)$/.test(filename)) + .map( + async (filename) => + await workspace.readText(filename.replace(rx, "")) + ) + ) +} +def("FILES", files, { endsWith: [".md", ".mdx"] }) -$`Fix the spelling and gramme of the content of ${files}. +$`Fix the spelling and gramme of the content of FILES. Use diff format for small changes. - do NOT fix the frontmatter - do NOT fix code regions - do NOT fix \`code\` and \`\`\`code\`\`\` - in .mdx files, do NOT fix inline typescript code ` + +defFileOutput(files, "fixed markdown or mdx files") diff --git a/packages/sample/genaisrc/style/genaiscript.d.ts b/packages/sample/genaisrc/style/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/packages/sample/genaisrc/style/genaiscript.d.ts +++ b/packages/sample/genaisrc/style/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/sample/src/aici/genaiscript.d.ts b/packages/sample/src/aici/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/packages/sample/src/aici/genaiscript.d.ts +++ b/packages/sample/src/aici/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/sample/src/errors/genaiscript.d.ts b/packages/sample/src/errors/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/packages/sample/src/errors/genaiscript.d.ts +++ b/packages/sample/src/errors/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/sample/src/genaiscript.d.ts b/packages/sample/src/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/packages/sample/src/genaiscript.d.ts +++ b/packages/sample/src/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/sample/src/makecode/genaiscript.d.ts b/packages/sample/src/makecode/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/packages/sample/src/makecode/genaiscript.d.ts +++ b/packages/sample/src/makecode/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/sample/src/tla/genaiscript.d.ts b/packages/sample/src/tla/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/packages/sample/src/tla/genaiscript.d.ts +++ b/packages/sample/src/tla/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/sample/src/vision/genaiscript.d.ts b/packages/sample/src/vision/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/packages/sample/src/vision/genaiscript.d.ts +++ b/packages/sample/src/vision/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/packages/vscode/genaisrc/genaiscript.d.ts b/packages/vscode/genaisrc/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/packages/vscode/genaisrc/genaiscript.d.ts +++ b/packages/vscode/genaisrc/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void diff --git a/slides/genaisrc/genaiscript.d.ts b/slides/genaisrc/genaiscript.d.ts index f9f02e4454..5e88b248f2 100644 --- a/slides/genaisrc/genaiscript.d.ts +++ b/slides/genaisrc/genaiscript.d.ts @@ -1908,7 +1908,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: ChatParticipantOptions ): void defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void @@ -2791,7 +2791,7 @@ declare function def( * @param options expectations about the generated file content */ declare function defFileOutput( - pattern: string | string[], + pattern: ElementOrArray, description?: string, options?: FileOutputOptions ): void