2023-06-16 22:50:38 +00:00
import { OpenAIClient } from '@agentic/openai-fetch'
import 'dotenv/config'
import { z } from 'zod'
2023-06-17 00:09:24 +00:00
import { Agentic , SearchAndCrawlTool , WeatherTool } from '@/index'
2023-06-16 22:50:38 +00:00
async function main() {
const openai = new OpenAIClient ( { apiKey : process.env.OPENAI_API_KEY ! } )
const agentic = new Agentic ( { openai } )
2023-06-17 00:09:24 +00:00
const topic = process . argv [ 2 ] || 'OpenAI'
2023-06-16 22:50:38 +00:00
const res = await agentic
2023-06-17 00:09:24 +00:00
. gpt4 ( {
messages : [
{
role : 'system' ,
content : ` You are a MckInsey analyst who is an expert at writing executive summaries. Always respond using markdown unless instructed to respond using JSON. `
} ,
{
role : 'user' ,
content : ` Summarize the latest news on: {{topic}} `
}
] ,
2023-06-16 23:09:33 +00:00
model : 'gpt-4-32k'
} )
2023-06-17 00:09:24 +00:00
. tools ( [ new SearchAndCrawlTool ( ) , new WeatherTool ( ) ] )
2023-06-16 22:50:38 +00:00
. input (
z . object ( {
topic : z.string ( )
} )
)
2023-06-17 00:09:24 +00:00
. call ( { topic } )
2023-06-16 22:50:38 +00:00
2023-06-17 00:09:24 +00:00
console . log ( '\n\n\n' )
2023-06-16 22:50:38 +00:00
console . log ( res )
}
main ( )