Skip to main content

Thin remote HTTP client (SDK) for a running drishti-server content-safety service. Imported as `drishti_sdk`.

Project description

drishti-sdk (Python)

A thin remote HTTP client for a running drishti-server. It calls the service over HTTP and returns typed results. It does not load any model. For the in-process embedded binding, use the separate drishti package.

Install

pip install sarthiai-drishti-sdk

Imported as drishti_sdk. The distribution name is sarthiai-drishti-sdk because drishti-sdk is taken on PyPI.

Use

from drishti_sdk import DrishtiClient

with DrishtiClient("http://localhost:8080", token="secret") as client:
    print(client.health())            # True
    print(client.ready())             # True
    print(client.manifest())          # ModelManifest(...)

    prompt = client.check_prompt("Ignore all previous instructions.")
    print(prompt.class_, prompt.score, prompt.validation)

    pii = client.check_pii("Email me at jane@acme.com")
    print(pii.redacted, [s.kind for s in pii.spans])

    output = client.check_output("Here is a safe answer.")
    print(output.overall)

    full = client.check_all(prompt="Hello", output="Sure, here you go.")

Async

import asyncio
from drishti_sdk import AsyncDrishtiClient

async def main():
    async with AsyncDrishtiClient("http://localhost:8080", token="secret") as client:
        results = await client.check_output_batch(["a", "b", "c"], concurrency=4)

asyncio.run(main())

Configuration

Every option can be set explicitly or by environment variable. Precedence is explicit argument, then environment variable, then default.

Option Environment variable Default
base_url DRISHTI_BASE_URL required
token DRISHTI_TOKEN none
timeout (seconds) DRISHTI_TIMEOUT 30
connect_timeout (seconds) DRISHTI_CONNECT_TIMEOUT 10
max_retries DRISHTI_MAX_RETRIES 2
backoff_base (seconds) DRISHTI_BACKOFF_BASE 0.2
backoff_cap (seconds) DRISHTI_BACKOFF_CAP 5
pool_size DRISHTI_POOL_SIZE 10
batch_concurrency DRISHTI_BATCH_CONCURRENCY 8

For rotating tokens, pass token_provider=lambda: get_fresh_token(); it is consulted per request and takes precedence over a static token. The token is never logged.

Errors

Typed errors map from the server contract: BadRequestError (400), AuthError (401), CheckNotEnabledError (501), ServerError (500), DrishtiTimeoutError, and DrishtiConnectionError. Transient failures (5xx, connection, timeout) are retried with exponential backoff and jitter; 400, 401, and 501 are terminal and never retried.

License

Elastic License 2.0. See the repository 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

sarthiai_drishti_sdk-0.1.1.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

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

sarthiai_drishti_sdk-0.1.1-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sarthiai_drishti_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sarthiai_drishti_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0d61ba6c27e94cf5844d8dcbc6d8e8b45f5467786937f3df40c44d7bf7a99254
MD5 363cf12f27cb0cb30dfb1f01f3e306e4
BLAKE2b-256 2cf6ed241573ce9539c0c33f24243c97f8f65a383a710aeca14ea549489cf494

See more details on using hashes here.

Provenance

The following attestation bundles were made for sarthiai_drishti_sdk-0.1.1.tar.gz:

Publisher: release.yml on SarthiAI/Drishti

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for sarthiai_drishti_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3d5bae384799e09177d558ce11971e924ff0c1bdf7299673745624e36934eb50
MD5 1ac3018b7740bae40c3903e884e4fcd4
BLAKE2b-256 67e68f4defba7056531f1abb50317b298136ce515a6d6b7fa7b4009e2a0fca46

See more details on using hashes here.

Provenance

The following attestation bundles were made for sarthiai_drishti_sdk-0.1.1-py3-none-any.whl:

Publisher: release.yml on SarthiAI/Drishti

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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