You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 76f2be6
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/services/rag.md
+48-21Lines changed: 48 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,10 +28,10 @@ configuration.
28
28
Before deploying a RAG service, your PostgreSQL database must have the
29
29
following items configured:
30
30
31
-
- The pgvector extension must be installed and enabled.
32
-
- The database must have document tables with text and vector columns.
33
-
- An HNSW index on vector columns enables fast similarity search.
34
-
- A GIN index on text columns enables keyword search (BM25).
31
+
- The pgvector extension must be installed and enabled
32
+
- The database must have document tables with text and vector columns
33
+
- An HNSW index on vector columns enables fast similarity search
34
+
- A GIN index on text columns enables keyword search (BM25)
35
35
36
36
The Control Plane can automatically provision all of these during
37
37
database creation using the `scripts.post_database_create` hook. See
@@ -74,6 +74,17 @@ In this example, `app_read_only` must be defined in `database_users`:
74
74
}
75
75
```
76
76
77
+
If the `connect_as` user is not a database owner or superuser, it must
78
+
have `SELECT` privilege on each document table. Grant this privilege in
79
+
the `scripts.post_database_create` array:
80
+
81
+
```sql
82
+
GRANTSELECTON documents_content_chunks TO app_read_only;
83
+
```
84
+
85
+
Without this grant, the RAG service will silently return
86
+
`"No relevant information found"` for all queries.
87
+
77
88
### Pipeline Configuration
78
89
79
90
The `pipelines` array (required) defines one or more RAG workflows.
@@ -187,7 +198,7 @@ CREATE EXTENSION IF NOT EXISTS vector;
187
198
CREATETABLEIF NOT EXISTS documents_content_chunks (
188
199
id BIGSERIALPRIMARY KEY,
189
200
content TEXTNOT NULL,
190
-
embedding vector(1536),
201
+
embedding vector(1536)NOT NULL,
191
202
title TEXT,
192
203
source TEXT,
193
204
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
@@ -259,7 +270,7 @@ that uses OpenAI for embeddings and Anthropic Claude to generate answers:
259
270
"scripts": {
260
271
"post_database_create": [
261
272
"CREATE EXTENSION IF NOT EXISTS vector",
262
-
"CREATE TABLE IF NOT EXISTS documents_content_chunks (id BIGSERIAL PRIMARY KEY, content TEXT NOT NULL, embedding vector(1536), title TEXT, source TEXT)",
273
+
"CREATE TABLE IF NOT EXISTS documents_content_chunks (id BIGSERIAL PRIMARY KEY, content TEXT NOT NULL, embedding vector(1536) NOT NULL, title TEXT, source TEXT)",
263
274
"CREATE INDEX ON documents_content_chunks USING hnsw (embedding vector_cosine_ops)",
264
275
"CREATE INDEX ON documents_content_chunks USING gin (to_tsvector('\''english'\'', content))"
265
276
]
@@ -307,8 +318,7 @@ that uses OpenAI for embeddings and Anthropic Claude to generate answers:
307
318
308
319
### OpenAI End-to-End
309
320
310
-
In the following example, OpenAI is used for both embeddings and to generate
311
-
answers:
321
+
In the following example, OpenAI handles both embeddings and answer generation:
312
322
313
323
=== "curl"
314
324
@@ -504,7 +514,6 @@ required; the Ollama server URL is provided via `base_url`:
504
514
In the following example, two pipelines share default values for
505
515
`token_budget` and `top_n`, set with the `defaults` properties:
506
516
507
-
508
517
=== "curl"
509
518
510
519
```sh
@@ -631,7 +640,7 @@ URL stays stable across container restarts.
631
640
"scripts": {
632
641
"post_database_create": [
633
642
"CREATE EXTENSION IF NOT EXISTS vector",
634
-
"CREATE TABLE IF NOT EXISTS documents_content_chunks (id BIGSERIAL PRIMARY KEY, content TEXT NOT NULL, embedding vector(1536), title TEXT, source TEXT)",
643
+
"CREATE TABLE IF NOT EXISTS documents_content_chunks (id BIGSERIAL PRIMARY KEY, content TEXT NOT NULL, embedding vector(1536) NOT NULL, title TEXT, source TEXT)",
635
644
"CREATE INDEX ON documents_content_chunks USING hnsw (embedding vector_cosine_ops)",
636
645
"CREATE INDEX ON documents_content_chunks USING gin (to_tsvector('\''english'\'', content))",
637
646
"GRANT SELECT ON documents_content_chunks TO app_read_only"
@@ -692,9 +701,9 @@ that the database is ready and the RAG service is running:
692
701
In the response, look for the following items:
693
702
694
703
- The `state: "available"` field at the top level confirms that the
695
-
database is provisioned and healthy.
704
+
database is provisioned and healthy
696
705
- The `service_ready: true` field inside `service_instances[].status`
697
-
confirms that the RAG container is up and accepting requests.
706
+
confirms that the RAG container is up and accepting requests
698
707
699
708
```text
700
709
{
@@ -976,9 +985,9 @@ The RAG service's hybrid search combines two complementary techniques,
976
985
merged using Reciprocal Rank Fusion (RRF):
977
986
978
987
- Vector similarity search retrieves documents semantically similar to
979
-
the query using cosine distance on embeddings.
988
+
the query using cosine distance on embeddings
980
989
- BM25 keyword search retrieves documents with exact keyword matches
981
-
using TF-IDF scoring.
990
+
using TF-IDF scoring
982
991
983
992
This combination ensures the LLM receives context that is both
984
993
semantically relevant and keyword-relevant. Documents appearing in
@@ -1000,7 +1009,8 @@ The following sections describe common issues and how to resolve them.
1000
1009
### About Automated Scripts
1001
1010
1002
1011
The `scripts.post_database_create` field executes SQL automatically
1003
-
during database creation. The following details apply:
1012
+
during database creation. The following table describes the execution
1013
+
properties:
1004
1014
1005
1015
| Property | Details |
1006
1016
|---|---|
@@ -1023,26 +1033,43 @@ To verify that the database is accessible, run the following command:
0 commit comments