Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make defOutputProcessor more flexible #634

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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. 🛡️
pelikhan marked this conversation as resolved.
Show resolved Hide resolved
})
}

Expand Down Expand Up @@ -226,7 +226,7 @@
) {
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. 📝
pelikhan marked this conversation as resolved.
Show resolved Hide resolved
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 @@
| 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. 🔄
pelikhan marked this conversation as resolved.
Show resolved Hide resolved

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.