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 event, actors, and context, using an LLM to generate the content and pattern matchin

Project description

newsstructure

PyPI version License: MIT Downloads LinkedIn

A Python package that takes a news headline or short text snippet as input and returns a structured summary of the key event, actors, and context. It uses an LLM to generate the content and pattern matching to ensure the output follows a consistent format. Ideal for news aggregation, automated reporting, and content tagging.

Installation

pip install newsstructure

Usage

Basic Example

from newsstructure import newsstructure

user_input = "Apple announces new iPhone with advanced AI features"
result = newsstructure(user_input)
print(result)

Using a Custom LLM

You can pass your own LangChain-compatible LLM instance. For example, to use OpenAI:

from langchain_openai import ChatOpenAI
from newsstructure import newsstructure

llm = ChatOpenAI()
user_input = "Tesla stock surges after earnings report"
response = newsstructure(user_input, llm=llm)

To use Anthropic:

from langchain_anthropic import ChatAnthropic
from newsstructure import newsstructure

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

To use Google Generative AI:

from langchain_google_genai import ChatGoogleGenerativeAI
from newsstructure import newsstructure

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

Using a Custom API Key

By default, the package uses the free tier of LLM7 (via langchain_llm7). You can provide your own API key either via environment variable or directly:

import os
os.environ["LLM7_API_KEY"] = "your_api_key_here"

# or

response = newsstructure(user_input, api_key="your_api_key_here")

Get a free API key by registering at https://token.llm7.io/.

Parameters

  • user_input (str): The text input (e.g., news headline or snippet) to process.
  • llm (Optional[BaseChatModel]): A LangChain LLM instance. If not provided, defaults to ChatLLM7.
  • api_key (Optional[str]): API key for LLM7. If not provided, the package will try to read from the LLM7_API_KEY environment variable.

License

This project is licensed under the MIT License.

Issues

Report issues or feature requests on GitHub.

Author

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

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

newsstructure-2025.12.20202005.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

newsstructure-2025.12.20202005-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file newsstructure-2025.12.20202005.tar.gz.

File metadata

  • Download URL: newsstructure-2025.12.20202005.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for newsstructure-2025.12.20202005.tar.gz
Algorithm Hash digest
SHA256 06aa45aa79a466c6cece728319c9f8fa789df7a73761baad24eab5fdd314f8aa
MD5 0ee8ea9ae6e6cf4c6f3f85bfa1fef04a
BLAKE2b-256 4e15c30e5688cc9ee0f566838c7a12c2b98a459c4f302636329730bc6f7c3980

See more details on using hashes here.

File details

Details for the file newsstructure-2025.12.20202005-py3-none-any.whl.

File metadata

File hashes

Hashes for newsstructure-2025.12.20202005-py3-none-any.whl
Algorithm Hash digest
SHA256 c83b3797815d810744dc7a194822bc0df03cfdfa5d787427d5cb0d8f52a07def
MD5 e04ed3b8f3b33d3829dd8efbcfabc4d4
BLAKE2b-256 c4d0367ad4eccb8d36fff38ac8dd34d03e85c883a6535df8fe9ae1ac8282e274

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