Skip to content

Commit

Permalink
Update CLI docs, improve spell checker script, and modify type defini…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
pelikhan committed Sep 30, 2024
1 parent 6ee9e18 commit b08274e
Show file tree
Hide file tree
Showing 24 changed files with 87 additions and 44 deletions.
4 changes: 2 additions & 2 deletions docs/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions docs/src/content/docs/reference/cli/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Runs a GenAIScript against files.
Options:
-ef, --excluded-files <string...> excluded files
-egi, --exclude-git-ignore exclude files that are ignored through the .gitignore file in the workspace root
-fcs, --file-chunk-size <number> file chunk size
-o, --out <string> 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 <string> output file for trace
Expand Down Expand Up @@ -236,9 +235,9 @@ Options:

## `retrieval`

```
Usage: genaiscript retrieval|retreival [options] [command]

RAG support
RAG support

Options:
Expand Down
11 changes: 10 additions & 1 deletion docs/src/content/docs/samples/gai.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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))

<Code code={source} wrap={true} lang="ts" title="gai.genai.mts" />

<Code code={gasource} wrap={true} lang="yaml" title="gai.yml" />
13 changes: 13 additions & 0 deletions docs/src/content/docs/samples/sc.mdx
Original file line number Diff line number Diff line change
@@ -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))

<Code code={source} wrap={true} lang="ts" title="sc.genai.mts" />
4 changes: 2 additions & 2 deletions genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/auto/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/core/src/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions packages/core/src/runpromptcontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,17 @@ export function createChatGenerationContext(
}

const defFileOutput = (
pattern: string,
pattern: ElementOrArray<string | WorkspaceFile>,
description: string,
options?: FileOutputOptions
): void => {
if (pattern)
appendChild(

Check failure on line 326 in packages/core/src/runpromptcontext.ts

View workflow job for this annotation

GitHub Actions / build

The 'pattern' parameter type has been changed from 'string' to 'ElementOrArray<string | WorkspaceFile>'. Ensure that all calls to 'defFileOutput' function are updated to pass the correct type.
node,
createFileOutput({
pattern: arrayify(pattern),
pattern: arrayify(pattern).map((p) =>
typeof p === "string" ? p : p.filename
),
description,
options,
})
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types/prompt_template.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext {
options?: ChatParticipantOptions
): void
defFileOutput(
pattern: string | string[],
pattern: ElementOrArray<string | WorkspaceFile>,
description?: string,
options?: FileOutputOptions
): void
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types/prompt_type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ declare function def(
* @param options expectations about the generated file content
*/
declare function defFileOutput(
pattern: string | string[],
pattern: ElementOrArray<string | WorkspaceFile>,
description?: string,
options?: FileOutputOptions
): void
Expand Down
4 changes: 2 additions & 2 deletions packages/sample/genaisrc/blog/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/sample/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/sample/genaisrc/node/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/sample/genaisrc/python/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 23 additions & 3 deletions packages/sample/genaisrc/sc.genai.mts
Original file line number Diff line number Diff line change
@@ -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")
4 changes: 2 additions & 2 deletions packages/sample/genaisrc/style/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/sample/src/aici/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/sample/src/errors/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/sample/src/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/sample/src/makecode/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/sample/src/tla/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/sample/src/vision/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b08274e

Please sign in to comment.