Skip to main content
TrustifAI’s MetricContext accepts documents in several formats out of the box. You do not need an adapter layer or a specific framework installed — the library normalizes whatever you pass into its internal representation. This means you can drop TrustifAI into an existing LangChain or LlamaIndex pipeline, or use it with plain Python strings and dicts, without changing how you retrieve documents.

Supported document formats

The documents field of MetricContext accepts any combination of the following: LangChain and LlamaIndex are not required dependencies. If you have neither installed, pass strings or dicts and TrustifAI works identically.

LangChain integration

The most common LangChain pattern is to retrieve documents with a vector store retriever and pass them directly into MetricContext. LangChain Document objects carry page_content and metadata, both of which TrustifAI reads automatically.

Connecting to a LangChain retriever

If you are using a LangChain retriever (FAISS, Chroma, Pinecone, etc.), the retrieved Document list can be passed directly without modification:

LlamaIndex integration

TrustifAI understands NodeWithScore objects returned by LlamaIndex query engines and retrievers. Pass the source_nodes list from a query result directly into MetricContext:

Plain strings and dicts

You do not need LangChain or LlamaIndex. Plain strings work for the simplest integration:
Dicts are supported when your documents carry structured metadata:

Supported LLM providers

TrustifAI routes all LLM and embedding calls through LiteLLM, which means it works with any provider LiteLLM supports. Configure the provider in config_file.yaml and export the corresponding API key:
LangChain and LlamaIndex are not required by TrustifAI. The library detects their document types at runtime if the packages are installed. You can evaluate RAG responses from any retrieval system by passing plain strings or dicts.
Source diversity scoring relies on source identifiers extracted from document metadata. Populate metadata fields such as source, url, document_id, or filename on your documents so TrustifAI can distinguish between sources and reward synthesis across multiple independent documents.

Configuration

Configure your LLM provider, embedding model, and API keys in config_file.yaml.

Batch evaluation

Scale evaluations across entire datasets with AsyncTrustifai and evaluate_dataset.