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
Multi-language SDK for AI prompt similarity detection — LSH signatures, jailbreak classification, and threat feed integration.
| Capability | Description |
|---|---|
| LSH Signatures | SimHash locality-sensitive hashing — 256-bit signatures for fast prompt similarity |
| SusFactor Classifier | ONNX-backed jailbreak/prompt-injection classifier (score 0–1) |
| Threat Feed | Compare signatures against live 0DIN threat intelligence feeds |
| Native Acceleration | PyO3 Rust extension for Python — up to ~600× faster LSH computation |
| Language | Package | Tests | Path |
|---|---|---|---|
| Rust | odin-prompt-toolkit v0.5.0 | 69 passing | packages/rust/ |
| Python | 0din-prompt-toolkit | 183 passing | packages/python/ |
| TypeScript | @0din/prompt-toolkit | 132 passing | packages/typescript/ |
| Go | github.com/0din-ai/prompt-toolkit/packages/go | 27+ passing | packages/go/ |
| Python Native | 0din-prompt-toolkit-native | — | packages/python-native/ |
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:
[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
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"
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 get github.com/0din-ai/prompt-toolkit/packages/go
# Also requires: ORT v1.29.0 shared lib + libtokenizers.a (see packages/go/README.md)
// 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
| Version | Provider | Model | Dimensions |
|---|---|---|---|
| V0 | OpenAI | text-embedding-3-large | 1536 |
| V1 | ONNX | 0din-jailbreak-embeddings-small | 1024 |
| Latest | → V1 | — | — |
V0 and V1 signatures are not comparable — different embedding spaces.
Signature format: 0din-v{N}:<64-char hex>
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
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
| Project | Language | What It Does |
|---|---|---|
| litellm-shield | Python | SusFactor jailbreak guardrail for LiteLLM — shadow, flag, or block enforcement at pre_call/during_call/post_call |
| openclaw-shield | TypeScript | Prompt injection detection for OpenClaw agents — LSH signatures + pattern matching at 5 lifecycle hooks including tool results |
| bedrock-shield | Python | SusFactor 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.
Apache License 2.0
Rust
35.3%
Python
26.6%
TypeScript
24.7%
Go
5.6%
Shell
5.6%
Makefile
1.7%
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
Multi-language SDK for AI prompt similarity detection — LSH signatures, jailbreak classification, and threat feed integration.
| Capability | Description |
|---|---|
| LSH Signatures | SimHash locality-sensitive hashing — 256-bit signatures for fast prompt similarity |
| SusFactor Classifier | ONNX-backed jailbreak/prompt-injection classifier (score 0–1) |
| Threat Feed | Compare signatures against live 0DIN threat intelligence feeds |
| Native Acceleration | PyO3 Rust extension for Python — up to ~600× faster LSH computation |
| Language | Package | Tests | Path |
|---|---|---|---|
| Rust | odin-prompt-toolkit v0.5.0 | 69 passing | packages/rust/ |
| Python | 0din-prompt-toolkit | 183 passing | packages/python/ |
| TypeScript | @0din/prompt-toolkit | 132 passing | packages/typescript/ |
| Go | github.com/0din-ai/prompt-toolkit/packages/go | 27+ passing | packages/go/ |
| Python Native | 0din-prompt-toolkit-native | — | packages/python-native/ |
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:
[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
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"
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 get github.com/0din-ai/prompt-toolkit/packages/go
# Also requires: ORT v1.29.0 shared lib + libtokenizers.a (see packages/go/README.md)
// 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
| Version | Provider | Model | Dimensions |
|---|---|---|---|
| V0 | OpenAI | text-embedding-3-large | 1536 |
| V1 | ONNX | 0din-jailbreak-embeddings-small | 1024 |
| Latest | → V1 | — | — |
V0 and V1 signatures are not comparable — different embedding spaces.
Signature format: 0din-v{N}:<64-char hex>
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
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
| Project | Language | What It Does |
|---|---|---|
| litellm-shield | Python | SusFactor jailbreak guardrail for LiteLLM — shadow, flag, or block enforcement at pre_call/during_call/post_call |
| openclaw-shield | TypeScript | Prompt injection detection for OpenClaw agents — LSH signatures + pattern matching at 5 lifecycle hooks including tool results |
| bedrock-shield | Python | SusFactor 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.
Apache License 2.0
Rust
35.3%
Python
26.6%
TypeScript
24.7%
Go
5.6%
Shell
5.6%
Makefile
1.7%