Initialize the Llama Index instrumentor to enable automatic tracing. This step ensures that all interactions with the Llama Index are tracked and monitored.
from traceai_llamaindex import LlamaIndexInstrumentorLlamaIndexInstrumentor().instrument(tracer_provider=trace_provider)
5. Create Llama Index Components
Set up your Llama Index components as you normally would. Our Instrumentor will automatically trace and send the telemetry data to our platform.
from llama_index.agent.openai import OpenAIAgentfrom llama_index.core import Settingsfrom llama_index.core.tools import FunctionToolfrom llama_index.llms.openai import OpenAIdef multiply(a: int, b: int) -> int: """Multiply two integers and return the result.""" return a * bdef add(a: int, b: int) -> int: """Add two integers and return the result.""" return a + bmultiply_tool = FunctionTool.from_defaults(fn=multiply)add_tool = FunctionTool.from_defaults(fn=add)agent = OpenAIAgent.from_tools([multiply_tool, add_tool])Settings.llm = OpenAI(model="gpt-3.5-turbo")response = agent.query("What is (121 * 3) + 42?")print(response)