Skip to main content

A new package that processes news headlines or short text snippets to generate structured summaries of current events. It uses an LLM to extract key entities, topics, and sentiment, ensuring the outpu

Project description

Headline Parser

PyPI version License: MIT Downloads LinkedIn

A package to process news headlines or short text snippets, extracting key entities, topics, and sentiment, and outputting structured summaries in a consistent format.

Installation

pip install headline_parser

Overview

This package uses a large language model (LLM) to process input text and generate structured summaries of current events. It's suitable for:

  • News aggregation
  • Content moderation analysis
  • Tracking public discourse on free speech and regulatory issues
  • Applications not requiring raw media files

Example usage

from headline_parser import headline_parser

response = headline_parser(
    user_input="Us Democrats pass a health care reform bill.",
)
print(response)

The headline_parser function can take in optional arguments:

  • llm: an instance of langchain_core.language_models.BaseChatModel, which defaults to langchain_llm7.ChatLLM7
  • api_key: an optional API key for LLM7, which defaults to the LLM7_API_KEY environment variable

You can pass your own LLM instance from other providers:

# Using OpenAI
from langchain_openai import ChatOpenAI
from headline_parser import headline_parser

llm = ChatOpenAI()
response = headline_parser("Your news headline", llm=llm)
print(response)

# Using Anthropic
from langchain_anthropic import ChatAnthropic
from headline_parser import headline_parser

llm = ChatAnthropic()
response = headline_parser("Your news headline", llm=llm)
print(response)

# Using Google
from langchain_google_genai import ChatGoogleGenerativeAI
from headline_parser import headline_parser

llm = ChatGoogleGenerativeAI()
response = headline_parser("Your news headline", llm=llm)
print(response)

For higher rate limits with LLM7, you can obtain a free API key by registering at https://token.llm7.io/ and pass it either as an environment variable or directly to the function:

from headline_parser import headline_parser

# Via environment variable
os.environ["LLM7_API_KEY"] = "your_api_key"

# Or directly
response = headline_parser("Your news headline", api_key="your_api_key")
print(response)

Contributing

Found an issue or have a feature request? Please report them on GitHub.

Author

Eugene Evstafev (hi@eugene.plus)

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

headline_parser-2025.12.21175317.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

headline_parser-2025.12.21175317-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file headline_parser-2025.12.21175317.tar.gz.

File metadata

File hashes

Hashes for headline_parser-2025.12.21175317.tar.gz
Algorithm Hash digest
SHA256 387716232fb85046ff0115a9632ea84ed59d9a3d6ec159d1ec3b86f719077a07
MD5 63cac63c448fd9a8e663d3185fae4fe0
BLAKE2b-256 386daba79866aebff3767c574bbbbdef3e7cdf46c81252dc9c20ef433caa87e3

See more details on using hashes here.

File details

Details for the file headline_parser-2025.12.21175317-py3-none-any.whl.

File metadata

File hashes

Hashes for headline_parser-2025.12.21175317-py3-none-any.whl
Algorithm Hash digest
SHA256 631fb42bb7e5b748a6417a9d9a10d44d7796608de99a235dea912452cfa3abe4
MD5 6eea918a4d2c816764b21c44f9bdc92d
BLAKE2b-256 af5c6ca4febf44aad3283eb6588d5c37ac8ddd37be76f5f55e2efbb748acdbd4

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