@freehour/supabase-langchain 1.0.0 → 1.0.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"embedding-service.d.ts","sourceRoot":"","sources":["../lib/embedding-service.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAc,oBAAoB,EAAE,OAAO,EAAgB,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAA+B,MAAM,yBAAyB,CAAC;AAU7N,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAEjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAG9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGrF,MAAM,MAAM,eAAe,CACvB,UAAU,SAAS,MAAM,EACzB,QAAQ,SAAS,UAAU,GAAG,UAAU,IACxC,QAAQ,CAAC,yBAAyB,CAAC,mBAAmB,CAAC,EAAE,aAAa,GAAG,QAAQ,CAAC,GAAG;IACrF,MAAM,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG,YAAY,GAAG,QAAQ,CAAC,CAAC;CACnG,CAAC;AAEF,MAAM,WAAW,sBAAsB,CACnC,QAAQ,SAAS,eAAe,CAAC,UAAU,CAAC,QAAQ,C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,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC;IAQtJ,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,GAAG,mBAAmB,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,OAAO,CACrG,oBAAoB,CAChB,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,CAC1C,EAAE,CACN;IAkBD,SAAS,CAAC,OAAO,EAAE,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,sBAAsB;CAGpF"}
@@ -0,0 +1,26 @@
1
+ import { TracedError } from '@freehour/supabase-core';
2
+ export interface FileNotSupportedErrorOptions extends ErrorOptions {
3
+ /**
4
+ * The name of the file that caused the error.
5
+ */
6
+ fileName?: string;
7
+ /**
8
+ * The type of the file that is not supported.
9
+ */
10
+ fileType?: string;
11
+ }
12
+ /**
13
+ * An error that indicates that a file is not supported, e.g. due to its MIME type or extension.
14
+ */
15
+ export declare class FileNotSupportedError extends TracedError {
16
+ /**
17
+ * The name of the file that caused the error.
18
+ */
19
+ readonly fileName?: string;
20
+ /**
21
+ * The type of the file that is not supported.
22
+ */
23
+ readonly fileType?: string;
24
+ constructor(message: string, { fileName, fileType, ...options }?: FileNotSupportedErrorOptions);
25
+ }
26
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,MAAM,WAAW,4BAA6B,SAAQ,YAAY;IAE9D;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,WAAW;IAElD;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAGvB,OAAO,EAAE,MAAM,EACf,EACI,QAAQ,EACR,QAAQ,EACR,GAAG,OAAO,EACb,GAAE,4BAAiC;CAM3C"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export type * from './document';
2
2
  export * from './embedding-service';
3
+ export * from './errors';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAC;AAChC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,YAAY,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Document as e } from "langchain";
2
2
  import { Mime as t } from "@freehour/mime";
3
- import { DatabaseService as n, FileNotSupportedError as r, StorageService as i } from "@freehour/supabase-core";
3
+ import { DatabaseService as n, StorageService as r, TracedError as i } from "@freehour/supabase-core";
4
4
  import { JSONLinesLoader as a, JSONLoader as o } from "@langchain/classic/document_loaders/fs/json";
5
5
  import { TextLoader as s } from "@langchain/classic/document_loaders/fs/text";
6
6
  import { CSVLoader as c } from "@langchain/community/document_loaders/fs/csv";
@@ -11,14 +11,20 @@ import { PPTXLoader as f } from "@langchain/community/document_loaders/fs/pptx";
11
11
  import { SRTLoader as p } from "@langchain/community/document_loaders/fs/srt";
12
12
  import { SupabaseVectorStore as m } from "@langchain/community/vectorstores/supabase";
13
13
  import { RecursiveCharacterTextSplitter as h } from "@langchain/textsplitters";
14
- //#region lib/embedding-service.ts
15
- var g = class {
14
+ //#region lib/errors.ts
15
+ var g = class extends i {
16
+ fileName;
17
+ fileType;
18
+ constructor(e, { fileName: t, fileType: n, ...r } = {}) {
19
+ super(e, r), this.fileName = t, this.fileType = n;
20
+ }
21
+ }, _ = class {
16
22
  database;
17
23
  storage;
18
24
  vectorStore;
19
25
  splitterOptions;
20
- constructor({ supabase: e, embeddings: t, chunkSize: r = 1e3, chunkOverlap: a = 200 }) {
21
- this.database = new n({ supabase: e }), this.storage = new i({
26
+ constructor({ supabase: e, embeddings: t, chunkSize: i = 1e3, chunkOverlap: a = 200 }) {
27
+ this.database = new n({ supabase: e }), this.storage = new r({
22
28
  client: e.storage,
23
29
  database: this.database
24
30
  }), this.vectorStore = new m(t, {
@@ -26,7 +32,7 @@ var g = class {
26
32
  tableName: "embeddings",
27
33
  queryName: "match_documents"
28
34
  }), this.splitterOptions = {
29
- chunkSize: r,
35
+ chunkSize: i,
30
36
  chunkOverlap: a
31
37
  };
32
38
  }
@@ -45,7 +51,7 @@ var g = class {
45
51
  if (n.equals("application/vnd.openxmlformats-officedocument.presentationml.presentation")) return new f(e);
46
52
  if (n.equals("application/x-subrip")) return new p(e);
47
53
  if (n.type === "text") return new s(e);
48
- throw new r(`File type ${e.type} is not supported`, {
54
+ throw new g(`File type ${e.type} is not supported`, {
49
55
  fileName: e.name,
50
56
  fileType: e.type
51
57
  });
@@ -110,4 +116,4 @@ var g = class {
110
116
  }
111
117
  };
112
118
  //#endregion
113
- export { g as EmbeddingService };
119
+ export { _ as EmbeddingService, g as FileNotSupportedError };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "private": false,
4
4
  "displayName": "Supabase-LangChain",
5
5
  "description": "Integration package for using LangChain with Supabase",
6
- "version": "1.0.0",
6
+ "version": "1.0.1",
7
7
  "type": "module",
8
8
  "repository": {
9
9
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  "files": [
18
18
  "dist",
19
19
  "supabase/migrations/0001_supabase_langchain.sql",
20
- "supabase/schemas/supabase-langchain.sql",
20
+ "supabase/schemas/supabase-langchain",
21
21
  "scripts/copy-supabase-assets.js"
22
22
  ],
23
23
  "exports": {
@@ -28,26 +28,31 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@freehour/mime": "^1.1.7",
31
- "@freehour/supabase-core": "^2.0.4",
32
- "@langchain/classic": "^1.0.29",
31
+ "@freehour/supabase-core": "^2.1.0",
32
+ "@langchain/classic": "^1.0.31",
33
33
  "@langchain/community": "^1.1.27",
34
- "@langchain/core": "^1.1.39",
34
+ "@langchain/core": "^1.1.41",
35
35
  "@langchain/textsplitters": "^1.0.1",
36
- "@supabase/storage-js": "^2.103.0",
37
- "@supabase/supabase-js": "^2.103.0",
38
- "langchain": "^1.3.1",
39
- "officeparser": "^6.0.7",
36
+ "langchain": "^1.3.4",
37
+ "officeparser": "^6.1.0",
40
38
  "pdf-parse": "^2.4.5",
41
39
  "srt-parser-2": "^1.2.3"
42
40
  },
41
+ "peerDependencies": {
42
+ "@supabase/supabase-js": "^2.104.0"
43
+ },
44
+ "overrides": {
45
+ "@browserbasehq/stagehand": "3.2.1"
46
+ },
43
47
  "devDependencies": {
44
48
  "@freehour/eslint-rules": "^1.0.19",
49
+ "@supabase/supabase-js": "^2.104.0",
45
50
  "ajv": "^8.18.0",
46
- "bun-types": "^1.3.11",
51
+ "bun-types": "^1.3.13",
47
52
  "eslint": "9.39.4",
48
- "supabase": "^2.88.1",
49
- "typescript": "^6.0.2",
50
- "vite": "^8.0.8",
53
+ "supabase": "^2.93.1",
54
+ "typescript": "^6.0.3",
55
+ "vite": "^8.0.10",
51
56
  "vite-plugin-dts": "^4.5.4"
52
57
  },
53
58
  "trustedDependencies": [
@@ -0,0 +1,11 @@
1
+ -- This file includes SQL commands for the langchain schema.
2
+ -- This schema is used by services of the supabase-langchain package.
3
+
4
+ -- Ensure the schema exists
5
+ CREATE SCHEMA IF NOT EXISTS langchain;
6
+
7
+ -- Grant access privileges
8
+ GRANT USAGE ON SCHEMA langchain TO "anon";
9
+ GRANT USAGE ON SCHEMA langchain TO "authenticated";
10
+ GRANT USAGE ON SCHEMA langchain TO "service_role";
11
+
@@ -0,0 +1,2 @@
1
+ -- enable the "vector" extension for embeddings
2
+ CREATE EXTENSION IF NOT EXISTS vector WITH SCHEMA extensions;
@@ -0,0 +1,71 @@
1
+ -- Function to match documents based on a query embedding and optional metadata filter
2
+ -- Returns the top 'match_count' documents ordered by similarity to the query embedding.
3
+ -- The 'filter' parameter allows for additional filtering based on document metadata using json containment.
4
+ -- Must be in the public schema to be compatible with langchain.
5
+ CREATE OR REPLACE FUNCTION public.match_documents(
6
+ query_embedding vector(768),
7
+ match_count int,
8
+ filter jsonb DEFAULT '{}'::jsonb
9
+ )
10
+ RETURNS TABLE (
11
+ id uuid,
12
+ file_id uuid,
13
+ created_at timestamptz,
14
+ content text,
15
+ metadata jsonb,
16
+ embedding vector(768),
17
+ similarity float
18
+ )
19
+ SET search_path = ''
20
+ AS $$
21
+ #variable_conflict use_column
22
+ BEGIN
23
+ RETURN QUERY
24
+ SELECT
25
+ id,
26
+ file_id,
27
+ created_at,
28
+ content,
29
+ metadata,
30
+ embedding,
31
+ 1 - (embedding OPERATOR(extensions.<=>) query_embedding) AS similarity
32
+ FROM public.embeddings
33
+ WHERE metadata @> filter
34
+ ORDER BY embedding OPERATOR(extensions.<=>) query_embedding
35
+ LIMIT match_count;
36
+ END;
37
+ $$ LANGUAGE plpgsql;
38
+
39
+
40
+ -- Function extracts the 'fileId' from metadata and assigns it to reference file_id.
41
+ -- LangChain inserts embeddings automatically with a user defined metadata;
42
+ -- this function is triggered before insert to populate the file_id column from the metadata.
43
+ CREATE OR REPLACE FUNCTION langchain.embeddings_apply_metadata()
44
+ RETURNS trigger
45
+ SET search_path = ''
46
+ AS $$
47
+ BEGIN
48
+ IF NEW.metadata ? 'fileId' THEN
49
+ NEW.file_id := NEW.metadata ->> 'fileId';
50
+ END IF;
51
+ RETURN NEW;
52
+ END;
53
+ $$ LANGUAGE plpgsql;
54
+
55
+
56
+ -- Function to return files in the specified bucket with no or outdated embeddings
57
+ CREATE OR REPLACE FUNCTION langchain.get_outdated_embeddings(bucket text)
58
+ RETURNS TABLE (
59
+ file_id uuid,
60
+ bucket_id uuid,
61
+ path_tokens text[]
62
+ )
63
+ SET search_path = ''
64
+ AS $$
65
+ BEGIN
66
+ RETURN QUERY
67
+ SELECT f.id, f.bucket_id, f.path_tokens
68
+ FROM langchain.outdated_embeddings AS f
69
+ WHERE f.bucket_id = bucket;
70
+ END;
71
+ $$ LANGUAGE plpgsql;
@@ -0,0 +1,48 @@
1
+ -- ==========================================================
2
+ -- Tables
3
+ -- ==========================================================
4
+
5
+
6
+ -- Create the embeddings table
7
+ -- ---------------------------------------------------------
8
+ -- The table holds embeddings for chunked text files.
9
+ -- Must remain in the `public` schema for compatibility with LangChain.
10
+ -- When a file is deleted from the storage.objects table,
11
+ -- the corresponding embeddings are also deleted.
12
+ CREATE TABLE IF NOT EXISTS public.embeddings (
13
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
14
+ file_id UUID NOT NULL REFERENCES storage.objects(id) ON DELETE CASCADE, -- Not unique due to chunking
15
+ created_at timestamptz NOT NULL DEFAULT (now() AT TIME ZONE 'utc'),
16
+ content TEXT NOT NULL,
17
+ metadata JSONB,
18
+ embedding vector(768) -- For nomic-embed-text (768 dimensions)
19
+ );
20
+
21
+
22
+ -- =========================================================
23
+ -- Indexes
24
+ -- =========================================================
25
+
26
+ -- Vector similarity index (used by LangChain)
27
+ CREATE INDEX IF NOT EXISTS public_embeddings_embedding_idx
28
+ ON public.embeddings
29
+ USING ivfflat (embedding vector_cosine_ops)
30
+ WITH (lists = 128);
31
+
32
+ -- File lookup index
33
+ CREATE INDEX IF NOT EXISTS public_embeddings_file_id_idx
34
+ ON public.embeddings (file_id);
35
+
36
+ -- =========================================================
37
+ -- Views
38
+ -- =========================================================
39
+
40
+ -- View to return files with no or outdated embeddings
41
+ CREATE OR REPLACE VIEW langchain.outdated_embeddings AS
42
+ SELECT f.*
43
+ FROM storage.objects AS f
44
+ LEFT JOIN public.embeddings AS e
45
+ ON e.file_id = f.id
46
+ WHERE e.file_id IS NULL OR f.updated_at > e.created_at;
47
+
48
+ GRANT SELECT ON langchain.outdated_embeddings TO authenticated, service_role, anon;
@@ -0,0 +1,8 @@
1
+ -- Trigger: Apply metadata before insert or update
2
+ -- ---------------------------------------------------------
3
+ -- LangChain inserts embeddings automatically; this trigger
4
+ -- allows customizing the insert by populating columns based on the provided document metadata.
5
+ CREATE TRIGGER langchain_embeddings_apply_metadata
6
+ BEFORE INSERT OR UPDATE ON public.embeddings
7
+ FOR EACH ROW
8
+ EXECUTE FUNCTION langchain.embeddings_apply_metadata();