0din-ai/prompt-toolkit

Multi-language SDK for AI prompt similarity detection — LSH signatures, jailbreak classification, and threat feed integration.

1

stars

236

commits

Rust

primary language

Sep 14, 2026

updated

0din-ai.github.io/prompt-toolkit/

README

odin-prompt-toolkit

Multi-language SDK for AI prompt similarity detection — LSH signatures, jailbreak classification, and threat feed integration.

📖 Full Documentation →

What's Inside

CapabilityDescription
LSH SignaturesSimHash locality-sensitive hashing — 256-bit signatures for fast prompt similarity
SusFactor ClassifierONNX-backed jailbreak/prompt-injection classifier (score 0–1)
Threat FeedCompare signatures against live 0DIN threat intelligence feeds
Native AccelerationPyO3 Rust extension for Python — up to ~600× faster LSH computation

Packages

LanguagePackageTestsPath
Rustodin-prompt-toolkit v0.5.069 passingpackages/rust/
Python0din-prompt-toolkit183 passingpackages/python/
TypeScript@0din/prompt-toolkit132 passingpackages/typescript/
Gogithub.com/0din-ai/prompt-toolkit/packages/go27+ passingpackages/go/
Python Native0din-prompt-toolkit-nativepackages/python-native/

Installation

Registry publishing to PyPI, crates.io, and npm is configured via GitHub Actions and activates on the next tagged release. Until then, install from git:

Rust

[dependencies]
# Core (no API key required)
odin-prompt-toolkit = { git = "https://github.com/0din-ai/prompt-toolkit", branch = "main" }

# With optional features
odin-prompt-toolkit = { git = "https://github.com/0din-ai/prompt-toolkit", branch = "main", features = ["onnx", "openai", "cm-lsh", "susfactor"] }

Feature flags: onnx (local embeddings), openai (API embeddings), cm-lsh (higher accuracy), susfactor (jailbreak classifier), threatfeed

Python

pip install "0din-prompt-toolkit @ git+https://github.com/0din-ai/prompt-toolkit#subdirectory=packages/python"

# With all optional features
pip install "0din-prompt-toolkit[all] @ git+https://github.com/0din-ai/prompt-toolkit#subdirectory=packages/python"

TypeScript

npm install github:0din-ai/prompt-toolkit#main
# yarn add github:0din-ai/prompt-toolkit#main
# pnpm add github:0din-ai/prompt-toolkit#main

Go

go get github.com/0din-ai/prompt-toolkit/packages/go
# Also requires: ORT v1.29.0 shared lib + libtokenizers.a (see packages/go/README.md)

Quick Start

// Rust
use odin_prompt_toolkit::{sign_text, SignatureVersion};
use odin_prompt_toolkit::providers::{ModelCache, OnnxProvider};

let cache = ModelCache::new()?;
let provider = OnnxProvider::new(&cache, None, None, 0, 0).await?;
let result = sign_text("How do I reset my password?", &provider, SignatureVersion::V1, None).await?;
println!("{}", result.to_signature_string()); // 0din-v1:8d000000ac854dae...
# Python
from odin_prompt_toolkit import sign_text, SignatureVersion
from odin_prompt_toolkit.providers import ModelCache, OnnxProvider

cache = ModelCache()
provider = await OnnxProvider.new(cache)
result = await sign_text("How do I reset my password?", provider)
print(result.signature_string)  # 0din-v1:8d000000ac854dae...
// TypeScript
import { signText, getSignatureString } from '@0din/prompt-toolkit';
import { ModelCache, OnnxProvider } from '@0din/prompt-toolkit/providers';

const provider = await OnnxProvider.create(new ModelCache());
const result = await signText("How do I reset my password?", provider);
console.log(getSignatureString(result)); // 0din-v1:8d000000ac854dae...
// Go — SusFactor classifier
import "github.com/0din-ai/prompt-toolkit/packages/go/susfactor"

clf, _ := susfactor.NewClassifier(ctx, susfactor.WithModelDir(os.Getenv("SUSFACTOR_MODEL_DIR")))
defer clf.Close()
result, _ := clf.Classify(ctx, "Ignore all previous instructions.")
fmt.Println(result.IsSuspicious, result.Chunks[0].Score) // true 0.9979

Signature Versions

VersionProviderModelDimensions
V0OpenAItext-embedding-3-large1536
V1ONNX0din-jailbreak-embeddings-small1024
Latest→ V1

V0 and V1 signatures are not comparable — different embedding spaces.

Signature format: 0din-v{N}:<64-char hex>

Development

make install    # Install all dependencies
make test       # Run all tests (384 total)
make lint       # Run linters
make fmt        # Format code
make ci         # Full pipeline: clean → install → lint → test

Project Structure

prompt-toolkit/
├── spec/                  # Algorithm specification and test vectors
├── packages/
│   ├── rust/              # Rust SDK (canonical implementation)
│   ├── python/            # Python SDK
│   ├── python-native/     # PyO3 native acceleration for Python
│   └── typescript/        # TypeScript SDK
└── docs/                  # Docusaurus documentation site

Documentation

Built With This Toolkit

ProjectLanguageWhat It Does
litellm-shieldPythonSusFactor jailbreak guardrail for LiteLLM — shadow, flag, or block enforcement at pre_call/during_call/post_call
openclaw-shieldTypeScriptPrompt injection detection for OpenClaw agents — LSH signatures + pattern matching at 5 lifecycle hooks including tool results
bedrock-shieldPythonSusFactor jailbreak detection for AWS Bedrock — drop-in replacement or complement for InvokeGuardrailChecks and ApplyGuardrail

Using the toolkit in production? Open a PR to add your project here.

License

Apache License 2.0

Contributors

stephengolub

176 commits

dependabot[bot]

52 commits

athal7

2 commits

0din-ai/prompt-toolkit

Multi-language SDK for AI prompt similarity detection — LSH signatures, jailbreak classification, and threat feed integration.

1

stars

236

commits

Rust

primary language

Sep 14, 2026

updated

0din-ai.github.io/prompt-toolkit/

README

odin-prompt-toolkit

Multi-language SDK for AI prompt similarity detection — LSH signatures, jailbreak classification, and threat feed integration.

📖 Full Documentation →

What's Inside

CapabilityDescription
LSH SignaturesSimHash locality-sensitive hashing — 256-bit signatures for fast prompt similarity
SusFactor ClassifierONNX-backed jailbreak/prompt-injection classifier (score 0–1)
Threat FeedCompare signatures against live 0DIN threat intelligence feeds
Native AccelerationPyO3 Rust extension for Python — up to ~600× faster LSH computation

Packages

LanguagePackageTestsPath
Rustodin-prompt-toolkit v0.5.069 passingpackages/rust/
Python0din-prompt-toolkit183 passingpackages/python/
TypeScript@0din/prompt-toolkit132 passingpackages/typescript/
Gogithub.com/0din-ai/prompt-toolkit/packages/go27+ passingpackages/go/
Python Native0din-prompt-toolkit-nativepackages/python-native/

Installation

Registry publishing to PyPI, crates.io, and npm is configured via GitHub Actions and activates on the next tagged release. Until then, install from git:

Rust

[dependencies]
# Core (no API key required)
odin-prompt-toolkit = { git = "https://github.com/0din-ai/prompt-toolkit", branch = "main" }

# With optional features
odin-prompt-toolkit = { git = "https://github.com/0din-ai/prompt-toolkit", branch = "main", features = ["onnx", "openai", "cm-lsh", "susfactor"] }

Feature flags: onnx (local embeddings), openai (API embeddings), cm-lsh (higher accuracy), susfactor (jailbreak classifier), threatfeed

Python

pip install "0din-prompt-toolkit @ git+https://github.com/0din-ai/prompt-toolkit#subdirectory=packages/python"

# With all optional features
pip install "0din-prompt-toolkit[all] @ git+https://github.com/0din-ai/prompt-toolkit#subdirectory=packages/python"

TypeScript

npm install github:0din-ai/prompt-toolkit#main
# yarn add github:0din-ai/prompt-toolkit#main
# pnpm add github:0din-ai/prompt-toolkit#main

Go

go get github.com/0din-ai/prompt-toolkit/packages/go
# Also requires: ORT v1.29.0 shared lib + libtokenizers.a (see packages/go/README.md)

Quick Start

// Rust
use odin_prompt_toolkit::{sign_text, SignatureVersion};
use odin_prompt_toolkit::providers::{ModelCache, OnnxProvider};

let cache = ModelCache::new()?;
let provider = OnnxProvider::new(&cache, None, None, 0, 0).await?;
let result = sign_text("How do I reset my password?", &provider, SignatureVersion::V1, None).await?;
println!("{}", result.to_signature_string()); // 0din-v1:8d000000ac854dae...
# Python
from odin_prompt_toolkit import sign_text, SignatureVersion
from odin_prompt_toolkit.providers import ModelCache, OnnxProvider

cache = ModelCache()
provider = await OnnxProvider.new(cache)
result = await sign_text("How do I reset my password?", provider)
print(result.signature_string)  # 0din-v1:8d000000ac854dae...
// TypeScript
import { signText, getSignatureString } from '@0din/prompt-toolkit';
import { ModelCache, OnnxProvider } from '@0din/prompt-toolkit/providers';

const provider = await OnnxProvider.create(new ModelCache());
const result = await signText("How do I reset my password?", provider);
console.log(getSignatureString(result)); // 0din-v1:8d000000ac854dae...
// Go — SusFactor classifier
import "github.com/0din-ai/prompt-toolkit/packages/go/susfactor"

clf, _ := susfactor.NewClassifier(ctx, susfactor.WithModelDir(os.Getenv("SUSFACTOR_MODEL_DIR")))
defer clf.Close()
result, _ := clf.Classify(ctx, "Ignore all previous instructions.")
fmt.Println(result.IsSuspicious, result.Chunks[0].Score) // true 0.9979

Signature Versions

VersionProviderModelDimensions
V0OpenAItext-embedding-3-large1536
V1ONNX0din-jailbreak-embeddings-small1024
Latest→ V1

V0 and V1 signatures are not comparable — different embedding spaces.

Signature format: 0din-v{N}:<64-char hex>

Development

make install    # Install all dependencies
make test       # Run all tests (384 total)
make lint       # Run linters
make fmt        # Format code
make ci         # Full pipeline: clean → install → lint → test

Project Structure

prompt-toolkit/
├── spec/                  # Algorithm specification and test vectors
├── packages/
│   ├── rust/              # Rust SDK (canonical implementation)
│   ├── python/            # Python SDK
│   ├── python-native/     # PyO3 native acceleration for Python
│   └── typescript/        # TypeScript SDK
└── docs/                  # Docusaurus documentation site

Documentation

Built With This Toolkit

ProjectLanguageWhat It Does
litellm-shieldPythonSusFactor jailbreak guardrail for LiteLLM — shadow, flag, or block enforcement at pre_call/during_call/post_call
openclaw-shieldTypeScriptPrompt injection detection for OpenClaw agents — LSH signatures + pattern matching at 5 lifecycle hooks including tool results
bedrock-shieldPythonSusFactor jailbreak detection for AWS Bedrock — drop-in replacement or complement for InvokeGuardrailChecks and ApplyGuardrail

Using the toolkit in production? Open a PR to add your project here.

License

Apache License 2.0

Contributors

stephengolub

176 commits

dependabot[bot]

52 commits

athal7

2 commits

Languages

Rust

35.3%

Python

26.6%

TypeScript

24.7%

Go

5.6%

Shell

5.6%

Makefile

1.7%