2024-06-02 02:04:13 +00:00
|
|
|
import 'dotenv/config'
|
|
|
|
|
2024-08-04 02:36:44 +00:00
|
|
|
import { createAISDKTools } from '@agentic/ai-sdk'
|
|
|
|
import { WeatherClient } from '@agentic/weather'
|
2024-10-21 23:10:07 +00:00
|
|
|
import { createOpenAI } from '@ai-sdk/openai'
|
2024-06-02 02:04:13 +00:00
|
|
|
import { generateText } from 'ai'
|
|
|
|
|
|
|
|
async function main() {
|
|
|
|
const weather = new WeatherClient()
|
2024-10-21 23:10:07 +00:00
|
|
|
const openai = createOpenAI({ compatibility: 'strict' })
|
2024-06-02 02:04:13 +00:00
|
|
|
|
|
|
|
const result = await generateText({
|
2024-08-04 10:55:47 +00:00
|
|
|
model: openai('gpt-4o-mini'),
|
2024-06-02 08:06:45 +00:00
|
|
|
tools: createAISDKTools(weather),
|
2024-06-02 02:04:13 +00:00
|
|
|
toolChoice: 'required',
|
2024-06-02 08:16:23 +00:00
|
|
|
temperature: 0,
|
2024-06-02 22:30:39 +00:00
|
|
|
system: 'You are a helpful assistant. Be as concise as possible.',
|
2024-06-02 08:16:23 +00:00
|
|
|
prompt: 'What is the weather in San Francisco?'
|
2024-06-02 02:04:13 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
console.log(result.toolResults[0])
|
|
|
|
}
|
|
|
|
|
|
|
|
await main()
|