Skip to content

A new package designed to facilitate the generation of structured summaries and insights from user-provided news headlines or short articles. It uses pattern matching to ensure responses are consisten

Notifications You must be signed in to change notification settings

chigwell/news-summarizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

News Summarizer

PyPI version License: MIT Downloads LinkedIn

A Python package designed to facilitate the generation of structured summaries and insights from user-provided news headlines or short articles. It uses pattern matching to ensure responses are consistently formatted, enabling quick extraction of key information such as main issues, affected regions, or sentiment.

Features

  • Structured summaries from news headlines or short articles
  • Pattern matching for consistent response formatting
  • Extraction of key information (main issues, affected regions, sentiment)
  • Support for multiple LLM providers
  • Easy integration with LangChain

Installation

pip install news_summarizer

Usage

Basic Usage

from news_summarizer import news_summarizer

user_input = "Your news headline or short article here"
response = news_summarizer(user_input)
print(response)

Using a Custom LLM

You can use any LLM compatible with LangChain. Here are examples with different providers:

OpenAI

from langchain_openai import ChatOpenAI
from news_summarizer import news_summarizer

llm = ChatOpenAI()
response = news_summarizer(user_input, llm=llm)
print(response)

Anthropic

from langchain_anthropic import ChatAnthropic
from news_summarizer import news_summarizer

llm = ChatAnthropic()
response = news_summarizer(user_input, llm=llm)
print(response)

Google

from langchain_google_genai import ChatGoogleGenerativeAI
from news_summarizer import news_summarizer

llm = ChatGoogleGenerativeAI()
response = news_summarizer(user_input, llm=llm)
print(response)

Using LLM7 with API Key

from news_summarizer import news_summarizer

user_input = "Your news headline or short article here"
api_key = "your_api_key_here"
response = news_summarizer(user_input, api_key=api_key)
print(response)

Parameters

  • user_input (str): The user input text to process
  • llm (Optional[BaseChatModel]): The LangChain LLM instance to use. If not provided, the default ChatLLM7 will be used.
  • api_key (Optional[str]): The API key for LLM7. If not provided, the environment variable LLM7_API_KEY will be used.

Default LLM

The package uses ChatLLM7 from langchain_llm7 by default. You can safely pass your own LLM instance if you want to use another LLM.

Rate Limits

The default rate limits for LLM7 free tier are sufficient for most use cases of this package. If you want higher rate limits for LLM7, you can pass your own API key via the environment variable LLM7_API_KEY or directly via the api_key parameter. You can get a free API key by registering at LLM7.

Issues

If you encounter any issues, please report them on the GitHub issues page.

Author