Skip to main content

Official Python SDK for Wauldo — Verified AI answers from your documents

Project description

Wauldo Python SDK

Verified AI answers from your documents — or no answer at all.

Most RAG APIs guess. Wauldo verifies.

0% hallucination  |  83% accuracy  |  61 eval tasks  |  14 LLMs tested

PyPI  Downloads  Python  MIT

DemoDocsFree API KeyBenchmarks


Quickstart (30 seconds)

pip install wauldo
from wauldo import HttpClient

client = HttpClient(base_url="https://api.wauldo.com", api_key="YOUR_API_KEY")

# Upload a document
client.rag_upload(content="Our refund policy allows returns within 60 days...", filename="policy.txt")

# Ask a question — answer is verified against the source
result = client.rag_query("What is the refund policy?")
print(result.answer)
print(result.sources)
Output:
Answer: Returns are accepted within 60 days of purchase.
Sources: policy.txt — "Our refund policy allows returns within 60 days"
Grounded: true | Confidence: 0.92

Try the demo | Get a free API key


Why Wauldo (and not standard RAG)

Typical RAG pipeline

retrieve → generate → hope it's correct

Wauldo pipeline

retrieve → extract facts → generate → verify → return or refuse

If the answer can't be verified, it returns "insufficient evidence" instead of guessing.

See the difference

Document: "Refunds are processed within 60 days"

Typical RAG:  "Refunds are processed within 30 days"     ← wrong
Wauldo:       "Refunds are processed within 60 days"     ← verified
              or "insufficient evidence" if unclear       ← safe

Examples

Upload a PDF and ask questions

# Upload — text extraction + quality scoring happens server-side
result = client.upload_file("contract.pdf", title="Q3 Contract")
print(f"Extracted {result.chunks_count} chunks, quality: {result.quality_label}")

# Query
result = client.rag_query("What are the payment terms?")
print(f"Answer: {result.answer}")
print(f"Confidence: {result.get_confidence():.0%}")
print(f"Grounded: {result.audit.grounded}")

Fact-check any LLM output

result = client.fact_check(
    text="Returns are accepted within 60 days.",
    source_context="Our policy allows returns within 14 days.",
    mode="lexical",
)
print(result.verdict)           # "rejected"
print(result.action)            # "block"
print(result.claims[0].reason)  # "numerical_mismatch"

Verify citations

result = client.verify_citation(
    text="The policy covers damage [Source: Manual]. Warranty is unlimited.",
    sources=[{"name": "Manual", "content": "Coverage for accidental damage only."}],
)
print(result.citation_ratio)     # 0.5
print(result.uncited_sentences)  # ["Warranty is unlimited."]

Chat (OpenAI-compatible)

reply = client.chat_simple("auto", "Explain Python decorators")
print(reply)

Streaming

Sync — print tokens as they arrive:

import sys
from wauldo import ChatRequest, HttpChatMessage

request = ChatRequest(
    model="auto",
    messages=[
        HttpChatMessage.system("You are a helpful assistant."),
        HttpChatMessage.user("Explain Python decorators"),
    ],
)

for chunk in client.chat_stream(request):
    sys.stdout.write(chunk)
    sys.stdout.flush()
print()

Async streaming (requires pip install wauldo[async]):

import asyncio
from wauldo import AsyncHttpClient, ChatRequest, HttpChatMessage

async def main():
    async with AsyncHttpClient(base_url="https://api.wauldo.com", api_key="YOUR_API_KEY") as client:
        req = ChatRequest.quick("auto", "How does HTTP/2 multiplexing work?")
        async for token in client.chat_stream(req):
            print(token, end="", flush=True)
        print()

asyncio.run(main())

RAG query with streaming answer:

client.rag_upload(content="Our SLA guarantees 99.9% uptime...", filename="sla.txt")

req = ChatRequest(
    model="auto",
    messages=[HttpChatMessage.user("What uptime does the SLA guarantee?")],
)
for chunk in client.chat_stream(req):
    print(chunk, end="", flush=True)
print()

Error handling during streaming:

from wauldo import WauldoError, ServerError, AgentConnectionError

try:
    for chunk in client.chat_stream(request):
        print(chunk, end="", flush=True)
except AgentConnectionError:
    print("\n[connection lost]")
except ServerError as e:
    print(f"\n[server error: {e}]")
except WauldoError as e:
    print(f"\n[error: {e}]")

See examples/streaming_chat.py and examples/async_streaming.py for runnable scripts.


Async Support

pip install wauldo[async]
import asyncio
from wauldo import AsyncHttpClient

async def main():
    async with AsyncHttpClient(base_url="https://api.wauldo.com", api_key="YOUR_API_KEY") as client:
        result = await client.rag_query("What are the payment terms?")
        print(result.answer)

asyncio.run(main())

All sync methods have async equivalents. Contributed by @qorexdev.


Features

  • Pre-generation fact extraction — numbers, dates, limits injected as constraints before the LLM call
  • Post-generation grounding check — every answer verified against sources
  • Citation validation — detects phantom references
  • Fact-check API — verify any claim against any source (3 modes: lexical, hybrid, semantic)
  • Native PDF/DOCX upload — server-side extraction with quality scoring
  • Smart model routing — auto-selects cheapest model that meets quality
  • OpenAI-compatible — swap your base_url, keep your existing code
  • Sync + Async — full async/await support

Built For

  • Production RAG systems that need reliable answers
  • Teams where "confidently wrong" is unacceptable
  • Legal, finance, healthcare, support automation
  • Anyone replacing "hope-based" RAG

Benchmarks

Metric Result
Hallucination rate 0%
Accuracy 83% (17% = correct refusals)
Eval tasks 61
LLMs tested 14 models, 3 runs each
Avg latency ~1.2s

Error Handling

from wauldo import WauldoError, ServerError, AgentTimeoutError

try:
    response = client.chat(ChatRequest.quick("auto", "Hello"))
except ServerError as e:
    print(f"Server error: {e}")
except AgentTimeoutError:
    print("Request timed out")
except WauldoError as e:
    print(f"SDK error: {e}")

RapidAPI

client = HttpClient(
    base_url="https://api.wauldo.com",
    headers={
        "X-RapidAPI-Key": "YOUR_RAPIDAPI_KEY",
        "X-RapidAPI-Host": "smart-rag-api.p.rapidapi.com",
    },
)

Free tier (300 req/month): RapidAPI


Contributing

PRs welcome. Check the good first issues.

Contributors

License

MIT — see LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wauldo-0.6.0.tar.gz (32.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wauldo-0.6.0-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file wauldo-0.6.0.tar.gz.

File metadata

  • Download URL: wauldo-0.6.0.tar.gz
  • Upload date:
  • Size: 32.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for wauldo-0.6.0.tar.gz
Algorithm Hash digest
SHA256 170b57717adb00c61e2ed68866c407b2212e9372db51889e3896719d5c83e905
MD5 0d7f3d87832fb25d2cc8fb96bc49f1ba
BLAKE2b-256 0a811e9970aacb51e5fc0da32003c3e54afc3dacdb6c893379f4846a44d1ed11

See more details on using hashes here.

File details

Details for the file wauldo-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: wauldo-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for wauldo-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df69f690343b5757723689a5e60b953e10fb7c0b76987f02bd5923a06de40de8
MD5 5eb18a2acbc383e4b710259794068c2d
BLAKE2b-256 ae5187c3283f51ad11bb53b7bddc5a310a70ada2615c8e029ec7d136f1a769f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page