Skip to content

Commit

Permalink
make defOutputProcessor more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Aug 20, 2024
1 parent 1aa2ab8 commit fdc277a
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 3 deletions.
2 changes: 2 additions & 0 deletions 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 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 packages/core/src/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/core/src/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ ${this.toResultIcon(success, "")}${title}
error: serializeError(error),
}
this.errors.push(err)
this.renderError(err, { details: false })
this.renderError(err, { details: true })

Check failure on line 199 in packages/core/src/trace.ts

View workflow job for this annotation

GitHub Actions / build

The change from `details: false` to `details: true` in the `renderError` function call might expose sensitive error details. Please ensure this does not lead to any security vulnerabilities. 🛡️
})
}

Expand Down Expand Up @@ -226,7 +226,7 @@ ${this.toResultIcon(success, "")}${title}
) {
const { message, error } = e
const emsg = errorMessage(error)
const msg = message || emsg
const msg = [message, emsg].filter((m) => m).join(", ")

Check failure on line 229 in packages/core/src/trace.ts

View workflow job for this annotation

GitHub Actions / build

The change in error message construction might lead to unclear error messages. The new code concatenates `message` and `emsg` with a comma, which might not make sense if one of them is undefined or empty. Please ensure the error messages are clear and helpful. 📝
this.disableChange(() => {
this.item(msg)
if (options.details && error?.stack) {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/types/prompt_template.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ type PromptOutputProcessorHandler = (
| Promise<PromptOutputProcessorResult>
| undefined
| Promise<undefined>
| void
| Promise<void>

Check failure on line 105 in packages/core/src/types/prompt_template.d.ts

View workflow job for this annotation

GitHub Actions / build

The addition of `void` and `Promise<void>` to the return types of `PromptOutputProcessorHandler` might lead to confusion as these types do not provide any meaningful information. Please ensure this is the intended behavior. 🔄

type PromptTemplateResponseType = "json_object" | "json_schema" | undefined

Expand Down
2 changes: 2 additions & 0 deletions 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: 2 additions & 0 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.

10 changes: 9 additions & 1 deletion packages/sample/genaisrc/output.genai.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
script({
model: "openai:gpt-3.5-turbo",
title: "custom output",
files: "src/rag/markdown.md", tests: { files: "src/rag/markdown.md" },
system: [],
})
const output = env.files[0].filename + ".txt"
def("FILE", env.files)
$`Summarize all the files. Respond as raw text.`

defOutputProcessor((o) => {
defOutputProcessor(async (o) => {
console.log(`writing to ${output}`)
return {
files: {
[output]: o.text,
},
}
})

defOutputProcessor(o => {
const { text } = o
console.log(`doing something with text`)
console.log(text)
})
2 changes: 2 additions & 0 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.

2 changes: 2 additions & 0 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.

2 changes: 2 additions & 0 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.

2 changes: 2 additions & 0 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.

2 changes: 2 additions & 0 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.

2 changes: 2 additions & 0 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.

2 changes: 2 additions & 0 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.

2 changes: 2 additions & 0 deletions 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 fdc277a

Please sign in to comment.