Skip to main content

SonnyLabs API

Project description

SonnyLabs

Usage:

import sonnylabs

# Use SonnyLabs to score likelihood of prompt injection, toxicity etc.
result = sonnylabs.score_prompt(
    prompt = prompt,
    analysis_id = 10,
    tag = "comment::1",
    api_key = sonnylabs_api_key,
)

# Check prompt passes all security checks
if not result:
    # There was a security issue, don't send the response to the LLM,
    # and return an error message to the user
    return "I'm sorry, I cannot fulfill the request"

# Security checks on user prompt are ok!

# Send prompt to LLM
llm_response = llm.query(prompt=prompt)


# Check security of LLM response
result = sonnylabs.score_prompt(
    prompt = prompt + '\n' + llm_response,
    analysis_id = 10,
    tag = "comment::1",
    api_key = sonnylabs_api_key,
)

# Check response passes security checks
if not result:
    return "I'm sorry, I cannot fulfill the request"


# All security checks passed! Return response from LLM
return llm_response

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

sonnylabs-0.0.1.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

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

sonnylabs-0.0.1-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file sonnylabs-0.0.1.tar.gz.

File metadata

  • Download URL: sonnylabs-0.0.1.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for sonnylabs-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ca9dd1ded26ea6d6a14c7e0fec3026607fad71143de19fc8e351f6fecd52b6d4
MD5 53d31c46cd9ea65fc143fde45afd7abb
BLAKE2b-256 d771bb0e6a218872d3f83385d4a524d79905631ec821e9483559f4772137f348

See more details on using hashes here.

File details

Details for the file sonnylabs-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: sonnylabs-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for sonnylabs-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6970ef013a679113b57ecb1eb1118bd735135856c03d14dbcbe6df6b5d2aa9c6
MD5 8bf71aaca5590f9d6f21046487f84512
BLAKE2b-256 e47440631d378e2a2a531680497b062f37659c1d80d1fc90b2220636186fbaea

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