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:
ClientandAsyncClientfor interacting with the APIInfluenceandTextInfluence- a statement made in a sourceRuling- the top-level object returned by the SDKSourceandTextSource- a source that could support or refute a claim, e.g. a documentStatement- a single statement in a claimVerdict- 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
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.2.dev0.tar.gz.
File metadata
- Download URL: truthsys-0.1.2.dev0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79e590f8db8c7173bdadb6adbb8b311d4965e2ce5c52a30d4e7ee79883e09882
|
|
| MD5 |
ef89456323d9af443279512aa25dcb4c
|
|
| BLAKE2b-256 |
60932cb9715a8e775fe7c422fc5f04c3372a1e51e1251b5f1213457585d35116
|
File details
Details for the file truthsys-0.1.2.dev0-py3-none-any.whl.
File metadata
- Download URL: truthsys-0.1.2.dev0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d56dfdddce6f4936c817ceb411e4c244906632023fc76a41a34319f3ef8edfc5
|
|
| MD5 |
7a3472f73144563c93e55a037a5792b6
|
|
| BLAKE2b-256 |
db740c46ee119070e7f43998cfa33450d0c6bc023f3e7dea2cf2cf820ec7fb22
|