Skip to main content

SDK for truthsystems.ai, a hallucination detection API

Project description

Truth Systems SDK

This is the Python SDK for the Truth Systems API. It allows you to easily interact with the API to judge the veracity of claims based on provided sources.

To use it, you must first have access to the Truth Systems API. See our website for more information.

Quickstart

from truthsys import (
    Client,  # or AsyncClient if you like
    TextInfluence,
    TextSource,
    Verdict,
)


client = Client.from_url("YOUR_BASE_URL")  # or Client.from_httpx

ruling = client.judge(
    claim="Sally is a pretty cat",
    sources=[
        TextSource.from_text("I have a cat"),
        TextSource.from_text("I only have one pet"),
        TextSource.from_text("My pet is called Sally"),
    ],
)

# ruling.verdict is an overall judgement of the claim's truthfulness
if ruling.verdict is Verdict.SUPPORTS:
    print("Sally really is a pretty cat!")

for statement in ruling.statements:
    # in this case, there are two statements: "Sally is a cat" and "Sally is pretty"
    print(f'The statement "{statement.text}" has been judged as {statement.verdict}')

    for influence in statement.influences:
        print(f"This is because {influence.source} says: {influence.text}")

        if isinstance(influence, TextInfluence):  # currently always true
            print(f"The character IDs are {influence.span[0]} to {influence.span[1]}")

Types

All types are available to import from truthsys. These are:

  • Client and AsyncClient for interacting with the API
  • Influence and TextInfluence - a statement made in a source
  • Ruling - the top-level object returned by the SDK
  • Source and TextSource - a source that could support or refute a claim, e.g. a document
  • Statement - a single statement in a claim
  • Verdict - an enum representing the possible assessments of a claim

Errors

All error types raised by the SDK are available to import from truthsys.errors. Please report unexpected errors.

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

truthsys-0.1.1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

truthsys-0.1.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file truthsys-0.1.1.tar.gz.

File metadata

  • Download URL: truthsys-0.1.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.22.2 CPython/3.13.0 Linux/6.12.4-1-MANJARO

File hashes

Hashes for truthsys-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9f7c37109fb5ece9c156047bd3bfdb190ac0a6decd561fca16c3844a227f8075
MD5 1e62f93e1141ad7b84cf1506f1cd167b
BLAKE2b-256 8739988c7379460520340923054b4250fec0359d1084135c3ecbf4bf28d3e1ac

See more details on using hashes here.

File details

Details for the file truthsys-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: truthsys-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.22.2 CPython/3.13.0 Linux/6.12.4-1-MANJARO

File hashes

Hashes for truthsys-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eec7454fc8c93043ac7ee177b1948310b4dab1eb68ab53bfc921b6b9f3cb6d64
MD5 35e6a42428cd1f6203699b7b8f7941ec
BLAKE2b-256 5738d8250814671dd5074bc50814b4334ff4c13838b9b6ddb828da8e2573db5e

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