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.2.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.2-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sarthiai_drishti_sdk-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 983d932a6afe102d97329d6eb916a817a668e0bf18a124aaab35525167f90fe1
MD5 68223565894bc9b13329b0c1665da4d2
BLAKE2b-256 3381d17bf41e07c36ecbb1e6053a0f7ae59b4c99045d9641993f5ad4b40c0a53

See more details on using hashes here.

Provenance

The following attestation bundles were made for sarthiai_drishti_sdk-0.1.2.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.2-py3-none-any.whl.

File metadata

File hashes

Hashes for sarthiai_drishti_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4106835491076b4682f376f4695a06954d565965f5bd1d5414422e49c5f107a2
MD5 6078a4f5f76debd8f94b14cb7a467c57
BLAKE2b-256 9f47e6ce5e6973e0bf5bf46d9c4d5a51ea8e3dfdd0ac839d0ec0b11c6f9deb79

See more details on using hashes here.

Provenance

The following attestation bundles were made for sarthiai_drishti_sdk-0.1.2-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