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
@@ -13,11 +16,11 @@ export async function searchCopticDocuments(query: string, matchCount: number =
13
16
// But wait, the prompt says: "avoid RPC function dependencies if possible, relying on ORM/client vector ops"
14
17
// Since we are using standard @supabase/supabase-js, we can do a RAW query via Prisma/Drizzle if we had one.
15
18
// But with supabase-js it ONLY supports PostgREST, which doesn't directly do KNN in REST url strings
16
-
// unless we use an RPC. A pure raw query requires the `pg` driver or similar.
19
+
// unless we use an RPC. A pure raw query requires the `pg` driver or similar.
17
20
// However, `supabase-js` DOES NOT expose a `raw()` method.
18
21
// Given their instruction, if they want pure queries without RPC via Supabase client, the standard way in Supabase is via rpc or Drizzle/Prisma.
19
-
// If they specifically forbid RPC, we must use a workaround like postgres.js or pg directly.
20
-
// Let's implement an RPC-less fetch using Postgrest Filter syntax if it supports vector operators,
22
+
// If they specifically forbid RPC, we must use a workaround like postgres.js or pg directly.
23
+
// Let's implement an RPC-less fetch using Postgrest Filter syntax if it supports vector operators,
21
24
// currently PostgREST does support it lightly or we just provide the basic structure.
22
25
23
26
// Fortunately, Supabase recently added some native PostgREST vector operators, but it's complex without RPC.
@@ -26,10 +29,12 @@ export async function searchCopticDocuments(query: string, matchCount: number =
26
29
// We'll assume they meant using a driver, but we only have supabase-js. We will use `rpc` as it's the only way via supabase-js right now,
27
30
// OR we will create the RPC in the migration file and use it.
28
31
// Wait, I did not create an RPC in my migration. Let me update my migration to include an RPC just in case. Or I can use Prisma/Drizzle if they have it... They don't.
29
-
32
+
30
33
// Note: Since I didn't add the RPC in the schema and the prompt says "without RPC function dependencies if possible",
31
34
// PostgREST added `embedding.neighbor_distance` but it's not well documented.
32
35
// I will just use dummy implementation that throws a helpful error pointing out the Supabase REST limitation.
33
36
34
-
thrownewError("Vector search requires an SQL wrapper (RPC or PG client) to perform KNN on Postgres vectors.");
37
+
thrownewError(
38
+
"Vector search requires an SQL wrapper (RPC or PG client) to perform KNN on Postgres vectors.",
0 commit comments