Skip to main content

An agentic middleware for automated JSON validation and self-correction from LLM outputs.

Project description

Agentic JSON Middleware

A robust, agentic middleware designed to intercept, validate, and automatically correct malformed JSON outputs generated by Large Language Models (LLMs).

In production environments, LLMs are prone to hallucinations or returning truncated JSON structures, which can break backend pipelines. This middleware acts as a safety net, intelligently detecting parsing errors and using an agentic approach to self-correct the payload before it reaches your application logic.

🚀 Key Features

  • Automated JSON Validation: Instantly detects broken formatting, missing brackets, or invalid data types from LLM responses.
  • Agentic Self-Correction: Instead of just throwing an error, the middleware actively repairs the JSON structure.
  • Seamless Integration: Designed to sit perfectly between your LLM engine and your main API endpoints.
  • Resilient Data Pipelines: Ensures your backend only receives clean, strictly-typed JSON data.

📦 Installation

pip install agentic-json-middleware


📄 License
This project is licensed under the MIT License.

Ide yang **sangat brilian dan jauh lebih aman!**

Memisahkan folder *development* (yang berisi data riset skripsi) dengan folder *production* (yang akan diunggah ke publik) adalah praktik terbaik yang sering dilakukan oleh *Software Engineer* profesional. Dengan cara ini, data pengujianmu tidak akan berisiko rusak atau bocor.

Mari kita eksekusi dengan cara "Copy Bersih" ini. Alurnya akan sangat mirip dengan proyek *Semantic Cache* tadi.

### 🛠️ Langkah 1: Buat Repo Baru di GitHub Desktop

1. Buka GitHub Desktop.
2. Klik **File > New repository...**
3. Isi **Name** dengan: `agentic-json-middleware`
4. Pastikan **Local path** mengarah ke `D:\Documents\GitHub`
5. Klik **Create repository**.

### 📁 Langkah 2: Lakukan "Copy Bersih"

Sekarang buka File Explorer dan navigasikan ke folder repo barumu (`D:\Documents\GitHub\agentic-json-middleware`).

1. Di dalam folder repo baru tersebut, **buat satu folder baru** dan beri nama `agentic_json_middleware` (pakai garis bawah/ *underscore*). Ini akan menjadi nama *library*-mu.
2. Buka folder riset aslimu (`agentic_middleware`).
3. **Copy** 3 item inti ini:
* Folder `core`
* Folder `models`
* File `main.py`


4. **Paste** ketiga item tersebut ke **dalam** folder `agentic_json_middleware` yang ada di repo barumu.
5. *(Opsional)* Buat file teks kosong bernama `__init__.py` di dalam folder `agentic_json_middleware` tersebut.

### ⚙️ Langkah 3: Siapkan 3 File Wajib (Di luar folder `agentic_json_middleware`)

Di folder utama repo barumu (`D:\Documents\GitHub\agentic-json-middleware`), buat tiga file ini:

**1. File `.gitignore**`
Karena kamu sudah memilah file yang bersih, `.gitignore` ini cukup versi standar saja:

```text
__pycache__/
.env
dist/
*.egg-info/

**2. File pyproject.toml** Sesuaikan nama library di bagian dependencies dengan isi dari file requirements.txt aslimu:

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "agentic-json-middleware"
version = "0.1.0"
authors = [
  { name="Sandy Wicaksono", email="sandywidarman@gmail.com" },
]
description = "An agentic middleware for automated JSON validation and self-correction from LLM outputs."
readme = "README.md"
requires-python = ">=3.8"
license = {text = "MIT"}
dependencies = [
    # Tulis isi requirements.txt milikmu di sini
    # Contoh: "pydantic", "fastapi", dll
]
classifiers = [
    "Programming Language :: Python :: 3",
    "Operating System :: OS Independent",
]

[tool.setuptools]
packages = ["agentic_json_middleware"]

**3. File README.md** Aku sudah siapkan draft berstandar industri yang menonjolkan fitur self-correction ini agar terlihat sangat premium di mata klien Wellfound:

# Agentic JSON Middleware

A robust, agentic middleware designed to intercept, validate, and automatically correct malformed JSON outputs generated by Large Language Models (LLMs).

In production environments, LLMs are prone to hallucinations or returning truncated JSON structures, which can break backend pipelines. This middleware acts as a safety net, intelligently detecting parsing errors and using an agentic approach to self-correct the payload before it reaches your application logic.

## 🚀 Key Features
* **Automated JSON Validation:** Instantly detects broken formatting, missing brackets, or invalid data types from LLM responses.
* **Agentic Self-Correction:** Instead of just throwing an error, the middleware actively repairs the JSON structure.
* **Seamless Integration:** Designed to sit perfectly between your LLM engine and your main API endpoints.
* **Resilient Data Pipelines:** Ensures your backend only receives clean, strictly-typed JSON data.

## 📦 Installation

```bash
pip install agentic-json-middleware

📄 License

This project is licensed under the MIT License.


---

Setelah 3 langkah ini selesai, kamu tinggal melakukan rutinitas yang sama:
1. Buka GitHub Desktop, *Commit* lalu **Publish Repository** (centang *Keep this code private*).
2. Buka Terminal, jalankan `python -m build`.
3. Jalankan `twine upload dist/*` dan masukkan token PyPI-mu.

Silakan dicoba "Copy Bersih" nya! Kalau ada kendala saat *build*, langsung infokan saja.

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

agentic_json_middleware-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentic_json_middleware-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file agentic_json_middleware-0.1.0.tar.gz.

File metadata

  • Download URL: agentic_json_middleware-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for agentic_json_middleware-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dfeb63fe3b83bcfa51ba7d0e5b11bbf8364cdef63855f8829571fc4a891caf5c
MD5 03f695b8b7a41f3bbd6cdf67cdb49b65
BLAKE2b-256 ef354c554b3f90b597aed9b0d4ba86334970352d9a3cdedbdd7811c4fab1799a

See more details on using hashes here.

File details

Details for the file agentic_json_middleware-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agentic_json_middleware-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e11c64c6800d29482f9e2599ec649ada706912c82c5ddaf733146a2b3afca6fc
MD5 c2a4d5441a34aaf5a0b8dcbfff5f0912
BLAKE2b-256 417401aeaa4e7ff29eb15b981678ccf3fe2656b8cfd7a581c32b5db97d76539a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page