feat: add qdrant vector adapter

This commit is contained in:
2026-08-08 17:43:15 +02:00
parent c875fa52ce
commit 7109ee15c4
8 changed files with 830 additions and 6 deletions
+25
View File
@@ -17,6 +17,31 @@ class VectorRecord(BaseModel):
metadata: dict = {}
def qdrant_semantic_kind(kind: str) -> str:
if kind in {"schema_table", "schema_column"}:
return "schema"
if kind in {"memory", "solved_question"}:
return "memory"
if kind == "evidence":
return "evidence"
raise ValueError(f"Unsupported vector kind: {kind}")
def qdrant_payload(record: VectorRecord, *, content_hash: str, workspace_id: str) -> dict:
semantic_kind = qdrant_semantic_kind(record.kind)
return {
"workspace_id": workspace_id,
"kind": semantic_kind,
"record_kind": record.kind,
"record_key": record.id,
"ref": record.ref,
"title": record.title,
"content": record.content,
"content_hash": content_hash,
**record.metadata,
}
def split_markdown(text: str, max_chars: int) -> list[str]:
"""Spezza un markdown: intero se sta nel limite, altrimenti per heading '##',
e in ultima istanza per accumulo greedy di righe."""
+1 -1
View File
@@ -42,7 +42,7 @@ def hit_from_metadata(similarity: float, metadata: dict | None) -> VectorHit:
md = metadata or {}
return VectorHit(
id=md.get("record_key", ""),
kind=md.get("kind", ""),
kind=md.get("record_kind", md.get("kind", "")),
ref=md.get("ref", ""),
title=md.get("title", ""),
content=md.get("content", ""),