Install

npm install @agentic/llamaindex llamaindex @llamaindex/openai @llamaindex/workflow

Usage

import 'dotenv/config'

import { createLlamaIndexTools } from '@agentic/llamaindex'
import { WeatherClient } from '@agentic/stdlib'
import { openai } from '@llamaindex/openai'
import { agent } from '@llamaindex/workflow'

async function main() {
  const weather = new WeatherClient()

  const tools = createLlamaIndexTools(weather)
  const weatherAgent = agent({
    name: 'Weather Agent',
    llm: openai({ model: 'gpt-4o-mini', temperature: 0 }),
    systemPrompt: 'You are a helpful assistant. Be as concise as possible.',
    tools
  })

  const response = await weatherAgent.run(
    'What is the weather in San Francisco?'
  )

  console.log(response.data.result)
}

await main()

Running this example

You’ll need a free API key from weatherapi.com to run this example. Store it in a local .env file as WEATHER_API_KEY.

You’ll need an OpenAI API key to run this example. Store it in a local .env file as OPENAI_API_KEY.

git clone git@github.com:transitive-bullshit/agentic.git
cd agentic
pnpm install
echo 'WEATHER_API_KEY=your-key' >> .env
echo 'OPENAI_API_KEY=your-key' >> .env
npx tsx examples/llamaindex/bin/weather.ts