Skip to main content

news-structurize

PyPI version License: MIT Downloads LinkedIn

news-structurize is a lightweight Python package that transforms a news headline or a short text snippet into a structured summary. The output contains key elements such as the person involved, the event, and the financial or business impact. It leverages an LLM (by default ChatLLM7) together with regex‑based pattern matching to guarantee a consistent, machine‑readable format—perfect for automated news aggregation, financial reporting, or data‑extraction pipelines.


Features

  • One‑function API – just call news_structurize() with your text.
  • Built‑in LLM – uses ChatLLM7 from the langchain_llm7 package out‑of‑the‑box.
  • Pluggable LLMs – pass any LangChain‑compatible chat model (OpenAI, Anthropic, Google, …).
  • Regex‑validated output – guarantees that the returned data matches the expected schema.
  • Zero‑configuration default – works with the free tier of LLM7; optional API key handling.

Installation

pip install news_structurize

Quick Start

from news_structurize import news_structurize

# Simple call – uses the default ChatLLM7 (needs LLM7_API_KEY in env or default key)
headline = "Apple CEO Tim Cook announces $2 billion investment in renewable energy"
summary = news_structurize(headline)

print(summary)
# Example output:
# ['Person: Tim Cook', 'Event: Investment announcement', 'Impact: $2 billion in renewable energy']

Advanced Usage – Supplying Your Own LLM

You can provide any LangChain chat model that follows the BaseChatModel interface.

OpenAI

from langchain_openai import ChatOpenAI
from news_structurize import news_structurize

llm = ChatOpenAI(model="gpt-4o-mini")
headline = "Tesla reports record Q3 deliveries"
summary = news_structurize(headline, llm=llm)

print(summary)

Anthropic

from langchain_anthropic import ChatAnthropic
from news_structurize import news_structurize

llm = ChatAnthropic(model="claude-3-haiku-20240307")
headline = "Amazon expands grocery footprint with 15 new stores"
summary = news_structurize(headline, llm=llm)

print(summary)

Google Generative AI

from langchain_google_genai import ChatGoogleGenerativeAI
from news_structurize import news_structurize

llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash")
headline = "Microsoft acquires AI startup for $1.2 billion"
summary = news_structurize(headline, llm=llm)

print(summary)

API Reference

news_structurize(
    user_input: str,
    llm: Optional[BaseChatModel] = None,
    api_key: Optional[str] = None
) -> List[str]
Parameter Type Description
user_input str The news headline or short text snippet to be structured.
llm Optional[BaseChatModel] A LangChain chat model instance. If omitted, the default ChatLLM7 is used.
api_key Optional[str] API key for LLM7. If omitted, the function looks for LLM7_API_KEY in the environment; otherwise a placeholder key ("None") is used (suitable for the free tier).

The function returns a list of strings, each representing a parsed element (e.g., ["Person: …", "Event: …", "Impact: …"]). If the LLM call fails, a RuntimeError is raised with the underlying error message.


Configuration & Rate Limits

  • LLM7 Free Tier – Adequate for most development and low‑volume production use cases.
  • Higher Limits – Obtain a personal API key by registering at https://token.llm7.io/ and set it via the environment variable LLM7_API_KEY or pass it directly to news_structurize().
export LLM7_API_KEY="your_api_key_here"

Contributing

Issues, feature requests, and pull requests are welcome! Please file them on the GitHub repository:

🔗 https://github....

When contributing, follow standard Python packaging conventions and keep the public interface limited to the news_structurize function.


License

This project is licensed under the MIT License.


Author

Eugene Evstafev
📧 Email: hi@euegne.plus
🐙 GitHub: chigwell


Acknowledgements

Metadata

Release files for news-structurize 2025.12.21125623

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

Source distribution (sdist)

Source distribution for news-structurize 2025.12.21125623
File Size Uploaded
news_structurize-2025.12.21125623.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for news-structurize 2025.12.21125623
File Interpreter ABI Platform
news_structurize-2025.12.21125623-py3-none-any.whl Python 3 none any Details

Total release size: 11.0 kB

Release files / news_structurize-2025.12.21125623.tar.gz

Download URL news_structurize-2025.12.21125623.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d1df301f4aa8cfd0a3ed3513ccf7fea2c9a46a8b4e006e79faebcf21b15cc46d
BLAKE2b-256 checksum
How to use checksums
4a8b5cebd181f31b46c69d28758fd4ffc5dc17dd28246ce5c416c0369eea40cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release files / news_structurize-2025.12.21125623-py3-none-any.whl

Download URL news_structurize-2025.12.21125623-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b39735391e9e11f3e50d8015d10b8528c58a664607c2c426370fdeebcaef402
BLAKE2b-256 checksum
How to use checksums
57ab2a9af73fa52893edade954eaecedf827efce385822c77b1ad28fb0c408aa
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.21125623 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