2024-06-05 00:58:50 +00:00
|
|
|
import 'dotenv/config'
|
|
|
|
|
2024-08-04 06:32:30 +00:00
|
|
|
import { createLlamaIndexTools } from '@agentic/llamaindex'
|
2024-08-04 10:34:47 +00:00
|
|
|
import { WeatherClient } from '@agentic/stdlib'
|
2025-05-26 15:03:04 +00:00
|
|
|
import { openai } from '@llamaindex/openai'
|
|
|
|
import { agent } from '@llamaindex/workflow'
|
2024-06-05 00:58:50 +00:00
|
|
|
|
|
|
|
async function main() {
|
|
|
|
const weather = new WeatherClient()
|
|
|
|
|
|
|
|
const tools = createLlamaIndexTools(weather)
|
2025-05-26 15:03:04 +00:00
|
|
|
const weatherAgent = agent({
|
|
|
|
name: 'Weather Agent',
|
|
|
|
llm: openai({ model: 'gpt-4o-mini', temperature: 0 }),
|
2024-06-05 00:58:50 +00:00
|
|
|
systemPrompt: 'You are a helpful assistant. Be as concise as possible.',
|
|
|
|
tools
|
|
|
|
})
|
|
|
|
|
2025-05-26 15:03:04 +00:00
|
|
|
const response = await weatherAgent.run(
|
|
|
|
'What is the weather in San Francisco?'
|
|
|
|
)
|
2024-06-05 00:58:50 +00:00
|
|
|
|
2025-05-26 15:03:04 +00:00
|
|
|
console.log(response.data.result)
|
2024-06-05 00:58:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
await main()
|