Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into participant
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Jun 9, 2024
2 parents 11a7f66 + 0027cc1 commit 6b28f4f
Show file tree
Hide file tree
Showing 20 changed files with 72 additions and 38 deletions.
2 changes: 1 addition & 1 deletion docs/genaisrc/genaiscript.d.ts

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

2 changes: 2 additions & 0 deletions docs/src/content/docs/guides/pull-request-reviewer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Pull Request Reviewer
sidebar:
order: 20
description: Learn how to automate pull request reviews with a GenAIScript that provides feedback and code analysis in GitHub Actions.
keywords: pull request automation, code review, GitHub Actions, GenAIScript reviewer, PR feedback
---
import { Code } from '@astrojs/starlight/components';
import importedCode from "../../../../../packages/sample/genaisrc/pr-review.genai?raw"
Expand Down
2 changes: 2 additions & 0 deletions docs/src/content/docs/reference/cli/test.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: Test
sidebar:
order: 3.5
description: Learn how to run tests for your scripts using GenAIScript CLI with support for multiple AI models.
keywords: CLI testing, script tests, AI model testing, test viewer, GenAIScript CLI
---

Runs the tests in scripts using [promptfoo](https://www.promptfoo.dev/).
Expand Down
1 change: 1 addition & 0 deletions docs/src/content/docs/slides.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ description: Slides

- [msr-eng-may2024](/genaiscript/slides/msr-eng-may2024/)
- [networking-apr2024](/genaiscript/slides/networking-apr2024/)
- [overview-june2024](/genaiscript/slides/overview-june2024/)
- [overview-may2024](/genaiscript/slides/overview-may2024/)
- [pnw-plse-may2024](/genaiscript/slides/pnw-plse-may2024/)
- [default](/genaiscript/slides/default/)
Expand Down
2 changes: 1 addition & 1 deletion genaisrc/genaiscript.d.ts

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

2 changes: 1 addition & 1 deletion packages/core/src/genaisrc/genaiscript.d.ts

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

24 changes: 0 additions & 24 deletions packages/core/src/promptcontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,29 +166,6 @@ export function createPromptContext(
},
}

const defImages = (files: StringLike, defOptions?: DefImagesOptions) => {
const { detail } = defOptions || {}
if (Array.isArray(files))
files.forEach((file) => defImages(file, defOptions))
else if (typeof files === "string")
appendPromptChild(createImageNode({ url: files, detail }))
else {
const file: WorkspaceFile = files
appendPromptChild(
createImageNode(
(async () => {
const url = await resolveFileDataUri(file, { trace })
return {
url,
filename: file.filename,
detail,
}
})()
)
)
}
}

const defOutputProcessor = (fn: PromptOutputProcessorHandler) => {
if (fn) appendPromptChild(createOutputProcessor(fn))
}
Expand Down Expand Up @@ -231,7 +208,6 @@ export function createPromptContext(
XML,
retrieval,
host: promptHost,
defImages,
defOutputProcessor,
defChatParticipant,
defFileMerge: (fn) => {
Expand Down
27 changes: 27 additions & 0 deletions packages/core/src/runpromptcontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
createDefDataNode,
createDefNode,
createFunctionNode,
createImageNode,
createSchemaNode,
createStringTemplateNode,
createTextNode,
Expand All @@ -27,6 +28,7 @@ import { promptParametersSchemaToJSONSchema } from "./parameters"
import { isJSONSchema } from "./schema"
import { consoleLogFormat } from "./logging"
import { host } from "./host"
import { resolveFileDataUri } from "./file"

export interface RunPromptContextNode extends RunPromptContext {
node: PromptNode
Expand Down Expand Up @@ -78,6 +80,30 @@ export function createRunPromptContext(
return name
}

const defImages = (files: StringLike, defOptions?: DefImagesOptions) => {
const { detail } = defOptions || {}
if (Array.isArray(files))
files.forEach((file) => defImages(file, defOptions))
else if (typeof files === "string")
appendChild(node, createImageNode({ url: files, detail }))
else {
const file: WorkspaceFile = files
appendChild(
node,
createImageNode(
(async () => {
const url = await resolveFileDataUri(file, { trace })
return {
url,
filename: file.filename,
detail,
}
})()
)
)
}
}

const ctx = <RunPromptContextNode>{
node,
writeText: (body, options) => {
Expand Down Expand Up @@ -140,6 +166,7 @@ export function createRunPromptContext(
},
defTool,
defSchema,
defImages,
fence(body, options?: DefOptions) {
ctx.def("", body, options)
return undefined
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 @@ -1233,6 +1233,7 @@ interface RunPromptContext {
generator: string | RunPromptGenerator,
options?: RunPromptOptions
): Promise<RunPromptResult>
defImages(files: StringLike, options?: DefImagesOptions): void
defTool(
name: string,
description: string,
Expand Down Expand Up @@ -1495,7 +1496,6 @@ interface ContainerHost extends ShellHost {
interface PromptContext extends RunPromptContext {
script(options: PromptArgs): void
system(options: PromptSystemArgs): void
defImages(files: StringLike, options?: DefImagesOptions): void
defFileMerge(fn: FileMergeHandler): void
defOutputProcessor(fn: PromptOutputProcessorHandler): void
fetchText(
Expand Down
26 changes: 26 additions & 0 deletions packages/sample/genaisrc/describe-image-run-prompt.genai.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
script({
title: "Describe objects in each image",
model: "gpt-3.5-turbo",
maxTokens: 4000,
system: [],
tests: {
files: "src/robots.jpg",
keywords: "robot",
},
})

for (const file of env.files) {
const res = await runPrompt(
(_) => {
_.$`Return the list of objects in the images.`
_.defImages(file, { detail: "low" })
},
{
model: "gpt-4-turbo-v",
maxTokens: 4000,
}
)
def("OBJECTS", res.text)
}

$`Summarize the objects in images.`
2 changes: 1 addition & 1 deletion packages/sample/genaisrc/genaiscript.d.ts

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

2 changes: 1 addition & 1 deletion packages/sample/genaisrc/node/genaiscript.d.ts

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

2 changes: 1 addition & 1 deletion packages/sample/genaisrc/python/genaiscript.d.ts

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

2 changes: 1 addition & 1 deletion packages/sample/genaisrc/style/genaiscript.d.ts

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

2 changes: 1 addition & 1 deletion packages/sample/src/aici/genaiscript.d.ts

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

2 changes: 1 addition & 1 deletion packages/sample/src/errors/genaiscript.d.ts

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

2 changes: 1 addition & 1 deletion packages/sample/src/makecode/genaiscript.d.ts

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

2 changes: 1 addition & 1 deletion packages/sample/src/tla/genaiscript.d.ts

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

2 changes: 1 addition & 1 deletion packages/sample/src/vision/genaiscript.d.ts

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

2 changes: 1 addition & 1 deletion slides/genaisrc/genaiscript.d.ts

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

0 comments on commit 6b28f4f

Please sign in to comment.