Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: import edge runtime types. (#22722)

Thor 雷神 Schaeffb9d62805116b
diff --git a/examples/ai/edge-functions/supabase/functions/generate-embedding/index.ts b/examples/ai/edge-functions/supabase/functions/generate-embedding/index.ts
index 4befba0338f..5efecefe1ba 100644
--- a/examples/ai/edge-functions/supabase/functions/generate-embedding/index.ts
+++ b/examples/ai/edge-functions/supabase/functions/generate-embedding/index.ts
@@ -1,4 +1,5 @@
-/// <reference types="https://esm.sh/@supabase/[email protected]/src/edge-runtime.d.ts" />
+/// <reference types="https://esm.sh/@supabase/functions-js/src/edge-runtime.d.ts" />
+
import { createClient } from "npm:@supabase/[email protected]";
import { Database, Tables } from "../_shared/database.types.ts";
@@ -15,6 +16,7 @@ const supabase = createClient<Database>(
Deno.env.get("SUPABASE_URL")!,
Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!,
);
+
const model = new Supabase.ai.Session("gte-small");
Deno.serve(async (req) => {
@@ -33,7 +35,9 @@ Deno.serve(async (req) => {
});
// Store in DB
- const { error } = await supabase.from("embeddings").update({ embedding }).eq(
+ const { error } = await supabase.from("embeddings").update({
+ embedding: JSON.stringify(embedding),
+ }).eq(
"id",
id,
);
diff --git a/examples/ai/edge-functions/supabase/functions/search/index.ts b/examples/ai/edge-functions/supabase/functions/search/index.ts
index a4551d25a3e..7054154a9dd 100644
--- a/examples/ai/edge-functions/supabase/functions/search/index.ts
+++ b/examples/ai/edge-functions/supabase/functions/search/index.ts
@@ -1,4 +1,5 @@
-/// <reference types="https://esm.sh/@supabase/[email protected]/src/edge-runtime.d.ts" />
+/// <reference types="https://esm.sh/@supabase/functions-js/src/edge-runtime.d.ts" />
+
import { createClient } from "npm:@supabase/[email protected]";
import { Database } from "../_shared/database.types.ts";
@@ -6,6 +7,7 @@ const supabase = createClient<Database>(
Deno.env.get("SUPABASE_URL")!,
Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")!,
);
+
const model = new Supabase.ai.Session("gte-small");
Deno.serve(async (req) => {
@@ -20,7 +22,7 @@ Deno.serve(async (req) => {
// Query embeddings.
const { data: result, error } = await supabase
.rpc("query_embeddings", {
- embedding,
+ embedding: JSON.stringify(embedding),
match_threshold: 0.8,
})
.select("content")