1. Installation

Install the FutureAGI package to access the observability framework.

pip install futureagi

2. Environment Configuration

Set up your environment variables to authenticate with FutureAGI services. These credentials enable: Authentication with FutureAGI’s observability platform Encrypted telemetry data transmission

import os
os.environ["FI_API_KEY"] = "your-futureagi-api-key"
os.environ["FI_SECRET_KEY"] = "your-futureagi-secret-key"

3. Initialize Trace Provider

Set up the trace provider to establish the observability pipeline. The trace provider:

  • Creates a new project in FutureAGI
  • Establishes telemetry data pipelines
  • Configures version tracking
  • Sets up evaluation frameworks
from fi.integrations.otel import register
from fi.integrations.otel.types import ProjectType

trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="llama_index_app",
    project_version_name="v1",
    session_name="s1"
)

4. Configure Llama Index Instrumentation

Initialize the Llama Index instrumentor to enable automatic tracing.

from fi.integrations.otel import LlamaIndexInstrumentor

LlamaIndexInstrumentor().instrument(tracer_provider=trace_provider)

5. Install Required Dependencies

Install the necessary Llama Index components required for your project.

pip install llama-index

6. Create Llama Index Components

Set up your Llama Index components with built-in observability.

from llama_index.agent.openai import OpenAIAgent
from llama_index.core import Settings
from llama_index.core.tools import FunctionTool
from llama_index.llms.openai import OpenAI

def multiply(a: int, b: int) -> int:
    """Multiply two integers and return the result."""
    return a * b

def add(a: int, b: int) -> int:
    """Add two integers and return the result."""
    return a + b

multiply_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")


7. Execute

Run your Llama Index application.

if __name__ == "__main__":
    response = agent.query("What is (121 * 3) + 42?")
    print(response)