Skip to main content

The Python SDK for LatentSense Inc services. www.latentsense.com

Project description

LatentSense Python SDK

Overview

The LatentSense Python SDK provides a convenient client for interacting with the Latentsense Interactive API. It simplifies authentication, file uploads, and requests to various API endpoints for text analysis and manipulation.

Installation

pip install latentsense-sdk

Configuration

The client can be configured by passing parameters to its constructor or by using environment variables.

Constructor Arguments

You can initialize the client directly with your credentials:

from latentsense_sdk import LatentSenseClient

client = LatentSenseClient(
    project_id="your-project-id",
    api_key="your-api-key",
)

Environment Variables

If constructor arguments are not provided, the client will fall back to reading from environment variables:

  • LST_PROJECT_ID: Your LatentSense project ID.
  • LST_API_KEY: Your LatentSense API key.

For example, in your shell:

export LST_PROJECT_ID="your-project-id"
export LST_API_KEY="your-api-key"

Usage

See https://docs.latentsense.com

Here's a basic example of how to initialize the client and use it to redact Personally Identifiable Information (PII) from a document.

import os
from latentsense_sdk import LatentSenseClient

# The client is configured via environment variables.
# Ensure they are set before running, for example:
# os.environ["LST_PROJECT_ID"] = "your-project-id"
# os.environ["LST_API_KEY"] = "your-api-key"

client = LatentSenseClient()

# Example 1: Redact PII from a file on disk
try:
    with open("document.txt", "w") as f:
        f.write("John Doe lives at 123 Main St. His email is john.doe@example.com.")

    files_to_redact = ["document.txt"]
    redacted_results = client.redact_pii(files=files_to_redact)

    for result in redacted_results:
        print(f"--- Results for {result.original_file_name} ---")
        print(f"Redacted text: {result.redacted_text}")

finally:
    if os.path.exists("document.txt"):
        os.remove("document.txt")


# Example 2: Redact PII from in-memory content
in_memory_file = ("report.txt", "This is a report about Jane Smith.")
redacted_results = client.redact_pii(files=[in_memory_file])

for result in redacted_results:
    print(f"--- Results for {result.original_file_name} ---")
    print(f"Redacted text: {result.redacted_text}")

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

latentsense_sdk-1.0.3.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

latentsense_sdk-1.0.3-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file latentsense_sdk-1.0.3.tar.gz.

File metadata

  • Download URL: latentsense_sdk-1.0.3.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.6

File hashes

Hashes for latentsense_sdk-1.0.3.tar.gz
Algorithm Hash digest
SHA256 5c85ff98d561a35b22eca889b89fa25a817f50bfdb0c959617e71c4dd4b8d61e
MD5 f70ffa6949aea4da5d971beca777d0c2
BLAKE2b-256 76e3f7e6d991f6bdaf0375e135d2b21f7fdf9ee91cc4e9270c45c4e967a2a156

See more details on using hashes here.

File details

Details for the file latentsense_sdk-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for latentsense_sdk-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 36b63ec179a2af87442e93c4540d68b2d4009efe171588338d50c53e871c99ac
MD5 50cff6b811abd5e85ed2f4ed6f194f6b
BLAKE2b-256 b8b47de006ebf29baf8c0d58f6c6bf18670f7d34e78f0ef9a89d36c5a52f61b3

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