LlamaIndex integration for TruthVouch Trust API — hallucination detection and content verification
Project description
llama-index-truthvouch
LlamaIndex integration for the TruthVouch Trust API. Add hallucination detection and content verification to any LlamaIndex RAG pipeline in minutes.
Installation
pip install llama-index-truthvouch
Quickstart
import os
os.environ["TRUTHVOUCH_API_KEY"] = "your-api-key"
from truthvouch_llamaindex import TruthVouchResponseEvaluator
evaluator = TruthVouchResponseEvaluator(threshold=0.8)
result = await evaluator.evaluate("The Eiffel Tower is in Paris, France.")
print(result.passing) # True
print(result.score) # e.g. 0.96
print(result.feedback) # human-readable explanation
Components
TrustApiClient
Low-level async/sync client for the Trust API verify endpoint.
from truthvouch_llamaindex import TrustApiClient
client = TrustApiClient(api_key="your-api-key")
result = client.verify_sync("The Eiffel Tower is in Paris.", mode="standard")
print(result.trust_score) # 0.97
TruthVouchNodePostprocessor
Filters retrieved nodes by trust score before they reach the LLM.
from llama_index.core import VectorStoreIndex
from truthvouch_llamaindex import TruthVouchNodePostprocessor
postprocessor = TruthVouchNodePostprocessor(threshold=0.75)
query_engine = index.as_query_engine(node_postprocessors=[postprocessor])
response = query_engine.query("What is the capital of France?")
TruthVouchResponseEvaluator
Evaluate a RAG response string for factual accuracy.
from truthvouch_llamaindex import TruthVouchResponseEvaluator
evaluator = TruthVouchResponseEvaluator(threshold=0.8)
result = await evaluator.evaluate("Some response text")
if not result.passing:
print("Hallucination risk:", result.feedback)
TruthVouchQueryEngine
Wrapper query engine that auto-verifies every response.
from truthvouch_llamaindex import TruthVouchQueryEngine
engine = TruthVouchQueryEngine(inner_query_engine=base_engine, threshold=0.8)
response = engine.query("Tell me about the Eiffel Tower.")
print(response.metadata["trust_score"])
Configuration
| Parameter | Env var | Default |
|---|---|---|
api_key |
TRUTHVOUCH_API_KEY |
(required) |
base_url |
— | http://localhost:5004/api/v1/trust |
threshold |
— | 0.8 |
mode |
— | spot_check |
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llama_index_truthvouch-1.0.0.tar.gz.
File metadata
- Download URL: llama_index_truthvouch-1.0.0.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b276c69bd2001c69aefa37b49ad86fcf6efb82536bc1dedfc6f9a62ea24ab95
|
|
| MD5 |
98038b416e01dde0890b6ab14acb4c1d
|
|
| BLAKE2b-256 |
9f063cee2d8f0467ba55ca91bc84ac2cec2c788e8bab6375637f8393d723ab32
|
File details
Details for the file llama_index_truthvouch-1.0.0-py3-none-any.whl.
File metadata
- Download URL: llama_index_truthvouch-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5c44800177747342bcdbd1b17f1a7fffd2b274767fbe36b4cba87a25daf8fcf
|
|
| MD5 |
9ca3295ccd827852eebc0d1df96121ca
|
|
| BLAKE2b-256 |
76904b886c3b53f832e57d030832a8700b99c44b5f807c86cb2edea076d3e7cd
|