File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -935,7 +935,6 @@ impl Collection {
935
935
/// Ok(())
936
936
/// }
937
937
#[ instrument( skip( self ) ) ]
938
- #[ allow( clippy:: type_complexity) ]
939
938
pub async fn vector_search (
940
939
& mut self ,
941
940
query : Json ,
@@ -995,6 +994,32 @@ impl Collection {
995
994
}
996
995
}
997
996
997
+ /// Same as vector_search but assumes embeddings are done locally
998
+ #[ instrument( skip( self ) ) ]
999
+ pub async fn vector_search_local (
1000
+ & self ,
1001
+ query : Json ,
1002
+ pipeline : & Pipeline ,
1003
+ ) -> anyhow:: Result < Vec < Json > > {
1004
+ let pool = get_or_initialize_pool ( & self . database_url ) . await ?;
1005
+ let ( built_query, values) =
1006
+ build_vector_search_query ( query. clone ( ) , self , pipeline) . await ?;
1007
+ let results: Vec < ( Json , String , f64 ) > = sqlx:: query_as_with ( & built_query, values)
1008
+ . fetch_all ( & pool)
1009
+ . await ?;
1010
+ Ok ( results
1011
+ . into_iter ( )
1012
+ . map ( |v| {
1013
+ serde_json:: json!( {
1014
+ "document" : v. 0 ,
1015
+ "chunk" : v. 1 ,
1016
+ "score" : v. 2
1017
+ } )
1018
+ . into ( )
1019
+ } )
1020
+ . collect ( ) )
1021
+ }
1022
+
998
1023
/// Archives a [Collection]
999
1024
/// This will free up the name to be reused. It does not delete it.
1000
1025
///
You can’t perform that action at this time.
0 commit comments