Skip to content

Commit 7e6eb73

Browse files
committed
RAG with sources and document key filtering on vector search
1 parent ec8b1e3 commit 7e6eb73

File tree

4 files changed

+362
-48
lines changed

4 files changed

+362
-48
lines changed

pgml-sdks/pgml/src/collection.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,21 +1025,13 @@ impl Collection {
10251025
}
10261026

10271027
#[instrument(skip(self))]
1028-
pub async fn rag(&self, query: Json, pipeline: &Pipeline) -> anyhow::Result<String> {
1028+
pub async fn rag(&self, query: Json, pipeline: &Pipeline) -> anyhow::Result<Json> {
10291029
let pool = get_or_initialize_pool(&self.database_url).await?;
10301030
let (built_query, values) = build_rag_query(query.clone(), self, pipeline).await?;
1031-
let results: Vec<(Json,)> = sqlx::query_as_with(&built_query, values)
1031+
let mut results: Vec<(Json,)> = sqlx::query_as_with(&built_query, values)
10321032
.fetch_all(&pool)
10331033
.await?;
1034-
Ok(results[0]
1035-
.0
1036-
.as_array()
1037-
.context("Error converting LLM response to Array")?
1038-
.first()
1039-
.context("Error getting first LLM response")?
1040-
.as_str()
1041-
.context("Error converting LLM response to string")?
1042-
.to_owned())
1034+
Ok(std::mem::take(&mut results[0].0))
10431035
}
10441036

10451037
/// Archives a [Collection]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy