vortexdb 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.
- vortexdb/__init__.py +35 -0
- vortexdb/_grpc_common.py +38 -0
- vortexdb/async_client.py +120 -0
- vortexdb/async_connection.py +41 -0
- vortexdb/client.py +182 -0
- vortexdb/config.py +48 -0
- vortexdb/connection.py +42 -0
- vortexdb/exceptions.py +30 -0
- vortexdb/grpc/__init__.py +1 -0
- vortexdb/grpc/vector_db_pb2.py +65 -0
- vortexdb/grpc/vector_db_pb2_grpc.py +317 -0
- vortexdb/models.py +131 -0
- vortexdb/protoutils.py +64 -0
- vortexdb-0.1.0.dist-info/METADATA +263 -0
- vortexdb-0.1.0.dist-info/RECORD +17 -0
- vortexdb-0.1.0.dist-info/WHEEL +4 -0
- vortexdb-0.1.0.dist-info/licenses/LICENSE +201 -0
vortexdb/__init__.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# vortexdb/__init__.py
|
|
2
|
+
|
|
3
|
+
from vortexdb.client import VortexDB
|
|
4
|
+
from vortexdb.async_client import AsyncVortexDB
|
|
5
|
+
from vortexdb.models import (
|
|
6
|
+
DenseVector,
|
|
7
|
+
Payload,
|
|
8
|
+
Point,
|
|
9
|
+
Similarity,
|
|
10
|
+
)
|
|
11
|
+
from vortexdb.exceptions import (
|
|
12
|
+
VortexDBError,
|
|
13
|
+
AuthenticationError,
|
|
14
|
+
NotFoundError,
|
|
15
|
+
InvalidArgumentError,
|
|
16
|
+
TimeoutError,
|
|
17
|
+
ServiceUnavailableError,
|
|
18
|
+
InternalServerError,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"VortexDB",
|
|
23
|
+
"AsyncVortexDB",
|
|
24
|
+
"DenseVector",
|
|
25
|
+
"Payload",
|
|
26
|
+
"Point",
|
|
27
|
+
"Similarity",
|
|
28
|
+
"VortexDBError",
|
|
29
|
+
"AuthenticationError",
|
|
30
|
+
"NotFoundError",
|
|
31
|
+
"InvalidArgumentError",
|
|
32
|
+
"TimeoutError",
|
|
33
|
+
"ServiceUnavailableError",
|
|
34
|
+
"InternalServerError",
|
|
35
|
+
]
|
vortexdb/_grpc_common.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
import grpc
|
|
4
|
+
|
|
5
|
+
from vortexdb.exceptions import (
|
|
6
|
+
AuthenticationError,
|
|
7
|
+
InternalServerError,
|
|
8
|
+
InvalidArgumentError,
|
|
9
|
+
NotFoundError,
|
|
10
|
+
ServiceUnavailableError,
|
|
11
|
+
TimeoutError,
|
|
12
|
+
VortexDBError,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def build_auth_metadata(api_key: str) -> tuple[tuple[str, str], ...]:
|
|
17
|
+
return (("authorization", f"Bearer {api_key}"),)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def map_grpc_error(error: Any) -> VortexDBError:
|
|
21
|
+
code = error.code()
|
|
22
|
+
|
|
23
|
+
if code == grpc.StatusCode.UNAUTHENTICATED:
|
|
24
|
+
return AuthenticationError(error.details())
|
|
25
|
+
|
|
26
|
+
if code == grpc.StatusCode.NOT_FOUND:
|
|
27
|
+
return NotFoundError(error.details())
|
|
28
|
+
|
|
29
|
+
if code == grpc.StatusCode.INVALID_ARGUMENT:
|
|
30
|
+
return InvalidArgumentError(error.details())
|
|
31
|
+
|
|
32
|
+
if code == grpc.StatusCode.DEADLINE_EXCEEDED:
|
|
33
|
+
return TimeoutError(error.details())
|
|
34
|
+
|
|
35
|
+
if code == grpc.StatusCode.UNAVAILABLE:
|
|
36
|
+
return ServiceUnavailableError(error.details())
|
|
37
|
+
|
|
38
|
+
return InternalServerError(error.details())
|
vortexdb/async_client.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
from vortexdb import protoutils as proto
|
|
4
|
+
from vortexdb.async_connection import AsyncGRPCConnection
|
|
5
|
+
from vortexdb.config import VortexDBConfig
|
|
6
|
+
from vortexdb.models import DenseVector, Payload, Point, Similarity
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AsyncVortexDB:
|
|
10
|
+
"""High-level async Python client for VortexDB."""
|
|
11
|
+
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
*,
|
|
15
|
+
grpc_url: str | None = None,
|
|
16
|
+
api_key: str | None = None,
|
|
17
|
+
timeout: float | None = None,
|
|
18
|
+
):
|
|
19
|
+
# Config order followed - args -> env vars -> defaults
|
|
20
|
+
self._config = VortexDBConfig.from_env(
|
|
21
|
+
grpc_url=grpc_url,
|
|
22
|
+
api_key=api_key,
|
|
23
|
+
timeout=timeout,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
self._conn = AsyncGRPCConnection(self._config)
|
|
27
|
+
|
|
28
|
+
async def insert(self, *, vector: DenseVector, payload: Payload) -> str:
|
|
29
|
+
"""
|
|
30
|
+
Insert a vector with payload.
|
|
31
|
+
Returns: point_id (str)
|
|
32
|
+
"""
|
|
33
|
+
if not isinstance(vector, DenseVector):
|
|
34
|
+
raise TypeError(
|
|
35
|
+
"vector must be a DenseVector. "
|
|
36
|
+
"Use: DenseVector([1.0, 2.0, 3.0])"
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
request = proto.build_insert_request(
|
|
40
|
+
vector=vector,
|
|
41
|
+
payload=payload,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
response = await self._conn.call(
|
|
45
|
+
self._conn.stub.InsertVector,
|
|
46
|
+
request,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
return response.id.value
|
|
50
|
+
|
|
51
|
+
async def get(self, *, point_id: str) -> Point | None:
|
|
52
|
+
"""
|
|
53
|
+
Retrieve a point by ID.
|
|
54
|
+
"""
|
|
55
|
+
request = proto.build_point_id_request(point_id)
|
|
56
|
+
|
|
57
|
+
response = await self._conn.call(
|
|
58
|
+
self._conn.stub.GetPoint,
|
|
59
|
+
request,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
if response is None:
|
|
63
|
+
return None
|
|
64
|
+
|
|
65
|
+
return Point.from_proto(response)
|
|
66
|
+
|
|
67
|
+
async def delete(self, *, point_id: str) -> None:
|
|
68
|
+
"""
|
|
69
|
+
Delete a point by ID.
|
|
70
|
+
"""
|
|
71
|
+
request = proto.build_point_id_request(point_id)
|
|
72
|
+
|
|
73
|
+
await self._conn.call(
|
|
74
|
+
self._conn.stub.DeletePoint,
|
|
75
|
+
request,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
async def search(
|
|
79
|
+
self,
|
|
80
|
+
*,
|
|
81
|
+
vector: DenseVector,
|
|
82
|
+
similarity: Similarity,
|
|
83
|
+
limit: int,
|
|
84
|
+
ef: int | None = None,
|
|
85
|
+
) -> List[str]:
|
|
86
|
+
"""
|
|
87
|
+
Search for nearest neighbors.
|
|
88
|
+
Returns: List of point IDs
|
|
89
|
+
"""
|
|
90
|
+
if not isinstance(vector, DenseVector):
|
|
91
|
+
raise TypeError(
|
|
92
|
+
"vector must be a DenseVector. "
|
|
93
|
+
"Use: DenseVector([1.0, 2.0, 3.0])"
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
request = proto.build_search_request(
|
|
97
|
+
vector=vector,
|
|
98
|
+
similarity=similarity,
|
|
99
|
+
limit=limit,
|
|
100
|
+
ef=ef,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
response = await self._conn.call(
|
|
104
|
+
self._conn.stub.SearchPoints,
|
|
105
|
+
request,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
return [pid.id.value for pid in response.result_point_ids]
|
|
109
|
+
|
|
110
|
+
async def close(self) -> None:
|
|
111
|
+
"""
|
|
112
|
+
Close the async gRPC connection.
|
|
113
|
+
"""
|
|
114
|
+
await self._conn.close()
|
|
115
|
+
|
|
116
|
+
async def __aenter__(self) -> "AsyncVortexDB":
|
|
117
|
+
return self
|
|
118
|
+
|
|
119
|
+
async def __aexit__(self, exc_type, exc, tb) -> None:
|
|
120
|
+
await self.close()
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from typing import Any, Callable
|
|
2
|
+
|
|
3
|
+
import grpc
|
|
4
|
+
|
|
5
|
+
from vortexdb._grpc_common import build_auth_metadata, map_grpc_error
|
|
6
|
+
from vortexdb.config import VortexDBConfig
|
|
7
|
+
from vortexdb.grpc.vector_db_pb2_grpc import VectorDBStub
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class AsyncGRPCConnection:
|
|
11
|
+
"""Async gRPC connection wrapper for VortexDB."""
|
|
12
|
+
|
|
13
|
+
def __init__(self, config: VortexDBConfig):
|
|
14
|
+
self._config = config
|
|
15
|
+
self._channel = grpc.aio.insecure_channel(config.grpc_url)
|
|
16
|
+
self._stub = VectorDBStub(self._channel)
|
|
17
|
+
self._metadata = build_auth_metadata(config.api_key)
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def stub(self) -> VectorDBStub:
|
|
21
|
+
return self._stub
|
|
22
|
+
|
|
23
|
+
async def call(
|
|
24
|
+
self,
|
|
25
|
+
rpc: Callable[..., Any],
|
|
26
|
+
request: Any,
|
|
27
|
+
) -> Any:
|
|
28
|
+
"""Execute an async gRPC call with standard error handling."""
|
|
29
|
+
try:
|
|
30
|
+
return await rpc(
|
|
31
|
+
request,
|
|
32
|
+
timeout=self._config.timeout,
|
|
33
|
+
metadata=self._metadata,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
except grpc.aio.AioRpcError as e:
|
|
37
|
+
raise map_grpc_error(e) from e
|
|
38
|
+
|
|
39
|
+
async def close(self) -> None:
|
|
40
|
+
"""Close the underlying async gRPC channel."""
|
|
41
|
+
await self._channel.close()
|
vortexdb/client.py
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
from typing import List, Sequence
|
|
2
|
+
|
|
3
|
+
from vortexdb.connection import GRPCConnection
|
|
4
|
+
from vortexdb.config import VortexDBConfig
|
|
5
|
+
from vortexdb.models import (
|
|
6
|
+
DenseVector,
|
|
7
|
+
Payload,
|
|
8
|
+
Point,
|
|
9
|
+
Similarity,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
from vortexdb import protoutils as proto
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class VortexDB:
|
|
16
|
+
""" High-level Python client for VortexDB """
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
*,
|
|
21
|
+
grpc_url: str | None = None,
|
|
22
|
+
api_key: str | None = None,
|
|
23
|
+
timeout: float | None = None,
|
|
24
|
+
):
|
|
25
|
+
# Config order followed - args -> env vars -> defaults
|
|
26
|
+
self._config = VortexDBConfig.from_env(
|
|
27
|
+
grpc_url=grpc_url,
|
|
28
|
+
api_key=api_key,
|
|
29
|
+
timeout=timeout,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
self._conn = GRPCConnection(self._config)
|
|
33
|
+
|
|
34
|
+
# The basic operations
|
|
35
|
+
|
|
36
|
+
def insert(self, *, vector: DenseVector, payload: Payload) -> str:
|
|
37
|
+
"""
|
|
38
|
+
Insert a vector with payload.
|
|
39
|
+
Returns: point_id (str)
|
|
40
|
+
"""
|
|
41
|
+
self._validate_dense_vector(vector)
|
|
42
|
+
|
|
43
|
+
request = proto.build_insert_request(
|
|
44
|
+
vector=vector,
|
|
45
|
+
payload=payload,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
response = self._conn.call(
|
|
49
|
+
self._conn.stub.InsertVector,
|
|
50
|
+
request,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
return response.id.value
|
|
54
|
+
|
|
55
|
+
def insert_batch(
|
|
56
|
+
self,
|
|
57
|
+
*,
|
|
58
|
+
points: Sequence[tuple[DenseVector, Payload]],
|
|
59
|
+
) -> List[str]:
|
|
60
|
+
"""
|
|
61
|
+
Insert multiple vectors with payloads.
|
|
62
|
+
Returns: List of point IDs
|
|
63
|
+
"""
|
|
64
|
+
for vector, _ in points:
|
|
65
|
+
self._validate_dense_vector(vector)
|
|
66
|
+
|
|
67
|
+
request = proto.build_batch_insert_request(
|
|
68
|
+
points=list(points),
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
response = self._conn.call(
|
|
72
|
+
self._conn.stub.InsertVectorsBatch,
|
|
73
|
+
request,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
return [pid.id.value for pid in response.ids]
|
|
77
|
+
|
|
78
|
+
def get(self, *, point_id: str) -> Point | None:
|
|
79
|
+
"""
|
|
80
|
+
Retrieve a point by ID.
|
|
81
|
+
"""
|
|
82
|
+
request = proto.build_point_id_request(point_id)
|
|
83
|
+
|
|
84
|
+
response = self._conn.call(
|
|
85
|
+
self._conn.stub.GetPoint,
|
|
86
|
+
request,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
if response is None:
|
|
90
|
+
return None
|
|
91
|
+
|
|
92
|
+
return Point.from_proto(response)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def delete(self, *, point_id: str) -> None:
|
|
96
|
+
"""
|
|
97
|
+
Delete a point by ID.
|
|
98
|
+
"""
|
|
99
|
+
request = proto.build_point_id_request(point_id)
|
|
100
|
+
|
|
101
|
+
self._conn.call(
|
|
102
|
+
self._conn.stub.DeletePoint,
|
|
103
|
+
request,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
def search(
|
|
107
|
+
self,
|
|
108
|
+
*,
|
|
109
|
+
vector: DenseVector,
|
|
110
|
+
similarity: Similarity,
|
|
111
|
+
limit: int,
|
|
112
|
+
ef: int | None = None,
|
|
113
|
+
) -> List[str]:
|
|
114
|
+
"""
|
|
115
|
+
Search for nearest neighbors.
|
|
116
|
+
Returns: List of point IDs
|
|
117
|
+
"""
|
|
118
|
+
self._validate_dense_vector(vector)
|
|
119
|
+
|
|
120
|
+
request = proto.build_search_request(
|
|
121
|
+
vector=vector,
|
|
122
|
+
similarity=similarity,
|
|
123
|
+
limit=limit,
|
|
124
|
+
ef=ef,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
response = self._conn.call(
|
|
128
|
+
self._conn.stub.SearchPoints,
|
|
129
|
+
request,
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
return [pid.id.value for pid in response.result_point_ids]
|
|
133
|
+
|
|
134
|
+
def search_batch(
|
|
135
|
+
self,
|
|
136
|
+
*,
|
|
137
|
+
queries: Sequence[tuple[DenseVector, Similarity, int]],
|
|
138
|
+
ef: int | None = None,
|
|
139
|
+
) -> List[List[str]]:
|
|
140
|
+
"""
|
|
141
|
+
Search nearest neighbors for multiple query vectors.
|
|
142
|
+
Returns: List of result point ID lists
|
|
143
|
+
"""
|
|
144
|
+
for vector, _, _ in queries:
|
|
145
|
+
self._validate_dense_vector(vector)
|
|
146
|
+
|
|
147
|
+
request = proto.build_batch_search_request(
|
|
148
|
+
queries=list(queries),
|
|
149
|
+
ef=ef,
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
response = self._conn.call(
|
|
153
|
+
self._conn.stub.SearchPointsBatch,
|
|
154
|
+
request,
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
return [
|
|
158
|
+
[pid.id.value for pid in result.result_point_ids]
|
|
159
|
+
for result in response.results
|
|
160
|
+
]
|
|
161
|
+
|
|
162
|
+
@staticmethod
|
|
163
|
+
def _validate_dense_vector(vector: DenseVector) -> None:
|
|
164
|
+
if not isinstance(vector, DenseVector):
|
|
165
|
+
raise TypeError(
|
|
166
|
+
"vector must be a DenseVector. "
|
|
167
|
+
"Use: DenseVector([1.0, 2.0, 3.0])"
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
def close(self) -> None:
|
|
171
|
+
"""
|
|
172
|
+
Close the gRPC connection.
|
|
173
|
+
"""
|
|
174
|
+
self._conn.close()
|
|
175
|
+
|
|
176
|
+
# Context Manager
|
|
177
|
+
# Will allow the usage of VortexDB with the 'with' keyword (Example given in examples/context_manager_usage.py)
|
|
178
|
+
def __enter__(self) -> "VortexDB":
|
|
179
|
+
return self
|
|
180
|
+
|
|
181
|
+
def __exit__(self, exc_type, exc, tb) -> None:
|
|
182
|
+
self.close()
|
vortexdb/config.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from vortexdb.exceptions import ConfigurationError
|
|
4
|
+
|
|
5
|
+
DEFAULT_GRPC_HOST = "localhost"
|
|
6
|
+
DEFAULT_GRPC_PORT = 50051
|
|
7
|
+
DEFAULT_TIMEOUT = 5.0
|
|
8
|
+
@dataclass(frozen=True)
|
|
9
|
+
class VortexDBConfig:
|
|
10
|
+
"""Configuration for the VortexDB Python client"""
|
|
11
|
+
|
|
12
|
+
grpc_url: str | None = None
|
|
13
|
+
api_key: str | None = None
|
|
14
|
+
timeout: float = DEFAULT_TIMEOUT
|
|
15
|
+
|
|
16
|
+
@staticmethod
|
|
17
|
+
def from_env(
|
|
18
|
+
*,
|
|
19
|
+
grpc_url: str | None = None,
|
|
20
|
+
api_key: str | None = None,
|
|
21
|
+
timeout: float | None = None,
|
|
22
|
+
) -> "VortexDBConfig":
|
|
23
|
+
""" Load configuration from explicit arguments with environment variable fallback """
|
|
24
|
+
|
|
25
|
+
resolved_grpc_url = (
|
|
26
|
+
grpc_url
|
|
27
|
+
or os.getenv("VORTEXDB_GRPC_URL")
|
|
28
|
+
or f"{DEFAULT_GRPC_HOST}:{DEFAULT_GRPC_PORT}"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
resolved_api_key = api_key or os.getenv("VORTEXDB_API_KEY")
|
|
32
|
+
if not resolved_api_key:
|
|
33
|
+
raise ConfigurationError(
|
|
34
|
+
"VortexDB API key is required. "
|
|
35
|
+
"Provide api_key argument or set VORTEXDB_API_KEY."
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
resolved_timeout = (
|
|
39
|
+
timeout
|
|
40
|
+
if timeout is not None
|
|
41
|
+
else float(os.getenv("VORTEXDB_TIMEOUT", DEFAULT_TIMEOUT))
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
return VortexDBConfig(
|
|
45
|
+
grpc_url=resolved_grpc_url,
|
|
46
|
+
api_key=resolved_api_key,
|
|
47
|
+
timeout=resolved_timeout,
|
|
48
|
+
)
|
vortexdb/connection.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import grpc
|
|
2
|
+
from typing import Any, Callable
|
|
3
|
+
|
|
4
|
+
from vortexdb._grpc_common import build_auth_metadata, map_grpc_error
|
|
5
|
+
from vortexdb.config import VortexDBConfig
|
|
6
|
+
|
|
7
|
+
from vortexdb.grpc.vector_db_pb2_grpc import VectorDBStub
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class GRPCConnection:
|
|
11
|
+
""" gRPC connection wrapper for VortexDB"""
|
|
12
|
+
|
|
13
|
+
def __init__(self, config: VortexDBConfig):
|
|
14
|
+
self._config = config
|
|
15
|
+
self._channel = grpc.insecure_channel(config.grpc_url)
|
|
16
|
+
self._stub = VectorDBStub(self._channel)
|
|
17
|
+
# Because this is required in every request
|
|
18
|
+
self._metadata = build_auth_metadata(config.api_key)
|
|
19
|
+
|
|
20
|
+
@property
|
|
21
|
+
def stub(self) -> VectorDBStub:
|
|
22
|
+
return self._stub
|
|
23
|
+
|
|
24
|
+
def call(
|
|
25
|
+
self,
|
|
26
|
+
rpc: Callable[..., Any],
|
|
27
|
+
request: Any,
|
|
28
|
+
) -> Any:
|
|
29
|
+
""" Execute a gRPC call with standard error handling """
|
|
30
|
+
try:
|
|
31
|
+
return rpc(
|
|
32
|
+
request,
|
|
33
|
+
timeout=self._config.timeout,
|
|
34
|
+
metadata=self._metadata,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
except grpc.RpcError as e:
|
|
38
|
+
raise map_grpc_error(e) from e
|
|
39
|
+
|
|
40
|
+
def close(self) -> None:
|
|
41
|
+
""" Close the underlying gRPC channel """
|
|
42
|
+
self._channel.close()
|
vortexdb/exceptions.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
class VortexDBError(Exception):
|
|
2
|
+
"""Base exception for all VortexDB client errors."""
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class AuthenticationError(VortexDBError):
|
|
6
|
+
"""Authentication failed (invalid or missing API key)"""
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class NotFoundError(VortexDBError):
|
|
10
|
+
"""Could not find requested resource"""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class InvalidArgumentError(VortexDBError):
|
|
14
|
+
"""Invalid input was provided"""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TimeoutError(VortexDBError):
|
|
18
|
+
"""Request timed out while communicating with the server"""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ServiceUnavailableError(VortexDBError):
|
|
22
|
+
"""The server is unavailable or unreachable"""
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class InternalServerError(VortexDBError):
|
|
26
|
+
"""Internal error in the server"""
|
|
27
|
+
|
|
28
|
+
class ConfigurationError(VortexDBError):
|
|
29
|
+
"""Invalid or missing client configuration."""
|
|
30
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# vortexdb/grpc/__init__.py
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# NO CHECKED-IN PROTOBUF GENCODE
|
|
4
|
+
# source: vector-db.proto
|
|
5
|
+
# Protobuf Python Version: 6.33.5
|
|
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
|
+
33,
|
|
16
|
+
5,
|
|
17
|
+
'',
|
|
18
|
+
'vector-db.proto'
|
|
19
|
+
)
|
|
20
|
+
# @@protoc_insertion_point(imports)
|
|
21
|
+
|
|
22
|
+
_sym_db = _symbol_database.Default()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0fvector-db.proto\x12\x08vectordb\x1a\x1bgoogle/protobuf/empty.proto\"\x15\n\x04UUID\x12\r\n\x05value\x18\x01 \x01(\t\"`\n\x13InsertVectorRequest\x12%\n\x06vector\x18\x01 \x01(\x0b\x32\x15.vectordb.DenseVector\x12\"\n\x07payload\x18\x02 \x01(\x0b\x32\x11.vectordb.Payload\"\x81\x01\n\rSearchRequest\x12+\n\x0cquery_vector\x18\x01 \x01(\x0b\x32\x15.vectordb.DenseVector\x12(\n\nsimilarity\x18\x02 \x01(\x0e\x32\x14.vectordb.Similarity\x12\r\n\x05limit\x18\x03 \x01(\x04\x12\n\n\x02\x65\x66\x18\x04 \x01(\x04\"=\n\x0eSearchResponse\x12+\n\x10result_point_ids\x18\x01 \x03(\x0b\x32\x11.vectordb.PointID\"\x1d\n\x0b\x44\x65nseVector\x12\x0e\n\x06values\x18\x01 \x03(\x02\"q\n\x05Point\x12\x1d\n\x02id\x18\x01 \x01(\x0b\x32\x11.vectordb.PointID\x12\"\n\x07payload\x18\x02 \x01(\x0b\x32\x11.vectordb.Payload\x12%\n\x06vector\x18\x03 \x01(\x0b\x32\x15.vectordb.DenseVector\"%\n\x07PointID\x12\x1a\n\x02id\x18\x01 \x01(\x0b\x32\x0e.vectordb.UUID\"G\n\x07Payload\x12+\n\x0c\x63ontent_type\x18\x01 \x01(\x0e\x32\x15.vectordb.ContentType\x12\x0f\n\x07\x63ontent\x18\x02 \x01(\t\"K\n\x19InsertVectorsBatchRequest\x12.\n\x07vectors\x18\x01 \x03(\x0b\x32\x1d.vectordb.InsertVectorRequest\"<\n\x1aInsertVectorsBatchResponse\x12\x1e\n\x03ids\x18\x01 \x03(\x0b\x32\x11.vectordb.PointID\"D\n\x18SearchPointsBatchRequest\x12(\n\x07queries\x18\x01 \x03(\x0b\x32\x17.vectordb.SearchRequest\"F\n\x19SearchPointsBatchResponse\x12)\n\x07results\x18\x01 \x03(\x0b\x32\x18.vectordb.SearchResponse*C\n\nSimilarity\x12\r\n\tEuclidean\x10\x00\x12\r\n\tManhattan\x10\x01\x12\x0b\n\x07Hamming\x10\x02\x12\n\n\x06\x43osine\x10\x03*\"\n\x0b\x43ontentType\x12\t\n\x05Image\x10\x00\x12\x08\n\x04Text\x10\x01\x32\xc4\x03\n\x08VectorDB\x12\x42\n\x0cInsertVector\x12\x1d.vectordb.InsertVectorRequest\x1a\x11.vectordb.PointID\"\x00\x12:\n\x0b\x44\x65letePoint\x12\x11.vectordb.PointID\x1a\x16.google.protobuf.Empty\"\x00\x12\x30\n\x08GetPoint\x12\x11.vectordb.PointID\x1a\x0f.vectordb.Point\"\x00\x12\x43\n\x0cSearchPoints\x12\x17.vectordb.SearchRequest\x1a\x18.vectordb.SearchResponse\"\x00\x12\x61\n\x12InsertVectorsBatch\x12#.vectordb.InsertVectorsBatchRequest\x1a$.vectordb.InsertVectorsBatchResponse\"\x00\x12^\n\x11SearchPointsBatch\x12\".vectordb.SearchPointsBatchRequest\x1a#.vectordb.SearchPointsBatchResponse\"\x00\x62\x06proto3')
|
|
29
|
+
|
|
30
|
+
_globals = globals()
|
|
31
|
+
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
|
32
|
+
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'vector_db_pb2', _globals)
|
|
33
|
+
if not _descriptor._USE_C_DESCRIPTORS:
|
|
34
|
+
DESCRIPTOR._loaded_options = None
|
|
35
|
+
_globals['_SIMILARITY']._serialized_start=913
|
|
36
|
+
_globals['_SIMILARITY']._serialized_end=980
|
|
37
|
+
_globals['_CONTENTTYPE']._serialized_start=982
|
|
38
|
+
_globals['_CONTENTTYPE']._serialized_end=1016
|
|
39
|
+
_globals['_UUID']._serialized_start=58
|
|
40
|
+
_globals['_UUID']._serialized_end=79
|
|
41
|
+
_globals['_INSERTVECTORREQUEST']._serialized_start=81
|
|
42
|
+
_globals['_INSERTVECTORREQUEST']._serialized_end=177
|
|
43
|
+
_globals['_SEARCHREQUEST']._serialized_start=180
|
|
44
|
+
_globals['_SEARCHREQUEST']._serialized_end=309
|
|
45
|
+
_globals['_SEARCHRESPONSE']._serialized_start=311
|
|
46
|
+
_globals['_SEARCHRESPONSE']._serialized_end=372
|
|
47
|
+
_globals['_DENSEVECTOR']._serialized_start=374
|
|
48
|
+
_globals['_DENSEVECTOR']._serialized_end=403
|
|
49
|
+
_globals['_POINT']._serialized_start=405
|
|
50
|
+
_globals['_POINT']._serialized_end=518
|
|
51
|
+
_globals['_POINTID']._serialized_start=520
|
|
52
|
+
_globals['_POINTID']._serialized_end=557
|
|
53
|
+
_globals['_PAYLOAD']._serialized_start=559
|
|
54
|
+
_globals['_PAYLOAD']._serialized_end=630
|
|
55
|
+
_globals['_INSERTVECTORSBATCHREQUEST']._serialized_start=632
|
|
56
|
+
_globals['_INSERTVECTORSBATCHREQUEST']._serialized_end=707
|
|
57
|
+
_globals['_INSERTVECTORSBATCHRESPONSE']._serialized_start=709
|
|
58
|
+
_globals['_INSERTVECTORSBATCHRESPONSE']._serialized_end=769
|
|
59
|
+
_globals['_SEARCHPOINTSBATCHREQUEST']._serialized_start=771
|
|
60
|
+
_globals['_SEARCHPOINTSBATCHREQUEST']._serialized_end=839
|
|
61
|
+
_globals['_SEARCHPOINTSBATCHRESPONSE']._serialized_start=841
|
|
62
|
+
_globals['_SEARCHPOINTSBATCHRESPONSE']._serialized_end=911
|
|
63
|
+
_globals['_VECTORDB']._serialized_start=1019
|
|
64
|
+
_globals['_VECTORDB']._serialized_end=1471
|
|
65
|
+
# @@protoc_insertion_point(module_scope)
|