2023-06-01 01:53:09 +00:00
|
|
|
import 'dotenv/config'
|
2023-06-18 05:52:22 +00:00
|
|
|
import { OpenAIClient } from 'openai-fetch'
|
2023-05-27 00:38:55 +00:00
|
|
|
import { z } from 'zod'
|
|
|
|
|
2023-06-17 00:42:21 +00:00
|
|
|
import { Agentic, SerpAPITool } from '@/index'
|
2023-05-27 00:38:55 +00:00
|
|
|
|
|
|
|
async function main() {
|
|
|
|
const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! })
|
2023-06-15 05:11:30 +00:00
|
|
|
const agentic = new Agentic({ openai })
|
2023-05-27 00:38:55 +00:00
|
|
|
|
2023-06-17 19:02:14 +00:00
|
|
|
const topic = process.argv[2] || 'HF0 accelerator'
|
|
|
|
|
2023-06-15 05:11:30 +00:00
|
|
|
const res = await agentic
|
2023-06-16 07:48:11 +00:00
|
|
|
.gpt4(`Summarize the latest news on {{topic}} using markdown.`)
|
2023-06-17 00:42:21 +00:00
|
|
|
.tools([new SerpAPITool()])
|
2023-05-27 00:38:55 +00:00
|
|
|
.input(
|
|
|
|
z.object({
|
2023-06-16 22:50:38 +00:00
|
|
|
topic: z.string()
|
2023-05-27 00:38:55 +00:00
|
|
|
})
|
|
|
|
)
|
|
|
|
.call({
|
2023-06-17 19:02:14 +00:00
|
|
|
topic
|
2023-05-27 00:38:55 +00:00
|
|
|
})
|
2023-06-15 05:11:30 +00:00
|
|
|
|
2023-06-17 00:42:21 +00:00
|
|
|
console.log('\n\n\n' + res)
|
2023-05-27 00:38:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main()
|