Content-Length: 1878 | pFad | http://github.com/postgresml/postgresml/pull/1387.patch

thub.com From 08fec35d6959edd4504ca335627b98676970b0e8 Mon Sep 17 00:00:00 2001 From: SilasMarvin <19626586+SilasMarvin@users.noreply.github.com> Date: Sat, 23 Mar 2024 15:22:22 -0700 Subject: [PATCH] Added vector_search_local --- pgml-sdks/pgml/src/collection.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/pgml-sdks/pgml/src/collection.rs b/pgml-sdks/pgml/src/collection.rs index 69dd8574a..f8107d050 100644 --- a/pgml-sdks/pgml/src/collection.rs +++ b/pgml-sdks/pgml/src/collection.rs @@ -935,7 +935,6 @@ impl Collection { //github.com/ Ok(()) //github.com/ } #[instrument(skip(self))] - #[allow(clippy::type_complexity)] pub async fn vector_search( &mut self, query: Json, @@ -995,6 +994,32 @@ impl Collection { } } + //github.com/ Same as vector_search but assumes embeddings are done locally + #[instrument(skip(self))] + pub async fn vector_search_local( + &self, + query: Json, + pipeline: &Pipeline, + ) -> anyhow::Result> { + let pool = get_or_initialize_pool(&self.database_url).await?; + let (built_query, values) = + build_vector_search_query(query.clone(), self, pipeline).await?; + let results: Vec<(Json, String, f64)> = sqlx::query_as_with(&built_query, values) + .fetch_all(&pool) + .await?; + Ok(results + .into_iter() + .map(|v| { + serde_json::json!({ + "document": v.0, + "chunk": v.1, + "score": v.2 + }) + .into() + }) + .collect()) + } + //github.com/ Archives a [Collection] //github.com/ This will free up the name to be reused. It does not delete it. //github.com/








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgresml/postgresml/pull/1387.patch

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy