A new package is designed to streamline the interaction with large language models like Claude Code via OpenRouter by accepting user prompts in natural language, processing them through structured mes
Project description
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
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 routerflu-2025.12.21112723.tar.gz.
File metadata
- Download URL: routerflu-2025.12.21112723.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b4e08cad815da587e61752401ac129aa50aaaced48967100b3525877a83e244
|
|
| MD5 |
b86ae082a633649dbe752c2ed29d8670
|
|
| BLAKE2b-256 |
4c41aff7004f3afaec30d733f10b68a14bd5e1cbddcc6e47fa906fc16dbbcfab
|
File details
Details for the file routerflu-2025.12.21112723-py3-none-any.whl.
File metadata
- Download URL: routerflu-2025.12.21112723-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2beec68b21c43acd8bb1bee3d666bbc9cb8fbc6c8330993da55cf719c2815634
|
|
| MD5 |
0f32ccbeb6ae834afd6fb589bf256e5d
|
|
| BLAKE2b-256 |
82424daa07d54ff67783d3bb19e0e8b1df54b2f3a61d189ae89226cf2db5f69e
|