structquery
structquery is a lightweight Python package that converts unstructured text queries into highly structured, search‑optimized outputs. By leveraging the llmatch‑messages utility and a default LLM7 model, the package extracts key elements from user input (e.g., location, difficulty, length) and returns them in a format that is ready for downstream search engines or information‑retrieval pipelines.
✨ Features
- One‑line transformation from free‑form text to a list of structured fields.
- Built‑in LLM7 support (
ChatLLM7fromlangchain_llm7) with automatic API‑key handling. - Pluggable LLMs – you can swap in any LangChain‑compatible chat model (OpenAI, Anthropic, Google, etc.).
- Regex‑driven output validation via
llmatchto guarantee format correctness. - Zero‑config defaults – works out‑of‑the‑box for common use‑cases.
📦 Installation
pip install structquery
🚀 Quick Start
from structquery import structquery
# Simple call – uses the default ChatLLM7 model
response = structquery(
user_input="best hiking trails in Colorado"
)
print(response) # → List of extracted structured strings
Parameters
| Name | Type | Description |
|---|---|---|
user_input |
str |
The raw user query or description you want to structure. |
llm |
Optional[BaseChatModel] |
Your own LangChain chat model. If omitted, the package creates a ChatLLM7 instance automatically. |
api_key |
Optional[str] |
LLM7 API key. If omitted, the package reads LLM7_API_KEY from the environment; otherwise it falls back to the placeholder "None" (which triggers an error from the LLM service). |
🔧 Using a Custom LLM
You can provide any LangChain‑compatible chat model that inherits from BaseChatModel. Below are examples for the most popular providers.
OpenAI
from langchain_openai import ChatOpenAI
from structquery import structquery
llm = ChatOpenAI(model="gpt-4o-mini")
response = structquery(
user_input="latest smartphones under $500",
llm=llm
)
Anthropic
from langchain_anthropic import ChatAnthropic
from structquery import structquery
llm = ChatAnthropic(model_name="claude-3-haiku-20240307")
response = structquery(
user_input="affordable vegan meal plan",
llm=llm
)
Google Generative AI
from langchain_google_genai import ChatGoogleGenerativeAI
from structquery import structquery
llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash")
response = structquery(
user_input="top-rated bike touring routes in Europe",
llm=llm
)
🔑 LLM7 API Key
- The free tier of LLM7 supplies generous rate limits that satisfy most experimentation and production needs.
- To obtain a free API key, register at https://token.llm7.io/.
- You can provide the key in three ways:
- Environment variable:
export LLM7_API_KEY=your_key - Direct argument:
structquery(user_input, api_key="your_key") - Pass a pre‑configured
ChatLLM7instance via thellmargument.
- Environment variable:
🐞 Issues & Contributions
- Bug reports / feature requests: https://github.com/chigwell/structquery/issues
- Contributions are welcome! Fork the repository, make your changes, and submit a pull request.
📝 License
Distributed under the MIT License. See the LICENSE file for details.
📧 Contact
Eugene Evstafev – hi@euegne.plus
GitHub: https://github.com/chigwell
Metadata
Release files for structquery 2025.12.21164456
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 |
|---|---|---|---|---|
| structquery-2025.12.21164456.tar.gz | 4.6 kB | Without provenance | Details for structquery-2025.12.21164456.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| structquery-2025.12.21164456-py3-none-any.whl | Python 3 | none | any | Details for structquery-2025.12.21164456-py3-none-any.whl |
Total release size: 9.8 kB
Release files / structquery-2025.12.21164456.tar.gz
| Download URL | structquery-2025.12.21164456.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f9242017715f27813c7cd393bed3738ac1aea2dc36965d5b2e90a944db00103e
|
|
BLAKE2b-256 checksum How to use checksums |
ea051000a3d151802b712ac8d110bc60b80cd112b25389e7ebd376c561b6af10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Release files / structquery-2025.12.21164456-py3-none-any.whl
| Download URL | structquery-2025.12.21164456-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6264d0db5fb0e310757d4950f97f3a2c3c9e96290271a4f7f3def5be35f493e3
|
|
BLAKE2b-256 checksum How to use checksums |
31a9d41e6942297f0c49c9593f1a3ac21c7090bde372e6f52e08dc692eb26e3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.1
|
Security for structquery 2025.12.21164456
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.