16
16
"params" : {"M" : 8 , "efConstruction" : 64 },
17
17
}
18
18
19
- PGVECTOR_URL = "postgresql://postgres:postgres@localhost:5432/postgres"
20
- PGVECTOR_INDEX_PARAMS = {
21
- "index_type" : "L2" ,
22
- "params" : {"lists" : 100 , "probes" : 10 }
23
- }
19
+ PGVECTOR_URL = "postgresql://postgres:postgres@localhost:5432/postgres"
20
+ PGVECTOR_INDEX_PARAMS = {"index_type" : "L2" , "params" : {"lists" : 100 , "probes" : 10 }}
24
21
25
22
COLLECTION_NAME = "gptcache"
26
23
@@ -169,6 +166,7 @@ def get(name, **kwargs):
169
166
)
170
167
elif name == "pgvector" :
171
168
from gptcache .manager .vector_data .pgvector import PGVector
169
+
172
170
dimension = kwargs .get ("dimension" , DIMENSION )
173
171
url = kwargs .get ("url" , PGVECTOR_URL )
174
172
collection_name = kwargs .get ("collection_name" , COLLECTION_NAME )
@@ -178,13 +176,27 @@ def get(name, **kwargs):
178
176
top_k = top_k ,
179
177
url = url ,
180
178
collection_name = collection_name ,
181
- index_params = index_params
179
+ index_params = index_params ,
182
180
)
183
181
elif name == "docarray" :
184
182
from gptcache .manager .vector_data .docarray_index import DocArrayIndex
185
183
186
184
index_path = kwargs .pop ("index_path" , "./docarray_index.bin" )
187
185
vector_base = DocArrayIndex (index_file_path = index_path , top_k = top_k )
186
+ elif name == "usearch" :
187
+ from gptcache .manager .vector_data .usearch import USearch
188
+
189
+ dimension = kwargs .get ("dimension" , DIMENSION )
190
+ index_path = kwargs .pop ("index_path" , "./index.usearch" )
191
+ metric = kwargs .get ("metric" , "cos" )
192
+ dtype = kwargs .get ("dtype" , "f32" )
193
+ vector_base = USearch (
194
+ index_file_path = index_path ,
195
+ dimension = dimension ,
196
+ top_k = top_k ,
197
+ metric = metric ,
198
+ dtype = dtype ,
199
+ )
188
200
else :
189
201
raise NotFoundError ("vector store" , name )
190
202
return vector_base
0 commit comments