polign 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
polign/__init__.py ADDED
@@ -0,0 +1,66 @@
1
+ """polign — Python client for polign_db.
2
+
3
+ HTTP client (zero dependencies):
4
+
5
+ from polign import Client
6
+ c = Client("http://localhost:23000")
7
+
8
+ gRPC client (pip install polign[grpc]):
9
+
10
+ from polign import GrpcClient
11
+ c = GrpcClient("localhost:23001")
12
+
13
+ Both expose the same operations: put, put_many, get, list, delete, search.
14
+ """
15
+
16
+ from .client import Client
17
+ from .errors import (
18
+ AuthenticationError,
19
+ ConflictError,
20
+ ConnectionError,
21
+ InvalidArgumentError,
22
+ NotEnabledError,
23
+ NotFoundError,
24
+ NotOwnerError,
25
+ PermissionDeniedError,
26
+ PolignError,
27
+ RateLimitError,
28
+ ServerError,
29
+ UnavailableError,
30
+ )
31
+ from .types import CollectionBackend, CollectionInfo, Fusion, Hit, Vector, VectorPage
32
+
33
+ __version__ = "0.1.0rc8"
34
+
35
+ __all__ = [
36
+ "Client",
37
+ "GrpcClient",
38
+ "Vector",
39
+ "Hit",
40
+ "Fusion",
41
+ "VectorPage",
42
+ "PolignError",
43
+ "ConnectionError",
44
+ "InvalidArgumentError",
45
+ "NotFoundError",
46
+ "AuthenticationError",
47
+ "PermissionDeniedError",
48
+ "RateLimitError",
49
+ "NotOwnerError",
50
+ "ServerError",
51
+ "ConflictError",
52
+ "NotEnabledError",
53
+ "UnavailableError",
54
+ "CollectionBackend",
55
+ "CollectionInfo",
56
+ "__version__",
57
+ ]
58
+
59
+
60
+ def __getattr__(name):
61
+ # Lazy import so the base package works without grpcio installed.
62
+ if name == "GrpcClient":
63
+ from .grpc_client import GrpcClient
64
+
65
+ return GrpcClient
66
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
polign/_filter.py ADDED
@@ -0,0 +1,161 @@
1
+ """Converts the dict filter language into the wire FilterExpr tree.
2
+
3
+ The gRPC client accepts the same metadata-filter dicts as the HTTP client
4
+ (the syntax of docs/FILTERING.md) and converts them client-side into the
5
+ ``polign.v1.FilterExpr`` proto. The semantics mirror the server's JSON parser
6
+ (internal/filter/json.go): bare values are equality, per-key operator objects
7
+ ($eq, $ne, $in, $gt, $gte, $lt, $lte, $exists) AND together with the four
8
+ range operators merged into one range, and $and/$or/$not compose sub-filters.
9
+
10
+ Only imported by the gRPC transport — needs the ``grpc`` extra for protobuf.
11
+ """
12
+
13
+ from __future__ import annotations
14
+
15
+ from typing import Any, Dict, List, Optional
16
+
17
+ from . import errors
18
+ from ._pb import vectordb_pb2 as pb
19
+
20
+ _RANGE_OPS = {"$gt": "gt", "$gte": "gte", "$lt": "lt", "$lte": "lte"}
21
+
22
+
23
+ def filter_expr_from_dict(obj: Optional[Dict[str, Any]]) -> Optional["pb.FilterExpr"]:
24
+ """Convert a filter dict to a FilterExpr, or None for no filter.
25
+
26
+ Raises :class:`polign.InvalidArgumentError` on a malformed filter, with
27
+ the same messages the server would produce.
28
+ """
29
+ if not obj:
30
+ return None
31
+ if not isinstance(obj, dict):
32
+ raise errors.InvalidArgumentError("filter: not a JSON object")
33
+ return _parse_object(obj)
34
+
35
+
36
+ def _parse_object(obj: Dict[str, Any]) -> Optional["pb.FilterExpr"]:
37
+ exprs: List[pb.FilterExpr] = []
38
+ for key in sorted(obj):
39
+ val = obj[key]
40
+ if key in ("$and", "$or"):
41
+ children = _parse_object_list(key, val)
42
+ junction = pb.FilterJunction(exprs=children)
43
+ if key == "$and":
44
+ exprs.append(pb.FilterExpr(**{"and": junction}))
45
+ else:
46
+ exprs.append(pb.FilterExpr(**{"or": junction}))
47
+ elif key == "$not":
48
+ if not isinstance(val, dict):
49
+ raise errors.InvalidArgumentError("filter: $not takes a filter object")
50
+ child = _parse_object(val)
51
+ if child is None:
52
+ raise errors.InvalidArgumentError(
53
+ "filter: $not takes a non-empty filter object"
54
+ )
55
+ exprs.append(pb.FilterExpr(**{"not": child}))
56
+ elif key.startswith("$"):
57
+ raise errors.InvalidArgumentError(f"filter: unknown operator {key!r}")
58
+ else:
59
+ exprs.append(_parse_field(key, val))
60
+ return _and_collapse(exprs)
61
+
62
+
63
+ def _parse_object_list(op: str, val: Any) -> List["pb.FilterExpr"]:
64
+ if not isinstance(val, list) or not val:
65
+ raise errors.InvalidArgumentError(
66
+ f"filter: {op} takes a non-empty array of filter objects"
67
+ )
68
+ children = []
69
+ for item in val:
70
+ if not isinstance(item, dict):
71
+ raise errors.InvalidArgumentError(
72
+ f"filter: {op} takes a non-empty array of filter objects"
73
+ )
74
+ child = _parse_object(item)
75
+ if child is None:
76
+ raise errors.InvalidArgumentError(f"filter: {op}: empty filter object")
77
+ children.append(child)
78
+ return children
79
+
80
+
81
+ def _parse_field(key: str, val: Any) -> "pb.FilterExpr":
82
+ if isinstance(val, dict):
83
+ return _parse_field_ops(key, val)
84
+ return _cond(pb.FilterCond(key=key, eq=_scalar(key, val)))
85
+
86
+
87
+ def _parse_field_ops(key: str, ops: Dict[str, Any]) -> "pb.FilterExpr":
88
+ if not ops:
89
+ raise errors.InvalidArgumentError(f"filter: key {key!r}: empty operator object")
90
+ exprs: List[pb.FilterExpr] = []
91
+ bounds: Dict[str, str] = {}
92
+ numeric_set = lex_set = False
93
+ for op in sorted(ops):
94
+ val = ops[op]
95
+ if op == "$eq":
96
+ exprs.append(_cond(pb.FilterCond(key=key, eq=_scalar(key, val))))
97
+ elif op == "$ne":
98
+ eq = _cond(pb.FilterCond(key=key, eq=_scalar(key, val)))
99
+ exprs.append(pb.FilterExpr(**{"not": eq}))
100
+ elif op == "$in":
101
+ if not isinstance(val, list):
102
+ raise errors.InvalidArgumentError(f"filter: key {key!r}: $in takes an array")
103
+ values = [_scalar(key, item) for item in val]
104
+ exprs.append(_cond(pb.FilterCond(key=key, **{"in": pb.ValueList(values=values)})))
105
+ elif op in _RANGE_OPS:
106
+ if isinstance(val, str):
107
+ lex_set = True
108
+ elif isinstance(val, (int, float)) and not isinstance(val, bool):
109
+ numeric_set = True
110
+ else:
111
+ raise errors.InvalidArgumentError(
112
+ f"filter: key {key!r}: {op} takes a string or number"
113
+ )
114
+ bounds[_RANGE_OPS[op]] = val if isinstance(val, str) else str(val)
115
+ elif op == "$exists":
116
+ if not isinstance(val, bool):
117
+ raise errors.InvalidArgumentError(
118
+ f"filter: key {key!r}: $exists takes a boolean"
119
+ )
120
+ exprs.append(_cond(pb.FilterCond(key=key, exists=val)))
121
+ else:
122
+ raise errors.InvalidArgumentError(
123
+ f"filter: key {key!r}: unknown operator {op!r}"
124
+ )
125
+ if bounds:
126
+ if numeric_set and lex_set:
127
+ raise errors.InvalidArgumentError(
128
+ f"filter: key {key!r}: range bounds mix numbers and strings"
129
+ )
130
+ rng = pb.FilterRange(numeric=numeric_set, **bounds)
131
+ exprs.append(_cond(pb.FilterCond(key=key, range=rng)))
132
+ collapsed = _and_collapse(exprs)
133
+ assert collapsed is not None # ops was non-empty
134
+ return collapsed
135
+
136
+
137
+ def _and_collapse(exprs: List["pb.FilterExpr"]) -> Optional["pb.FilterExpr"]:
138
+ if not exprs:
139
+ return None
140
+ if len(exprs) == 1:
141
+ return exprs[0]
142
+ return pb.FilterExpr(**{"and": pb.FilterJunction(exprs=exprs)})
143
+
144
+
145
+ def _cond(c: "pb.FilterCond") -> "pb.FilterExpr":
146
+ return pb.FilterExpr(cond=c)
147
+
148
+
149
+ def _scalar(key: str, val: Any) -> str:
150
+ """A scalar's metadata string form: strings as-is, numbers by their
151
+ literal ("0.5"), booleans as "true"/"false" — matching what the HTTP
152
+ client's JSON encoding would send."""
153
+ if isinstance(val, bool): # before int: bool subclasses int
154
+ return "true" if val else "false"
155
+ if isinstance(val, str):
156
+ return val
157
+ if isinstance(val, (int, float)):
158
+ return str(val)
159
+ raise errors.InvalidArgumentError(
160
+ f"filter: key {key!r}: expected a string, number or boolean"
161
+ )
polign/_pb/__init__.py ADDED
File without changes
@@ -0,0 +1,117 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: vectordb.proto
5
+ # Protobuf Python Version: 6.31.1
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 6,
15
+ 31,
16
+ 1,
17
+ '',
18
+ 'vectordb.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+
26
+
27
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0evectordb.proto\x12\tpolign.v1\"t\n\x11\x43ollectionBackend\x12\x0b\n\x03uri\x18\x01 \x01(\t\x12\x10\n\x08role_arn\x18\x02 \x01(\t\x12\x13\n\x0b\x65xternal_id\x18\x03 \x01(\t\x12\x0e\n\x06region\x18\x04 \x01(\t\x12\x1b\n\x13gcs_service_account\x18\x05 \x01(\t\"\xfe\x01\n\x0e\x43ollectionInfo\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06status\x18\x02 \x01(\t\x12-\n\x07\x62\x61\x63kend\x18\x03 \x01(\x0b\x32\x1c.polign.v1.CollectionBackend\x12\x12\n\nbackend_id\x18\x04 \x01(\t\x12\x1d\n\x15verified_capabilities\x18\x05 \x03(\t\x12\x17\n\x0f\x63reated_at_unix\x18\x06 \x01(\x03\x12\x18\n\x10verified_at_unix\x18\x07 \x01(\x03\x12\x13\n\x0b\x63laim_token\x18\x08 \x01(\t\x12\x12\n\nclaim_path\x18\t \x01(\t\x12\x10\n\x08warnings\x18\n \x03(\t\"\\\n\x17\x43reateCollectionRequest\x12\x12\n\ncollection\x18\x01 \x01(\t\x12-\n\x07\x62\x61\x63kend\x18\x02 \x01(\x0b\x32\x1c.polign.v1.CollectionBackend\"C\n\x18\x43reateCollectionResponse\x12\'\n\x04info\x18\x01 \x01(\x0b\x32\x19.polign.v1.CollectionInfo\"*\n\x14GetCollectionRequest\x12\x12\n\ncollection\x18\x01 \x01(\t\"@\n\x15GetCollectionResponse\x12\'\n\x04info\x18\x01 \x01(\x0b\x32\x19.polign.v1.CollectionInfo\"\x18\n\x16ListCollectionsRequest\"I\n\x17ListCollectionsResponse\x12.\n\x0b\x63ollections\x18\x01 \x03(\x0b\x32\x19.polign.v1.CollectionInfo\"-\n\x17\x44\x65leteCollectionRequest\x12\x12\n\ncollection\x18\x01 \x01(\t\"+\n\x18\x44\x65leteCollectionResponse\x12\x0f\n\x07\x64\x65leted\x18\x01 \x01(\x08\"-\n\x17VerifyCollectionRequest\x12\x12\n\ncollection\x18\x01 \x01(\t\"C\n\x18VerifyCollectionResponse\x12\'\n\x04info\x18\x01 \x01(\x0b\x32\x19.polign.v1.CollectionInfo\"\x88\x01\n\x06Vector\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0e\n\x06values\x18\x02 \x03(\x02\x12\x31\n\x08metadata\x18\x03 \x03(\x0b\x32\x1f.polign.v1.Vector.MetadataEntry\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"I\n\x10PutVectorRequest\x12\x12\n\ncollection\x18\x01 \x01(\t\x12!\n\x06vector\x18\x02 \x01(\x0b\x32\x11.polign.v1.Vector\"\x1f\n\x11PutVectorResponse\x12\n\n\x02id\x18\x01 \x01(\t\"K\n\x11PutVectorsRequest\x12\x12\n\ncollection\x18\x01 \x01(\t\x12\"\n\x07vectors\x18\x02 \x03(\x0b\x32\x11.polign.v1.Vector\"!\n\x12PutVectorsResponse\x12\x0b\n\x03ids\x18\x01 \x03(\t\"2\n\x10GetVectorRequest\x12\x12\n\ncollection\x18\x01 \x01(\t\x12\n\n\x02id\x18\x02 \x01(\t\"6\n\x11GetVectorResponse\x12!\n\x06vector\x18\x01 \x01(\x0b\x32\x11.polign.v1.Vector\"4\n\x11GetVectorsRequest\x12\x12\n\ncollection\x18\x01 \x01(\t\x12\x0b\n\x03ids\x18\x02 \x03(\t\"8\n\x12GetVectorsResponse\x12\"\n\x07vectors\x18\x01 \x03(\x0b\x32\x11.polign.v1.Vector\"G\n\x12ListVectorsRequest\x12\x12\n\ncollection\x18\x01 \x01(\t\x12\r\n\x05limit\x18\x02 \x01(\x05\x12\x0e\n\x06offset\x18\x03 \x01(\x05\"H\n\x13ListVectorsResponse\x12\"\n\x07vectors\x18\x01 \x03(\x0b\x32\x11.polign.v1.Vector\x12\r\n\x05total\x18\x02 \x01(\x05\"5\n\x13\x44\x65leteVectorRequest\x12\x12\n\ncollection\x18\x01 \x01(\t\x12\n\n\x02id\x18\x02 \x01(\t\"\'\n\x14\x44\x65leteVectorResponse\x12\x0f\n\x07\x64\x65leted\x18\x01 \x01(\x08\"\xc9\x02\n\x14SearchVectorsRequest\x12\x12\n\ncollection\x18\x01 \x01(\t\x12\x0e\n\x06values\x18\x02 \x03(\x02\x12\t\n\x01k\x18\x03 \x01(\x05\x12\n\n\x02\x65\x66\x18\x04 \x01(\x05\x12\x0c\n\x04\x63old\x18\x05 \x01(\x08\x12\x0e\n\x06nprobe\x18\x06 \x01(\x05\x12;\n\x06\x66ilter\x18\x07 \x03(\x0b\x32+.polign.v1.SearchVectorsRequest.FilterEntry\x12\x0c\n\x04text\x18\x08 \x01(\t\x12!\n\x06\x66usion\x18\t \x01(\x0b\x32\x11.polign.v1.Fusion\x12*\n\x0b\x66ilter_expr\x18\n \x01(\x0b\x32\x15.polign.v1.FilterExpr\x12\x0f\n\x07rescore\x18\x0b \x01(\x05\x1a-\n\x0b\x46ilterEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xb4\x01\n\nFilterExpr\x12(\n\x03\x61nd\x18\x01 \x01(\x0b\x32\x19.polign.v1.FilterJunctionH\x00\x12\'\n\x02or\x18\x02 \x01(\x0b\x32\x19.polign.v1.FilterJunctionH\x00\x12$\n\x03not\x18\x03 \x01(\x0b\x32\x15.polign.v1.FilterExprH\x00\x12%\n\x04\x63ond\x18\x04 \x01(\x0b\x32\x15.polign.v1.FilterCondH\x00\x42\x06\n\x04\x65xpr\"6\n\x0e\x46ilterJunction\x12$\n\x05\x65xprs\x18\x01 \x03(\x0b\x32\x15.polign.v1.FilterExpr\"\x8c\x01\n\nFilterCond\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x0c\n\x02\x65q\x18\x02 \x01(\tH\x00\x12\"\n\x02in\x18\x03 \x01(\x0b\x32\x14.polign.v1.ValueListH\x00\x12\'\n\x05range\x18\x04 \x01(\x0b\x32\x16.polign.v1.FilterRangeH\x00\x12\x10\n\x06\x65xists\x18\x05 \x01(\x08H\x00\x42\x04\n\x02op\"\x1b\n\tValueList\x12\x0e\n\x06values\x18\x01 \x03(\t\"\x82\x01\n\x0b\x46ilterRange\x12\x0f\n\x02gt\x18\x01 \x01(\tH\x00\x88\x01\x01\x12\x10\n\x03gte\x18\x02 \x01(\tH\x01\x88\x01\x01\x12\x0f\n\x02lt\x18\x03 \x01(\tH\x02\x88\x01\x01\x12\x10\n\x03lte\x18\x04 \x01(\tH\x03\x88\x01\x01\x12\x0f\n\x07numeric\x18\x05 \x01(\x08\x42\x05\n\x03_gtB\x06\n\x04_gteB\x05\n\x03_ltB\x06\n\x04_lte\"6\n\x06\x46usion\x12\x0e\n\x06method\x18\x01 \x01(\t\x12\r\n\x05\x61lpha\x18\x02 \x01(\x01\x12\r\n\x05rrf_k\x18\x03 \x01(\x05\"\x9f\x01\n\tSearchHit\x12\n\n\x02id\x18\x01 \x01(\t\x12\x10\n\x08\x64istance\x18\x02 \x01(\x02\x12\x34\n\x08metadata\x18\x03 \x03(\x0b\x32\".polign.v1.SearchHit.MetadataEntry\x12\r\n\x05score\x18\x04 \x01(\x02\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\";\n\x15SearchVectorsResponse\x12\"\n\x04hits\x18\x01 \x03(\x0b\x32\x14.polign.v1.SearchHit2\xe8\x07\n\x08VectorDB\x12\x46\n\tPutVector\x12\x1b.polign.v1.PutVectorRequest\x1a\x1c.polign.v1.PutVectorResponse\x12I\n\nPutVectors\x12\x1c.polign.v1.PutVectorsRequest\x1a\x1d.polign.v1.PutVectorsResponse\x12\x46\n\tGetVector\x12\x1b.polign.v1.GetVectorRequest\x1a\x1c.polign.v1.GetVectorResponse\x12I\n\nGetVectors\x12\x1c.polign.v1.GetVectorsRequest\x1a\x1d.polign.v1.GetVectorsResponse\x12L\n\x0bListVectors\x12\x1d.polign.v1.ListVectorsRequest\x1a\x1e.polign.v1.ListVectorsResponse\x12O\n\x0c\x44\x65leteVector\x12\x1e.polign.v1.DeleteVectorRequest\x1a\x1f.polign.v1.DeleteVectorResponse\x12R\n\rSearchVectors\x12\x1f.polign.v1.SearchVectorsRequest\x1a .polign.v1.SearchVectorsResponse\x12[\n\x10\x43reateCollection\x12\".polign.v1.CreateCollectionRequest\x1a#.polign.v1.CreateCollectionResponse\x12R\n\rGetCollection\x12\x1f.polign.v1.GetCollectionRequest\x1a .polign.v1.GetCollectionResponse\x12X\n\x0fListCollections\x12!.polign.v1.ListCollectionsRequest\x1a\".polign.v1.ListCollectionsResponse\x12[\n\x10\x44\x65leteCollection\x12\".polign.v1.DeleteCollectionRequest\x1a#.polign.v1.DeleteCollectionResponse\x12[\n\x10VerifyCollection\x12\".polign.v1.VerifyCollectionRequest\x1a#.polign.v1.VerifyCollectionResponseB,Z*github.com/Polign/polign_db/internal/pb;pbb\x06proto3')
28
+
29
+ _globals = globals()
30
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
31
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'vectordb_pb2', _globals)
32
+ if not _descriptor._USE_C_DESCRIPTORS:
33
+ _globals['DESCRIPTOR']._loaded_options = None
34
+ _globals['DESCRIPTOR']._serialized_options = b'Z*github.com/Polign/polign_db/internal/pb;pb'
35
+ _globals['_VECTOR_METADATAENTRY']._loaded_options = None
36
+ _globals['_VECTOR_METADATAENTRY']._serialized_options = b'8\001'
37
+ _globals['_SEARCHVECTORSREQUEST_FILTERENTRY']._loaded_options = None
38
+ _globals['_SEARCHVECTORSREQUEST_FILTERENTRY']._serialized_options = b'8\001'
39
+ _globals['_SEARCHHIT_METADATAENTRY']._loaded_options = None
40
+ _globals['_SEARCHHIT_METADATAENTRY']._serialized_options = b'8\001'
41
+ _globals['_COLLECTIONBACKEND']._serialized_start=29
42
+ _globals['_COLLECTIONBACKEND']._serialized_end=145
43
+ _globals['_COLLECTIONINFO']._serialized_start=148
44
+ _globals['_COLLECTIONINFO']._serialized_end=402
45
+ _globals['_CREATECOLLECTIONREQUEST']._serialized_start=404
46
+ _globals['_CREATECOLLECTIONREQUEST']._serialized_end=496
47
+ _globals['_CREATECOLLECTIONRESPONSE']._serialized_start=498
48
+ _globals['_CREATECOLLECTIONRESPONSE']._serialized_end=565
49
+ _globals['_GETCOLLECTIONREQUEST']._serialized_start=567
50
+ _globals['_GETCOLLECTIONREQUEST']._serialized_end=609
51
+ _globals['_GETCOLLECTIONRESPONSE']._serialized_start=611
52
+ _globals['_GETCOLLECTIONRESPONSE']._serialized_end=675
53
+ _globals['_LISTCOLLECTIONSREQUEST']._serialized_start=677
54
+ _globals['_LISTCOLLECTIONSREQUEST']._serialized_end=701
55
+ _globals['_LISTCOLLECTIONSRESPONSE']._serialized_start=703
56
+ _globals['_LISTCOLLECTIONSRESPONSE']._serialized_end=776
57
+ _globals['_DELETECOLLECTIONREQUEST']._serialized_start=778
58
+ _globals['_DELETECOLLECTIONREQUEST']._serialized_end=823
59
+ _globals['_DELETECOLLECTIONRESPONSE']._serialized_start=825
60
+ _globals['_DELETECOLLECTIONRESPONSE']._serialized_end=868
61
+ _globals['_VERIFYCOLLECTIONREQUEST']._serialized_start=870
62
+ _globals['_VERIFYCOLLECTIONREQUEST']._serialized_end=915
63
+ _globals['_VERIFYCOLLECTIONRESPONSE']._serialized_start=917
64
+ _globals['_VERIFYCOLLECTIONRESPONSE']._serialized_end=984
65
+ _globals['_VECTOR']._serialized_start=987
66
+ _globals['_VECTOR']._serialized_end=1123
67
+ _globals['_VECTOR_METADATAENTRY']._serialized_start=1076
68
+ _globals['_VECTOR_METADATAENTRY']._serialized_end=1123
69
+ _globals['_PUTVECTORREQUEST']._serialized_start=1125
70
+ _globals['_PUTVECTORREQUEST']._serialized_end=1198
71
+ _globals['_PUTVECTORRESPONSE']._serialized_start=1200
72
+ _globals['_PUTVECTORRESPONSE']._serialized_end=1231
73
+ _globals['_PUTVECTORSREQUEST']._serialized_start=1233
74
+ _globals['_PUTVECTORSREQUEST']._serialized_end=1308
75
+ _globals['_PUTVECTORSRESPONSE']._serialized_start=1310
76
+ _globals['_PUTVECTORSRESPONSE']._serialized_end=1343
77
+ _globals['_GETVECTORREQUEST']._serialized_start=1345
78
+ _globals['_GETVECTORREQUEST']._serialized_end=1395
79
+ _globals['_GETVECTORRESPONSE']._serialized_start=1397
80
+ _globals['_GETVECTORRESPONSE']._serialized_end=1451
81
+ _globals['_GETVECTORSREQUEST']._serialized_start=1453
82
+ _globals['_GETVECTORSREQUEST']._serialized_end=1505
83
+ _globals['_GETVECTORSRESPONSE']._serialized_start=1507
84
+ _globals['_GETVECTORSRESPONSE']._serialized_end=1563
85
+ _globals['_LISTVECTORSREQUEST']._serialized_start=1565
86
+ _globals['_LISTVECTORSREQUEST']._serialized_end=1636
87
+ _globals['_LISTVECTORSRESPONSE']._serialized_start=1638
88
+ _globals['_LISTVECTORSRESPONSE']._serialized_end=1710
89
+ _globals['_DELETEVECTORREQUEST']._serialized_start=1712
90
+ _globals['_DELETEVECTORREQUEST']._serialized_end=1765
91
+ _globals['_DELETEVECTORRESPONSE']._serialized_start=1767
92
+ _globals['_DELETEVECTORRESPONSE']._serialized_end=1806
93
+ _globals['_SEARCHVECTORSREQUEST']._serialized_start=1809
94
+ _globals['_SEARCHVECTORSREQUEST']._serialized_end=2138
95
+ _globals['_SEARCHVECTORSREQUEST_FILTERENTRY']._serialized_start=2093
96
+ _globals['_SEARCHVECTORSREQUEST_FILTERENTRY']._serialized_end=2138
97
+ _globals['_FILTEREXPR']._serialized_start=2141
98
+ _globals['_FILTEREXPR']._serialized_end=2321
99
+ _globals['_FILTERJUNCTION']._serialized_start=2323
100
+ _globals['_FILTERJUNCTION']._serialized_end=2377
101
+ _globals['_FILTERCOND']._serialized_start=2380
102
+ _globals['_FILTERCOND']._serialized_end=2520
103
+ _globals['_VALUELIST']._serialized_start=2522
104
+ _globals['_VALUELIST']._serialized_end=2549
105
+ _globals['_FILTERRANGE']._serialized_start=2552
106
+ _globals['_FILTERRANGE']._serialized_end=2682
107
+ _globals['_FUSION']._serialized_start=2684
108
+ _globals['_FUSION']._serialized_end=2738
109
+ _globals['_SEARCHHIT']._serialized_start=2741
110
+ _globals['_SEARCHHIT']._serialized_end=2900
111
+ _globals['_SEARCHHIT_METADATAENTRY']._serialized_start=1076
112
+ _globals['_SEARCHHIT_METADATAENTRY']._serialized_end=1123
113
+ _globals['_SEARCHVECTORSRESPONSE']._serialized_start=2902
114
+ _globals['_SEARCHVECTORSRESPONSE']._serialized_end=2961
115
+ _globals['_VECTORDB']._serialized_start=2964
116
+ _globals['_VECTORDB']._serialized_end=3964
117
+ # @@protoc_insertion_point(module_scope)
@@ -0,0 +1,326 @@
1
+ from google.protobuf.internal import containers as _containers
2
+ from google.protobuf import descriptor as _descriptor
3
+ from google.protobuf import message as _message
4
+ from collections.abc import Iterable as _Iterable, Mapping as _Mapping
5
+ from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union
6
+
7
+ DESCRIPTOR: _descriptor.FileDescriptor
8
+
9
+ class CollectionBackend(_message.Message):
10
+ __slots__ = ("uri", "role_arn", "external_id", "region", "gcs_service_account")
11
+ URI_FIELD_NUMBER: _ClassVar[int]
12
+ ROLE_ARN_FIELD_NUMBER: _ClassVar[int]
13
+ EXTERNAL_ID_FIELD_NUMBER: _ClassVar[int]
14
+ REGION_FIELD_NUMBER: _ClassVar[int]
15
+ GCS_SERVICE_ACCOUNT_FIELD_NUMBER: _ClassVar[int]
16
+ uri: str
17
+ role_arn: str
18
+ external_id: str
19
+ region: str
20
+ gcs_service_account: str
21
+ def __init__(self, uri: _Optional[str] = ..., role_arn: _Optional[str] = ..., external_id: _Optional[str] = ..., region: _Optional[str] = ..., gcs_service_account: _Optional[str] = ...) -> None: ...
22
+
23
+ class CollectionInfo(_message.Message):
24
+ __slots__ = ("name", "status", "backend", "backend_id", "verified_capabilities", "created_at_unix", "verified_at_unix", "claim_token", "claim_path", "warnings")
25
+ NAME_FIELD_NUMBER: _ClassVar[int]
26
+ STATUS_FIELD_NUMBER: _ClassVar[int]
27
+ BACKEND_FIELD_NUMBER: _ClassVar[int]
28
+ BACKEND_ID_FIELD_NUMBER: _ClassVar[int]
29
+ VERIFIED_CAPABILITIES_FIELD_NUMBER: _ClassVar[int]
30
+ CREATED_AT_UNIX_FIELD_NUMBER: _ClassVar[int]
31
+ VERIFIED_AT_UNIX_FIELD_NUMBER: _ClassVar[int]
32
+ CLAIM_TOKEN_FIELD_NUMBER: _ClassVar[int]
33
+ CLAIM_PATH_FIELD_NUMBER: _ClassVar[int]
34
+ WARNINGS_FIELD_NUMBER: _ClassVar[int]
35
+ name: str
36
+ status: str
37
+ backend: CollectionBackend
38
+ backend_id: str
39
+ verified_capabilities: _containers.RepeatedScalarFieldContainer[str]
40
+ created_at_unix: int
41
+ verified_at_unix: int
42
+ claim_token: str
43
+ claim_path: str
44
+ warnings: _containers.RepeatedScalarFieldContainer[str]
45
+ def __init__(self, name: _Optional[str] = ..., status: _Optional[str] = ..., backend: _Optional[_Union[CollectionBackend, _Mapping]] = ..., backend_id: _Optional[str] = ..., verified_capabilities: _Optional[_Iterable[str]] = ..., created_at_unix: _Optional[int] = ..., verified_at_unix: _Optional[int] = ..., claim_token: _Optional[str] = ..., claim_path: _Optional[str] = ..., warnings: _Optional[_Iterable[str]] = ...) -> None: ...
46
+
47
+ class CreateCollectionRequest(_message.Message):
48
+ __slots__ = ("collection", "backend")
49
+ COLLECTION_FIELD_NUMBER: _ClassVar[int]
50
+ BACKEND_FIELD_NUMBER: _ClassVar[int]
51
+ collection: str
52
+ backend: CollectionBackend
53
+ def __init__(self, collection: _Optional[str] = ..., backend: _Optional[_Union[CollectionBackend, _Mapping]] = ...) -> None: ...
54
+
55
+ class CreateCollectionResponse(_message.Message):
56
+ __slots__ = ("info",)
57
+ INFO_FIELD_NUMBER: _ClassVar[int]
58
+ info: CollectionInfo
59
+ def __init__(self, info: _Optional[_Union[CollectionInfo, _Mapping]] = ...) -> None: ...
60
+
61
+ class GetCollectionRequest(_message.Message):
62
+ __slots__ = ("collection",)
63
+ COLLECTION_FIELD_NUMBER: _ClassVar[int]
64
+ collection: str
65
+ def __init__(self, collection: _Optional[str] = ...) -> None: ...
66
+
67
+ class GetCollectionResponse(_message.Message):
68
+ __slots__ = ("info",)
69
+ INFO_FIELD_NUMBER: _ClassVar[int]
70
+ info: CollectionInfo
71
+ def __init__(self, info: _Optional[_Union[CollectionInfo, _Mapping]] = ...) -> None: ...
72
+
73
+ class ListCollectionsRequest(_message.Message):
74
+ __slots__ = ()
75
+ def __init__(self) -> None: ...
76
+
77
+ class ListCollectionsResponse(_message.Message):
78
+ __slots__ = ("collections",)
79
+ COLLECTIONS_FIELD_NUMBER: _ClassVar[int]
80
+ collections: _containers.RepeatedCompositeFieldContainer[CollectionInfo]
81
+ def __init__(self, collections: _Optional[_Iterable[_Union[CollectionInfo, _Mapping]]] = ...) -> None: ...
82
+
83
+ class DeleteCollectionRequest(_message.Message):
84
+ __slots__ = ("collection",)
85
+ COLLECTION_FIELD_NUMBER: _ClassVar[int]
86
+ collection: str
87
+ def __init__(self, collection: _Optional[str] = ...) -> None: ...
88
+
89
+ class DeleteCollectionResponse(_message.Message):
90
+ __slots__ = ("deleted",)
91
+ DELETED_FIELD_NUMBER: _ClassVar[int]
92
+ deleted: bool
93
+ def __init__(self, deleted: bool = ...) -> None: ...
94
+
95
+ class VerifyCollectionRequest(_message.Message):
96
+ __slots__ = ("collection",)
97
+ COLLECTION_FIELD_NUMBER: _ClassVar[int]
98
+ collection: str
99
+ def __init__(self, collection: _Optional[str] = ...) -> None: ...
100
+
101
+ class VerifyCollectionResponse(_message.Message):
102
+ __slots__ = ("info",)
103
+ INFO_FIELD_NUMBER: _ClassVar[int]
104
+ info: CollectionInfo
105
+ def __init__(self, info: _Optional[_Union[CollectionInfo, _Mapping]] = ...) -> None: ...
106
+
107
+ class Vector(_message.Message):
108
+ __slots__ = ("id", "values", "metadata")
109
+ class MetadataEntry(_message.Message):
110
+ __slots__ = ("key", "value")
111
+ KEY_FIELD_NUMBER: _ClassVar[int]
112
+ VALUE_FIELD_NUMBER: _ClassVar[int]
113
+ key: str
114
+ value: str
115
+ def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
116
+ ID_FIELD_NUMBER: _ClassVar[int]
117
+ VALUES_FIELD_NUMBER: _ClassVar[int]
118
+ METADATA_FIELD_NUMBER: _ClassVar[int]
119
+ id: str
120
+ values: _containers.RepeatedScalarFieldContainer[float]
121
+ metadata: _containers.ScalarMap[str, str]
122
+ def __init__(self, id: _Optional[str] = ..., values: _Optional[_Iterable[float]] = ..., metadata: _Optional[_Mapping[str, str]] = ...) -> None: ...
123
+
124
+ class PutVectorRequest(_message.Message):
125
+ __slots__ = ("collection", "vector")
126
+ COLLECTION_FIELD_NUMBER: _ClassVar[int]
127
+ VECTOR_FIELD_NUMBER: _ClassVar[int]
128
+ collection: str
129
+ vector: Vector
130
+ def __init__(self, collection: _Optional[str] = ..., vector: _Optional[_Union[Vector, _Mapping]] = ...) -> None: ...
131
+
132
+ class PutVectorResponse(_message.Message):
133
+ __slots__ = ("id",)
134
+ ID_FIELD_NUMBER: _ClassVar[int]
135
+ id: str
136
+ def __init__(self, id: _Optional[str] = ...) -> None: ...
137
+
138
+ class PutVectorsRequest(_message.Message):
139
+ __slots__ = ("collection", "vectors")
140
+ COLLECTION_FIELD_NUMBER: _ClassVar[int]
141
+ VECTORS_FIELD_NUMBER: _ClassVar[int]
142
+ collection: str
143
+ vectors: _containers.RepeatedCompositeFieldContainer[Vector]
144
+ def __init__(self, collection: _Optional[str] = ..., vectors: _Optional[_Iterable[_Union[Vector, _Mapping]]] = ...) -> None: ...
145
+
146
+ class PutVectorsResponse(_message.Message):
147
+ __slots__ = ("ids",)
148
+ IDS_FIELD_NUMBER: _ClassVar[int]
149
+ ids: _containers.RepeatedScalarFieldContainer[str]
150
+ def __init__(self, ids: _Optional[_Iterable[str]] = ...) -> None: ...
151
+
152
+ class GetVectorRequest(_message.Message):
153
+ __slots__ = ("collection", "id")
154
+ COLLECTION_FIELD_NUMBER: _ClassVar[int]
155
+ ID_FIELD_NUMBER: _ClassVar[int]
156
+ collection: str
157
+ id: str
158
+ def __init__(self, collection: _Optional[str] = ..., id: _Optional[str] = ...) -> None: ...
159
+
160
+ class GetVectorResponse(_message.Message):
161
+ __slots__ = ("vector",)
162
+ VECTOR_FIELD_NUMBER: _ClassVar[int]
163
+ vector: Vector
164
+ def __init__(self, vector: _Optional[_Union[Vector, _Mapping]] = ...) -> None: ...
165
+
166
+ class GetVectorsRequest(_message.Message):
167
+ __slots__ = ("collection", "ids")
168
+ COLLECTION_FIELD_NUMBER: _ClassVar[int]
169
+ IDS_FIELD_NUMBER: _ClassVar[int]
170
+ collection: str
171
+ ids: _containers.RepeatedScalarFieldContainer[str]
172
+ def __init__(self, collection: _Optional[str] = ..., ids: _Optional[_Iterable[str]] = ...) -> None: ...
173
+
174
+ class GetVectorsResponse(_message.Message):
175
+ __slots__ = ("vectors",)
176
+ VECTORS_FIELD_NUMBER: _ClassVar[int]
177
+ vectors: _containers.RepeatedCompositeFieldContainer[Vector]
178
+ def __init__(self, vectors: _Optional[_Iterable[_Union[Vector, _Mapping]]] = ...) -> None: ...
179
+
180
+ class ListVectorsRequest(_message.Message):
181
+ __slots__ = ("collection", "limit", "offset")
182
+ COLLECTION_FIELD_NUMBER: _ClassVar[int]
183
+ LIMIT_FIELD_NUMBER: _ClassVar[int]
184
+ OFFSET_FIELD_NUMBER: _ClassVar[int]
185
+ collection: str
186
+ limit: int
187
+ offset: int
188
+ def __init__(self, collection: _Optional[str] = ..., limit: _Optional[int] = ..., offset: _Optional[int] = ...) -> None: ...
189
+
190
+ class ListVectorsResponse(_message.Message):
191
+ __slots__ = ("vectors", "total")
192
+ VECTORS_FIELD_NUMBER: _ClassVar[int]
193
+ TOTAL_FIELD_NUMBER: _ClassVar[int]
194
+ vectors: _containers.RepeatedCompositeFieldContainer[Vector]
195
+ total: int
196
+ def __init__(self, vectors: _Optional[_Iterable[_Union[Vector, _Mapping]]] = ..., total: _Optional[int] = ...) -> None: ...
197
+
198
+ class DeleteVectorRequest(_message.Message):
199
+ __slots__ = ("collection", "id")
200
+ COLLECTION_FIELD_NUMBER: _ClassVar[int]
201
+ ID_FIELD_NUMBER: _ClassVar[int]
202
+ collection: str
203
+ id: str
204
+ def __init__(self, collection: _Optional[str] = ..., id: _Optional[str] = ...) -> None: ...
205
+
206
+ class DeleteVectorResponse(_message.Message):
207
+ __slots__ = ("deleted",)
208
+ DELETED_FIELD_NUMBER: _ClassVar[int]
209
+ deleted: bool
210
+ def __init__(self, deleted: bool = ...) -> None: ...
211
+
212
+ class SearchVectorsRequest(_message.Message):
213
+ __slots__ = ("collection", "values", "k", "ef", "cold", "nprobe", "filter", "text", "fusion", "filter_expr", "rescore")
214
+ class FilterEntry(_message.Message):
215
+ __slots__ = ("key", "value")
216
+ KEY_FIELD_NUMBER: _ClassVar[int]
217
+ VALUE_FIELD_NUMBER: _ClassVar[int]
218
+ key: str
219
+ value: str
220
+ def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
221
+ COLLECTION_FIELD_NUMBER: _ClassVar[int]
222
+ VALUES_FIELD_NUMBER: _ClassVar[int]
223
+ K_FIELD_NUMBER: _ClassVar[int]
224
+ EF_FIELD_NUMBER: _ClassVar[int]
225
+ COLD_FIELD_NUMBER: _ClassVar[int]
226
+ NPROBE_FIELD_NUMBER: _ClassVar[int]
227
+ FILTER_FIELD_NUMBER: _ClassVar[int]
228
+ TEXT_FIELD_NUMBER: _ClassVar[int]
229
+ FUSION_FIELD_NUMBER: _ClassVar[int]
230
+ FILTER_EXPR_FIELD_NUMBER: _ClassVar[int]
231
+ RESCORE_FIELD_NUMBER: _ClassVar[int]
232
+ collection: str
233
+ values: _containers.RepeatedScalarFieldContainer[float]
234
+ k: int
235
+ ef: int
236
+ cold: bool
237
+ nprobe: int
238
+ filter: _containers.ScalarMap[str, str]
239
+ text: str
240
+ fusion: Fusion
241
+ filter_expr: FilterExpr
242
+ rescore: int
243
+ def __init__(self, collection: _Optional[str] = ..., values: _Optional[_Iterable[float]] = ..., k: _Optional[int] = ..., ef: _Optional[int] = ..., cold: bool = ..., nprobe: _Optional[int] = ..., filter: _Optional[_Mapping[str, str]] = ..., text: _Optional[str] = ..., fusion: _Optional[_Union[Fusion, _Mapping]] = ..., filter_expr: _Optional[_Union[FilterExpr, _Mapping]] = ..., rescore: _Optional[int] = ...) -> None: ...
244
+
245
+ class FilterExpr(_message.Message):
246
+ __slots__ = ("cond",)
247
+ AND_FIELD_NUMBER: _ClassVar[int]
248
+ OR_FIELD_NUMBER: _ClassVar[int]
249
+ NOT_FIELD_NUMBER: _ClassVar[int]
250
+ COND_FIELD_NUMBER: _ClassVar[int]
251
+ cond: FilterCond
252
+ def __init__(self, cond: _Optional[_Union[FilterCond, _Mapping]] = ..., **kwargs) -> None: ...
253
+
254
+ class FilterJunction(_message.Message):
255
+ __slots__ = ("exprs",)
256
+ EXPRS_FIELD_NUMBER: _ClassVar[int]
257
+ exprs: _containers.RepeatedCompositeFieldContainer[FilterExpr]
258
+ def __init__(self, exprs: _Optional[_Iterable[_Union[FilterExpr, _Mapping]]] = ...) -> None: ...
259
+
260
+ class FilterCond(_message.Message):
261
+ __slots__ = ("key", "eq", "range", "exists")
262
+ KEY_FIELD_NUMBER: _ClassVar[int]
263
+ EQ_FIELD_NUMBER: _ClassVar[int]
264
+ IN_FIELD_NUMBER: _ClassVar[int]
265
+ RANGE_FIELD_NUMBER: _ClassVar[int]
266
+ EXISTS_FIELD_NUMBER: _ClassVar[int]
267
+ key: str
268
+ eq: str
269
+ range: FilterRange
270
+ exists: bool
271
+ def __init__(self, key: _Optional[str] = ..., eq: _Optional[str] = ..., range: _Optional[_Union[FilterRange, _Mapping]] = ..., exists: bool = ..., **kwargs) -> None: ...
272
+
273
+ class ValueList(_message.Message):
274
+ __slots__ = ("values",)
275
+ VALUES_FIELD_NUMBER: _ClassVar[int]
276
+ values: _containers.RepeatedScalarFieldContainer[str]
277
+ def __init__(self, values: _Optional[_Iterable[str]] = ...) -> None: ...
278
+
279
+ class FilterRange(_message.Message):
280
+ __slots__ = ("gt", "gte", "lt", "lte", "numeric")
281
+ GT_FIELD_NUMBER: _ClassVar[int]
282
+ GTE_FIELD_NUMBER: _ClassVar[int]
283
+ LT_FIELD_NUMBER: _ClassVar[int]
284
+ LTE_FIELD_NUMBER: _ClassVar[int]
285
+ NUMERIC_FIELD_NUMBER: _ClassVar[int]
286
+ gt: str
287
+ gte: str
288
+ lt: str
289
+ lte: str
290
+ numeric: bool
291
+ def __init__(self, gt: _Optional[str] = ..., gte: _Optional[str] = ..., lt: _Optional[str] = ..., lte: _Optional[str] = ..., numeric: bool = ...) -> None: ...
292
+
293
+ class Fusion(_message.Message):
294
+ __slots__ = ("method", "alpha", "rrf_k")
295
+ METHOD_FIELD_NUMBER: _ClassVar[int]
296
+ ALPHA_FIELD_NUMBER: _ClassVar[int]
297
+ RRF_K_FIELD_NUMBER: _ClassVar[int]
298
+ method: str
299
+ alpha: float
300
+ rrf_k: int
301
+ def __init__(self, method: _Optional[str] = ..., alpha: _Optional[float] = ..., rrf_k: _Optional[int] = ...) -> None: ...
302
+
303
+ class SearchHit(_message.Message):
304
+ __slots__ = ("id", "distance", "metadata", "score")
305
+ class MetadataEntry(_message.Message):
306
+ __slots__ = ("key", "value")
307
+ KEY_FIELD_NUMBER: _ClassVar[int]
308
+ VALUE_FIELD_NUMBER: _ClassVar[int]
309
+ key: str
310
+ value: str
311
+ def __init__(self, key: _Optional[str] = ..., value: _Optional[str] = ...) -> None: ...
312
+ ID_FIELD_NUMBER: _ClassVar[int]
313
+ DISTANCE_FIELD_NUMBER: _ClassVar[int]
314
+ METADATA_FIELD_NUMBER: _ClassVar[int]
315
+ SCORE_FIELD_NUMBER: _ClassVar[int]
316
+ id: str
317
+ distance: float
318
+ metadata: _containers.ScalarMap[str, str]
319
+ score: float
320
+ def __init__(self, id: _Optional[str] = ..., distance: _Optional[float] = ..., metadata: _Optional[_Mapping[str, str]] = ..., score: _Optional[float] = ...) -> None: ...
321
+
322
+ class SearchVectorsResponse(_message.Message):
323
+ __slots__ = ("hits",)
324
+ HITS_FIELD_NUMBER: _ClassVar[int]
325
+ hits: _containers.RepeatedCompositeFieldContainer[SearchHit]
326
+ def __init__(self, hits: _Optional[_Iterable[_Union[SearchHit, _Mapping]]] = ...) -> None: ...