@freehour/supabase-langchain 1.2.3 → 1.3.0
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/document.d.ts +4 -0
- package/dist/document.d.ts.map +1 -1
- package/dist/embedding-service.d.ts +3 -3
- package/dist/embedding-service.d.ts.map +1 -1
- package/dist/errors.d.ts +5 -13
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.js +16 -22
- package/package.json +3 -3
package/dist/document.d.ts
CHANGED
|
@@ -8,4 +8,8 @@ export interface FileMetadata {
|
|
|
8
8
|
}
|
|
9
9
|
export type MetadataGeneratorFn<BucketName extends string = string, Metadata extends JsonObject = JsonObject> = (location: StorageLocation<BucketName>) => Metadata;
|
|
10
10
|
export type StorageDocument<BucketName extends string = string, Metadata extends JsonObject = JsonObject> = DocumentInterface<StorageLocation<BucketName> & FileMetadata & Metadata>;
|
|
11
|
+
export interface EmbeddedFile<BucketName extends string = string, Metadata extends JsonObject = JsonObject> {
|
|
12
|
+
location: StorageLocation<BucketName>;
|
|
13
|
+
documents: StorageDocument<BucketName, Metadata>[];
|
|
14
|
+
}
|
|
11
15
|
//# sourceMappingURL=document.d.ts.map
|
package/dist/document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../lib/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGzC,MAAM,WAAW,YAAY;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,mBAAmB,CAC3B,UAAU,SAAS,MAAM,GAAG,MAAM,EAClC,QAAQ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 @@ import { BaseRetrieverInterface } from '@langchain/core/retrievers';
|
|
|
5
5
|
import { VectorStoreRetrieverInput } from '@langchain/core/vectorstores';
|
|
6
6
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
7
7
|
import { Database as LangChainDatabase } from './generated/database';
|
|
8
|
-
import { FileMetadata, MetadataGeneratorFn
|
|
8
|
+
import { EmbeddedFile, FileMetadata, MetadataGeneratorFn } from './document';
|
|
9
9
|
import { JsonObject } from './json';
|
|
10
10
|
export type RetriverOptions<BucketName extends string, Metadata extends JsonObject = JsonObject> = OmitFrom<VectorStoreRetrieverInput<SupabaseVectorStore>, 'vectorStore' | 'filter'> & {
|
|
11
11
|
filter?: SupabaseFilterRPCCall | Partial<StorageLocation<BucketName> & FileMetadata & Metadata>;
|
|
@@ -28,8 +28,8 @@ export declare class EmbeddingService<Database extends GenericDatabase<SchemaNam
|
|
|
28
28
|
private createEmbeddings;
|
|
29
29
|
private deleteEmbeddings;
|
|
30
30
|
private updateEmbeddings;
|
|
31
|
-
ingest(fileRef: FileRef<BucketName>, metadata: Metadata | MetadataGeneratorFn<BucketName, Metadata>): Promise<
|
|
32
|
-
update(bucket: BucketName, metadata: Metadata | MetadataGeneratorFn<BucketName, Metadata>): Promise<PromiseSettledResult<
|
|
31
|
+
ingest(fileRef: FileRef<BucketName>, metadata: Metadata | MetadataGeneratorFn<BucketName, Metadata>): Promise<EmbeddedFile<BucketName, Metadata>>;
|
|
32
|
+
update(bucket: BucketName, metadata: Metadata | MetadataGeneratorFn<BucketName, Metadata>): Promise<PromiseSettledResult<EmbeddedFile<BucketName, Metadata>>[]>;
|
|
33
33
|
retriever(options: RetriverOptions<BucketName, Metadata>): BaseRetrieverInterface;
|
|
34
34
|
}
|
|
35
35
|
//# sourceMappingURL=embedding-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding-service.d.ts","sourceRoot":"","sources":["../lib/embedding-service.ts"],"names":[],"mappings":"AAKA,OAAO,KAA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AC,eAAe,CAA8B;gBAElD,EACR,QAAQ,EACR,UAAU,EACV,SAAgB,EAChB,YAAkB,GACrB,EAAE,sBAAsB,CAAC,QAAQ,EAAE,aAAa,CAAC;IAWlD,OAAO,KAAK,UAAU,GAErB;IAED,OAAO,CAAC,SAAS;IAuCjB,OAAO,CAAC,WAAW;YA6BL,gBAAgB;YA8BhB,gBAAgB;YAYhB,gBAAgB;IAKxB,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,mBAAmB,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAejJ,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,GAAG,mBAAmB,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,OAAO,CACrG,oBAAoB,CAChB,YAAY,CAAC,UAAU,EAAE,QAAQ,CAAC,CACrC,EAAE,CACN;IAmBD,SAAS,CAAC,OAAO,EAAE,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,sBAAsB;CAGpF"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
import { StorageLocation, TracedError } from '@freehour/supabase-core';
|
|
2
2
|
export interface FileNotSupportedErrorOptions extends ErrorOptions {
|
|
3
3
|
/**
|
|
4
|
-
* The
|
|
4
|
+
* The file that caused the error.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The type of the file that is not supported.
|
|
9
|
-
*/
|
|
10
|
-
fileType?: string;
|
|
6
|
+
file: File;
|
|
11
7
|
}
|
|
12
8
|
/**
|
|
13
9
|
* An error that indicates that a file is not supported, e.g. due to its MIME type or extension.
|
|
14
10
|
*/
|
|
15
11
|
export declare class FileNotSupportedError extends TracedError {
|
|
16
12
|
/**
|
|
17
|
-
* The
|
|
18
|
-
*/
|
|
19
|
-
readonly fileName?: string;
|
|
20
|
-
/**
|
|
21
|
-
* The type of the file that is not supported.
|
|
13
|
+
* The file that caused the error.
|
|
22
14
|
*/
|
|
23
|
-
readonly
|
|
24
|
-
constructor(message: string, {
|
|
15
|
+
readonly file: File;
|
|
16
|
+
constructor(message: string, { file, ...options }: FileNotSupportedErrorOptions);
|
|
25
17
|
}
|
|
26
18
|
export interface EmbeddingErrorOptions extends ErrorOptions {
|
|
27
19
|
/**
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,MAAM,WAAW,4BAA6B,SAAQ,YAAY;IAE9D;;OAEG;IACH,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGtD,MAAM,WAAW,4BAA6B,SAAQ,YAAY;IAE9D;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;CACd;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,WAAW;IAElD;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;gBAGhB,OAAO,EAAE,MAAM,EACf,EACI,IAAI,EACJ,GAAG,OAAO,EACb,EAAE,4BAA4B;CAKtC;AAED,MAAM,WAAW,qBAAsB,SAAQ,YAAY;IAEvD;;OAEG;IACH,QAAQ,EAAE,eAAe,CAAC;CAC7B;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,WAAW;IAE3C;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;gBAG/B,OAAO,EAAE,MAAM,EACf,EACI,QAAQ,EACR,GAAG,OAAO,EACb,EAAE,qBAAqB;CAK/B"}
|
package/dist/index.js
CHANGED
|
@@ -11387,17 +11387,15 @@ var am = class {
|
|
|
11387
11387
|
super(e, t), this.name = this.constructor.name, Error.captureStackTrace(this, this.constructor);
|
|
11388
11388
|
}
|
|
11389
11389
|
}, um = class extends lm {
|
|
11390
|
-
|
|
11391
|
-
|
|
11392
|
-
|
|
11393
|
-
constructor(e, { id: t, bucket: n, path: r } = {}) {
|
|
11394
|
-
super(e), this.id = t, this.bucket = n, this.path = r;
|
|
11390
|
+
ref;
|
|
11391
|
+
constructor(e, { ref: t }) {
|
|
11392
|
+
super(e), this.ref = t;
|
|
11395
11393
|
}
|
|
11396
11394
|
}, dm = class extends lm {
|
|
11397
11395
|
schema;
|
|
11398
11396
|
relation;
|
|
11399
11397
|
id;
|
|
11400
|
-
constructor(e, { schema: t, relation: n, id: r }
|
|
11398
|
+
constructor(e, { schema: t, relation: n, id: r }) {
|
|
11401
11399
|
super(e), this.schema = t, this.relation = n, this.id = r;
|
|
11402
11400
|
}
|
|
11403
11401
|
};
|
|
@@ -11733,7 +11731,7 @@ var Dm = class {
|
|
|
11733
11731
|
};
|
|
11734
11732
|
}
|
|
11735
11733
|
let { id: t } = e, n = await this.files.get(t, ["bucket_id", "path_tokens"]);
|
|
11736
|
-
if (n === void 0) throw new um(`File with ID ${t} not found`, {
|
|
11734
|
+
if (n === void 0) throw new um(`File with ID ${t} not found`, { ref: e });
|
|
11737
11735
|
return {
|
|
11738
11736
|
id: t,
|
|
11739
11737
|
bucket: m.notNull(n.bucket_id, "bucket_id must not be null"),
|
|
@@ -11762,12 +11760,9 @@ var Dm = class {
|
|
|
11762
11760
|
return r;
|
|
11763
11761
|
}
|
|
11764
11762
|
async assertExistsFile(e) {
|
|
11765
|
-
let { bucket:
|
|
11766
|
-
if (
|
|
11767
|
-
if (!
|
|
11768
|
-
bucket: t,
|
|
11769
|
-
path: n
|
|
11770
|
-
});
|
|
11763
|
+
let t = await this.getFileStorageLocation(e), { bucket: n, path: r } = t, { data: i, error: a } = await this.client.from(n).exists(r);
|
|
11764
|
+
if (a) throw a;
|
|
11765
|
+
if (!i) throw new um(`File not found in bucket '${n}' at path '${r}'`, { ref: t });
|
|
11771
11766
|
}
|
|
11772
11767
|
async uploadFile(e, { bucket: t, path: n }, { overwriteExisting: r = !1 } = {}) {
|
|
11773
11768
|
let { data: i, error: a } = await this.client.from(t).upload(`${n}/${e.name}`, e, { upsert: r });
|
|
@@ -11807,10 +11802,9 @@ var Dm = class {
|
|
|
11807
11802
|
})))).flat();
|
|
11808
11803
|
}
|
|
11809
11804
|
}, Om = class extends lm {
|
|
11810
|
-
|
|
11811
|
-
|
|
11812
|
-
|
|
11813
|
-
super(e, r), this.fileName = t, this.fileType = n;
|
|
11805
|
+
file;
|
|
11806
|
+
constructor(e, { file: t, ...n }) {
|
|
11807
|
+
super(e, n), this.file = t;
|
|
11814
11808
|
}
|
|
11815
11809
|
}, km = class extends lm {
|
|
11816
11810
|
location;
|
|
@@ -11850,10 +11844,7 @@ var Dm = class {
|
|
|
11850
11844
|
if (d.equals("application/vnd.openxmlformats-officedocument.presentationml.presentation")) return new l(e);
|
|
11851
11845
|
if (d.equals("application/x-subrip")) return new u(e);
|
|
11852
11846
|
if (d.type === "text") return new i(e);
|
|
11853
|
-
throw new Om(`File type ${e.type} is not supported`, {
|
|
11854
|
-
fileName: e.name,
|
|
11855
|
-
fileType: e.type
|
|
11856
|
-
});
|
|
11847
|
+
throw new Om(`File type ${e.type} is not supported`, { file: e });
|
|
11857
11848
|
}
|
|
11858
11849
|
getSplitter(e) {
|
|
11859
11850
|
let n = {
|
|
@@ -11900,7 +11891,10 @@ var Dm = class {
|
|
|
11900
11891
|
}
|
|
11901
11892
|
async ingest(e, t) {
|
|
11902
11893
|
let n = await this.storage.getFileStorageLocation(e);
|
|
11903
|
-
return this.updateEmbeddings(n, typeof t == "function" ? t(n) : t).
|
|
11894
|
+
return this.updateEmbeddings(n, typeof t == "function" ? t(n) : t).then((e) => ({
|
|
11895
|
+
location: n,
|
|
11896
|
+
documents: e
|
|
11897
|
+
})).catch((e) => {
|
|
11904
11898
|
throw new km("Failed to update embedding", {
|
|
11905
11899
|
cause: e,
|
|
11906
11900
|
location: n
|
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.
|
|
6
|
+
"version": "1.3.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"srt-parser-2": "^1.2.3"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@freehour/supabase-core": "^2.5.
|
|
41
|
+
"@freehour/supabase-core": "^2.5.2",
|
|
42
42
|
"@supabase/supabase-js": "^2.106.2"
|
|
43
43
|
},
|
|
44
44
|
"overrides": {
|
|
45
45
|
"@browserbasehq/stagehand": "3.2.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@freehour/supabase-core": "^2.5.
|
|
48
|
+
"@freehour/supabase-core": "^2.5.2",
|
|
49
49
|
"@freehour/eslint-rules": "^1.0.19",
|
|
50
50
|
"@supabase/supabase-js": "^2.106.2",
|
|
51
51
|
"ajv": "^8.20.0",
|