Skip to content

API Reference

Complete module reference for the Latent framework, organized by category.


Orchestration

Module Description
latent.prefect.decorators @flow and @task decorators with auto-config, caching, retries
latent.prefect.config_loader YAML loading, get_config(), get_catalog()
latent.prefect.concurrency Batched submit/wait for concurrent task execution
latent.prefect.checkpoint Checkpoint caching for intermediate results
latent.prefect.context Context vars: params, logger, get_flow_name()

See Prefect Flows & Tasks for usage guide.


Agents

Module Description
latent.agents.LiteLLMAgent General-purpose LLM agent with tool support
latent.agents.Judge Score data rows against a Pydantic output schema
latent.agents.Classifier Semantic classification with accuracy/F1/precision/recall
latent.agents.RAGAgent Config-driven agent with pluggable retrieval pipeline
latent.agents.tool @tool decorator for standalone and method-based tools
latent.agents.scores ScoredModel, OrdinalScore, BinaryScore, ContinuousScore

See Agents for usage guide.

Pipeline Agents

Module Description
latent.agents.pipeline.PipelineAgent Phase-based agent with deterministic routing
latent.agents.pipeline.decorators @phase, @tool, @respond, @subagent
latent.agents.pipeline.types PipelineState, Transition, Respond

See Pipeline Agents for usage guide.


Guardrails

Module Description
latent.guardrails.decorators @guardrail method decorator for auto-discovery
latent.guardrails.middleware GuardrailMiddleware composable scanner pipeline
latent.guardrails.scanners.builtin LanguageScanner, InvisibleTextScanner, TokenLimitScanner
latent.guardrails.scanners.llm LLMGuardrailScanner for custom LLM-backed rules
latent.guardrails.config TOML-based guardrail configuration
latent.guardrails.metrics Guardrail evaluation metrics

See Guardrails for usage guide.


Prompt Optimization

Module Description
latent.optimize.dspy DSPyOptimizer -- teleprompter-based prompt optimization
latent.optimize.ace ACEOptimizer -- section-level prompt refinement
latent.optimize.combined CombinedOptimizer -- DSPy then ACE pipeline
latent.optimize.autoresearch AutoResearchOptimizer -- git-based codebase optimization
latent.optimize.tracker ExperimentTracker for optimization history
latent.optimize.analysis Trajectory analysis and optimizer comparison

See Prompt Optimization for usage guide.


RAG

Module Description
latent.rag.chroma ChromaRetriever -- vector store with automatic embedding
latent.rag.hybrid HybridRetriever -- dense + BM25 with RRF fusion
latent.rag.bm25 BM25Retriever -- sparse keyword search
latent.rag.adaptive Query rewriting, HyDE, reranking, CRAG, caching
latent.rag.pipeline PipelineBuilder -- config-driven pipeline composition
latent.rag.tune rag_grid_search -- hyperparameter sweep
latent.rag.metrics Retrieval evaluation metrics (NDCG, MRR, recall)
latent.rag.embeddings Embedding provider adapters
latent.raptor RAPTOR recursive abstractive retrieval

See RAG Pipelines and RAPTOR Integration for usage guides.


Pre-built Eval Flows

Scoring

Flow Description
latent.flows.judge_flow Score free-text outputs with LLM judge
latent.flows.classification_flow Classify + compute accuracy/F1/precision/recall
latent.flows.comparison_flow Compare model A vs B with statistical tests

Conversation

Flow Description
latent.flows.conversation_scoring_flow Turn-level scoring with aggregation
latent.flows.conversation_sop_flow SOP compliance checking
latent.flows.conversation_trajectory_flow Trajectory distance analysis

Agent Evaluation

Flow Description
latent.flows.agent_eval_flow End-to-end agent evaluation
latent.flows.agent_inference_flow Batch agent inference with tool tracking

Analysis

Flow Description
latent.flows.drift_flow Distribution drift detection
latent.flows.failure_mode_flow Failure mode clustering
latent.flows.knowledge_coverage_flow Knowledge gap analysis
latent.flows.retrieval_eval_flow RAG retrieval quality evaluation
latent.flows.eval_report_flow Aggregate report generation

Specialized

Flow Description
latent.flows.ner_flow Named entity recognition evaluation
latent.flows.text_to_sql_flow Text-to-SQL accuracy evaluation
latent.flows.model_garden_flow Multi-model comparison
latent.flows.autoresearch_flow Optimization experiment orchestration
latent.flows.validate_dataset Dataset schema validation

See Eval Flows for usage guide.


Statistical Analysis

Module Description
latent.stats.bootstrap Bootstrap confidence intervals
latent.stats.intervals Wilson intervals, paired bootstrap
latent.stats.comparison compare_systems(), McNemar's test, non-inferiority
latent.stats.classification classification_metrics(), confusion matrices with CIs
latent.stats.structured Field-level accuracy, composite accuracy, schema compliance
latent.stats.ordinal Ordinal distributions, binarization
latent.stats.drift detect_drift(), drift_report(), multi-run trends
latent.stats.effect_size Cohen's d, odds ratio, risk ratio
latent.stats.gating threshold_gate(), multiple comparison correction
latent.stats.agreement Cohen's kappa, Fleiss' kappa, Krippendorff's alpha
latent.stats.conversation Turn-level scoring, aggregation
latent.stats.trajectory Edit distance, tool trajectory distance
latent.stats.sop SOP compliance scoring
latent.stats.bayesian Beta-binomial posterior
latent.stats.calibration Score calibration
latent.stats.ppi Prediction-powered inference
latent.stats.markdown Markdown report rendering
latent.stats.models StatisticalReport, ComparisonResult, GatingResult

See Statistical Analysis for usage guides.


Experiment Tracking

Module Description
latent.mlflow.mlflow Wrapped MLflow API (safe when tracking disabled)
latent.mlflow.mlflow_setup Experiment creation and configuration
latent.mlflow.evaluate MLflow evaluation integration
latent.mlflow.wrapper Safe MLflow wrapper (no-ops when disabled)

See MLflow Tracking for usage guide.


Data

Type Extension Engine Description
pandas.CSV .csv pandas Comma-separated values
pandas.Parquet .parquet pandas Apache Parquet format
pandas.JSON .jsonl pandas JSON Lines (line-delimited)
polars.CSV .csv polars CSV via Polars
polars.Parquet .parquet polars Parquet via Polars
json.JSON .json stdlib Plain JSON
pickle.Pickle .pkl cloudpickle Pickle serialization
text.Text .txt stdlib Plain text (file or directory)
text.Markdown .md stdlib Markdown (file or directory)
conversation.JSONL .jsonl stdlib JSONL with turn structure
agent_studio.JSONL .jsonl httpx Remote Agent Studio dataset
agent_studio.Report .jsonl httpx Agent Studio report dataset

Infrastructure & CLI

Module Description
latent.infra Docker-based service management (PostgreSQL, Prefect, MLflow)
latent.cli CLI entry point (latent run, latent list, latent chat, etc.)
latent.workspace Path resolution with env var overrides
latent.config TOML configuration loading

See CLI Tools and Infrastructure for usage guides.


Events & Observability

Module Description
latent.events Event system for agent lifecycle hooks
latent.pricing Token usage and cost tracking

Utilities

Module Description
latent.registry Task and flow registry for pipeline visualization
latent.flow_registry Flow discovery and registration
latent.agent_registry Agent discovery via @agent decorator
latent.testing Testing utilities for unit tests
latent.exceptions Custom exception types