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
Thedocuments 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 intoMetricContext. 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 retrievedDocument list can be passed directly without modification:
LlamaIndex integration
TrustifAI understandsNodeWithScore 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:Supported LLM providers
TrustifAI routes all LLM and embedding calls through LiteLLM, which means it works with any provider LiteLLM supports. Configure the provider inconfig_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.
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.