Skip to main content

sec-summary-llm

PyPI version License: MIT Downloads LinkedIn

sec-summary-llm is a tiny Python package that extracts structured, concise summaries from security‑ and government‑related text (news headlines, reports, etc.). It drives a language model (LLM) with a system prompt that focuses on factual details such as roles, events, and implications, and then validates the LLM output against a strict regex pattern. The result is a clean, plain‑text summary ready for downstream analysis or reporting.


Features

  • One‑function API – call sec_summary_llm() with raw text and get back a list of extracted summary strings.
  • Built‑in LLM7 support – automatically uses ChatLLM7 from the langchain_llm7 package if no LLM is supplied.
  • Pattern‑based validation – output must match the predefined regex pattern, guaranteeing consistent formatting.
  • Pluggable LLMs – works with any LangChain‑compatible chat model (OpenAI, Anthropic, Google, etc.).
  • Zero‑markdown/HTML output – the function returns plain text, suitable for CSV, databases, or further NLP pipelines.

Installation

pip install sec_summary_llm

Quick Start

from sec_summary_llm import sec_summary_llm

# Simple call using the default ChatLLM7 (requires an API key in the environment)
summary = sec_summary_llm(
    user_input="The Treasury Department announced new sanctions against..."
)

print(summary)   # -> ['...']  (list of formatted summary strings)

Parameters

Name Type Description
user_input str The raw text (e.g., headline, report excerpt) to be summarized.
llm Optional[BaseChatModel] A LangChain chat model instance. If omitted, the function creates a ChatLLM7 instance automatically.
api_key Optional[str] API key for LLM7. If not supplied, the function reads LLM7_API_KEY from the environment or falls back to "None" (which will raise an error from the provider).

Using a Custom LLM

You can pass any LangChain‑compatible chat model. Below are examples for the most common providers.

OpenAI

from langchain_openai import ChatOpenAI
from sec_summary_llm import sec_summary_llm

llm = ChatOpenAI(model="gpt-4o-mini")
response = sec_summary_llm(
    user_input="Recent congressional hearings revealed...",
    llm=llm
)
print(response)

Anthropic

from langchain_anthropic import ChatAnthropic
from sec_summary_llm import sec_summary_llm

llm = ChatAnthropic(model="claude-3-haiku-20240307")
response = sec_summary_llm(
    user_input="A new cyber‑espionage campaign has been traced...",
    llm=llm
)
print(response)

Google Generative AI

from langchain_google_genai import ChatGoogleGenerativeAI
from sec_summary_llm import sec_summary_llm

llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash")
response = sec_summary_llm(
    user_input="The Ministry of Defense released a statement about...",
    llm=llm
)
print(response)

LLM7 (Default)

  • Package: langchain_llm7 – https://pypi.org/project/langchain-llm7/
  • Free‑tier rate limits are sufficient for typical usage (few requests per minute).
  • To increase limits, provide a paid API key via the LLM7_API_KEY environment variable or pass it directly:
response = sec_summary_llm(
    user_input="...",
    api_key="your_paid_llm7_key"
)

Contributing & Issues

If you encounter bugs or have feature requests, please open an issue:

https://github... (replace with actual repository URL)


License

This project is licensed under the MIT License.


Author

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

Metadata

Release files for sec-summary-llm 2025.12.21193952

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sec-summary-llm 2025.12.21193952
File Size Uploaded
sec_summary_llm-2025.12.21193952.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sec-summary-llm 2025.12.21193952
File Interpreter ABI Platform
sec_summary_llm-2025.12.21193952-py3-none-any.whl Python 3 none any Details

Total release size: 10.7 kB

Release files / sec_summary_llm-2025.12.21193952.tar.gz

Download URL sec_summary_llm-2025.12.21193952.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
edf06444b757f37ae4abb37d05eff5f1785175426a914410920bb788907a858f
BLAKE2b-256 checksum
How to use checksums
8fc14dc3ec3488494a3bd6374e4bcabdebccb555f9176e8115a5bdd56be60a71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release files / sec_summary_llm-2025.12.21193952-py3-none-any.whl

Download URL sec_summary_llm-2025.12.21193952-py3-none-any.whl
Size 5.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1eec4e3c559f2da655fe4d6b08c24bce792ceaa84e4f7e5f32396d7655023925
BLAKE2b-256 checksum
How to use checksums
29c9eed5901916c7fbd92755b2105a9229c98ecfad7312f3c597c0030cf93a08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release history Release notifications | RSS feed

This release

2025.12.21193952 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page