Skip to content

Commit

Permalink
make defOutputProcessor more flexible (#634)
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan authored Aug 20, 2024
1 parent 1aa2ab8 commit aeabd7a
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 })
})
}

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(", ")
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>

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 aeabd7a

Please sign in to comment.