Dateien nach "scripts" hochladen
All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 2s
All checks were successful
Deploy mindnet to llm-node / deploy (push) Successful in 2s
This commit is contained in:
parent
0ca54f429e
commit
c487db6534
|
|
@ -2,13 +2,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Script: scripts/import_markdown.py — Markdown → Qdrant (Notes, Chunks, Edges)
|
||||
Version: 3.8.2
|
||||
Version: 3.8.3
|
||||
Datum: 2025-11-08
|
||||
|
||||
Änderungen gegenüber 3.8.1
|
||||
Änderungen gegenüber 3.8.2
|
||||
--------------------------
|
||||
- Behebt IndentationError bei der vorherigen Patch-Einfügung.
|
||||
- Konsolidiert alle Abwärtskompatibilitäten (Qdrant-Indices, qdrant_points, dim-Ermittlung).
|
||||
- Ruft **ensure_collections nie direkt** auf, sondern ausschließlich über
|
||||
`_ensure_collections_compat(client, cfg, dim)`.
|
||||
- Payload-Index-Erzeugung ausschließlich via `_ensure_payload_indexes_compat(client, cfg)`.
|
||||
- Keine Annahmen über Signaturen im Projektstand; alle Varianten sind abgefedert.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
|
|
@ -38,7 +40,7 @@ except Exception: # pragma: no cover
|
|||
from app.core.qdrant import (
|
||||
QdrantConfig,
|
||||
get_client,
|
||||
ensure_collections,
|
||||
ensure_collections, # nur für Wrapper, unten niemals direkt aufrufen!
|
||||
)
|
||||
|
||||
# Abwärtskompatibler Import für Payload-Index-Erzeugung
|
||||
|
|
@ -122,51 +124,6 @@ except Exception:
|
|||
# Helper
|
||||
# ---------------------------------------------------------------------
|
||||
|
||||
# Compatibility wrappers for legacy qdrant helpers
|
||||
def _ensure_collections_compat(client, cfg, dim):
|
||||
"""
|
||||
Call ensure_collections with the correct signature across releases:
|
||||
- preferred: ensure_collections(client, cfg)
|
||||
- fallbacks: (client, cfg.prefix, dim) -> (client, cfg.prefix) -> (client)
|
||||
"""
|
||||
try:
|
||||
return ensure_collections(client, cfg)
|
||||
except TypeError:
|
||||
pass
|
||||
try:
|
||||
return ensure_collections(client, cfg.prefix, dim)
|
||||
except TypeError:
|
||||
pass
|
||||
try:
|
||||
return ensure_collections(client, cfg.prefix)
|
||||
except TypeError:
|
||||
pass
|
||||
try:
|
||||
return ensure_collections(client)
|
||||
except TypeError:
|
||||
pass
|
||||
# If everything fails, do nothing
|
||||
return None
|
||||
|
||||
def _ensure_payload_indexes_compat(client, cfg):
|
||||
"""
|
||||
Try calling payload index creation with cfg, then prefix; ignore if unsupported.
|
||||
"""
|
||||
try:
|
||||
_ensure_payload_indexes(client, cfg)
|
||||
return
|
||||
except TypeError:
|
||||
pass
|
||||
try:
|
||||
_ensure_payload_indexes(client, cfg.prefix)
|
||||
return
|
||||
except TypeError:
|
||||
pass
|
||||
except AttributeError:
|
||||
pass
|
||||
# final no-op
|
||||
return
|
||||
|
||||
def iter_md(root: str) -> List[str]:
|
||||
out: List[str] = []
|
||||
for dirpath, _, filenames in os.walk(root):
|
||||
|
|
@ -286,6 +243,54 @@ def _resolve_dim(cfg) -> int:
|
|||
return 384
|
||||
|
||||
|
||||
# ---- Compatibility wrappers (no direct calls to project-specific signatures) ----
|
||||
def _ensure_collections_compat(client, cfg, dim):
|
||||
"""
|
||||
Call ensure_collections with the correct signature across releases:
|
||||
- preferred: ensure_collections(client, cfg)
|
||||
- fallbacks: (client, cfg.prefix, dim) -> (client, cfg.prefix) -> (client)
|
||||
"""
|
||||
try:
|
||||
return ensure_collections(client, cfg)
|
||||
except TypeError:
|
||||
pass
|
||||
try:
|
||||
return ensure_collections(client, cfg.prefix, dim)
|
||||
except TypeError:
|
||||
pass
|
||||
try:
|
||||
return ensure_collections(client, cfg.prefix)
|
||||
except TypeError:
|
||||
pass
|
||||
try:
|
||||
return ensure_collections(client)
|
||||
except TypeError:
|
||||
pass
|
||||
# If everything fails, do nothing
|
||||
return None
|
||||
|
||||
def _ensure_payload_indexes_compat(client, cfg):
|
||||
"""
|
||||
Try calling payload index creation with cfg, then prefix; ignore if unsupported.
|
||||
"""
|
||||
try:
|
||||
_ensure_payload_indexes(client, cfg)
|
||||
return
|
||||
except TypeError:
|
||||
pass
|
||||
except AttributeError:
|
||||
pass
|
||||
try:
|
||||
_ensure_payload_indexes(client, getattr(cfg, "prefix", None))
|
||||
return
|
||||
except TypeError:
|
||||
pass
|
||||
except AttributeError:
|
||||
pass
|
||||
# final no-op
|
||||
return
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Main
|
||||
# ---------------------------------------------------------------------
|
||||
|
|
@ -332,16 +337,10 @@ def main() -> None:
|
|||
cfg.prefix = args.prefix.strip()
|
||||
client = get_client(cfg)
|
||||
dim = _resolve_dim(cfg)
|
||||
# ensure_collections signature compatibility
|
||||
try:
|
||||
ensure_collections(client, cfg.prefix, dim)
|
||||
except TypeError:
|
||||
try:
|
||||
ensure_collections(client, cfg.prefix)
|
||||
except TypeError:
|
||||
ensure_collections(client)
|
||||
# abwärtskompatible Index-Erstellung
|
||||
_ensure_payload_indexes(client, cfg.prefix)
|
||||
|
||||
# Collections & Indexe (nur über Wrapper)
|
||||
_ensure_collections_compat(client, cfg, dim)
|
||||
_ensure_payload_indexes_compat(client, cfg)
|
||||
|
||||
# Type-Registry laden (optional)
|
||||
reg = None
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user