Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

mdi-llmkit

Utilities for managing LLM chat conversations and structured JSON responses with OpenAI's Responses API.

Installation

pip install mdi-llmkit

Quick Start

Preferred subpackage imports:

from mdi_llmkit.gpt_api import GptConversation
from mdi_llmkit.json_surgery import json_surgery

gpt_submit

from openai import OpenAI
from mdi_llmkit.gpt_api import gpt_submit

client = OpenAI()

reply = gpt_submit(
    messages=[{"role": "user", "content": "Say hello."}],
    openai_client=client,
)
print(reply)

GptConversation

from openai import OpenAI
from mdi_llmkit.gpt_api import GptConversation

client = OpenAI()
conversation = GptConversation(openai_client=client)

reply = conversation.submit_user_message("Give me three project name ideas.")
print(reply)

JSON Response Mode

from openai import OpenAI
from mdi_llmkit.gpt_api import gpt_submit

client = OpenAI()

result = gpt_submit(
    messages=[{"role": "user", "content": "Return JSON with keys a and b."}],
    openai_client=client,
    json_response=True,
)

print(type(result))  # dict or list
print(result)

JSON Surgery

from openai import OpenAI
from mdi_llmkit.json_surgery import json_surgery

client = OpenAI()

obj = {"status": "pending", "tags": ["alpha"]}
result = json_surgery(
    client,
    obj,
    'Set status to "approved" and append "done" to tags.',
)

print(result)

Placemark helpers are available in mdi_llmkit.json_surgery.placemarked_json:

  • placemarked_json_stringify(obj, indent=2, skipped_keys=None)
  • navigate_to_json_path(obj, json_path)

Semantic List Comparison (compare_item_lists)

Use compare_item_lists when you need to compare a before list and an after list and classify items as removed, added, renamed, or unchanged. This uses AI to resolve semantic renames that would otherwise appear as unrelated remove/add pairs in strict string comparison.

from openai import OpenAI
from mdi_llmkit.semantic_match import compare_item_lists

client = OpenAI()

result = compare_item_lists(
    client,
    ["Legacy Plan", "Shared Item"],
    ["Modern Plan", "shared item"],
    (
        "Legacy Plan was renamed to Modern Plan. "
        "Shared Item is unchanged."
    ),
)

print(result)
# [
#   {
#     "item": "Legacy Plan",
#     "classification": "renamed",
#     "new_name": "Modern Plan",
#   },
#   {
#     "item": "Shared Item",
#     "classification": "unchanged",
#     "new_name": None,
#   },
# ]

Accepted input item formats:

  • String item name: "Item Name"
  • Object with optional context: {"name": "Item Name", "description": "..."}

Notes:

  • Name matching is case-insensitive for exact unchanged detection.
  • Names should be unique within each input list (case-insensitive).
  • Optional description is context-only and does not define identity.

Local Dev (Windows venv)

From packages/python-mdi-llmkit, activate the project venv and run tests:

.\venv\Scripts\Activate.ps1
python -c "import sys; print(sys.executable)"
python -m unittest tests/test_placemarked_json.py tests/test_json_surgery_unit.py

Live json_surgery integration tests (real API) require OPENAI_API_KEY:

python -m unittest tests/test_json_surgery.py

Notes

  • Package name for pip install is mdi-llmkit.
  • Python import package is mdi_llmkit.
  • gpt_submit supports optional warning reporting via warning_callback.

Metadata

Release files for mdi-llmkit 1.1.3

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

Source distribution (sdist)

Source distribution for mdi-llmkit 1.1.3
File Size Uploaded Provenance Actions
mdi_llmkit-1.1.3.tar.gz 42.4 kB Without provenance Details for mdi_llmkit-1.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mdi-llmkit 1.1.3
File Interpreter ABI Platform Actions
mdi_llmkit-1.1.3-py3-none-any.whl Python 3 none any Details for mdi_llmkit-1.1.3-py3-none-any.whl

Total release size: 69.1 kB

Release files / mdi_llmkit-1.1.3.tar.gz

Download URL mdi_llmkit-1.1.3.tar.gz
Size 42.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c254afd015f7c9d18fa704303a567a3ab58f9e403ab71ba88a6bcaf0db87ab3a
BLAKE2b-256 checksum
How to use checksums
13774498363e4aad411fb14a484e36e7843d913cf835583b0de82e6d24912256
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / mdi_llmkit-1.1.3-py3-none-any.whl

Download URL mdi_llmkit-1.1.3-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d993637a636fa634ffd0d20512e1ece5e96712db01874622cd4e681052f19d4f
BLAKE2b-256 checksum
How to use checksums
d022890f1fb389e7cdd41e482da02b68afa009c1e4344949848b4ca850c0cf79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Security for mdi-llmkit 1.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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