routerflu – Structured LLM Response Extractor
Streamline interactions with large language models (LLMs) like Claude via OpenRouter by processing natural language inputs into structured, pattern-matched outputs. routerflu ensures consistent, extractable responses for programming, data querying, or content creation tasks.
📌 Key Features
✅ Pattern-Matched Outputs – Forces LLM responses to follow strict regex patterns for reliability.
✅ Flexible LLM Integration – Works with LLM7 (default), OpenAI, Anthropic, Google, or any BaseChatModel.
✅ Environment-Aware – Uses LLM7_API_KEY from env vars or accepts direct API keys.
✅ Minimal Dependencies – Built on langchain and llmatch_messages.
🚀 Installation
pip install routerflu
🔧 Usage Examples
1. Basic Usage (Default: LLM7)
from routerflu import routerflu
response = routerflu(
user_input="Write a Python function to reverse a string."
)
print(response) # Structured output matching predefined patterns
2. Custom LLM Integration
OpenAI
from langchain_openai import ChatOpenAI
from routerflu import routerflu
llm = ChatOpenAI()
response = routerflu(user_input="Explain how REST APIs work.", llm=llm)
Anthropic (Claude)
from langchain_anthropic import ChatAnthropic
from routerflu import routerflu
llm = ChatAnthropic()
response = routerflu(user_input="Debug this SQL query.", llm=llm)
Google Vertex AI
from langchain_google_genai import ChatGoogleGenerativeAI
from routerflu import routerflu
llm = ChatGoogleGenerativeAI()
response = routerflu(user_input="Summarize this document.", llm=llm)
🔑 Configuration
API Key
- Default: Uses
LLM7_API_KEYfrom environment variables. - Manual Override:
routerflu(user_input="...", api_key="your_llm7_api_key")
- Get a Free Key: LLM7 Token Registration
Rate Limits
- LLM7 Free Tier: Sufficient for most use cases.
- Upgrade: Use a custom API key or switch to a paid plan.
📦 Dependencies
langchain-core(forBaseChatModel)llmatch_messages(for pattern extraction)langchain_llm7(default LLM provider)
📝 Function Signature
routerflu(
user_input: str,
api_key: Optional[str] = None,
llm: Optional[BaseChatModel] = None
) -> List[str]
user_input(str): Natural language prompt for the LLM.api_key(Optional[str]): LLM7 API key (falls back to env varLLM7_API_KEY).llm(Optional[BaseChatModel]): Custom LLM (e.g.,ChatOpenAI,ChatAnthropic).
🔄 How It Works
- System Prompt: Guides the LLM to format responses strictly.
- Pattern Matching: Uses regex to extract structured data from responses.
- Error Handling: Raises
RuntimeErrorif LLM fails to comply.
📜 License
MIT
📢 Support & Issues
- GitHub Issues: routerflu GitHub
- Author: Eugene Evstafev
- GitHub: @chigwell
Metadata
Release files for routerflu 2025.12.21112723
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| routerflu-2025.12.21112723.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| routerflu-2025.12.21112723-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.7 kB
Release files / routerflu-2025.12.21112723.tar.gz
| Download URL | routerflu-2025.12.21112723.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b4e08cad815da587e61752401ac129aa50aaaced48967100b3525877a83e244
|
|
BLAKE2b-256 checksum How to use checksums |
4c41aff7004f3afaec30d733f10b68a14bd5e1cbddcc6e47fa906fc16dbbcfab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.11
|
Release files / routerflu-2025.12.21112723-py3-none-any.whl
| Download URL | routerflu-2025.12.21112723-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2beec68b21c43acd8bb1bee3d666bbc9cb8fbc6c8330993da55cf719c2815634
|
|
BLAKE2b-256 checksum How to use checksums |
82424daa07d54ff67783d3bb19e0e8b1df54b2f3a61d189ae89226cf2db5f69e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.11
|