A quality, clarity, and risk validation SDK for LLM inputs.
Project description
PromptClarity SDK
Guard prompts before they become bad outputs.
PromptClarity SDK is a pre-LLM validation layer that detects unclear, incomplete, risky, or low-quality prompts before they reach an AI system.
Positioning
PromptClarity SDK helps teams validate LLM inputs for:
- prompt quality scoring
- missing context detection
- ambiguity detection
- dataset metadata validation
- agent-readiness checks
- RAG-readiness checks
- cost and token waste reduction
- safer enterprise AI workflows
Rule Coverage
PromptClarity currently uses 250+ deterministic rule signals across:
- vague prompt wording
- missing objective, audience, constraints, timeframe, examples, and success criteria
- dataset details and privacy handling
- output format and analysis type detection
- evaluation and selection criteria
- RAG source/citation readiness
- agent/tool boundary readiness
- sensitive-data patterns such as emails, phone numbers, SSNs, API keys, tokens, private keys, IPs, and cards
- unsafe-intent terms such as phishing, malware, prompt injection, SQL injection, credential theft, and bypass attempts
Enterprise tagline:
A quality, clarity, and risk validation SDK for LLM inputs.
Install
pip install promptclarity-sdk
Usage
from promptclarity import PromptClarity
guard = PromptClarity()
result = guard.validate("Analyze this data and give insights")
print(result.to_dict())
Optional LLM Assistance
PromptClarity can run in two modes:
- Rule-only mode: default, local, deterministic, no API key, no network call.
- LLM-assisted mode: optional semantic review using an LLM advisor that you provide.
PromptClarity does not choose, bundle, or call an LLM provider by itself. Your application decides which provider and model to use, then passes a callback to the SDK.
You can use any model/provider, including:
- OpenAI
- Anthropic Claude
- Google Gemini
- Mistral
- Groq
- Ollama or other local models
- Azure OpenAI
- private/internal enterprise models
- any custom API that your application can call
Who Decides What?
- Your app decides the LLM provider and model.
- Your app owns API keys, auth, network calls, retries, and provider-specific SDKs.
- PromptClarity decides the baseline score, status, risk level, and rule findings.
- The optional LLM advisor only adds semantic missing items and recommendations.
- No LLM call happens unless
use_llm=True. - If
use_llm=True, anllm_advisorcallback is required.
The LLM advisor can return a plain dictionary or an LLMReport.
from promptclarity import PromptClarity, LLMReport
def my_llm_advisor(prompt, *, metadata=None):
# Call your chosen LLM here:
# - OpenAI
# - Claude
# - Gemini
# - Ollama/local model
# - internal enterprise model
# - any other provider
#
# Then normalize the model response into this shape.
return {
"model": "your-model-name",
"confidence": 0.86,
"missing_items": ["domain assumptions"],
"recommendations": ["Clarify the assumptions the model should use."],
}
guard = PromptClarity(llm_advisor=my_llm_advisor)
result = guard.validate("Analyze this data", use_llm=True)
print(result.to_dict())
Expected advisor return shape:
{
"model": "provider-model-name",
"confidence": 0.86,
"missing_items": ["domain assumptions"],
"recommendations": ["Clarify the assumptions the model should use."],
}
The same result can be returned as an LLMReport:
from promptclarity import LLMReport
def my_llm_advisor(prompt, *, metadata=None):
return LLMReport(
model="your-model-name",
confidence=0.86,
missing_items=["domain assumptions"],
recommendations=["Clarify the assumptions the model should use."],
)
Why PromptClarity Does Not Pick the LLM
Different teams have different constraints:
- cost
- latency
- privacy
- compliance
- deployment region
- model quality
- internal vendor policy
- local/offline requirements
Because of that, PromptClarity stays provider-agnostic. It gives you the validation interface; your application chooses the model.
Example output:
{
"status": "needs_clarification",
"prompt_score": 42,
"risk_level": "low",
"missing_items": [
"success criteria",
"dataset details",
"business objective",
"output format",
],
"recommendations": [
"Define the success criteria for a useful answer.",
"Describe the dataset, including source, fields, and size.",
"State the business objective or decision the answer should support.",
"Define the expected output format.",
"Specify the type of analysis required.",
"Mention whether you need EDA, prediction, reporting, or recommendations.",
],
}
Package Layout
promptclarity/
|-- analyzer.py # prompt quality analyzer
|-- rules.py # rule-based checks
|-- risk.py # unsafe / sensitive / vague input checks
|-- metadata.py # dataset/file metadata analysis
|-- recommender.py # missing-detail suggestions
|-- prompt_builder.py # improved prompt generator
|-- llm.py # optional LLM advisor interface
`-- __init__.py
Development
python -m pytest
Release Checklist
- Update the version in
pyproject.tomlandpromptclarity/__init__.py. - Run
python -m pytest. - Build with
python -m build. - Check the distribution with
python -m twine check dist/*. - Upload to TestPyPI first, then PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file promptclarity_sdk-0.1.1.tar.gz.
File metadata
- Download URL: promptclarity_sdk-0.1.1.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c56de926c8a4413305323c7c7de44cbc0d3c3da59b5ddb6701130f7e04da42b0
|
|
| MD5 |
73d642c47da79194be969dcecc901564
|
|
| BLAKE2b-256 |
f4d8b56efeb13a28a24f724c68abcc6c7da5ecd31cb37d8ad590c93665fa33ca
|
File details
Details for the file promptclarity_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: promptclarity_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c385489efaf54a2aba7b24e0480ade26fabfeffb6ec8f77dab2173830f0030c1
|
|
| MD5 |
8575a4dddf35cc751a72996ea628f630
|
|
| BLAKE2b-256 |
6f91c3e35e5fa57ef7e2cb74c56892ad19e3b787fccd01a37fcff67345004058
|