@retrivora-ai/rag-engine 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js
CHANGED
|
@@ -3779,8 +3779,8 @@ var MultiTablePostgresProvider = class extends BaseVectorProvider {
|
|
|
3779
3779
|
sqlQuery = `
|
|
3780
3780
|
SELECT *,
|
|
3781
3781
|
(1 - (embedding <=> $1::vector)) AS vector_score,
|
|
3782
|
-
ts_rank(to_tsvector('english', t.*::text), plainto_tsquery('english', $2)) AS keyword_score,
|
|
3783
|
-
((1 - (embedding <=> $1::vector)) + (ts_rank(to_tsvector('english', t.*::text), plainto_tsquery('english', $2)) * 2.0)) AS hybrid_score
|
|
3782
|
+
COALESCE(ts_rank(to_tsvector('english', t.*::text), NULLIF(REPLACE(plainto_tsquery('english', $2)::text, '&', '|'), '')::tsquery), 0) AS keyword_score,
|
|
3783
|
+
((1 - (embedding <=> $1::vector)) + (COALESCE(ts_rank(to_tsvector('english', t.*::text), NULLIF(REPLACE(plainto_tsquery('english', $2)::text, '&', '|'), '')::tsquery), 0) * 2.0)) AS hybrid_score
|
|
3784
3784
|
FROM "${table}" t
|
|
3785
3785
|
ORDER BY hybrid_score DESC
|
|
3786
3786
|
LIMIT 50
|
package/dist/server.mjs
CHANGED
|
@@ -422,8 +422,8 @@ var MultiTablePostgresProvider = class extends BaseVectorProvider {
|
|
|
422
422
|
sqlQuery = `
|
|
423
423
|
SELECT *,
|
|
424
424
|
(1 - (embedding <=> $1::vector)) AS vector_score,
|
|
425
|
-
ts_rank(to_tsvector('english', t.*::text), plainto_tsquery('english', $2)) AS keyword_score,
|
|
426
|
-
((1 - (embedding <=> $1::vector)) + (ts_rank(to_tsvector('english', t.*::text), plainto_tsquery('english', $2)) * 2.0)) AS hybrid_score
|
|
425
|
+
COALESCE(ts_rank(to_tsvector('english', t.*::text), NULLIF(REPLACE(plainto_tsquery('english', $2)::text, '&', '|'), '')::tsquery), 0) AS keyword_score,
|
|
426
|
+
((1 - (embedding <=> $1::vector)) + (COALESCE(ts_rank(to_tsvector('english', t.*::text), NULLIF(REPLACE(plainto_tsquery('english', $2)::text, '&', '|'), '')::tsquery), 0) * 2.0)) AS hybrid_score
|
|
427
427
|
FROM "${table}" t
|
|
428
428
|
ORDER BY hybrid_score DESC
|
|
429
429
|
LIMIT 50
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@retrivora-ai/rag-engine",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Retrivora AI is a plug-and-play AI engine for RAG chat experiences — generic vector DB + LLM provider, embeddable or standalone.",
|
|
5
5
|
"author": "Abhinav Alkuchi",
|
|
6
6
|
"license": "MIT",
|
|
@@ -135,11 +135,13 @@ export class MultiTablePostgresProvider extends BaseVectorProvider {
|
|
|
135
135
|
|
|
136
136
|
if (queryText) {
|
|
137
137
|
// Actual Hybrid Search: Semantic Vector Score + Full-Text Keyword Rank
|
|
138
|
+
// We convert plainto_tsquery's AND (&) operator to OR (|) so that natural language queries
|
|
139
|
+
// (which contain words like "price", "product" not found in the row text) still match entities like "Router".
|
|
138
140
|
sqlQuery = `
|
|
139
141
|
SELECT *,
|
|
140
142
|
(1 - (embedding <=> $1::vector)) AS vector_score,
|
|
141
|
-
ts_rank(to_tsvector('english', t.*::text), plainto_tsquery('english', $2)) AS keyword_score,
|
|
142
|
-
((1 - (embedding <=> $1::vector)) + (ts_rank(to_tsvector('english', t.*::text), plainto_tsquery('english', $2)) * 2.0)) AS hybrid_score
|
|
143
|
+
COALESCE(ts_rank(to_tsvector('english', t.*::text), NULLIF(REPLACE(plainto_tsquery('english', $2)::text, '&', '|'), '')::tsquery), 0) AS keyword_score,
|
|
144
|
+
((1 - (embedding <=> $1::vector)) + (COALESCE(ts_rank(to_tsvector('english', t.*::text), NULLIF(REPLACE(plainto_tsquery('english', $2)::text, '&', '|'), '')::tsquery), 0) * 2.0)) AS hybrid_score
|
|
143
145
|
FROM "${table}" t
|
|
144
146
|
ORDER BY hybrid_score DESC
|
|
145
147
|
LIMIT 50
|