sf-vector-sdk 0.2.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.
- sf_vector_sdk-0.2.0.dist-info/METADATA +476 -0
- sf_vector_sdk-0.2.0.dist-info/RECORD +27 -0
- sf_vector_sdk-0.2.0.dist-info/WHEEL +4 -0
- vector_sdk/__init__.py +262 -0
- vector_sdk/client.py +538 -0
- vector_sdk/content_types.py +233 -0
- vector_sdk/generated/embedding_pipeline/content_types/v1/content_types_pb2.py +57 -0
- vector_sdk/generated/embedding_pipeline/content_types/v1/content_types_pb2.pyi +141 -0
- vector_sdk/generated/embedding_pipeline/db/vectors/v1/vectors_pb2.py +58 -0
- vector_sdk/generated/embedding_pipeline/db/vectors/v1/vectors_pb2.pyi +145 -0
- vector_sdk/generated/embedding_pipeline/query/v1/query_pb2.py +58 -0
- vector_sdk/generated/embedding_pipeline/query/v1/query_pb2.pyi +109 -0
- vector_sdk/generated/embedding_pipeline/tools/v1/tools_pb2.py +39 -0
- vector_sdk/generated/embedding_pipeline/tools/v1/tools_pb2.pyi +31 -0
- vector_sdk/hash/__init__.py +31 -0
- vector_sdk/hash/hasher.py +259 -0
- vector_sdk/hash/types.py +67 -0
- vector_sdk/namespaces/__init__.py +13 -0
- vector_sdk/namespaces/base.py +45 -0
- vector_sdk/namespaces/db.py +230 -0
- vector_sdk/namespaces/embeddings.py +268 -0
- vector_sdk/namespaces/search.py +258 -0
- vector_sdk/structured/__init__.py +60 -0
- vector_sdk/structured/router.py +190 -0
- vector_sdk/structured/structured_embeddings.py +431 -0
- vector_sdk/structured/tool_config.py +254 -0
- vector_sdk/types.py +864 -0
vector_sdk/__init__.py
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Vector SDK for Python
|
|
3
|
+
|
|
4
|
+
A client library for embedding generation, vector search, and database operations
|
|
5
|
+
via the Vector Gateway services.
|
|
6
|
+
|
|
7
|
+
Basic usage:
|
|
8
|
+
from vector_sdk import VectorClient
|
|
9
|
+
|
|
10
|
+
client = VectorClient(
|
|
11
|
+
redis_url="redis://localhost:6379",
|
|
12
|
+
http_url="http://localhost:8080",
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# Create embeddings
|
|
16
|
+
result = client.embeddings.create_and_wait(
|
|
17
|
+
texts=[{"id": "doc1", "text": "Hello world"}],
|
|
18
|
+
content_type="topic",
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
# Vector search
|
|
22
|
+
search_result = client.search.query_and_wait(
|
|
23
|
+
query_text="machine learning",
|
|
24
|
+
database="turbopuffer",
|
|
25
|
+
namespace="topics",
|
|
26
|
+
top_k=10,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Direct database lookup
|
|
30
|
+
docs = client.db.get_by_ids(
|
|
31
|
+
ids=["doc1"],
|
|
32
|
+
database="turbopuffer",
|
|
33
|
+
namespace="topics",
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
client.close()
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
# ============================================================================
|
|
40
|
+
# Client Exports (New API)
|
|
41
|
+
# ============================================================================
|
|
42
|
+
|
|
43
|
+
from vector_sdk.client import EmbeddingClient, VectorClient
|
|
44
|
+
|
|
45
|
+
# ============================================================================
|
|
46
|
+
# Content Type Registry
|
|
47
|
+
# ============================================================================
|
|
48
|
+
from vector_sdk.content_types import (
|
|
49
|
+
CONTENT_TYPE_CONFIGS,
|
|
50
|
+
SUPPORTED_CONTENT_TYPES,
|
|
51
|
+
ContentType,
|
|
52
|
+
ContentTypeConfig,
|
|
53
|
+
EmbeddingModel,
|
|
54
|
+
MongoDBStorageConfig,
|
|
55
|
+
Priority,
|
|
56
|
+
TurboPufferStorageConfig,
|
|
57
|
+
get_content_type_config,
|
|
58
|
+
get_model_name,
|
|
59
|
+
get_priority_string,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# ============================================================================
|
|
63
|
+
# Content Hash
|
|
64
|
+
# ============================================================================
|
|
65
|
+
from vector_sdk.hash import (
|
|
66
|
+
AnswerObject,
|
|
67
|
+
AudioRecapSectionData,
|
|
68
|
+
FlashCardData,
|
|
69
|
+
FlashCardType,
|
|
70
|
+
MultipleChoiceOption,
|
|
71
|
+
QuestionData,
|
|
72
|
+
ToolCollection,
|
|
73
|
+
compute_content_hash,
|
|
74
|
+
extract_tool_text,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# ============================================================================
|
|
78
|
+
# Namespace Exports
|
|
79
|
+
# ============================================================================
|
|
80
|
+
from vector_sdk.namespaces import (
|
|
81
|
+
BaseNamespace,
|
|
82
|
+
DBNamespace,
|
|
83
|
+
EmbeddingsNamespace,
|
|
84
|
+
SearchNamespace,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# ============================================================================
|
|
88
|
+
# Structured Embeddings
|
|
89
|
+
# ============================================================================
|
|
90
|
+
from vector_sdk.structured import (
|
|
91
|
+
TOOL_CONFIGS,
|
|
92
|
+
DatabaseRoutingError,
|
|
93
|
+
DatabaseRoutingMode,
|
|
94
|
+
PineconeToolConfig,
|
|
95
|
+
QuestionType,
|
|
96
|
+
StructuredEmbeddingsNamespace,
|
|
97
|
+
TestQuestionInput,
|
|
98
|
+
ToolConfig,
|
|
99
|
+
ToolDatabaseConfig,
|
|
100
|
+
ToolMetadata,
|
|
101
|
+
TurboPufferToolConfig,
|
|
102
|
+
build_storage_config,
|
|
103
|
+
get_content_type,
|
|
104
|
+
get_database_routing_mode,
|
|
105
|
+
get_flashcard_namespace_suffix,
|
|
106
|
+
get_pinecone_namespace,
|
|
107
|
+
get_question_namespace_suffix,
|
|
108
|
+
get_tool_config,
|
|
109
|
+
get_turbopuffer_namespace,
|
|
110
|
+
validate_database_routing,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
# ============================================================================
|
|
114
|
+
# Types
|
|
115
|
+
# ============================================================================
|
|
116
|
+
from vector_sdk.types import (
|
|
117
|
+
# Query stream constants
|
|
118
|
+
QUERY_STREAM_CRITICAL,
|
|
119
|
+
QUERY_STREAM_HIGH,
|
|
120
|
+
QUERY_STREAM_LOW,
|
|
121
|
+
QUERY_STREAM_NORMAL,
|
|
122
|
+
# Model registry
|
|
123
|
+
SUPPORTED_MODELS,
|
|
124
|
+
VECTOR_DATABASE_MONGODB,
|
|
125
|
+
VECTOR_DATABASE_PINECONE,
|
|
126
|
+
VECTOR_DATABASE_TURBOPUFFER,
|
|
127
|
+
# Types
|
|
128
|
+
CallbackConfig,
|
|
129
|
+
CloneResult,
|
|
130
|
+
DeleteFromNamespaceResult,
|
|
131
|
+
Document,
|
|
132
|
+
EmbeddingConfigOverride,
|
|
133
|
+
EmbeddingError,
|
|
134
|
+
EmbeddingProvider,
|
|
135
|
+
EmbeddingRequest,
|
|
136
|
+
EmbeddingResult,
|
|
137
|
+
LookupResult,
|
|
138
|
+
LookupTiming,
|
|
139
|
+
ModelConfig,
|
|
140
|
+
ModelValidationError,
|
|
141
|
+
MongoDBStorage,
|
|
142
|
+
PineconeStorageConfig,
|
|
143
|
+
# Query types
|
|
144
|
+
QueryConfig,
|
|
145
|
+
QueryRequest,
|
|
146
|
+
QueryResult,
|
|
147
|
+
QueryTiming,
|
|
148
|
+
StorageConfig,
|
|
149
|
+
TextInput,
|
|
150
|
+
TimingBreakdown,
|
|
151
|
+
TurboPufferStorage,
|
|
152
|
+
VectorMatch,
|
|
153
|
+
get_google_models,
|
|
154
|
+
get_model_config,
|
|
155
|
+
get_openai_models,
|
|
156
|
+
get_query_stream_for_priority,
|
|
157
|
+
get_supported_models,
|
|
158
|
+
is_model_supported,
|
|
159
|
+
validate_model,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
__version__ = "0.2.0"
|
|
163
|
+
|
|
164
|
+
__all__ = [
|
|
165
|
+
# Clients (New API)
|
|
166
|
+
"VectorClient",
|
|
167
|
+
# Backward compatibility
|
|
168
|
+
"EmbeddingClient",
|
|
169
|
+
# Namespaces
|
|
170
|
+
"BaseNamespace",
|
|
171
|
+
"EmbeddingsNamespace",
|
|
172
|
+
"SearchNamespace",
|
|
173
|
+
"DBNamespace",
|
|
174
|
+
# Embedding Request/Response types
|
|
175
|
+
"EmbeddingRequest",
|
|
176
|
+
"EmbeddingResult",
|
|
177
|
+
"TextInput",
|
|
178
|
+
"StorageConfig",
|
|
179
|
+
"MongoDBStorage",
|
|
180
|
+
"TurboPufferStorage",
|
|
181
|
+
"PineconeStorageConfig",
|
|
182
|
+
"CallbackConfig",
|
|
183
|
+
"EmbeddingError",
|
|
184
|
+
"TimingBreakdown",
|
|
185
|
+
# Query types
|
|
186
|
+
"QueryConfig",
|
|
187
|
+
"QueryRequest",
|
|
188
|
+
"QueryResult",
|
|
189
|
+
"VectorMatch",
|
|
190
|
+
"QueryTiming",
|
|
191
|
+
"EmbeddingConfigOverride",
|
|
192
|
+
# Lookup types
|
|
193
|
+
"Document",
|
|
194
|
+
"LookupResult",
|
|
195
|
+
"LookupTiming",
|
|
196
|
+
# Clone and Delete types
|
|
197
|
+
"CloneResult",
|
|
198
|
+
"DeleteFromNamespaceResult",
|
|
199
|
+
# Query constants
|
|
200
|
+
"QUERY_STREAM_CRITICAL",
|
|
201
|
+
"QUERY_STREAM_HIGH",
|
|
202
|
+
"QUERY_STREAM_NORMAL",
|
|
203
|
+
"QUERY_STREAM_LOW",
|
|
204
|
+
"VECTOR_DATABASE_MONGODB",
|
|
205
|
+
"VECTOR_DATABASE_TURBOPUFFER",
|
|
206
|
+
"VECTOR_DATABASE_PINECONE",
|
|
207
|
+
"get_query_stream_for_priority",
|
|
208
|
+
# Model registry
|
|
209
|
+
"SUPPORTED_MODELS",
|
|
210
|
+
"EmbeddingProvider",
|
|
211
|
+
"ModelConfig",
|
|
212
|
+
"ModelValidationError",
|
|
213
|
+
"is_model_supported",
|
|
214
|
+
"get_model_config",
|
|
215
|
+
"get_supported_models",
|
|
216
|
+
"get_google_models",
|
|
217
|
+
"get_openai_models",
|
|
218
|
+
"validate_model",
|
|
219
|
+
# Content type registry
|
|
220
|
+
"ContentType",
|
|
221
|
+
"EmbeddingModel",
|
|
222
|
+
"Priority",
|
|
223
|
+
"ContentTypeConfig",
|
|
224
|
+
"MongoDBStorageConfig",
|
|
225
|
+
"TurboPufferStorageConfig",
|
|
226
|
+
"CONTENT_TYPE_CONFIGS",
|
|
227
|
+
"SUPPORTED_CONTENT_TYPES",
|
|
228
|
+
"get_content_type_config",
|
|
229
|
+
"get_model_name",
|
|
230
|
+
"get_priority_string",
|
|
231
|
+
# Content hash
|
|
232
|
+
"compute_content_hash",
|
|
233
|
+
"extract_tool_text",
|
|
234
|
+
"ToolCollection",
|
|
235
|
+
"FlashCardType",
|
|
236
|
+
"FlashCardData",
|
|
237
|
+
"QuestionData",
|
|
238
|
+
"AudioRecapSectionData",
|
|
239
|
+
"MultipleChoiceOption",
|
|
240
|
+
"AnswerObject",
|
|
241
|
+
# Structured Embeddings
|
|
242
|
+
"StructuredEmbeddingsNamespace",
|
|
243
|
+
"ToolMetadata",
|
|
244
|
+
"TestQuestionInput",
|
|
245
|
+
"ToolConfig",
|
|
246
|
+
"ToolDatabaseConfig",
|
|
247
|
+
"TurboPufferToolConfig",
|
|
248
|
+
"PineconeToolConfig",
|
|
249
|
+
"QuestionType",
|
|
250
|
+
"TOOL_CONFIGS",
|
|
251
|
+
"get_tool_config",
|
|
252
|
+
"get_flashcard_namespace_suffix",
|
|
253
|
+
"get_question_namespace_suffix",
|
|
254
|
+
"get_turbopuffer_namespace",
|
|
255
|
+
"get_pinecone_namespace",
|
|
256
|
+
"DatabaseRoutingMode",
|
|
257
|
+
"DatabaseRoutingError",
|
|
258
|
+
"get_database_routing_mode",
|
|
259
|
+
"validate_database_routing",
|
|
260
|
+
"build_storage_config",
|
|
261
|
+
"get_content_type",
|
|
262
|
+
]
|