Extracts and organizes leaderboard/ranking data from text via smart pattern matching and retries, delivering clean, structured summaries effortlessly.
Project description
Leaderboard Summarizer
leaderboard-summarizer is a lightweight Python package that extracts structured summaries and analyses from free‑form text describing leaderboards, rankings, or score tables.
It leverages LLM pattern matching (via llmatch) to ensure the extracted data matches a predefined regular expression, providing reliable, machine‑readable output without the need to manually parse raw documents.
Features
- One‑function API – just call
leaderboard_summarizer(...). - Built‑in LLM7 support – defaults to
ChatLLM7from thelangchain_llm7package. - Pluggable LLMs – pass any LangChain‑compatible
BaseChatModel(OpenAI, Anthropic, Google, etc.). - Robust pattern matching – uses a compiled regex to validate and extract the result.
- Zero‑configuration fallback – works out‑of‑the‑box with a free LLM7 API key.
Installation
pip install leaderboard_summarizer
Quick Start
from leaderboard_summarizer import leaderboard_summarizer
# Minimal usage – LLM7 will be used automatically (API key read from LLM7_API_KEY)
text = """
Top players this week:
1️⃣ Alice – 1500 pts
2️⃣ Bob – 1450 pts
3️⃣ Carol – 1400 pts
"""
summary = leaderboard_summarizer(user_input=text)
print(summary)
Using a custom LLM
You can provide any LangChain BaseChatModel instance that follows the same interface.
OpenAI
from langchain_openai import ChatOpenAI
from leaderboard_summarizer import leaderboard_summarizer
llm = ChatOpenAI(model="gpt-4o-mini")
summary = leaderboard_summarizer(user_input="...", llm=llm)
Anthropic
from langchain_anthropic import ChatAnthropic
from leaderboard_summarizer import leaderboard_summarizer
llm = ChatAnthropic(model="claude-3-haiku-20240307")
summary = leaderboard_summarizer(user_input="...", llm=llm)
Google Gemini
from langchain_google_genai import ChatGoogleGenerativeAI
from leaderboard_summarizer import leaderboard_summarizer
llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash")
summary = leaderboard_summarizer(user_input="...", llm=llm)
Supplying an explicit LLM7 API key
from leaderboard_summarizer import leaderboard_summarizer
summary = leaderboard_summarizer(
user_input="...",
api_key="your_llm7_api_key"
)
API Reference
leaderboard_summarizer(
user_input: str,
llm: Optional[BaseChatModel] = None,
api_key: Optional[str] = None
) -> List[str]
| Parameter | Type | Description |
|---|---|---|
user_input |
str |
Free‑form text that contains leaderboard or ranking information. |
llm |
Optional[BaseChatModel] |
A LangChain‑compatible chat model. If omitted, the function creates a ChatLLM7 instance automatically. |
api_key |
Optional[str] |
LLM7 API key. If not provided, the function looks for the LLM7_API_KEY environment variable, falling back to a placeholder "None" (which triggers an error from the service). |
Return value – a list of strings extracted from the input text that match the internal regex pattern defined in leaderboard_summarizer.prompts.pattern.
How It Works
- Prompt Construction – System and human prompts (defined in
leaderboard_summarizer.prompts) guide the LLM to produce output that conforms to a strict regex. - LLM Call –
llmatchsends the prompts to the chosen LLM. - Pattern Validation – The raw LLM response is checked against the compiled regular expression.
- Extraction – If the response matches, the captured groups are returned as a list; otherwise a
RuntimeErroris raised.
Environment Variables
LLM7_API_KEY– API key for the default LLM7 service. You can obtain a free key at https://token.llm7.io/.
License
This project is licensed under the MIT License.
Contributing & Support
- Issue Tracker: https://github.com/chigwell/leaderboard-summarizer/issues
- Author: Eugene Evstafev – hi@eugene.plus
- GitHub: https://github.com/chigwell
Feel free to open issues, submit pull requests, or contact the author for feature requests and bug reports.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file leaderboard_summarizer-2025.12.21232414.tar.gz.
File metadata
- Download URL: leaderboard_summarizer-2025.12.21232414.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3de850a095bc89adc1438c370f448a39efcd3ecc49e8fadadd9d3df754bb3b6
|
|
| MD5 |
775760bf9d3c02b6ef0659db5d0d0518
|
|
| BLAKE2b-256 |
04ea195822f7642f974b7b04d0911f70f2ce89bdafae4fdbc9a92544e22ac34c
|
File details
Details for the file leaderboard_summarizer-2025.12.21232414-py3-none-any.whl.
File metadata
- Download URL: leaderboard_summarizer-2025.12.21232414-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb6029bc0a4e654e9748f31d980619dabd516fe37a99fbf37fc49313c7659497
|
|
| MD5 |
7b7a477286a5ea91ddcc2b4b97fa3cd9
|
|
| BLAKE2b-256 |
e8b3b946530dbba7984eb4f7bba44cd266eed821de75fbd20295eea41fae5543
|