Skip to content

Latest commit

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

structuredxtract

PyPI versionLicense: MITDownloadsLinkedIn

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)

fromstructuredxtractimportstructuredxtractuser_input="""Name: John DoeAge: 30Occupation: 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

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

Anthropic

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

Google Vertex AI

fromlangchain_google_genaiimportChatGoogleGenerativeAIfromstructuredxtractimportstructuredxtractllm=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.
    importosos.environ["LLM7_API_KEY"] ="your_api_key_here"

Get a free API key at LLM7 Token.


📜 Parameters

ParameterTypeDescription
user_inputstrPlain text input to extract structured data from.
api_keyOptional[str]LLM7 API key (optional if using environment variable).
llmOptional[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

Releases

Packages

Contributors

Languages