Coverage for src / lexigram / contracts / data / vector / types.py: 0%
49 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-15 18:57 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-15 18:57 +0800
1"""Vector store value types — all immutable, no implementation."""
3from __future__ import annotations
5from dataclasses import dataclass, field
6from typing import TYPE_CHECKING, Any
8from lexigram.contracts.data.vector.enums import (
9 DistanceMetric,
10 IndexState,
11 IndexType,
12)
14if TYPE_CHECKING:
15 from lexigram.contracts.data.vector.filters import MetadataFilter
18@dataclass(frozen=True, slots=True)
19class VectorRecord:
20 """A stored vector with optional metadata and content."""
22 id: str
23 vector: list[float]
24 metadata: dict[str, Any] = field(default_factory=dict)
25 content: str | None = None
28@dataclass(frozen=True, slots=True)
29class SearchQuery:
30 """Parameters for a similarity search."""
32 vector: list[float]
33 top_k: int = 10
34 filter: MetadataFilter | None = None
35 include_vectors: bool = False
36 include_metadata: bool = True
37 min_score: float | None = None
40@dataclass(frozen=True, slots=True)
41class SearchResult:
42 """A single similarity search result."""
44 id: str
45 score: float
46 metadata: dict[str, Any] = field(default_factory=dict)
47 vector: list[float] | None = None
48 content: str | None = None
51@dataclass(frozen=True, slots=True)
52class CollectionConfig:
53 """Configuration for creating a new vector collection."""
55 name: str
56 dimension: int
57 distance_metric: DistanceMetric = DistanceMetric.COSINE
58 index_type: IndexType = IndexType.HNSW
59 hnsw_m: int = 16
60 hnsw_ef_construction: int = 200
61 metadata_schema: dict[str, str] | None = None
64@dataclass(frozen=True, slots=True)
65class CollectionInfo:
66 """Metadata about an existing collection."""
68 name: str
69 dimension: int
70 distance_metric: DistanceMetric
71 index_type: IndexType
72 vector_count: int
73 state: IndexState
76@dataclass(frozen=True, slots=True)
77class UpsertResult:
78 """Result of a vector upsert operation."""
80 upserted_count: int
83@dataclass(frozen=True, slots=True)
84class DeleteResult:
85 """Result of a vector delete operation."""
87 deleted_count: int
90__all__ = [
91 "CollectionConfig",
92 "CollectionInfo",
93 "DeleteResult",
94 "SearchQuery",
95 "SearchResult",
96 "UpsertResult",
97 "VectorRecord",
98]