Skip to main content

structuredxtract

PyPI version License: MIT Downloads LinkedIn

Extract structured information from unstructured text with pattern-matching precision.

A Python package that simplifies structured data extraction from plain text inputs using a language model with pattern-matching capabilities. Ideal for surveys, feedback analysis, and report generation where consistent, well-formatted outputs are required.


🚀 Features

  • Pattern-based extraction: Uses regex patterns to enforce structured output formats.
  • Flexible LLM integration: Works with default ChatLLM7 or any LangChain-compatible model.
  • No multimedia support: Focuses solely on text-based inputs for reliability.
  • Consistent formatting: Ensures responses match expected schemas (tables, summaries, key-value pairs).
  • Easy customization: Replace default LLM with OpenAI, Anthropic, Google, or any other LangChain model.

📦 Installation

pip install structuredxtract

🔧 Usage

Basic Usage (Default LLM7)

from structuredxtract import structuredxtract

user_input = """
Name: John Doe
Age: 30
Occupation: Software Engineer
"""

response = structuredxtract(user_input)
print(response)  # Structured output based on predefined patterns

Custom LLM Integration

Replace the default ChatLLM7 with your preferred model:

OpenAI

from langchain_openai import ChatOpenAI
from structuredxtract import structuredxtract

llm = ChatOpenAI()
response = structuredxtract(user_input, llm=llm)

Anthropic

from langchain_anthropic import ChatAnthropic
from structuredxtract import structuredxtract

llm = ChatAnthropic()
response = structuredxtract(user_input, llm=llm)

Google Vertex AI

from langchain_google_genai import ChatGoogleGenerativeAI
from structuredxtract import structuredxtract

llm = ChatGoogleGenerativeAI()
response = structuredxtract(user_input, llm=llm)

🔑 API Key

  • Default: Uses LLM7_API_KEY from environment variables.
  • Manual override: Pass via api_key parameter or set LLM7_API_KEY before importing.
    import os
    os.environ["LLM7_API_KEY"] = "your_api_key_here"
    

Get a free API key at LLM7 Token.


📜 Parameters

Parameter Type Description
user_input str Plain text input to extract structured data from.
api_key Optional[str] LLM7 API key (optional if using environment variable).
llm Optional[BaseChatModel] Custom LangChain LLM (e.g., ChatOpenAI, ChatAnthropic). Defaults to ChatLLM7.

📊 Output

Returns a List[str] of extracted data matching predefined patterns. Example:

[
    {"Name": "John Doe", "Age": "30", "Occupation": "Software Engineer"},
    {"Key1": "Value1", "Key2": "Value2"}
]

🔄 Rate Limits

  • LLM7 Free Tier: Sufficient for most use cases.
  • Custom API Key: For higher limits, pass via api_key or environment variable.

📝 License

MIT


📢 Support & Issues

For bugs or feature requests, open an issue on GitHub.


👤 Author

Eugene Evstafev 📧 hi@euegne.plus 🔗 GitHub: chigwell

Metadata

Release files for structuredxtract 2025.12.21145156

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

Source distribution (sdist)

Source distribution for structuredxtract 2025.12.21145156
File Size Uploaded
structuredxtract-2025.12.21145156.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for structuredxtract 2025.12.21145156
File Interpreter ABI Platform
structuredxtract-2025.12.21145156-py3-none-any.whl Python 3 none any Details

Total release size: 10.1 kB

Release files / structuredxtract-2025.12.21145156.tar.gz

Download URL structuredxtract-2025.12.21145156.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
efe8305cb7ac9c024765591caf89f1121c6d98bc7ad68587a131f8524eb673b2
BLAKE2b-256 checksum
How to use checksums
75c409585b9bff0ffb2e11544539e7fa064f3c00ac0d53724773e6bd88cf6514
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release files / structuredxtract-2025.12.21145156-py3-none-any.whl

Download URL structuredxtract-2025.12.21145156-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb160fd3d635c4efe53aa5172223e1b8d839e29b198e1bd92becdcc00d030781
BLAKE2b-256 checksum
How to use checksums
9663f6c35f452449e18715ea41f43887dff1bc91e2ba37f26ee326acb7ff0364
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release history Release notifications | RSS feed

This release

2025.12.21145156 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