@nocobase/plugin-ai 2.1.0-beta.14 → 2.1.0-beta.15

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,96 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- var __create = Object.create;
11
- var __defProp = Object.defineProperty;
12
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
- var __getOwnPropNames = Object.getOwnPropertyNames;
14
- var __getProtoOf = Object.getPrototypeOf;
15
- var __hasOwnProp = Object.prototype.hasOwnProperty;
16
- var __export = (target, all) => {
17
- for (var name in all)
18
- __defProp(target, name, { get: all[name], enumerable: true });
19
- };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") {
22
- for (let key of __getOwnPropNames(from))
23
- if (!__hasOwnProp.call(to, key) && key !== except)
24
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
- }
26
- return to;
27
- };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
36
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
- var text_exports = {};
38
- __export(text_exports, {
39
- TextLoader: () => TextLoader
40
- });
41
- module.exports = __toCommonJS(text_exports);
42
- var import_documents = require("@langchain/core/documents");
43
- var import_env = require("@langchain/core/utils/env");
44
- var import_base = require("@langchain/core/document_loaders/base");
45
- class TextLoader extends import_base.BaseDocumentLoader {
46
- filePathOrBlob;
47
- constructor(filePathOrBlob) {
48
- super();
49
- this.filePathOrBlob = filePathOrBlob;
50
- }
51
- async parse(raw) {
52
- return [raw];
53
- }
54
- async load() {
55
- let text;
56
- let metadata;
57
- if (typeof this.filePathOrBlob === "string") {
58
- const { readFile } = await TextLoader.imports();
59
- text = await readFile(this.filePathOrBlob, "utf8");
60
- metadata = { source: this.filePathOrBlob };
61
- } else {
62
- text = await this.filePathOrBlob.text();
63
- metadata = { source: "blob", blobType: this.filePathOrBlob.type };
64
- }
65
- const parsed = await this.parse(text);
66
- parsed.forEach((pageContent, i) => {
67
- if (typeof pageContent !== "string") {
68
- throw new Error(`Expected string, at position ${i} got ${typeof pageContent}`);
69
- }
70
- });
71
- return parsed.map(
72
- (pageContent, i) => new import_documents.Document({
73
- pageContent,
74
- metadata: parsed.length === 1 ? metadata : {
75
- ...metadata,
76
- line: i + 1
77
- }
78
- })
79
- );
80
- }
81
- static async imports() {
82
- try {
83
- const { readFile } = await import("node:fs/promises");
84
- return { readFile };
85
- } catch (e) {
86
- console.error(e);
87
- throw new Error(
88
- `Failed to load fs/promises. TextLoader available only on environment 'node'. It appears you are running environment '${(0, import_env.getEnv)()}'. See https://<link to docs> for alternatives.`
89
- );
90
- }
91
- }
92
- }
93
- // Annotate the CommonJS export names for ESM import in node:
94
- 0 && (module.exports = {
95
- TextLoader
96
- });