kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
35 wiersze
716 B
TypeScript
35 wiersze
716 B
TypeScript
import { OpenAIClient } from '@agentic/openai-fetch'
|
|
import 'dotenv/config'
|
|
import { z } from 'zod'
|
|
|
|
import { Agentic, SerpAPITool } from '@/index'
|
|
|
|
async function main() {
|
|
const openai = new OpenAIClient({ apiKey: process.env.OPENAI_API_KEY! })
|
|
const agentic = new Agentic({ openai })
|
|
|
|
const res = await agentic
|
|
.gpt4(
|
|
`Can you summarize the top {{numResults}} results for today's news about {{topic}}?`
|
|
)
|
|
.tools([new SerpAPITool()])
|
|
.input(
|
|
z.object({
|
|
topic: z.string(),
|
|
numResults: z.number().default(3)
|
|
})
|
|
)
|
|
.output(
|
|
z.object({
|
|
summary: z.string()
|
|
})
|
|
)
|
|
.call({
|
|
topic: 'OpenAI'
|
|
})
|
|
|
|
console.log(res)
|
|
}
|
|
|
|
main()
|