Skip to main content

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.

Release files for agentic-json-middleware 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentic-json-middleware 0.1.0
File Size Uploaded
agentic_json_middleware-0.1.0.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentic-json-middleware 0.1.0
File Interpreter ABI Platform
agentic_json_middleware-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size:8.3 kB

Release files / agentic_json_middleware-0.1.0.tar.gz

Download URL agentic_json_middleware-0.1.0.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
dfeb63fe3b83bcfa51ba7d0e5b11bbf8364cdef63855f8829571fc4a891caf5c
BLAKE2b-256 checksum
How to use checksums
ef354c554b3f90b597aed9b0d4ba86334970352d9a3cdedbdd7811c4fab1799a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / agentic_json_middleware-0.1.0-py3-none-any.whl

Download URL agentic_json_middleware-0.1.0-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e11c64c6800d29482f9e2599ec649ada706912c82c5ddaf733146a2b3afca6fc
BLAKE2b-256 checksum
How to use checksums
417401aeaa4e7ff29eb15b981678ccf3fe2656b8cfd7a581c32b5db97d76539a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page