Extract structured information from government or organizational tech/AI initiatives
A Python package that processes text inputs (e.g., news headlines, announcements) to extract structured data about government or organizational technology and AI initiatives. It uses a language model to identify key details like entity, initiative name, focus, and more, returning results in a consistent format (JSON/XML-compatible).
pip install govaitextextractfrom govaitextextract import govaitextextract
user_input = "The Ministry of Digital Transformation announces a new AI project with 50 specialists."
response = govaitextextract(user_input)
print(response)You can replace the default ChatLLM7 with any LangChain-compatible LLM (e.g., OpenAI, Anthropic, Google):
from langchain_openai import ChatOpenAI
from govaitextextract import govaitextextract
llm = ChatOpenAI()
response = govaitextextract(user_input, llm=llm)from langchain_anthropic import ChatAnthropic
from govaitextextract import govaitextextract
llm = ChatAnthropic()
response = govaitextextract(user_input, llm=llm)from langchain_google_genai import ChatGoogleGenerativeAI
from govaitextextract import govaitextextract
llm = ChatGoogleGenerativeAI()
response = govaitextextract(user_input, llm=llm)| Parameter | Type | Description |
|---|---|---|
user_input |
str |
The input text (e.g., news headline) to process. |
api_key |
Optional[str] |
LLM7 API key (defaults to LLM7_API_KEY env var). |
llm |
Optional[BaseChatModel] |
Custom LangChain LLM (e.g., ChatOpenAI). Falls back to ChatLLM7. |
- Default LLM:
ChatLLM7(from langchain_llm7). - Free Tier: Sufficient for most use cases.
- Custom Key: Pass via
api_keyorLLM7_API_KEYenv var. - Get a Key: Register at LLM7.
The function returns structured data (e.g., JSON-like) extracted from the input text, such as:
{
"entity": "Ministry of Digital Transformation",
"initiative_name": "New AI Project",
"specialists": 50,
"focus": "AI"
}- Uses regex validation for consistency.
- Error handling included for LLM failures.
- Extensible for custom patterns via
patternin prompts.
Report bugs or feature requests at: GitHub Issues
Eugene Evstafev 📧 hi@euegne.plus 🔗 GitHub: chigwell