2023-06-14 02:49:54 +00:00
|
|
|
import 'dotenv/config'
|
2023-06-18 05:52:22 +00:00
|
|
|
import { OpenAIClient } from 'openai-fetch'
|
2023-06-14 02:49:54 +00:00
|
|
|
import { z } from 'zod'
|
|
|
|
|
2023-06-15 00:40:48 +00:00
|
|
|
import { Agentic, CalculatorTool, WeatherTool } from '@/index'
|
2023-06-14 02:49:54 +00:00
|
|
|
|
|
|
|
async function main() {
|
|
|
|
const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! })
|
|
|
|
const agentic = new Agentic({ openai })
|
|
|
|
|
|
|
|
const example = await agentic
|
2023-06-15 00:40:48 +00:00
|
|
|
.gpt3('What is the temperature in san francisco today?')
|
|
|
|
.tools([new CalculatorTool(), new WeatherTool()])
|
|
|
|
.output(
|
|
|
|
z.object({
|
|
|
|
answer: z.number(),
|
|
|
|
units: z.union([z.literal('fahrenheit'), z.literal('celcius')])
|
|
|
|
})
|
|
|
|
)
|
2023-06-14 02:49:54 +00:00
|
|
|
.call()
|
2023-06-15 04:01:24 +00:00
|
|
|
|
2023-06-14 02:49:54 +00:00
|
|
|
console.log(example)
|
|
|
|
}
|
|
|
|
|
|
|
|
main()
|