Skip to main content

Python SDK for General Analysis Guardrails

Project description

General Analysis SDK

Python SDK for General Analysis AI Guardrails.

Installation

pip install generalanalysis

Quick Start

import generalanalysis

# Uses GA_API_KEY env var by default
client = generalanalysis.Client()

# Check text against guard policies
result = client.guards.invoke(text="Text to check", guard_name="@pii_guard")

if result.block:
    print("Blocked:", [p.name for p in result.policies if not p.passed])

# Optional: scope requests to a specific project (env var or kwarg)
# export GA_PROJECT_ID=123
# client = generalanalysis.Client()
# result = client.guards.invoke(text="...", guard_name="@pii_guard", project_id=456)

API Reference

Guards Operations

# List guards
guards = client.guards.list()

# Invoke guard
result = client.guards.invoke(text="...", guard_name="@pii_guard")
print(f"Blocked: {result.block}, Latency: {result.latency_ms}ms")

# Build inline configurations when you want to tweak policies without saving them first
from generalanalysis import GuardConfigurationBuilder

builder = GuardConfigurationBuilder()
builder.add_policy(
    guard_name="@pii_guard",
    policy_id=10,
    policy_name="EMAIL_ADDRESS",
    sensitivity=0.4,
)
result = client.guards.invoke(text="Reach me at foo@example.com", configuration=builder)

# Get logs (paginated)
logs = client.guards.list_logs(guard_name="@pii_guard", page=1, page_size=50)

# Inspect available guard policies
policies = client.guards.list_policies()
for policy in policies:
    print(policy.name, policy.definition)

# List saved guard configurations (requires project scope)
configs = client.guard_configurations.list(project_id=123)
print([cfg.name for cfg in configs])

Async Support

import asyncio
import generalanalysis

async def main():
    async with generalanalysis.AsyncClient() as client:
        results = await asyncio.gather(*[
            client.guards.invoke(text=t, guard_name="@pii_guard") 
            for t in texts
        ])

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

generalanalysis-0.3.0.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

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

generalanalysis-0.3.0-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file generalanalysis-0.3.0.tar.gz.

File metadata

  • Download URL: generalanalysis-0.3.0.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for generalanalysis-0.3.0.tar.gz
Algorithm Hash digest
SHA256 323e75d97f7dc50a31869f48268d0ddd6e7844523a103e6ea84e780f670f6dea
MD5 4b9b0c3c39e5ceef58d1f5673f408100
BLAKE2b-256 b179ce85a370417397e9fcb01fd452f06917ac7698f6d1587843ead4a854d72f

See more details on using hashes here.

File details

Details for the file generalanalysis-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for generalanalysis-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b63e73e83ebcd305f7184fd7fcdb4ba9b880894a0727b294c165c822f2d0e5e8
MD5 386a7e2da8253574deb1393280eee7f3
BLAKE2b-256 40ec111eca9b2597f2f6a63bf7e11d63e31570102a3bc241e54d9112cd4cf704

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