2023-06-14 02:49:54 +00:00
|
|
|
import { OpenAIClient } from '@agentic/openai-fetch'
|
2023-06-01 01:53:09 +00:00
|
|
|
import 'dotenv/config'
|
2023-05-25 21:59:22 +00:00
|
|
|
import { z } from 'zod'
|
|
|
|
|
2023-06-07 19:13:01 +00:00
|
|
|
import { Agentic } from '@/agentic'
|
2023-05-25 21:59:22 +00:00
|
|
|
|
|
|
|
async function main() {
|
|
|
|
const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! })
|
|
|
|
const ai = new Agentic({ openai })
|
|
|
|
|
|
|
|
const out = await ai
|
2023-05-27 01:18:15 +00:00
|
|
|
.gpt3(`Give me {{numFacts}} random facts about {{topic}}`)
|
|
|
|
.input(
|
2023-06-01 01:56:21 +00:00
|
|
|
z.object({
|
|
|
|
topic: z.string(),
|
2023-06-12 22:01:55 +00:00
|
|
|
numFacts: z.number().int().default(5)
|
2023-06-01 01:56:21 +00:00
|
|
|
})
|
2023-05-27 01:18:15 +00:00
|
|
|
)
|
|
|
|
.output(z.object({ facts: z.array(z.string()) }))
|
2023-05-25 21:59:22 +00:00
|
|
|
.modelParams({ temperature: 0.9 })
|
|
|
|
.call({ topic: 'cats' })
|
2023-05-26 03:30:36 +00:00
|
|
|
|
2023-05-25 21:59:22 +00:00
|
|
|
console.log(out)
|
|
|
|
}
|
|
|
|
|
|
|
|
main()
|