1. Installation

Install the traceAI package to access the observability framework:
pip install traceai_experiment

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
  • Access to experiment tracking features
import os
os.environ["FI_API_KEY"] = "your-futureagi-api-key"
os.environ["FI_SECRET_KEY"] = "your-futureagi-secret-key"

3. Configure Evaluation Tags

Define evaluation criteria for monitoring experiment responses. Evaluation tags allow you to:
  • Define custom evaluation criteria
  • Set up automated response quality checks
  • Track model performance metrics
Click here here to learn how to configure eval tags for observability.
from fi_instrumentation.fi_types import EvalName, EvalSpanKind, EvalTag, EvalTagType

eval_tags = [
    EvalTag(
        eval_name=EvalName.DETERMINISTIC_EVALS,
        value=EvalSpanKind.TOOL,
        type=EvalTagType.OBSERVATION_SPAN,
        config={
            "multi_choice": False,
            "choices": ["Yes", "No"],
            "rule_prompt": "Evaluate if the experiment result is valid",
        },
        custom_eval_name="det_eval_experiment_1"
    )
]

4. 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_instrumentation import register
from fi_instrumentation.fi_types import ProjectType

trace_provider = register(
    project_type=ProjectType.EXPERIMENT,
    project_name="my_experiment",
    project_version_name="v1",
    eval_tags=eval_tags
)

5. Configure Experiment Instrumentation

Initialize the Experiment instrumentor to enable automatic tracing:
from fi_instrumentation import ExperimentInstrumentor

ExperimentInstrumentor().instrument(tracer_provider=trace_provider)

6. Create Experiment Components

Set up your experiment with built-in observability:
from futureagi import Experiment

experiment = Experiment(
    name="my_experiment",
    description="Testing model performance on classification tasks",
    dataset_id="your-dataset-id"
)

7. Execute

Run your experiment with observability enabled:
def run_experiment():
    try:
        # Configure experiment parameters
        experiment.configure(
            model_config={
                "model": "claude-3-sonnet-20240229",
                "temperature": 0.7,
                "max_tokens": 1000
            },
            prompt_template="Your task is to classify the following text: {{input}}",
            evaluation_metrics=["accuracy", "f1_score"]
        )
        
        # Run the experiment
        results = experiment.run()
        print(f"Experiment results: {results}")
    except Exception as e:
        print(f"Error: {str(e)}")

if __name__ == "__main__":
    run_experiment()