Skip to main content

A client library for content security detection

Project description


Framewise SecureLine

Framewise SecureLine is a Python library for analyzing text and audio for security concerns. The library supports text-based detection and audio chunk predictions, offering flexibility for content security use cases.

Features

  • Text Detection: Analyze text for security concerns, such as banned topics, PII, or profanity.
  • Audio Chunk Analysis: Process audio data in chunks for classification and security predictions.
  • Custom Filters: Easily configure filters for denied topics, PII information, and word lists.
  • Extensibility: Supports structured outputs for easy integration with your workflows.
  • Robust Error Handling: Handles API errors, validation errors, and request timeouts gracefully.

Installation

Framewise SecureLine is available for installation using Poetry or pip.

Install using Poetry

poetry add framewise-secureline

Install using pip

pip install framewise-secureline

Getting Started

Initialization

To use Framewise SecureLine, you need an API key. Initialize the SecureLine client as shown below:

from framewise_secureline import SecureLine

# Initialize the client
client = SecureLine(
    api_key="your-api-key",
    denied_topics="medical diagnoses, competitors",
    ppi_information="SSN, Medical Records",
    word_filters="profanity",
)

Text Detection

Analyze a piece of text for security concerns.

result = client.detect("Sample text for analysis.")

# Access raw response
print(result)

Audio Chunk Analysis

Analyze an audio chunk for predictions. The library accepts a single chunk of type AudioSegment.

from pydub import AudioSegment

# Load an audio file and extract a chunk
audio = AudioSegment.from_file("/path/to/audio.mpga").set_frame_rate(16000).set_channels(1)
chunk = audio[:100]  # Extract first 100ms

# Analyze the chunk
result = client.analyze_audio_chunk(chunk)

# Access predictions
for prediction in result.predictions:
    print(f"Label: {prediction.label}, Score: {prediction.score}")
print(f"Latency: {result.latency}, Device: {result.device}")

Advanced Usage

Custom Filters

You can update the filters dynamically using the update_filters method:

client.update_filters(
    denied_topics="new denied topics",
    ppi_information="new PII types",
    word_filters="new word list",
)

Handling Multiple Audio Chunks

While SecureLine processes one audio chunk at a time, you can handle multiple chunks by iterating over the audio file:

chunks = [audio[i:i+100] for i in range(0, len(audio), 100)]  # Split into 100ms chunks

for i, chunk in enumerate(chunks):
    result = client.analyze_audio_chunk(chunk)
    print(f"Chunk {i}:")
    for prediction in result.predictions:
        print(f"  Label: {prediction.label}, Score: {prediction.score}")

Error Handling

Framewise SecureLine provides robust error handling for common scenarios:

  • ValidationError: Raised for invalid inputs (e.g., empty text, incorrect audio format).
  • APIError: Raised for server-side errors during API calls.
  • TimeoutError: Raised when an API call exceeds the timeout.

Example

from framewise_secureline.exceptions import ValidationError, APIError, TimeoutError

try:
    result = client.detect("text to analyze")
except ValidationError as e:
    print(f"Validation failed: {e}")
except APIError as e:
    print(f"API error: {e}")
except TimeoutError as e:
    print(f"Request timed out: {e}")

Testing

The library includes a comprehensive suite of tests.

Run Tests

poetry run pytest

Coverage Report

poetry run pytest --cov=framewise_secureline

Support

For any issues or feature requests, please contact:
Email: sigireddybalasai@gmail.com


License

This project is licensed under the MIT License. See the LICENSE file for details.


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

framewise_secureline-0.1.2.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

framewise_secureline-0.1.2-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: framewise_secureline-0.1.2.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.3 Linux/6.8.0-1017-gcp

File hashes

Hashes for framewise_secureline-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2539398200f15fadaf7a655e4d019cbf1a849a5523c0771d17f81e4786806f7b
MD5 b262edb729dbcaa20c7529b18d537026
BLAKE2b-256 daf929c08ac16245a55195024875f04c2972290519153cd173cb86770cd5391b

See more details on using hashes here.

File details

Details for the file framewise_secureline-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for framewise_secureline-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 02ece6cd284d2b0ce7b2facff21bfedf8957f0167f0ad4ec06cbaad90d7091f2
MD5 15a16d8a661a9e41677808e73b96d004
BLAKE2b-256 4ed571e7b536c32ee031282a5c1d290ddbe43f1b26220709dd496fc4fe6c19ec

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page