swiss-truth-haystack
Haystack 2.x components for Swiss Truth — the certified, hallucination-free knowledge base for AI agents.
Stop your Haystack pipelines from hallucinating. Ground every LLM response in 3000+ certified Swiss and EU facts, verified by a 5-stage validation pipeline.
Features
- 🔍
SwissTruthRetriever— Drop-in Haystack Retriever component. Plug into any RAG pipeline. - ✅
SwissTruthFactChecker— Verify LLM outputs against certified facts. Returnssupported/contradicted/unverified. - 🌍 3000+ certified claims across 38 domains (Swiss law, EU health, AI/ML, finance, climate, …)
- 🗣️ 10 languages — DE, EN, FR, IT, ES, ZH, AR, RU, JA, KO
- 🔒 EU AI Act compliant — SHA256 integrity hashes + weekly blockchain anchoring
- ⚡ Zero config — no API key required for public endpoints
Installation
pip install swiss-truth-haystack
Quick Start
RAG Pipeline with Certified Facts
from swiss_truth_haystack import SwissTruthRetriever
from haystack import Pipeline
from haystack.components.builders import PromptBuilder
from haystack.components.generators import OpenAIGenerator
retriever = SwissTruthRetriever(domain="swiss-law", top_k=5)
prompt = PromptBuilder(template="""
Answer the question using only the certified facts below.
Facts:
{% for doc in documents %}
- {{ doc.content }} (confidence: {{ doc.meta.confidence }})
{% endfor %}
Question: {{ query }}
Answer:
""")
pipeline = Pipeline()
pipeline.add_component("retriever", retriever)
pipeline.add_component("prompt", prompt)
pipeline.add_component("generator", OpenAIGenerator(model="gpt-4o"))
pipeline.connect("retriever.documents", "prompt.documents")
pipeline.connect("prompt.prompt", "generator.prompt")
result = pipeline.run({
"retriever": {"query": "Is health insurance mandatory in Switzerland?"},
"prompt": {"query": "Is health insurance mandatory in Switzerland?"},
})
print(result["generator"]["replies"][0])
Standalone Retriever
from swiss_truth_haystack import SwissTruthRetriever
retriever = SwissTruthRetriever(domain="ai-ml", top_k=8)
result = retriever.run(query="What are the EU AI Act risk categories?")
for doc in result["documents"]:
print(f"[{doc.meta['confidence']:.0%}] {doc.content}")
print(f" Source: {doc.meta['source_url']}")
Fact-Checking Pipeline
from swiss_truth_haystack import SwissTruthFactChecker
checker = SwissTruthFactChecker(domain="swiss-law")
result = checker.run(claim="Health insurance is optional in Switzerland.")
print(f"Verdict: {result['verdict']}") # "contradicted"
for doc in result["documents"]:
print(f" Certified fact: {doc.content}")
Post-Generation Fact Check
from swiss_truth_haystack import SwissTruthFactChecker
from haystack import Pipeline
from haystack.components.generators import OpenAIGenerator
pipeline = Pipeline()
pipeline.add_component("generator", OpenAIGenerator(model="gpt-4o"))
pipeline.add_component("checker", SwissTruthFactChecker(domain="swiss-law"))
# Note: connect generator output to checker input in your pipeline logic
result = pipeline.run({"generator": {"prompt": "Explain Swiss health insurance."}})
Components
SwissTruthRetriever
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str |
None |
Optional API key (not required for public endpoints) |
base_url |
str |
https://swisstruth.org |
API base URL |
timeout |
float |
30.0 |
HTTP timeout in seconds |
domain |
str |
None |
Domain filter (e.g. "swiss-law", "ai-ml") |
top_k |
int |
5 |
Max documents to retrieve (1-20) |
min_confidence |
float |
0.8 |
Minimum confidence threshold |
run() inputs:
| Input | Type | Description |
|---|---|---|
query |
str |
Search query |
domain |
str (optional) |
Per-call domain override |
top_k |
int (optional) |
Per-call result count override |
run() outputs:
| Output | Type | Description |
|---|---|---|
documents |
List[Document] |
Certified facts as Haystack Documents |
SwissTruthFactChecker
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str |
None |
Optional API key |
base_url |
str |
https://swisstruth.org |
API base URL |
timeout |
float |
30.0 |
HTTP timeout in seconds |
domain |
str |
None |
Domain hint for verification |
run() inputs:
| Input | Type | Description |
|---|---|---|
claim |
str |
Factual statement to verify |
domain |
str (optional) |
Per-call domain override |
run() outputs:
| Output | Type | Description |
|---|---|---|
documents |
List[Document] |
Matching certified claims |
verdict |
str |
"supported" / "contradicted" / "unverified" |
raw |
dict |
Raw API response |
Available Domains
| Domain | Description |
|---|---|
swiss-law |
Swiss federal and cantonal law |
eu-health |
EU health regulations |
ai-ml |
AI/ML facts and EU AI Act |
finance |
Swiss and EU financial regulations |
climate |
Climate science and Swiss policy |
quantum-computing |
Quantum computing facts |
swiss-history |
Swiss historical facts |
| … | 38 domains total — see swisstruth.org/domains |
Document Metadata
Every retrieved Document includes:
doc.meta = {
"claim_id": "uuid", # Unique claim identifier
"domain": "swiss-law", # Knowledge domain
"language": "en", # ISO 639-1 language code
"source_url": "https://...", # Primary source URL
"verified": True, # Verification status
"confidence": 0.97, # Confidence score 0.0-1.0
"swiss_truth": True, # Swiss Truth provenance marker
}
doc.score = 0.97 # Same as confidence (for Haystack ranking)
Serialization
Both components support Haystack's standard serialization for pipeline YAML export:
import yaml
from haystack import Pipeline
from swiss_truth_haystack import SwissTruthRetriever
pipeline = Pipeline()
pipeline.add_component("retriever", SwissTruthRetriever(domain="swiss-law"))
# Export
print(pipeline.dumps())
# Import
pipeline2 = Pipeline.loads(pipeline.dumps())
Links
- 🌐 API: swisstruth.org
- 📖 Docs: swisstruth.org/docs/integrations/haystack
- 🐙 GitHub: github.com/swisstruthorg/swiss-truth-mcp
- 📦 PyPI: pypi.org/project/swiss-truth-haystack
- 🤖 MCP Server: swisstruth.org/mcp
License
MIT — see LICENSE
Metadata
Release files for swiss-truth-haystack 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swiss_truth_haystack-0.1.0.tar.gz | 8.2 kB | Without provenance | Details for swiss_truth_haystack-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swiss_truth_haystack-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for swiss_truth_haystack-0.1.0-py3-none-any.whl |
Total release size: 16.8 kB
Release files / swiss_truth_haystack-0.1.0.tar.gz
| Download URL | swiss_truth_haystack-0.1.0.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c3adbea9c6744d239088d451de9d507136412d044b3d1dc887e8c3a01fc4f4f5
|
|
BLAKE2b-256 checksum How to use checksums |
c8e4715ef78054399bb4e4abec5efa9146501cb938dc7fd31698a7acbb52986f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / swiss_truth_haystack-0.1.0-py3-none-any.whl
| Download URL | swiss_truth_haystack-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
48c7f1e0d36219e32a1dd8a130d68d0ce3cc71723f89bc09cd54174020609dcc
|
|
BLAKE2b-256 checksum How to use checksums |
9c193d6209e70fecfea9f02c21fa62977ee3d0d5168832b817d929e1b41397f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for swiss-truth-haystack 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.