chatgpt-api/legacy/examples/llamaindex/bin/weather.ts

27 wiersze
686 B
TypeScript
Czysty Zwykły widok Historia

2024-06-05 00:58:50 +00:00
import 'dotenv/config'
import { createLlamaIndexTools } from '@agentic/llamaindex'
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()