kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
old-agentic-v1^2
rodzic
203db5fa7f
commit
8b3ebb4515
11
src/llm.ts
11
src/llm.ts
|
@ -209,8 +209,16 @@ export class OpenAIChatModelBuilder<
|
||||||
: z.object(this._options.output)
|
: z.object(this._options.output)
|
||||||
|
|
||||||
const { node } = zodToTs(outputSchema)
|
const { node } = zodToTs(outputSchema)
|
||||||
|
|
||||||
|
if (node.kind === 152) {
|
||||||
|
// ignore raw strings
|
||||||
|
messages.push({
|
||||||
|
role: 'system',
|
||||||
|
content: dedent`Output a string`
|
||||||
|
})
|
||||||
|
} else {
|
||||||
const tsTypeString = printNode(node, {
|
const tsTypeString = printNode(node, {
|
||||||
removeComments: true,
|
removeComments: false,
|
||||||
// TODO: this doesn't seem to actually work, so we're doing it manually below
|
// TODO: this doesn't seem to actually work, so we're doing it manually below
|
||||||
omitTrailingSemicolon: true,
|
omitTrailingSemicolon: true,
|
||||||
noEmitHelpers: true
|
noEmitHelpers: true
|
||||||
|
@ -226,6 +234,7 @@ export class OpenAIChatModelBuilder<
|
||||||
\`\`\``
|
\`\`\``
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: filter/compress messages based on token counts
|
// TODO: filter/compress messages based on token counts
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,9 @@ async function main() {
|
||||||
// .call()
|
// .call()
|
||||||
// console.log(ex0)
|
// console.log(ex0)
|
||||||
|
|
||||||
const ex1 = await $.gpt4(`give me fake data conforming to this schema`)
|
const ex1 = await $.gpt4(`give me fake data`)
|
||||||
.output(z.object({ foo: z.string(), bar: z.number() }))
|
.output(z.object({ foo: z.string(), bar: z.number() }))
|
||||||
|
// .output(z.string())
|
||||||
// .retry({ attempts: 3 })
|
// .retry({ attempts: 3 })
|
||||||
.call()
|
.call()
|
||||||
console.log(ex1)
|
console.log(ex1)
|
||||||
|
|
Ładowanie…
Reference in New Issue