Files
zeekay 74110d03f8 chat-rag-api: add Qdrant (hanzoai/vector) backend
Extracted from the deployed chat-rag-api:0.7.8-hanzo image; adds a Qdrant
vector store targeting hanzoai/vector as a drop-in for pgvector.

- app/services/vector_store/qdrant_vector.py: QdrantVector(QdrantVectorStore)
  with the id helpers (get_all_ids/get_filtered_ids/get_documents_by_ids),
  delete-by-file_id, and the route's Mongo-style file_id filter translated to
  native Qdrant filters. file_id stored in payload metadata (unique point ids).
- factory.get_vector_store: mode='qdrant' (lazy import; pg/atlas deploys
  unaffected).
- config: VectorDBType.QDRANT + QDRANT_URL/QDRANT_API_KEY/QDRANT_DISTANCE/
  EMBEDDINGS_DIM(1536) + construction branch.
- health: qdrant_health_check (client.get_collections()).
- requirements: langchain-qdrant==0.2.0, qdrant-client==1.12.1.

Verified: pytest tests/test_qdrant_vector.py (4 tests) against in-memory
Qdrant; factory builds QdrantVector with all route methods present.
2026-06-23 21:47:45 -07:00

45 lines
823 B
Python

# app/models.py
import hashlib
from enum import Enum
from pydantic import BaseModel
from typing import Optional, List
class DocumentResponse(BaseModel):
page_content: str
metadata: dict
class DocumentModel(BaseModel):
page_content: str
metadata: Optional[dict] = {}
def generate_digest(self):
hash_obj = hashlib.md5(self.page_content.encode())
return hash_obj.hexdigest()
class StoreDocument(BaseModel):
filepath: str
filename: str
file_content_type: str
file_id: str
class QueryRequestBody(BaseModel):
query: str
file_id: str
k: int = 4
entity_id: Optional[str] = None
class CleanupMethod(str, Enum):
incremental = "incremental"
full = "full"
class QueryMultipleBody(BaseModel):
query: str
file_ids: List[str]
k: int = 4