Skip to 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

Notifications You must be signed in to change notification settings

chigwell/headline-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

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)

Releases

No releases published

Packages

No packages published

Languages