old-agentic-v1^2
Travis Fischer 2023-05-26 17:03:25 -07:00
rodzic b755db7c67
commit 49043941ca
3 zmienionych plików z 32 dodań i 2 usunięć

Wyświetl plik

@ -16,7 +16,7 @@ async function main() {
// .call()
// console.log(ex0)
const ex1 = await $.gpt4(`give me fake data`)
const ex1 = await $.gpt4(`generate fake data`)
.output(z.object({ foo: z.string(), bar: z.number() }))
// .output(z.string())
// .retry({ attempts: 3 })

Wyświetl plik

@ -34,6 +34,36 @@ export class Agentic {
}
}
llm(
promptOrChatCompletionParams:
| string
| Partial<types.openai.ChatCompletionParams> // TODO: make more strict
) {
let options: Partial<types.openai.ChatCompletionParams>
if (typeof promptOrChatCompletionParams === 'string') {
options = {
messages: [
{
role: 'user',
content: promptOrChatCompletionParams
}
]
}
} else {
options = promptOrChatCompletionParams
if (!options.messages) {
throw new Error('messages must be provided')
}
}
return new OpenAIChatModelBuilder(this._client, {
...(this._defaults as any), // TODO
...options
})
}
gpt4(
promptOrChatCompletionParams:
| string

Wyświetl plik

@ -147,7 +147,7 @@ export abstract class BaseChatModelBuilder<
messages.push({
role: 'system',
content: dedent`Output JSON only in the following TypeScript format:
content: dedent`Do not output code. Output JSON only in the following TypeScript format:
\`\`\`ts
${tsTypeString}
\`\`\``