Validate LLM tool-call payloads with small JSON-like contracts. Python port of @mukundakatta/tool-call-contracts.
Project description
tool-call-contracts-py
Validate LLM tool-call payloads with small JSON-like contracts. Pure Python, zero deps. Python port of @mukundakatta/tool-call-contracts.
pip install tool-call-contracts-py
from tool_call_contracts import validate_tool_call, assert_tool_call, ContractError
contract = {
"name": "search",
"arguments": {
"query": {"type": "string", "required": True},
"limit": {"type": "int", "enum": [10, 25, 50]},
},
}
res = validate_tool_call({"name": "search", "arguments": {"query": "python"}}, contract)
# ValidationResult(valid=True, errors=[])
assert_tool_call({"name": "fetch", "arguments": {}}, contract)
# raises ContractError: expected tool search, got fetch; query is required
Supported rule fields per argument: type (string/int/float/bool/list/dict), required, enum, pattern (regex for strings).
License
MIT
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 tool_call_contracts_py-0.1.0.tar.gz.
File metadata
- Download URL: tool_call_contracts_py-0.1.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bae2e9b0d28abcc38f052c8a68b5a72f78b2a6837095dbbd87620a87281cf5e9
|
|
| MD5 |
dc43830c7918cb9ffb07b8d9e65d90c2
|
|
| BLAKE2b-256 |
0c34bbc5c794a7dbeb0bf79dc72ed608c4e8ac5a88cb291acba9b139a7d53632
|
File details
Details for the file tool_call_contracts_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tool_call_contracts_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43b8eec4de260ff09ade3bb770a7a9d457755d1dfd28e81ee49ccf340ac1629a
|
|
| MD5 |
7b01f9bbdf7b38a44f999df87e1308ab
|
|
| BLAKE2b-256 |
74ab7de9c086ca25fb54fdf6d082ade9eb08b94765b4c6961bc2a256309fce32
|