geopolitex-analyzer
geopolitex-analyzer is a lightweight Python package that turns short news headlines or text snippets about geopolitics, defense, and international competition into structured, LLM‑generated summaries. The output always follows a predefined pattern (subject, comparative context, implications) and is validated with robust regex matching to guarantee consistency and accuracy.
Features
- One‑line summarisation for geopolitical and defense‑related texts.
- Pattern‑based validation using
llmatchto ensure the LLM output conforms to the expected format. - Pluggable LLM backend – defaults to
ChatLLM7but works with any LangChain‑compatible chat model (OpenAI, Anthropic, Google, etc.). - Simple API: just pass the raw text and get a list of structured strings back.
Installation
pip install geopolitex_analyzer
Quick Start
from geopolitex_analyzer import geopolitex_analyzer
# Simple usage with the default ChatLLM7 (requires an API key)
summary = geopolitex_analyzer(
user_input="China launches a new hypersonic missile system, threatening regional stability."
)
print(summary)
# -> ['Subject: China...', 'Comparative Context: ...', 'Implications: ...']
Using a custom LangChain LLM
You can provide any LangChain chat model that implements BaseChatModel. This is useful if you prefer OpenAI, Anthropic, Google Gemini, etc.
OpenAI example
from langchain_openai import ChatOpenAI
from geopolitex_analyzer import geopolitex_analyzer
my_llm = ChatOpenAI(model="gpt-4o-mini")
summary = geopolitex_analyzer(
user_input="Russia expands its naval presence in the Arctic.",
llm=my_llm,
)
print(summary)
Anthropic example
from langchain_anthropic import ChatAnthropic
from geopolitex_analyzer import geopolitex_analyzer
my_llm = ChatAnthropic(model="claude-3-haiku-20240307")
summary = geopolitex_analyzer(
user_input="India announces a new defense budget focusing on AI‑driven weaponry.",
llm=my_llm,
)
print(summary)
Google Gemini example
from langchain_google_genai import ChatGoogleGenerativeAI
from geopolitex_analyzer import geopolitex_analyzer
my_llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash")
summary = geopolitex_analyzer(
user_input="EU sanctions target new Russian aerospace firms.",
llm=my_llm,
)
print(summary)
Supplying an API key for the default LLM7 backend
If you rely on the built‑in ChatLLM7 model, provide an API key either via the LLM7_API_KEY environment variable or directly:
from geopolitex_analyzer import geopolitex_analyzer
summary = geopolitex_analyzer(
user_input="Turkey acquires advanced drone technology from South Korea.",
api_key="your_llm7_api_key_here",
)
print(summary)
A free API key can be obtained by registering at https://token.llm7.io/. The free tier’s rate limits are sufficient for most typical use cases.
Function Reference
geopolitex_analyzer(
user_input: str,
api_key: Optional[str] = None,
llm: Optional[BaseChatModel] = None,
) -> List[str]
| Parameter | Type | Description |
|---|---|---|
user_input |
str |
Raw headline or short text describing a geopolitical/defense topic. |
api_key |
Optional[str] |
API key for the default ChatLLM7. If omitted, the function looks for the LLM7_API_KEY env var. |
llm |
Optional[BaseChatModel] |
Any LangChain chat model. If provided, it overrides the default ChatLLM7. |
Return value: A list of strings that match the defined output pattern (e.g., subject, comparative context, implications). If the LLM response does not satisfy the pattern, a RuntimeError is raised.
Dependencies
llmatch_messages– pattern‑matching helper used to enforce output format.langchain-core– core interfaces for LLMs (BaseChatModel, message types).langchain-llm7– wrapper for the LLM7 service (automatically installed).geopolitex-analyzer’s ownprompts.py(contains the system / human prompts and the regex pattern).
Contributing & Support
- Bug reports & feature requests: https://github.com/chigwell/geopolitex_analyzer/issues
- Pull requests: Contributions are welcome—please follow the standard GitHub workflow.
Author
Eugene Evstafev
Email: hi@euegne.plus
GitHub: chigwell
License
MIT License – see the LICENSE file in the repository for details.
Happy analysing!
Metadata
Release files for geopolitex-analyzer 2025.12.21165107
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 |
|---|---|---|---|---|
| geopolitex_analyzer-2025.12.21165107.tar.gz | 5.3 kB | Without provenance | Details for geopolitex_analyzer-2025.12.21165107.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| geopolitex_analyzer-2025.12.21165107-py3-none-any.whl | Python 3 | none | any | Details for geopolitex_analyzer-2025.12.21165107-py3-none-any.whl |
Total release size: 11.4 kB
Release files / geopolitex_analyzer-2025.12.21165107.tar.gz
| Download URL | geopolitex_analyzer-2025.12.21165107.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
913b0080cf2abdb754a3c29beab3b7453baafb49ae0367405766160ffe1e2c1d
|
|
BLAKE2b-256 checksum How to use checksums |
e0c73169e18daea6439a16a266ad30f603e4e303d0b7405213f576e10db8a84a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Release files / geopolitex_analyzer-2025.12.21165107-py3-none-any.whl
| Download URL | geopolitex_analyzer-2025.12.21165107-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bcca2964dd7fb3db1cfec692577a92f6204f4b8b837adebc1f803040da1fd639
|
|
BLAKE2b-256 checksum How to use checksums |
449ce3d4ef89e6b838a6da8ecca6d727853ad773dd00089eb22db18e11dcf3d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Security for geopolitex-analyzer 2025.12.21165107
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.