chatgpt-api/examples/basic.ts

18 wiersze
432 B
TypeScript
Czysty Zwykły widok Historia

import { OpenAIClient } from '@agentic/openai-fetch'
2023-06-01 01:53:09 +00:00
import 'dotenv/config'
2023-05-26 03:30:36 +00:00
import { z } from 'zod'
2023-06-07 19:13:01 +00:00
import { Agentic } from '@/agentic'
2023-05-26 03:30:36 +00:00
async function main() {
const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! })
const $ = new Agentic({ openai })
2023-05-27 04:43:30 +00:00
const example = await $.gpt4(`generate fake data`)
2023-05-26 19:06:39 +00:00
.output(z.object({ foo: z.string(), bar: z.number() }))
.call()
2023-05-27 04:43:30 +00:00
console.log(example)
2023-05-26 03:30:36 +00:00
}
main()