feat: add qdrant vector adapter
This commit is contained in:
@@ -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."""
|
||||
|
||||
@@ -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", ""),
|
||||
|
||||
Reference in New Issue
Block a user