A progressive JSON schema validator
Project description
JSON schema enforcer
A progressive JSON schema validator. For use with large language models, to force their output to strictly adhere to a pre-defined schema. The goal is to be able to validate whether the partial JSON output breaks the schema, in a way where you can't get yourself into a dead end - if "...ab" is valid, then there is an x for which "...abx" is valid, all the way until you got the complete output.
This is a quick experiment to show how easy it is to implement a JSON schema enforcer. I made it out of spite after OpenAI didn't enforce the schema of the returns of the function call feature, and I made it in a day, which does prove my point - OpenAI could have done this, they just didn't bother.
Note that I am not a programming language developer, not at all, therefore I fully expect this code to be very shitty.
Another note: I am not using the full JSON schema specification, but my own simplified standard similar to the one OpenAI use.
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
Built Distribution
Hashes for json_schema_enforcer-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac98a6adeb8b94eb5a2559b347d8f96327cb3d0992bf62d8614d2c846fe8b59f |
|
MD5 | a985ca74a635b2ce54c97534bd010cc1 |
|
BLAKE2b-256 | a4d5b86da4238ab695c6534d38b8883ef50d319047cc5985635541634958d7c8 |
Hashes for json_schema_enforcer-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3092239a7c86c900932d7169f9ecf13642de47cb5c255865aae0a414ab92eb79 |
|
MD5 | 9f14892d0bc90f2a2000f27652b7260d |
|
BLAKE2b-256 | 3d4eb8efb4b5cc51c3920ba4971736134c32fbd5e2b8b448944c17887cd75979 |