Skip to main content

A new package that takes a news headline or short text snippet as input and returns a structured summary of the key details, such as the person involved, the event, and the financial or business impac

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

news_structurize-2025.12.21125623.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

news_structurize-2025.12.21125623-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file news_structurize-2025.12.21125623.tar.gz.

File metadata

File hashes

Hashes for news_structurize-2025.12.21125623.tar.gz
Algorithm Hash digest
SHA256 d1df301f4aa8cfd0a3ed3513ccf7fea2c9a46a8b4e006e79faebcf21b15cc46d
MD5 07c1267048506cd4880a86fa8b8c9eca
BLAKE2b-256 4a8b5cebd181f31b46c69d28758fd4ffc5dc17dd28246ce5c416c0369eea40cf

See more details on using hashes here.

File details

Details for the file news_structurize-2025.12.21125623-py3-none-any.whl.

File metadata

File hashes

Hashes for news_structurize-2025.12.21125623-py3-none-any.whl
Algorithm Hash digest
SHA256 7b39735391e9e11f3e50d8015d10b8528c58a664607c2c426370fdeebcaef402
MD5 42f20d230944f8cbbe3fad20aa448359
BLAKE2b-256 57ab2a9af73fa52893edade954eaecedf827efce385822c77b1ad28fb0c408aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page