Shared core for provider-agnostic LLM support and configuration mapping for qdrant-loader ecosystem
Project description
QDrant Loader Core
Shared core library for the QDrant Loader ecosystem. It provides a provider‑agnostic LLM layer (embeddings and chat), configuration mapping, safe logging, and normalized error handling used by the CLI and MCP Server packages.
🚀 What It Provides
- Provider‑agnostic LLM facade: OpenAI, Azure OpenAI, OpenAI‑compatible, and Ollama
- Unified async APIs:
EmbeddingsClient.embed(inputs: list[str]) -> list[list[float]]ChatClient.chat(messages: list[dict], **kwargs) -> dictTokenCounter.count(text: str) -> int
- Typed settings and mapping:
LLMSettings.from_global_config(...)supports the newglobal.llmschema and maps legacy fields with deprecation warnings - Structured logging with redaction:
LoggingConfig.setup(...)masks secrets and reduces noisy logs - Normalized errors: consistent exceptions across providers (
TimeoutError,RateLimitedError,InvalidRequestError,AuthError,ServerError) - Optional dependencies via extras:
openai,ollama
📦 Installation
# Minimal core
pip install qdrant-loader-core
# With OpenAI/Azure OpenAI support
pip install "qdrant-loader-core[openai]"
# With Ollama support
pip install "qdrant-loader-core[ollama]"
# From source (development)
git clone https://github.com/martin-papy/qdrant-loader.git
cd qdrant-loader
pip install -e packages/qdrant-loader-core
⚡ Quick Start
Example using the new global.llm schema:
global:
llm:
provider: "openai" # openai | azure_openai | ollama | openai_compat
base_url: "https://api.openai.com/v1"
api_key: "${OPENAI_API_KEY}"
models:
embeddings: "text-embedding-3-small"
chat: "gpt-4o-mini"
import asyncio
from qdrant_loader_core.llm.settings import LLMSettings
from qdrant_loader_core.llm.factory import create_provider
global_config = {
"llm": {
"provider": "openai",
"base_url": "https://api.openai.com/v1",
"api_key": "${OPENAI_API_KEY}",
"models": {"embeddings": "text-embedding-3-small", "chat": "gpt-4o-mini"},
}
}
settings = LLMSettings.from_global_config(global_config)
provider = create_provider(settings)
async def main() -> None:
vectors = await provider.embeddings().embed(["hello", "world"]) # list[list[float]]
reply = await provider.chat().chat([
{"role": "system", "content": "You are helpful."},
{"role": "user", "content": "Say hi!"},
])
print(len(vectors), reply["text"]) # 2 "Hi!" (example)
asyncio.run(main())
🔌 Supported Providers
- OpenAI (
[openai]extra): Uses the officialopenaiPython SDK. Configure withbase_url,api_key, andmodels.chat/models.embeddings. - Azure OpenAI (
[openai]extra): Requiresapi_version. Auto‑detected when the host is*.openai.azure.comor*.cognitiveservices.azure.com. Optionalprovider_options.azure_endpointoverrides the endpoint. - OpenAI‑compatible (
[openai]extra): Any endpoint exposing OpenAI‑style/v1APIs. Setprovider: openai_compat(or rely onbase_urlcontainingopenai). - Ollama (
[ollama]extra): Works with native/apiand OpenAI‑compatible/v1endpoints. Optionalprovider_options.native_endpoint: auto | embed | embeddingsselects native behavior.
🔧 Configuration Mapping
LLMSettings.from_global_config(...) accepts a parsed dict for global and supports:
-
New schema (recommended):
global.llmprovider,base_url,api_key,api_version(Azure),headersmodels:{ embeddings, chat }tokenizerrequest:{ timeout_s, max_retries, backoff_s_min, backoff_s_max }rate_limits:{ rpm, tpm, concurrency }embeddings:{ vector_size }provider_options: provider‑specific opts (e.g.,azure_endpoint,native_endpoint)
-
Legacy mapping (deprecated):
global.embedding.*andfile_conversion.markitdown.llm_model- Maps to provider + models (embeddings/chat), emits a deprecation warning
- Prefer migrating to
global.llmfor clarity and future features
🧾 Logging
Use the built‑in structured logging with redaction:
from qdrant_loader_core.logging import LoggingConfig
LoggingConfig.setup(level="INFO", format="console", file=None)
logger = LoggingConfig.get_logger(__name__)
logger.info("LLM ready", provider=settings.provider)
Notes
- Secrets (keys/tokens) are masked in both stdlib and structlog output
- Noisy third‑party logs are toned down; Qdrant version checks are filtered
- For MCP integration, set
MCP_DISABLE_CONSOLE_LOGGING=trueto disable console output
🧰 Error Handling
Catch provider‑normalized exceptions from qdrant_loader_core.llm.errors:
TimeoutError— request timed outRateLimitedError— rate limit exceededInvalidRequestError— bad parameters or unsupported operationAuthError— authentication/authorization failedServerError— transport/server failures
📚 Documentation
- Website — Project site and guides
- Core package docs — Package‑specific page
- Monorepo docs — Source documentation in this repository
🤝 Contributing
This package is part of the QDrant Loader monorepo. See the main contributing guide.
🆘 Support
- Issues: https://github.com/martin-papy/qdrant-loader/issues
- Discussions: https://github.com/martin-papy/qdrant-loader/discussions
📄 License
Licensed under the GNU GPLv3 — see LICENSE.
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 qdrant_loader_core-0.7.2.tar.gz.
File metadata
- Download URL: qdrant_loader_core-0.7.2.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b5fe99c41c275a3a1cf645872f075f4cc82b544d4991c95edce3b3fb5e63ab1
|
|
| MD5 |
0a49096a51f3fea0f16e86b5dde15c50
|
|
| BLAKE2b-256 |
3a6aca437e287234b456480beb3def290dc99e5c83c668da4c9c2b50fbc916a6
|
Provenance
The following attestation bundles were made for qdrant_loader_core-0.7.2.tar.gz:
Publisher:
publish.yml on martin-papy/qdrant-loader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qdrant_loader_core-0.7.2.tar.gz -
Subject digest:
4b5fe99c41c275a3a1cf645872f075f4cc82b544d4991c95edce3b3fb5e63ab1 - Sigstore transparency entry: 473253862
- Sigstore integration time:
-
Permalink:
martin-papy/qdrant-loader@8dd73cd68fc176f8b6b8524f1d224031cd34d6b4 -
Branch / Tag:
refs/tags/qdrant-loader-core-v0.7.2 - Owner: https://github.com/martin-papy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8dd73cd68fc176f8b6b8524f1d224031cd34d6b4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file qdrant_loader_core-0.7.2-py3-none-any.whl.
File metadata
- Download URL: qdrant_loader_core-0.7.2-py3-none-any.whl
- Upload date:
- Size: 19.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f49d4a7705620cc758be5ffe07bdd57b8dd9337c10776c7ccd0774d7f909d422
|
|
| MD5 |
62407bf50ac82a7637da9524bd5cd4d8
|
|
| BLAKE2b-256 |
2a053e4a0111867e2085faaf28ce6dea2887b5548f11de7296f52b2466a403cb
|
Provenance
The following attestation bundles were made for qdrant_loader_core-0.7.2-py3-none-any.whl:
Publisher:
publish.yml on martin-papy/qdrant-loader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
qdrant_loader_core-0.7.2-py3-none-any.whl -
Subject digest:
f49d4a7705620cc758be5ffe07bdd57b8dd9337c10776c7ccd0774d7f909d422 - Sigstore transparency entry: 473253864
- Sigstore integration time:
-
Permalink:
martin-papy/qdrant-loader@8dd73cd68fc176f8b6b8524f1d224031cd34d6b4 -
Branch / Tag:
refs/tags/qdrant-loader-core-v0.7.2 - Owner: https://github.com/martin-papy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8dd73cd68fc176f8b6b8524f1d224031cd34d6b4 -
Trigger Event:
release
-
Statement type: