From 4ddb91cecd64675ddfe1e14264dd2d74e33e2ddb Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Tue, 25 Jun 2024 16:26:30 +0000 Subject: [PATCH] removing batch cli command, removing gpspecs --- .../docs/case-studies/image-alt-text.mdx | 28 +- .../docs/case-studies/seo-frontmatter.mdx | 8 +- docs/src/content/docs/faq.md | 6 - docs/src/content/docs/reference/cli/batch.mdx | 101 ------- .../docs/reference/transparency-note.md | 5 - packages/cli/src/batch.ts | 286 ------------------ packages/cli/src/build.ts | 20 +- packages/cli/src/cli.ts | 42 --- packages/cli/src/run.ts | 13 +- packages/core/src/constants.ts | 2 - packages/vscode/package.json | 1 - packages/vscode/src/fragmentcommands.ts | 22 +- packages/vscode/src/state.ts | 77 ++--- 13 files changed, 59 insertions(+), 552 deletions(-) delete mode 100644 docs/src/content/docs/reference/cli/batch.mdx delete mode 100644 packages/cli/src/batch.ts diff --git a/docs/src/content/docs/case-studies/image-alt-text.mdx b/docs/src/content/docs/case-studies/image-alt-text.mdx index 6c8f3d4ea1..7653d9871b 100644 --- a/docs/src/content/docs/case-studies/image-alt-text.mdx +++ b/docs/src/content/docs/case-studies/image-alt-text.mdx @@ -1,18 +1,19 @@ --- title: Image Alt Text sidebar: - order: 10 + order: 10 description: Learn how to automatically generate descriptive alt text for images using OpenAI Vision model to enhance accessibility and SEO. keywords: alt text automation, image accessibility, SEO optimization, OpenAI Vision, Astro integration --- -import { Image } from 'astro:assets'; -import { Code } from '@astrojs/starlight/components'; + +import { Image } from "astro:assets" +import { Code } from "@astrojs/starlight/components" import scriptSrc from "../../../../genaisrc/image-alt-text.genai.js?raw" -import src from '../../../assets/debugger.png'; +import src from "../../../assets/debugger.png" import alt from "../../../assets/debugger.png.txt?raw" -It is a best practice to provide an `alt` attribute for images. -This attribute is used to describe the image to users who are unable to see it. +It is a best practice to provide an `alt` attribute for images. +This attribute is used to describe the image to users who are unable to see it. It is also used by search engines to understand the content of the image. ```html "alt" @@ -30,7 +31,7 @@ However, this task can be tedious and developer are often tempted to skip it, or To solve this issue, we created a script that uses the OpenAI Vision model to analyze the documentation images and generate a description alt text. -To start, we assume that the script is run on a single image file +To start, we assume that the script is run on a single image file and we use [defImage](/genaiscript/reference/scripts/images) to add it to the prompt context. ```js title="image-alt-text.genai.js" @@ -55,18 +56,16 @@ The GenAIScript documentation uses Astro, which allows to author pages in [MDX]( The code below shows how the generate alt text, stored in a separate text file, is injected in the final HTML. ```mdx - -import { Image } from 'astro:assets'; -import src from '../../../assets/debugger.png'; +import { Image } from "astro:assets" +import src from "../../../assets/debugger.png" import alt from "../../../assets/debugger.png.txt?raw" -{alt}/ - +{alt} ``` The `debugger.png` image shows the screenshot of a debugging session and the generate alt text file contents. -{alt}/ +{alt} @@ -76,7 +75,8 @@ Using the [batch](/genaiscript/reference/cli/batch) command, we can apply the sc in a single command. ```sh -npx --yes genaiscript batch image-alt-text assets/**.png --apply-edits +for file in assets/**.png; do + npx --yes genaiscript run image-alt-text "$file" --apply-edits ``` To avoid regenerating the alt text, we also detect if a file exists in the script and cancel accordingly. diff --git a/docs/src/content/docs/case-studies/seo-frontmatter.mdx b/docs/src/content/docs/case-studies/seo-frontmatter.mdx index 29709ad4e2..78e4c35ba9 100644 --- a/docs/src/content/docs/case-studies/seo-frontmatter.mdx +++ b/docs/src/content/docs/case-studies/seo-frontmatter.mdx @@ -21,11 +21,11 @@ to merge the new front matter with the existing front matter. ## Batching over all files Once the script has been tuned on a few files, you can automate using -the [CLI](/genaiscript/reference/cli). The CLI has a **batch** mode that applies a LLM generation -on each file and a **--apply-edits** flag to apply the changes to the file. +the [CLI](/genaiscript/reference/cli). The CLI has a **--apply-edits** flag to apply the changes to the file. -```bash -genaiscript batch frontmatter src/**/*.md --apply-edits +```sh +for file in src/**/*.md; do + npx --yes genaiscript run frontmatter "$file" --apply-edits ``` You can run this command in your CI/CD pipeline to keep your SEO front matter up to date. diff --git a/docs/src/content/docs/faq.md b/docs/src/content/docs/faq.md index 837dcce635..2e6d7a59ab 100644 --- a/docs/src/content/docs/faq.md +++ b/docs/src/content/docs/faq.md @@ -26,9 +26,6 @@ keywords: AI, script generation, performance, best practices, limitations - **Can I use GenAIScript in IDEs other than VS Code?** Currently, GenAIScript is integrated with VS Code, but it can be written in any IDE. The VS Code extension, however, provides additional support for creating and debugging scripts. -- **What is a GPSpec and how do I create one?** - A GPSpec is an optional markdown file that provides context for a GenAIScript. You can create one by writing a markdown document that lists arguments or includes more complex documentation. - - **What are foundation models and LLMs in the context of GenAIScript?** Foundation models and LLMs (Large Language Models) are AI models that GenAIScript can interact with to perform tasks like generating text or processing information. @@ -60,9 +57,6 @@ keywords: AI, script generation, performance, best practices, limitations - **How can I use GenAIScript to automate document translation?** One of our case studies illustrates the use of GenAIScript for translating document fragments between languages: [Translation Case Study](/genaiscript/case-studies/documentation-translations) -- **Is it possible to generate executable code from natural language specifications using GenAIScript?** - Yes, you can use a GPSpec to define the task and a GenAIScript to translate the spec into code in a particular programming language. - - **Can I use GenAIScript to summarize documents or create dialogues from monologues?** Yes, LLMs are good at summarizing and can be used within GenAIScript to summarize documents or convert monologues into dialogues. diff --git a/docs/src/content/docs/reference/cli/batch.mdx b/docs/src/content/docs/reference/cli/batch.mdx deleted file mode 100644 index d8b8e6014a..0000000000 --- a/docs/src/content/docs/reference/cli/batch.mdx +++ /dev/null @@ -1,101 +0,0 @@ ---- -title: Batch -description: Learn how to use the batch command to process multiple files with GenAIScript, including JSON Lines output and GitHub Actions integration. -sidebar: - order: 4 -keywords: batch processing, JSON Lines, CLI tool, automation, GitHub Actions ---- -import { Steps } from '@astrojs/starlight/components'; -import { Tabs, TabItem } from '@astrojs/starlight/components'; - -Once you have a script that works in Visual Studio Code, you can use the [command line](/genaiscript/reference/cli/) -to run the script automatically over many files. - -The `batch` command runs the tool over many files in a batch mode (one full LLM iteration per file). - -```bash "batch" -npx genaiscript batch