mohitkhare
Developer utilities and AI engineering tools by Mohit Khare -- practical helpers for text processing, LLM token estimation, and everyday dev productivity.
Install
pip install mohitkhare
Text Utilities
from mohitkhare import slugify, truncate, chunk_text, reading_time
# URL-safe slugs
slugify("My Blog Post Title!") # 'my-blog-post-title'
slugify("Cafe & Restaurant -- Paris") # 'cafe-restaurant-paris'
# Smart truncation
truncate("Long article text here...", 15) # 'Long article...'
# Chunk text for LLM processing (splits on sentence boundaries)
chunks = chunk_text(long_document, max_chars=4000, overlap=200)
# Reading time estimate
reading_time("word " * 500) # '2 min read'
LLM Token Estimation
Estimate token counts and API costs without importing heavy tokenizers.
from mohitkhare import estimate_tokens, estimate_cost
# Token estimation (character-based heuristic)
estimate_tokens("Hello, how are you?") # 5
estimate_tokens("Long prompt " * 100, model="claude") # ~336
# Cost estimation
estimate_cost("A " * 10000, model="gpt-4o") # '$0.0050'
estimate_cost("Short text", model="claude-haiku") # '$0.0000'
estimate_cost("Output text", model="gpt-4o", is_output=True)
Supports: GPT-4o, GPT-4, GPT-3.5, Claude (Opus/Sonnet/Haiku), Gemini, Llama, Mistral.
Dev Productivity
from mohitkhare import timer, retry, flatten, chunk_list, dedupe
# Time function execution
@timer
def slow_function():
... # prints "slow_function took 1.234s"
# Retry with exponential backoff
@retry(max_attempts=3, delay=1.0, backoff=2.0)
def flaky_api_call():
...
# Flatten nested lists
flatten([[1, 2], [3, [4, 5]]]) # [1, 2, 3, 4, 5]
# Chunk lists for batch processing
chunk_list(range(10), 3) # [[0,1,2], [3,4,5], [6,7,8], [9]]
# Dedupe preserving order
dedupe([3, 1, 2, 1, 3]) # [3, 1, 2]
dedupe(["a", "A", "b"], key=str.lower) # ['a', 'b']
Links
- mohitkhare.me -- Blog and portfolio
- Blog -- AI engineering articles
License
MIT
Metadata
Release files for mohitkhare 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mohitkhare-0.1.0.tar.gz | 7.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mohitkhare-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.3 kB
Release files / mohitkhare-0.1.0.tar.gz
| Download URL | mohitkhare-0.1.0.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0b2430da5989e92644e054cd8e59dd9aad95e7266e6ccb59d3723ed98433ff6
|
|
BLAKE2b-256 checksum How to use checksums |
e9d6e4dccf8b0806e28937628f6757effc3da032ec8b153b867cf24fe012ed3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / mohitkhare-0.1.0-py3-none-any.whl
| Download URL | mohitkhare-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f5f0d1ecf7912c430a52f16028af004bb221bb84285d40f8202ed1a13508240a
|
|
BLAKE2b-256 checksum How to use checksums |
d5c3c487bfb42646ffa955aa8bdd1e8e194fe623631cea89f2233dd3d304fccf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for mohitkhare 0.1.0
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.