llm_jsonl_converter
This Python package provides functionality to convert unstructured text into JSONL (JSON Lines) format using a Large Language Model (LLM). It intelligently chunks text, prompts the LLM to generate JSON objects conforming to specified formats, and validates the output to produce a clean JSONL string.
Features
- LLM-Powered Conversion: Leverages LLMs to extract structured data from free-form text.
- JSONL Output: Generates data in the widely-used JSON Lines format.
- Configurable Formats: Supports defining and using custom JSONL schemas.
- Chunking Strategy: Divides large texts into manageable chunks for LLM processing.
- Validation: Ensures generated JSON lines conform to a specified regex pattern.
- Progress Indication: Uses
tqdmfor a visual progress bar during conversion.
Installation
To install llm_jsonl_converter, use pip:
pip install llm_jsonl_converter
Usage
The primary function is generate_jsonl_from_text. You need to provide the text to convert and the name of the target JSONL format.
from llm_jsonl_converter import generate_jsonl_from_text
from langchain_llm7 import ChatLLM7 # Or any other compatible BaseChatModel
# Initialize your LLM (replace with your actual LLM setup if needed)
# If llm is None, a default ChatLLM7 instance will be used.
llm_instance = ChatLLM7(
model="gemini-2.5-flash-lite",
base_url="https://api.llm7.io/v1"
)
# Example unstructured text
sample_text = """
John Doe is a software engineer based in New York. He works at Tech Innovations Inc.
His email is john.doe@example.com and his phone number is 123-456-7890.
He has over 5 years of experience in Python and JavaScript.
Jane Smith is a data scientist from San Francisco. She can be reached at jane.smith@company.org.
Her expertise lies in machine learning and statistical analysis.
"""
# Define the target format name (ensure this format is available via get_llm_jsonl_formats())
target_format = "OpenAI Prompt–Completion (SFT)"
try:
jsonl_output = generate_jsonl_from_text(
text=sample_text,
target_format_name=target_format,
llm=llm_instance,
chunk_word_size=150, # Adjust chunk size as needed
verbose=True # Set to True for detailed logs
)
print(jsonl_output)
except ValueError as e:
print(f"Error: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
License
llm_jsonl_converter is licensed under the MIT License.
Author
Eugene Evstafev hi@eugene.plus Repository: https://github.com/chigwell/llm_jsonl_converter
Metadata
Release files for llm-jsonl-converter 2025.9.141156
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| llm_jsonl_converter-2025.9.141156.tar.gz | 6.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_jsonl_converter-2025.9.141156-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.1 kB
Release files / llm_jsonl_converter-2025.9.141156.tar.gz
| Download URL | llm_jsonl_converter-2025.9.141156.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1283717ae30ff185488480f70af26cc4d7e0676091cf62ee8f762b43ea23d55
|
|
BLAKE2b-256 checksum How to use checksums |
20d56a8eeae141a7ed662a53c3bc451099ff4de480da215d58d95bcddd6cfda2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.11
|
Release files / llm_jsonl_converter-2025.9.141156-py3-none-any.whl
| Download URL | llm_jsonl_converter-2025.9.141156-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8600d0f32bda17a9081eaea43ce80b083f0d3564448c130780ea1f380c59412a
|
|
BLAKE2b-256 checksum How to use checksums |
b240ae89a02dc1c76474674a73cc7ae8491c6195de29e052949528f1d4eddeac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.11
|