kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
27 wiersze
632 B
TypeScript
27 wiersze
632 B
TypeScript
import 'dotenv/config'
|
|
import { OpenAIClient } from 'openai-fetch'
|
|
import { z } from 'zod'
|
|
|
|
import { Agentic } from '@/agentic'
|
|
|
|
async function main() {
|
|
const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! })
|
|
const ai = new Agentic({ openai })
|
|
|
|
const out = await ai
|
|
.gpt3(`Give me {{numFacts}} random facts about {{topic}}`)
|
|
.input(
|
|
z.object({
|
|
topic: z.string(),
|
|
numFacts: z.number().int().default(5).optional()
|
|
})
|
|
)
|
|
.output(z.object({ facts: z.array(z.string()) }))
|
|
.modelParams({ temperature: 0.9 })
|
|
.call({ topic: 'cats' })
|
|
|
|
console.log(out)
|
|
}
|
|
|
|
main()
|