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="dspy_app",
    project_version_name="v1",
    session_name="s1"
)

4. Configure DSPy Instrumentation

Initialize the DSPy instrumentor to enable automatic tracing.

from fi.integrations.otel import DSPyInstrumentor

DSPyInstrumentor().instrument(tracer_provider=trace_provider)

5. Install Required Dependencies

Install the necessary DSPy components required for your project.

pip install dspy

6. Create DSPy Components

Set up your DSPy components with built-in observability.

import dspy

class BasicQA(dspy.Signature):
    """Answer questions with short factoid answers."""

    question = dspy.InputField()
    answer = dspy.OutputField(desc="often between 1 and 5 words")

7. Execute

Run your DSPy application.

if __name__ == "__main__":
    turbo = dspy.LM(model="openai/gpt-4")

    dspy.settings.configure(lm=turbo)

    # Define the predictor.
    generate_answer = dspy.Predict(BasicQA)

    # Call the predictor on a particular input.
    pred = generate_answer(question="What is the capital of the united states?")
    print(f"Predicted Answer: {pred.answer}")