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, TextInfluence, TextSource # or AsyncClient if you like
client = Client.from_url("YOUR_BASE_URL")
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 # whether the claim is supported by the sources - one of "SUPPORTED", "UNSUPPORTED", "CONTRADICTED"
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:
# the reasons for the judgement are statements within sources
print(
f'The statement "{influence.text}" made in "{influence.source}" influenced this judgement'
)
if isinstance(influence, TextInfluence):
# currently always the case, might change in future versions
print(
f"The influence spans characters {influence.span[0]} to {influence.span[1]}"
)
Errors
All error types raised by the SDK are available to import from truthsys.errors. Please report unexpected errors.
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 truthsys-0.1.0.tar.gz.
File metadata
- Download URL: truthsys-0.1.0.tar.gz
- Upload date:
- Size: 8.1 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a694f1ef1499abd68a37e6408e99132ea35e329504099fc7575decc21f51c45
|
|
| MD5 |
1a11fecf70b11ed0d2c0fa5f0bf90ee1
|
|
| BLAKE2b-256 |
124269cc7e99bf56e52753be3a6af412bf93a9ee384dd02441cfd30d6be6ea5d
|
File details
Details for the file truthsys-0.1.0-py3-none-any.whl.
File metadata
- Download URL: truthsys-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b684510efc8f86c74f8ed5b558c3e143900c55ef584b94edd557ee8ad961ebe
|
|
| MD5 |
d87674fb3b4f1096010b75703d48045f
|
|
| BLAKE2b-256 |
5e8b0b77ee349844ac5cc85a84a8f133ab12b551498123442b57be3fa2287894
|