From 978658472d61e702e8a8172bb7d1b103a631a38b Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Wed, 11 Sep 2024 14:56:49 -0700 Subject: [PATCH] Update defImages function to support multiple file types and handle Blob conversion (#705) * Update defImages function to support multiple file types and handle Blob conversion * add azure blob sample * Renamed file and updated default parameters and logging in azure-blobs.genai.mts * Update Azure Blob Storage guide and script for image processing and summarization * Update frontmatter support for mdx, enhance blog drafts, and improve documentation details across various guides. * Update function name to defImages in images.md documentation --- docs/genaisrc/genaiscript.d.ts | 6 +- docs/package.json | 2 +- ...-to-prioritize-and-manage-github-issues.md | 3 + ...testing-and-deployment-with-genaiscript.md | 3 + ...-your-debugging-skills-with-genaiscript.md | 3 + ...wer-of-dynamic-content-with-genaiscript.md | 3 + ...ing-genaiscript-for-streamlined-testing.md | 4 + .../docs/case-studies/release-notes.mdx | 5 +- .../docs/guides/auto-git-commit-message.mdx | 9 +- .../guides/images-in-azure-blob-storage.mdx | 100 ++++++++++++++++++ docs/src/content/docs/guides/llm-as-tool.mdx | 5 +- .../content/docs/guides/transformers-js.mdx | 7 +- .../src/content/docs/guides/using-secrets.mdx | 3 + docs/src/content/docs/guides/zod-schema.mdx | 3 + .../reference/scripts/chat-participants.mdx | 6 +- .../content/docs/reference/scripts/images.md | 26 +++++ .../content/docs/reference/scripts/prompty.md | 6 +- genaisrc/genaiscript.d.ts | 6 +- packages/core/src/genaisrc/genaiscript.d.ts | 6 +- packages/core/src/runpromptcontext.ts | 22 +++- packages/core/src/types/prompt_template.d.ts | 4 +- packages/core/src/types/prompt_type.d.ts | 2 +- .../sample/genaisrc/azure-blobs.genai.mts | 44 ++++++++ .../sample/genaisrc/front-matter.genai.mjs | 2 +- packages/sample/genaisrc/genaiscript.d.ts | 6 +- .../sample/genaisrc/node/genaiscript.d.ts | 6 +- .../sample/genaisrc/python/genaiscript.d.ts | 6 +- .../sample/genaisrc/style/genaiscript.d.ts | 6 +- packages/sample/package.json | 2 + packages/sample/src/aici/genaiscript.d.ts | 6 +- packages/sample/src/errors/genaiscript.d.ts | 6 +- packages/sample/src/genaiscript.d.ts | 6 +- packages/sample/src/makecode/genaiscript.d.ts | 6 +- packages/sample/src/tla/genaiscript.d.ts | 6 +- packages/sample/src/vision/genaiscript.d.ts | 6 +- slides/genaisrc/genaiscript.d.ts | 6 +- yarn.lock | 63 ++++++++++- 37 files changed, 365 insertions(+), 46 deletions(-) create mode 100644 docs/src/content/docs/guides/images-in-azure-blob-storage.mdx create mode 100644 packages/sample/genaisrc/azure-blobs.genai.mts diff --git a/docs/genaisrc/genaiscript.d.ts b/docs/genaisrc/genaiscript.d.ts index 21c83b94d5..2977b99f3c 100644 --- a/docs/genaisrc/genaiscript.d.ts +++ b/docs/genaisrc/genaiscript.d.ts @@ -1,5 +1,7 @@ type OptionsOrString = (string & {}) | TOptions +type ElementOrArray = T | T[] + interface PromptGenerationConsole { log(...data: any[]): void warn(...data: any[]): void @@ -1570,7 +1572,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: DefSchemaOptions ): string defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void defTool( @@ -2515,7 +2517,7 @@ declare function defSchema( * @param options */ declare function defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void diff --git a/docs/package.json b/docs/package.json index 550766aa79..e41e48630b 100644 --- a/docs/package.json +++ b/docs/package.json @@ -14,7 +14,7 @@ "preview": "astro preview", "astro": "astro", "genai:test": "node ../packages/cli/built/genaiscript.cjs test src/**/*.md", - "genai:frontmatter": "node ../packages/cli/built/genaiscript.cjs run frontmatter \"src/**/*.md\" --apply-edits", + "genai:frontmatter": "node ../packages/cli/built/genaiscript.cjs run frontmatter \"src/**/*.{md,mdx}\" --apply-edits", "genai:technical": "for file in \"src/**/*.md\"; do\nnode ../packages/cli/built/genaiscript.cjs run technical \"$file\" --apply-edits\ndone", "genai:alt-text": "node scripts/image-alt-text.mjs" }, diff --git a/docs/src/content/docs/blog/drafts/streamlining-issue-triage-with-genaiscript-harnessing-ai-to-prioritize-and-manage-github-issues.md b/docs/src/content/docs/blog/drafts/streamlining-issue-triage-with-genaiscript-harnessing-ai-to-prioritize-and-manage-github-issues.md index cc9e2a3592..1cd993d25a 100644 --- a/docs/src/content/docs/blog/drafts/streamlining-issue-triage-with-genaiscript-harnessing-ai-to-prioritize-and-manage-github-issues.md +++ b/docs/src/content/docs/blog/drafts/streamlining-issue-triage-with-genaiscript-harnessing-ai-to-prioritize-and-manage-github-issues.md @@ -10,6 +10,9 @@ tags: - Project Management - Automation - GenAIScript +description: Employ GenAIScript to automate GitHub issue triage with AI, + improving project management and issue resolution efficiency. +keywords: GitHub issues, AI, project management, automation, issue triage --- diff --git a/docs/src/content/docs/blog/drafts/unlock-devops-superpowers-automate-testing-and-deployment-with-genaiscript.md b/docs/src/content/docs/blog/drafts/unlock-devops-superpowers-automate-testing-and-deployment-with-genaiscript.md index 509d885309..ec2aa86c38 100644 --- a/docs/src/content/docs/blog/drafts/unlock-devops-superpowers-automate-testing-and-deployment-with-genaiscript.md +++ b/docs/src/content/docs/blog/drafts/unlock-devops-superpowers-automate-testing-and-deployment-with-genaiscript.md @@ -9,6 +9,9 @@ tags: - Automation - Testing - Deployment +description: Streamline your DevOps pipeline with GenAIScript by automating + testing and deployment through a tutorial script. +keywords: DevOps, automation, testing, deployment, scripting --- diff --git a/docs/src/content/docs/blog/drafts/unlock-the-power-of-ai-enhance-your-debugging-skills-with-genaiscript.md b/docs/src/content/docs/blog/drafts/unlock-the-power-of-ai-enhance-your-debugging-skills-with-genaiscript.md index 8badeb2798..8da8a1eb04 100644 --- a/docs/src/content/docs/blog/drafts/unlock-the-power-of-ai-enhance-your-debugging-skills-with-genaiscript.md +++ b/docs/src/content/docs/blog/drafts/unlock-the-power-of-ai-enhance-your-debugging-skills-with-genaiscript.md @@ -8,6 +8,9 @@ tags: - Programming - Efficiency draft: true +description: Leverage AI with GenAIScript to improve your debugging skills, + featuring a practical example for an efficient workflow. +keywords: AI, debugging, programming efficiency, developer tools, GenAIScript --- diff --git a/docs/src/content/docs/blog/drafts/unlock-the-power-of-dynamic-content-with-genaiscript.md b/docs/src/content/docs/blog/drafts/unlock-the-power-of-dynamic-content-with-genaiscript.md index 75196943b3..f7bc89f236 100644 --- a/docs/src/content/docs/blog/drafts/unlock-the-power-of-dynamic-content-with-genaiscript.md +++ b/docs/src/content/docs/blog/drafts/unlock-the-power-of-dynamic-content-with-genaiscript.md @@ -8,6 +8,9 @@ tags: - Dynamic Content Generation - AI - Automation +description: Discover how GenAIScript can automate dynamic content generation + using AI, with an easy-to-understand script example. +keywords: dynamic content, automation, AI, content generation, scripting --- diff --git a/docs/src/content/docs/blog/drafts/unlock-the-power-of-test-automation-mastering-genaiscript-for-streamlined-testing.md b/docs/src/content/docs/blog/drafts/unlock-the-power-of-test-automation-mastering-genaiscript-for-streamlined-testing.md index 46b003c89f..bbf16768c6 100644 --- a/docs/src/content/docs/blog/drafts/unlock-the-power-of-test-automation-mastering-genaiscript-for-streamlined-testing.md +++ b/docs/src/content/docs/blog/drafts/unlock-the-power-of-test-automation-mastering-genaiscript-for-streamlined-testing.md @@ -9,6 +9,10 @@ tags: - Test Automation - Software Development - Best Practices +description: Explore test automation using GenAIScript to enhance and streamline + your testing processes with structured script breakdown. +keywords: test automation, scripting, software testing, streamlined process, + developer tools --- diff --git a/docs/src/content/docs/case-studies/release-notes.mdx b/docs/src/content/docs/case-studies/release-notes.mdx index decf67fe09..589270f6aa 100644 --- a/docs/src/content/docs/case-studies/release-notes.mdx +++ b/docs/src/content/docs/case-studies/release-notes.mdx @@ -1,7 +1,10 @@ --- title: Release Notes sidebar: - order: 7 + order: 7 +description: Generate comprehensive release notes combining commit history and code diffs +keywords: release notes, automation, commit history, code diffs, release management + --- import { Code } from '@astrojs/starlight/components'; import scriptSrc from "../../../../../packages/sample/genaisrc/git-release-notes.genai?raw" diff --git a/docs/src/content/docs/guides/auto-git-commit-message.mdx b/docs/src/content/docs/guides/auto-git-commit-message.mdx index 6cd0a30049..87fb7659b2 100644 --- a/docs/src/content/docs/guides/auto-git-commit-message.mdx +++ b/docs/src/content/docs/guides/auto-git-commit-message.mdx @@ -1,8 +1,11 @@ --- -title: "Automated Git Commit Messages" -keywords: ["GenAI", "Git", "Automation"] +title: Automated Git Commit Messages +keywords: Git, commit automation, software development, CLI, husky sidebar: - order: 15 + order: 15 +description: Streamline your Git workflow with an automation script for + generating commit messages + --- In the world of software development, making consistent and informative commit messages is crucial but often overlooked. diff --git a/docs/src/content/docs/guides/images-in-azure-blob-storage.mdx b/docs/src/content/docs/guides/images-in-azure-blob-storage.mdx new file mode 100644 index 0000000000..7e376c75ca --- /dev/null +++ b/docs/src/content/docs/guides/images-in-azure-blob-storage.mdx @@ -0,0 +1,100 @@ +--- +title: Images in Azure Blob Storage +sidebar: + order: 55 +description: Leverage Azure SDK to handle image files in Blob Storage within prompts +keywords: Azure Blob Storage, Azure SDK, image handling, Node.js Buffer, inline prompts + +--- + +import { Code } from '@astrojs/starlight/components'; +import { Steps } from "@astrojs/starlight/components" +import source from "../../../../../packages/sample/genaisrc/azure-blobs.genai.mts?raw" + +It is possible to use the Azure Node.JS SDK to download images from Azure Blog Storage +and use them in the prompt. The `defImages` function support the node.js [Buffer] type. + +## Configuration + +Install the [@azure/storage-blob](https://www.npmjs.com/package/@azure/storage-blob) and [@azure/identity](https://www.npmjs.com/package/@azure/identity) packages. + +```sh +npm install -D @azure/storage-blob @azure/identity +``` + +Make sure to login with the Azure CLI and set the subscription. + +```sh +az login +``` + +## Reading blobs + +Open a connection to the Azure Blob Storage and get a client to the container. +We deconstruct the `account` and `container` from the `env.vars` object +so that they can be set through the [cli](/genaiscript/reference/cli). + +```ts +import { BlobServiceClient } from "@azure/storage-blob" +import { DefaultAzureCredential } from "@azure/identity" + +const { account = "myblobs", container = "myimages" } = env.vars +const blobServiceClient = new BlobServiceClient( + `https://${account}.blob.core.windows.net`, + new DefaultAzureCredential() +) +const containerClient = blobServiceClient.getContainerClient(container) +``` + +If you do not have a specific blob in mind, you can iterate through the blobs, +and download them into a buffer (`buf`). + +```ts "image" +import { buffer } from "node:stream/consumers" + +for await (const blob of containerClient.listBlobsFlat()) { + const blockBlobClient = containerClient.getBlockBlobClient(blob.name) + const downloadBlockBlobResponse = await blockBlobClient.download(0) + const body = await downloadBlockBlobResponse.readableStreamBody + const image = await buffer(body) + ... +``` + +## Using images in the prompt + +The `image` buffer can be passed in `defImages` to be used in the prompt. + +```ts + defImages(image, { detail: "low" }) +``` + +However since images can be "heavy", you will most likely have to use +[inline prompts](/genaiscript/reference/prompts/inline-prompts) to split into smaller queries. (Note the use of `_.`) + +```ts 'await runPrompt(_ =>' '_.' +for await (const blob of containerClient.listBlobsFlat()) { + ... + const res = await runPrompt(_ => { + _.defImages(image, { detail: "low" }) + _.$`Describe the image.` + }) + // res contains the LLM response for the inner prompt + ... +``` + +## Summarizing results + +To summarize all images, we store each image summary using the `def` function and +add prompting to summarize the descriptions. + +```ts + ... + def("IMAGES_SUMMARY", { filename: blob.name, content: res.text }) +} +$`Summarize IMAGES_SUMMARY.` +``` + +## Full source + + + diff --git a/docs/src/content/docs/guides/llm-as-tool.mdx b/docs/src/content/docs/guides/llm-as-tool.mdx index c8bca902e0..6049478197 100644 --- a/docs/src/content/docs/guides/llm-as-tool.mdx +++ b/docs/src/content/docs/guides/llm-as-tool.mdx @@ -1,7 +1,10 @@ --- title: LLM as a tool sidebar: - order: 60 + order: 60 +description: Create tools and inline prompts using LLM models for executing various tasks +keywords: LLM, inline prompts, tools, gpt-3.5-turbo, task automation + --- It is possible [tools](/genaiscript/reference/scripts/tools) diff --git a/docs/src/content/docs/guides/transformers-js.mdx b/docs/src/content/docs/guides/transformers-js.mdx index f6742d0d87..04d7fc983d 100644 --- a/docs/src/content/docs/guides/transformers-js.mdx +++ b/docs/src/content/docs/guides/transformers-js.mdx @@ -1,7 +1,12 @@ --- title: Transformer.js sidebar: - order: 20 + order: 20 +description: Implement summarization with Transformers.js and leverage local + hardware acceleration +keywords: Transformers.js, summarization, onnxruntime, CPU/GPU acceleration, + pretrained models + --- import { Code } from "@astrojs/starlight/components" import sampleSrc from "../../../../../packages/sample/genaisrc/summary-with-transformers.genai?raw" diff --git a/docs/src/content/docs/guides/using-secrets.mdx b/docs/src/content/docs/guides/using-secrets.mdx index ec650a3b58..eb2fb36d85 100644 --- a/docs/src/content/docs/guides/using-secrets.mdx +++ b/docs/src/content/docs/guides/using-secrets.mdx @@ -2,6 +2,9 @@ title: Using Secrets sidebar: order: 20 +description: Utilize secrets to augment documents with TypeScript and REST APIs +keywords: TypeScript, secrets, REST API, document augmentation, web search + --- import { Code } from '@astrojs/starlight/components'; import tavilyCode from "../../../../../packages/sample/genaisrc/tavily.mjs?raw" diff --git a/docs/src/content/docs/guides/zod-schema.mdx b/docs/src/content/docs/guides/zod-schema.mdx index 138c6cb910..218a85ffa5 100644 --- a/docs/src/content/docs/guides/zod-schema.mdx +++ b/docs/src/content/docs/guides/zod-schema.mdx @@ -2,6 +2,9 @@ title: Zod Schema sidebar: order: 80 +description: Learn how to define and convert TypeScript-first Zod schemas to JSON schema +keywords: TypeScript, Zod schema, JSON schema, schema validation, type inference + --- [zod](https://zod.dev/) is a TypeScript-first schema validation with static type inference. diff --git a/docs/src/content/docs/reference/scripts/chat-participants.mdx b/docs/src/content/docs/reference/scripts/chat-participants.mdx index 6d16506465..ec63d49232 100644 --- a/docs/src/content/docs/reference/scripts/chat-participants.mdx +++ b/docs/src/content/docs/reference/scripts/chat-participants.mdx @@ -1,7 +1,11 @@ --- title: Chat Participants sidebar: - order: 50 + order: 50 +description: Create multi-turn chats or simulate conversations with multiple + chat participants +keywords: chat, multi-turn, conversation, chat participant, engagement + --- import { Code } from '@astrojs/starlight/components'; import scriptSource from "../../../../../../packages/sample/genaisrc/multi-turn.genai.js?raw" diff --git a/docs/src/content/docs/reference/scripts/images.md b/docs/src/content/docs/reference/scripts/images.md index 5dcc07f9f8..e65fb491a5 100644 --- a/docs/src/content/docs/reference/scripts/images.md +++ b/docs/src/content/docs/reference/scripts/images.md @@ -15,3 +15,29 @@ defImages(env.files) ``` Read more about [OpenAI Vision](https://platform.openai.com/docs/guides/vision/limitations). + +## URLs + +Public URLs (that do not require authentication) will be passed directly to OpenAI. + +```js +defImages( + "https://github.com/microsoft/genaiscript/blob/main/docs/public/images/logo.png?raw=true" +) +``` + +Local files are loaded and encoded as a data uri. + +## Buffer, Blob + +The `defImages` function also supports [Buffer](https://nodejs.org/api/buffer.html) +and [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob). + + +This example takes a screenshot of bing.com and adds it to the images. + +```js +const page = await host.browse("https://bing.com") +const screenshot = await page.screenshot() // returns a node.js Buffer +defImages(screenshot) +``` diff --git a/docs/src/content/docs/reference/scripts/prompty.md b/docs/src/content/docs/reference/scripts/prompty.md index ff31414e6c..d69f96bdd0 100644 --- a/docs/src/content/docs/reference/scripts/prompty.md +++ b/docs/src/content/docs/reference/scripts/prompty.md @@ -1,7 +1,11 @@ --- title: Prompty sidebar: - order: 51 + order: 51 +description: Learn about the .prompty file format for parameterized prompts and + its integration with GenAIScript for AI scripting. +keywords: prompty, scripts, AI, parameterized prompts, automation + --- GenAIScript supports running [.prompty](https://prompty.ai/) files as scripts (with some limitations). diff --git a/genaisrc/genaiscript.d.ts b/genaisrc/genaiscript.d.ts index 21c83b94d5..2977b99f3c 100644 --- a/genaisrc/genaiscript.d.ts +++ b/genaisrc/genaiscript.d.ts @@ -1,5 +1,7 @@ type OptionsOrString = (string & {}) | TOptions +type ElementOrArray = T | T[] + interface PromptGenerationConsole { log(...data: any[]): void warn(...data: any[]): void @@ -1570,7 +1572,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: DefSchemaOptions ): string defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void defTool( @@ -2515,7 +2517,7 @@ declare function defSchema( * @param options */ declare function defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void diff --git a/packages/core/src/genaisrc/genaiscript.d.ts b/packages/core/src/genaisrc/genaiscript.d.ts index 21c83b94d5..2977b99f3c 100644 --- a/packages/core/src/genaisrc/genaiscript.d.ts +++ b/packages/core/src/genaisrc/genaiscript.d.ts @@ -1,5 +1,7 @@ type OptionsOrString = (string & {}) | TOptions +type ElementOrArray = T | T[] + interface PromptGenerationConsole { log(...data: any[]): void warn(...data: any[]): void @@ -1570,7 +1572,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: DefSchemaOptions ): string defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void defTool( @@ -2515,7 +2517,7 @@ declare function defSchema( * @param options */ declare function defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void diff --git a/packages/core/src/runpromptcontext.ts b/packages/core/src/runpromptcontext.ts index 89fc75b5ee..c356f4d5af 100644 --- a/packages/core/src/runpromptcontext.ts +++ b/packages/core/src/runpromptcontext.ts @@ -238,7 +238,10 @@ export function createChatGenerationContext( return name } - const defImages = (files: StringLike, defOptions?: DefImagesOptions) => { + const defImages = ( + files: ElementOrArray, + defOptions?: DefImagesOptions + ) => { const { detail } = defOptions || {} if (Array.isArray(files)) files.forEach((file) => defImages(file, defOptions)) @@ -260,6 +263,23 @@ export function createChatGenerationContext( })() ) ) + } else if (files instanceof Blob) { + const blob: Blob = files + appendChild( + node, + createImageNode( + (async () => { + const buffer = Buffer.from(await blob.arrayBuffer()) + const mime = await fileTypeFromBuffer(buffer) + const b64 = await buffer.toString("base64") + const url = `data:${mime.mime};base64,${b64}` + return { + url, + detail, + } + })() + ) + ) } else { const file: WorkspaceFile = files appendChild( diff --git a/packages/core/src/types/prompt_template.d.ts b/packages/core/src/types/prompt_template.d.ts index 59c044b53f..71784d9693 100644 --- a/packages/core/src/types/prompt_template.d.ts +++ b/packages/core/src/types/prompt_template.d.ts @@ -1,5 +1,7 @@ type OptionsOrString = (string & {}) | TOptions +type ElementOrArray = T | T[] + interface PromptGenerationConsole { log(...data: any[]): void warn(...data: any[]): void @@ -1537,7 +1539,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: DefSchemaOptions ): string defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void defTool( diff --git a/packages/core/src/types/prompt_type.d.ts b/packages/core/src/types/prompt_type.d.ts index 2de186bb6a..be32281ae0 100644 --- a/packages/core/src/types/prompt_type.d.ts +++ b/packages/core/src/types/prompt_type.d.ts @@ -203,7 +203,7 @@ declare function defSchema( * @param options */ declare function defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void diff --git a/packages/sample/genaisrc/azure-blobs.genai.mts b/packages/sample/genaisrc/azure-blobs.genai.mts new file mode 100644 index 0000000000..3190ee6a67 --- /dev/null +++ b/packages/sample/genaisrc/azure-blobs.genai.mts @@ -0,0 +1,44 @@ +import { BlobServiceClient } from "@azure/storage-blob" +import { DefaultAzureCredential } from "@azure/identity" +import { buffer } from "node:stream/consumers" + +script({ + parameters: { + account: { + description: "Azure Storage Account Name", + default: "genaiscript", + type: "string", + }, + container: { + description: "Azure Storage Container Name", + default: "images", + type: "string", + }, + }, +}) + +const { account, container } = env.vars +const url = `https://${account}.blob.core.windows.net` +console.log(`analyzing images in ${account}/${container} at ${url}`) +const blobServiceClient = new BlobServiceClient( + url, + new DefaultAzureCredential() +) +const containerClient = blobServiceClient.getContainerClient(container) +for await (const blob of containerClient.listBlobsFlat()) { + console.log(`blob: ` + blob.name) + const blockBlobClient = containerClient.getBlockBlobClient(blob.name) + const downloadBlockBlobResponse = await blockBlobClient.download(0) + const body = await downloadBlockBlobResponse.readableStreamBody + const image = await buffer(body) + + const res = await runPrompt(_ => { + _.defImages(image, { detail: "low" }) + _.$`Describe the images.` + }) + + def("IMAGES_SUMMARY", { filename: blob.name, content: res.text }) +} + +$`Summarize IMAGES_SUMMARY.` + diff --git a/packages/sample/genaisrc/front-matter.genai.mjs b/packages/sample/genaisrc/front-matter.genai.mjs index 6cf5514b14..a4e08963eb 100644 --- a/packages/sample/genaisrc/front-matter.genai.mjs +++ b/packages/sample/genaisrc/front-matter.genai.mjs @@ -21,7 +21,7 @@ defFileMerge(function frontmatter(fn, label, before, generated) { return updated }) -def("FILE", env.files, { glob: "*.md*" }) +def("FILE", env.files, { glob: "**.{md,mdx}" }) $` You are a search engine optimization expert at creating front matter for markdown document. diff --git a/packages/sample/genaisrc/genaiscript.d.ts b/packages/sample/genaisrc/genaiscript.d.ts index 21c83b94d5..2977b99f3c 100644 --- a/packages/sample/genaisrc/genaiscript.d.ts +++ b/packages/sample/genaisrc/genaiscript.d.ts @@ -1,5 +1,7 @@ type OptionsOrString = (string & {}) | TOptions +type ElementOrArray = T | T[] + interface PromptGenerationConsole { log(...data: any[]): void warn(...data: any[]): void @@ -1570,7 +1572,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: DefSchemaOptions ): string defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void defTool( @@ -2515,7 +2517,7 @@ declare function defSchema( * @param options */ declare function defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void diff --git a/packages/sample/genaisrc/node/genaiscript.d.ts b/packages/sample/genaisrc/node/genaiscript.d.ts index 21c83b94d5..2977b99f3c 100644 --- a/packages/sample/genaisrc/node/genaiscript.d.ts +++ b/packages/sample/genaisrc/node/genaiscript.d.ts @@ -1,5 +1,7 @@ type OptionsOrString = (string & {}) | TOptions +type ElementOrArray = T | T[] + interface PromptGenerationConsole { log(...data: any[]): void warn(...data: any[]): void @@ -1570,7 +1572,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: DefSchemaOptions ): string defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void defTool( @@ -2515,7 +2517,7 @@ declare function defSchema( * @param options */ declare function defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void diff --git a/packages/sample/genaisrc/python/genaiscript.d.ts b/packages/sample/genaisrc/python/genaiscript.d.ts index 21c83b94d5..2977b99f3c 100644 --- a/packages/sample/genaisrc/python/genaiscript.d.ts +++ b/packages/sample/genaisrc/python/genaiscript.d.ts @@ -1,5 +1,7 @@ type OptionsOrString = (string & {}) | TOptions +type ElementOrArray = T | T[] + interface PromptGenerationConsole { log(...data: any[]): void warn(...data: any[]): void @@ -1570,7 +1572,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: DefSchemaOptions ): string defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void defTool( @@ -2515,7 +2517,7 @@ declare function defSchema( * @param options */ declare function defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void diff --git a/packages/sample/genaisrc/style/genaiscript.d.ts b/packages/sample/genaisrc/style/genaiscript.d.ts index 21c83b94d5..2977b99f3c 100644 --- a/packages/sample/genaisrc/style/genaiscript.d.ts +++ b/packages/sample/genaisrc/style/genaiscript.d.ts @@ -1,5 +1,7 @@ type OptionsOrString = (string & {}) | TOptions +type ElementOrArray = T | T[] + interface PromptGenerationConsole { log(...data: any[]): void warn(...data: any[]): void @@ -1570,7 +1572,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: DefSchemaOptions ): string defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void defTool( @@ -2515,7 +2517,7 @@ declare function defSchema( * @param options */ declare function defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void diff --git a/packages/sample/package.json b/packages/sample/package.json index 1da0f8b35d..3764bd0534 100644 --- a/packages/sample/package.json +++ b/packages/sample/package.json @@ -18,6 +18,8 @@ "@agentic/calculator": "^7.0.0", "@agentic/core": "^7.0.0", "@agentic/weather": "^7.0.0", + "@azure/identity": "^4.4.1", + "@azure/storage-blob": "^12.24.0", "@tidyjs/tidy": "^2.5.2", "@xenova/transformers": "^2.17.2", "vectorstore": "^0.0.4", diff --git a/packages/sample/src/aici/genaiscript.d.ts b/packages/sample/src/aici/genaiscript.d.ts index 21c83b94d5..2977b99f3c 100644 --- a/packages/sample/src/aici/genaiscript.d.ts +++ b/packages/sample/src/aici/genaiscript.d.ts @@ -1,5 +1,7 @@ type OptionsOrString = (string & {}) | TOptions +type ElementOrArray = T | T[] + interface PromptGenerationConsole { log(...data: any[]): void warn(...data: any[]): void @@ -1570,7 +1572,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: DefSchemaOptions ): string defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void defTool( @@ -2515,7 +2517,7 @@ declare function defSchema( * @param options */ declare function defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void diff --git a/packages/sample/src/errors/genaiscript.d.ts b/packages/sample/src/errors/genaiscript.d.ts index 21c83b94d5..2977b99f3c 100644 --- a/packages/sample/src/errors/genaiscript.d.ts +++ b/packages/sample/src/errors/genaiscript.d.ts @@ -1,5 +1,7 @@ type OptionsOrString = (string & {}) | TOptions +type ElementOrArray = T | T[] + interface PromptGenerationConsole { log(...data: any[]): void warn(...data: any[]): void @@ -1570,7 +1572,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: DefSchemaOptions ): string defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void defTool( @@ -2515,7 +2517,7 @@ declare function defSchema( * @param options */ declare function defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void diff --git a/packages/sample/src/genaiscript.d.ts b/packages/sample/src/genaiscript.d.ts index 21c83b94d5..2977b99f3c 100644 --- a/packages/sample/src/genaiscript.d.ts +++ b/packages/sample/src/genaiscript.d.ts @@ -1,5 +1,7 @@ type OptionsOrString = (string & {}) | TOptions +type ElementOrArray = T | T[] + interface PromptGenerationConsole { log(...data: any[]): void warn(...data: any[]): void @@ -1570,7 +1572,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: DefSchemaOptions ): string defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void defTool( @@ -2515,7 +2517,7 @@ declare function defSchema( * @param options */ declare function defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void diff --git a/packages/sample/src/makecode/genaiscript.d.ts b/packages/sample/src/makecode/genaiscript.d.ts index 21c83b94d5..2977b99f3c 100644 --- a/packages/sample/src/makecode/genaiscript.d.ts +++ b/packages/sample/src/makecode/genaiscript.d.ts @@ -1,5 +1,7 @@ type OptionsOrString = (string & {}) | TOptions +type ElementOrArray = T | T[] + interface PromptGenerationConsole { log(...data: any[]): void warn(...data: any[]): void @@ -1570,7 +1572,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: DefSchemaOptions ): string defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void defTool( @@ -2515,7 +2517,7 @@ declare function defSchema( * @param options */ declare function defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void diff --git a/packages/sample/src/tla/genaiscript.d.ts b/packages/sample/src/tla/genaiscript.d.ts index 21c83b94d5..2977b99f3c 100644 --- a/packages/sample/src/tla/genaiscript.d.ts +++ b/packages/sample/src/tla/genaiscript.d.ts @@ -1,5 +1,7 @@ type OptionsOrString = (string & {}) | TOptions +type ElementOrArray = T | T[] + interface PromptGenerationConsole { log(...data: any[]): void warn(...data: any[]): void @@ -1570,7 +1572,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: DefSchemaOptions ): string defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void defTool( @@ -2515,7 +2517,7 @@ declare function defSchema( * @param options */ declare function defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void diff --git a/packages/sample/src/vision/genaiscript.d.ts b/packages/sample/src/vision/genaiscript.d.ts index 21c83b94d5..2977b99f3c 100644 --- a/packages/sample/src/vision/genaiscript.d.ts +++ b/packages/sample/src/vision/genaiscript.d.ts @@ -1,5 +1,7 @@ type OptionsOrString = (string & {}) | TOptions +type ElementOrArray = T | T[] + interface PromptGenerationConsole { log(...data: any[]): void warn(...data: any[]): void @@ -1570,7 +1572,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: DefSchemaOptions ): string defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void defTool( @@ -2515,7 +2517,7 @@ declare function defSchema( * @param options */ declare function defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void diff --git a/slides/genaisrc/genaiscript.d.ts b/slides/genaisrc/genaiscript.d.ts index 21c83b94d5..2977b99f3c 100644 --- a/slides/genaisrc/genaiscript.d.ts +++ b/slides/genaisrc/genaiscript.d.ts @@ -1,5 +1,7 @@ type OptionsOrString = (string & {}) | TOptions +type ElementOrArray = T | T[] + interface PromptGenerationConsole { log(...data: any[]): void warn(...data: any[]): void @@ -1570,7 +1572,7 @@ interface ChatGenerationContext extends ChatTurnGenerationContext { options?: DefSchemaOptions ): string defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void defTool( @@ -2515,7 +2517,7 @@ declare function defSchema( * @param options */ declare function defImages( - files: StringLike | Buffer | Blob, + files: ElementOrArray, options?: DefImagesOptions ): void diff --git a/yarn.lock b/yarn.lock index 10bb102296..c7a6869093 100644 --- a/yarn.lock +++ b/yarn.lock @@ -60,7 +60,7 @@ "@azure/core-util" "^1.1.0" tslib "^2.6.2" -"@azure/core-client@^1.9.2": +"@azure/core-client@^1.3.0", "@azure/core-client@^1.6.2", "@azure/core-client@^1.9.2": version "1.9.2" resolved "https://registry.yarnpkg.com/@azure/core-client/-/core-client-1.9.2.tgz#6fc69cee2816883ab6c5cdd653ee4f2ff9774f74" integrity sha512-kRdry/rav3fUKHl/aDLd/pDLcB+4pOFwPPTVEExuMyaI5r+JBbMWqRbCY1pn5BniDaU3lRxO9eaQ1AmSMehl/w== @@ -73,7 +73,33 @@ "@azure/logger" "^1.0.0" tslib "^2.6.2" -"@azure/core-rest-pipeline@^1.1.0", "@azure/core-rest-pipeline@^1.9.1": +"@azure/core-http-compat@^2.0.0": + version "2.1.2" + resolved "https://registry.yarnpkg.com/@azure/core-http-compat/-/core-http-compat-2.1.2.tgz#d1585ada24ba750dc161d816169b33b35f762f0d" + integrity sha512-5MnV1yqzZwgNLLjlizsU3QqOeQChkIXw781Fwh1xdAqJR5AA32IUaq6xv1BICJvfbHoa+JYcaij2HFkhLbNTJQ== + dependencies: + "@azure/abort-controller" "^2.0.0" + "@azure/core-client" "^1.3.0" + "@azure/core-rest-pipeline" "^1.3.0" + +"@azure/core-lro@^2.2.0": + version "2.7.2" + resolved "https://registry.yarnpkg.com/@azure/core-lro/-/core-lro-2.7.2.tgz#787105027a20e45c77651a98b01a4d3b01b75a08" + integrity sha512-0YIpccoX8m/k00O7mDDMdJpbr6mf1yWo2dfmxt5A8XVZVVMz2SSKaEbMCeJRvgQ0IaSlqhjT47p4hVIRRy90xw== + dependencies: + "@azure/abort-controller" "^2.0.0" + "@azure/core-util" "^1.2.0" + "@azure/logger" "^1.0.0" + tslib "^2.6.2" + +"@azure/core-paging@^1.1.1": + version "1.6.2" + resolved "https://registry.yarnpkg.com/@azure/core-paging/-/core-paging-1.6.2.tgz#40d3860dc2df7f291d66350b2cfd9171526433e7" + integrity sha512-YKWi9YuCU04B55h25cnOYZHxXYtEvQEbKST5vqRga7hWY9ydd3FZHdeQF8pyh+acWZvppw13M/LMGx0LABUVMA== + dependencies: + tslib "^2.6.2" + +"@azure/core-rest-pipeline@^1.1.0", "@azure/core-rest-pipeline@^1.10.1", "@azure/core-rest-pipeline@^1.3.0", "@azure/core-rest-pipeline@^1.9.1": version "1.16.3" resolved "https://registry.yarnpkg.com/@azure/core-rest-pipeline/-/core-rest-pipeline-1.16.3.tgz#bde3bc3ebad7f885ddd9de6af5e5a8fc254b287e" integrity sha512-VxLk4AHLyqcHsfKe4MZ6IQ+D+ShuByy+RfStKfSjxJoL3WBWq17VNmrz8aT8etKzqc2nAeIyLxScjpzsS4fz8w== @@ -87,14 +113,14 @@ https-proxy-agent "^7.0.0" tslib "^2.6.2" -"@azure/core-tracing@^1.0.0", "@azure/core-tracing@^1.0.1": +"@azure/core-tracing@^1.0.0", "@azure/core-tracing@^1.0.1", "@azure/core-tracing@^1.1.2": version "1.1.2" resolved "https://registry.yarnpkg.com/@azure/core-tracing/-/core-tracing-1.1.2.tgz#065dab4e093fb61899988a1cdbc827d9ad90b4ee" integrity sha512-dawW9ifvWAWmUm9/h+/UQ2jrdvjCJ7VJEuCJ6XVNudzcOwm53BFZH4Q845vjfgoUAM8ZxokvVNxNxAITc502YA== dependencies: tslib "^2.6.2" -"@azure/core-util@^1.1.0", "@azure/core-util@^1.3.0", "@azure/core-util@^1.6.1", "@azure/core-util@^1.9.0": +"@azure/core-util@^1.1.0", "@azure/core-util@^1.2.0", "@azure/core-util@^1.3.0", "@azure/core-util@^1.6.1", "@azure/core-util@^1.9.0": version "1.9.2" resolved "https://registry.yarnpkg.com/@azure/core-util/-/core-util-1.9.2.tgz#1dc37dc5b0dae34c578be62cf98905ba7c0cafe7" integrity sha512-l1Qrqhi4x1aekkV+OlcqsJa4AnAkj5p0JV8omgwjaV9OAbP41lvrMvs+CptfetKkeEaGRGSzby7sjPZEX7+kkQ== @@ -102,6 +128,14 @@ "@azure/abort-controller" "^2.0.0" tslib "^2.6.2" +"@azure/core-xml@^1.3.2": + version "1.4.3" + resolved "https://registry.yarnpkg.com/@azure/core-xml/-/core-xml-1.4.3.tgz#a74f37a0e584fee7e9adae19f51016d4b59e9ca2" + integrity sha512-D6G7FEmDiTctPKuWegX2WTrS1enKZwqYwdKTO6ZN6JMigcCehlT0/CYl+zWpI9vQ9frwwp7GQT3/owaEXgnOsA== + dependencies: + fast-xml-parser "^4.3.2" + tslib "^2.6.2" + "@azure/identity@^4.1.0", "@azure/identity@^4.4.1": version "4.4.1" resolved "https://registry.yarnpkg.com/@azure/identity/-/identity-4.4.1.tgz#490fa2ad26786229afa36411892bb53dfa3478d3" @@ -150,6 +184,25 @@ jsonwebtoken "^9.0.0" uuid "^8.3.0" +"@azure/storage-blob@^12.24.0": + version "12.24.0" + resolved "https://registry.yarnpkg.com/@azure/storage-blob/-/storage-blob-12.24.0.tgz#d4ae1e29574b4a19d90eaf082cfde95f996d3f9b" + integrity sha512-l8cmWM4C7RoNCBOImoFMxhTXe1Lr+8uQ/IgnhRNMpfoA9bAFWoLG4XrWm6O5rKXortreVQuD+fc1hbzWklOZbw== + dependencies: + "@azure/abort-controller" "^1.0.0" + "@azure/core-auth" "^1.4.0" + "@azure/core-client" "^1.6.2" + "@azure/core-http-compat" "^2.0.0" + "@azure/core-lro" "^2.2.0" + "@azure/core-paging" "^1.1.1" + "@azure/core-rest-pipeline" "^1.10.1" + "@azure/core-tracing" "^1.1.2" + "@azure/core-util" "^1.6.1" + "@azure/core-xml" "^1.3.2" + "@azure/logger" "^1.0.0" + events "^3.0.0" + tslib "^2.2.0" + "@babel/code-frame@^7.0.0": version "7.24.7" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.24.7.tgz#882fd9e09e8ee324e496bd040401c6f046ef4465" @@ -2227,7 +2280,7 @@ fast-uri@^3.0.1: resolved "https://registry.yarnpkg.com/fast-uri/-/fast-uri-3.0.1.tgz#cddd2eecfc83a71c1be2cc2ef2061331be8a7134" integrity sha512-MWipKbbYiYI0UC7cl8m/i/IWTqfC8YXsqjzybjddLsFjStroQzsHXkc73JutMvBiXmOvapk+axIl79ig5t55Bw== -fast-xml-parser@^4.5.0: +fast-xml-parser@^4.3.2, fast-xml-parser@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.5.0.tgz#2882b7d01a6825dfdf909638f2de0256351def37" integrity sha512-/PlTQCI96+fZMAOLMZK4CWG1ItCbfZ/0jx7UIJFChPNrx7tcEgerUgWbeieCM9MfHInUDyK8DWYZ+YrywDJuTg==