hist-pred-extractor
hist-pred-extractor is a tiny Python package that extracts and structures historical predictions (foresights, prophecies, or prognostications) from free‑form text.
Given a passage about a historical figure or event, the tool uses a LLM to locate statements that contain a prediction, validates them against a strict regex pattern, and returns a clean, structured list of the extracted predictions together with their context.
The package is useful for historians, researchers, educators, and anyone who wants to systematically analyse historical foresights.
Features
- One‑function API – just pass a string (and optionally a custom LLM or API key).
- LLM‑agnostic – defaults to
ChatLLM7(vialangchain_llm7) but works with any LangChain chat model. - Regex‑validated output – ensures extracted data follows the pattern defined in
prompts.pattern. - Zero‑configuration – works out of the box with the free tier of LLM7.
Installation
pip install hist_pred_extractor
Quick Start
from hist_pred_extractor import hist_pred_extractor
# Simple call – uses the default ChatLLM7 and the LLM7_API_KEY
text = """
In 1846, the astronomer John Herschel wrote: "In the next fifty years, the continents will drift apart,
forming the Atlantic as we know it today." This prediction was later confirmed by plate tectonics.
"""
predictions = hist_pred_extractor(user_input=text)
print(predictions)
# Example output:
# [
# "In the next fifty years, the continents will drift apart, forming the Atlantic as we know it today."
# ]
API Reference
hist_pred_extractor(user_input, llm=None, api_key=None) → List[str]
| Parameter | Type | Description |
|---|---|---|
| user_input | str |
The raw text containing historical statements to be analysed. |
| 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 the LLM7_API_KEY environment variable, falling back to the default free‑tier key. |
Returns: List[str] – a list of extracted prediction strings that match the internal regex pattern.
Using a Custom LLM
You can supply any LangChain‑compatible chat model, e.g. OpenAI, Anthropic, or Google Gemini.
OpenAI
from langchain_openai import ChatOpenAI
from hist_pred_extractor import hist_pred_extractor
llm = ChatOpenAI(model="gpt-4o-mini")
predictions = hist_pred_extractor(user_input="...", llm=llm)
Anthropic
from langchain_anthropic import ChatAnthropic
from hist_pred_extractor import hist_pred_extractor
llm = ChatAnthropic()
predictions = hist_pred_extractor(user_input="...", llm=llm)
Google Gemini
from langchain_google_genai import ChatGoogleGenerativeAI
from hist_pred_extractor import hist_pred_extractor
llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash")
predictions = hist_pred_extractor(user_input="...", llm=llm)
API Key & Rate Limits
- The default free tier of LLM7 provides enough calls for typical research tasks.
- For higher throughput, set your own key:
export LLM7_API_KEY="your_api_key_here"
or pass it directly:
predictions = hist_pred_extractor(user_input="...", api_key="your_api_key_here")
You can obtain a free API key by registering at https://token.llm7.io/.
Contributing & Support
- Issue Tracker: https://github.com/chigwell/hist_pred_extractor/issues
- Feel free to open a GitHub issue for bugs, feature requests, or questions.
License
This project is licensed under the MIT License.
Author
Eugene Evstafev – hi@euegne.plus
GitHub: chigwell
Acknowledgements
- ChatLLM7 from the
langchain_llm7package: https://pypi.org/project/langchain-llm7/ - LangChain framework for unified LLM access.
Metadata
Release files for hist-pred-extractor 2025.12.21195029
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hist_pred_extractor-2025.12.21195029.tar.gz | 4.6 kB | Without provenance | Details for hist_pred_extractor-2025.12.21195029.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hist_pred_extractor-2025.12.21195029-py3-none-any.whl | Python 3 | none | any | Details for hist_pred_extractor-2025.12.21195029-py3-none-any.whl |
Total release size: 9.9 kB
Release files / hist_pred_extractor-2025.12.21195029.tar.gz
| Download URL | hist_pred_extractor-2025.12.21195029.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e9a88e132ea69130a4975bb9e28ac84dd54411eb1e2e91a1e7a280c7a422176
|
|
BLAKE2b-256 checksum How to use checksums |
fab4be69ae4c979b61ce3615d21de93a5dc5549705cb91f88d4da3755623f7b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Release files / hist_pred_extractor-2025.12.21195029-py3-none-any.whl
| Download URL | hist_pred_extractor-2025.12.21195029-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1f2d9f21215c1762d03f0ed9abdcd85678080b405df6a8fa620ac9dba78699ce
|
|
BLAKE2b-256 checksum How to use checksums |
0fb622eb4fe3277263631d3bb8afc10b1f2c968d36f2fb2cee4eda41a37333a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Security for hist-pred-extractor 2025.12.21195029
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.