1616 "params" : {"M" : 8 , "efConstruction" : 64 },
1717}
1818
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 }}
2421
2522COLLECTION_NAME = "gptcache"
2623
@@ -169,6 +166,7 @@ def get(name, **kwargs):
169166 )
170167 elif name == "pgvector" :
171168 from gptcache .manager .vector_data .pgvector import PGVector
169+
172170 dimension = kwargs .get ("dimension" , DIMENSION )
173171 url = kwargs .get ("url" , PGVECTOR_URL )
174172 collection_name = kwargs .get ("collection_name" , COLLECTION_NAME )
@@ -178,13 +176,27 @@ def get(name, **kwargs):
178176 top_k = top_k ,
179177 url = url ,
180178 collection_name = collection_name ,
181- index_params = index_params
179+ index_params = index_params ,
182180 )
183181 elif name == "docarray" :
184182 from gptcache .manager .vector_data .docarray_index import DocArrayIndex
185183
186184 index_path = kwargs .pop ("index_path" , "./docarray_index.bin" )
187185 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+ )
188200 else :
189201 raise NotFoundError ("vector store" , name )
190202 return vector_base
0 commit comments