@truto/truto-jsonata 1.0.50 → 1.0.51

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/README.md CHANGED
@@ -15,7 +15,7 @@
15
15
 
16
16
  <p align="center">
17
17
  <a href="https://truto.one" target="_blank" rel="noopener noreferrer">Website</a> •
18
- <a href="https://docs.truto.one "target="_blank" rel="noopener noreferrer">Docs</a>
18
+ <a href="https://truto.one/docs" target="_blank" rel="noopener noreferrer">Docs</a>
19
19
  </p>
20
20
 
21
21
  ---
@@ -75926,62 +75926,38 @@ async function encodingForModel(model) {
75926
75926
  }
75927
75927
 
75928
75928
  // node_modules/@langchain/textsplitters/dist/text_splitter.js
75929
- class TextSplitter extends BaseDocumentTransformer {
75929
+ var TextSplitter = class extends BaseDocumentTransformer {
75930
+ lc_namespace = [
75931
+ "langchain",
75932
+ "document_transformers",
75933
+ "text_splitters"
75934
+ ];
75935
+ chunkSize = 1000;
75936
+ chunkOverlap = 200;
75937
+ keepSeparator = false;
75938
+ lengthFunction;
75930
75939
  constructor(fields) {
75931
75940
  super(fields);
75932
- Object.defineProperty(this, "lc_namespace", {
75933
- enumerable: true,
75934
- configurable: true,
75935
- writable: true,
75936
- value: ["langchain", "document_transformers", "text_splitters"]
75937
- });
75938
- Object.defineProperty(this, "chunkSize", {
75939
- enumerable: true,
75940
- configurable: true,
75941
- writable: true,
75942
- value: 1000
75943
- });
75944
- Object.defineProperty(this, "chunkOverlap", {
75945
- enumerable: true,
75946
- configurable: true,
75947
- writable: true,
75948
- value: 200
75949
- });
75950
- Object.defineProperty(this, "keepSeparator", {
75951
- enumerable: true,
75952
- configurable: true,
75953
- writable: true,
75954
- value: false
75955
- });
75956
- Object.defineProperty(this, "lengthFunction", {
75957
- enumerable: true,
75958
- configurable: true,
75959
- writable: true,
75960
- value: undefined
75961
- });
75962
75941
  this.chunkSize = fields?.chunkSize ?? this.chunkSize;
75963
75942
  this.chunkOverlap = fields?.chunkOverlap ?? this.chunkOverlap;
75964
75943
  this.keepSeparator = fields?.keepSeparator ?? this.keepSeparator;
75965
75944
  this.lengthFunction = fields?.lengthFunction ?? ((text) => text.length);
75966
- if (this.chunkOverlap >= this.chunkSize) {
75945
+ if (this.chunkOverlap >= this.chunkSize)
75967
75946
  throw new Error("Cannot have chunkOverlap >= chunkSize");
75968
- }
75969
75947
  }
75970
75948
  async transformDocuments(documents, chunkHeaderOptions = {}) {
75971
75949
  return this.splitDocuments(documents, chunkHeaderOptions);
75972
75950
  }
75973
75951
  splitOnSeparator(text, separator) {
75974
75952
  let splits;
75975
- if (separator) {
75953
+ if (separator)
75976
75954
  if (this.keepSeparator) {
75977
75955
  const regexEscapedSeparator = separator.replace(/[/\-\\^$*+?.()|[\]{}]/g, "\\$&");
75978
- splits = text.split(new RegExp(`(?=${regexEscapedSeparator})`));
75979
- } else {
75956
+ splits = text.split(/* @__PURE__ */ new RegExp(`(?=${regexEscapedSeparator})`));
75957
+ } else
75980
75958
  splits = text.split(separator);
75981
- }
75982
- } else {
75959
+ else
75983
75960
  splits = text.split("");
75984
- }
75985
75961
  return splits.filter((s2) => s2 !== "");
75986
75962
  }
75987
75963
  async createDocuments(texts, metadatas = [], chunkHeaderOptions = {}) {
@@ -76008,9 +75984,8 @@ class TextSplitter extends BaseDocumentTransformer {
76008
75984
  const numberOfIntermediateNewLines = this.numberOfNewLines(text, indexChunk, indexEndPrevChunk);
76009
75985
  lineCounterIndex -= numberOfIntermediateNewLines;
76010
75986
  }
76011
- if (appendChunkOverlapHeader) {
75987
+ if (appendChunkOverlapHeader)
76012
75988
  pageContent += chunkOverlapHeader;
76013
- }
76014
75989
  }
76015
75990
  const newLinesCount = this.numberOfNewLines(chunk2);
76016
75991
  const loc = _metadatas[i3].loc && typeof _metadatas[i3].loc === "object" ? { ..._metadatas[i3].loc } : {};
@@ -76055,15 +76030,13 @@ class TextSplitter extends BaseDocumentTransformer {
76055
76030
  for (const d of splits) {
76056
76031
  const _len = await this.lengthFunction(d);
76057
76032
  if (total + _len + currentDoc.length * separator.length > this.chunkSize) {
76058
- if (total > this.chunkSize) {
76033
+ if (total > this.chunkSize)
76059
76034
  console.warn(`Created a chunk of size ${total}, +
76060
76035
  which is longer than the specified ${this.chunkSize}`);
76061
- }
76062
76036
  if (currentDoc.length > 0) {
76063
- const doc3 = this.joinDocs(currentDoc, separator);
76064
- if (doc3 !== null) {
76065
- docs.push(doc3);
76066
- }
76037
+ const doc$1 = this.joinDocs(currentDoc, separator);
76038
+ if (doc$1 !== null)
76039
+ docs.push(doc$1);
76067
76040
  while (total > this.chunkOverlap || total + _len + currentDoc.length * separator.length > this.chunkSize && total > 0) {
76068
76041
  total -= await this.lengthFunction(currentDoc[0]);
76069
76042
  currentDoc.shift();
@@ -76074,27 +76047,26 @@ which is longer than the specified ${this.chunkSize}`);
76074
76047
  total += _len;
76075
76048
  }
76076
76049
  const doc2 = this.joinDocs(currentDoc, separator);
76077
- if (doc2 !== null) {
76050
+ if (doc2 !== null)
76078
76051
  docs.push(doc2);
76079
- }
76080
76052
  return docs;
76081
76053
  }
76082
- }
76083
- class RecursiveCharacterTextSplitter extends TextSplitter {
76054
+ };
76055
+ var RecursiveCharacterTextSplitter = class RecursiveCharacterTextSplitter2 extends TextSplitter {
76084
76056
  static lc_name() {
76085
76057
  return "RecursiveCharacterTextSplitter";
76086
76058
  }
76059
+ separators = [
76060
+ `
76061
+
76062
+ `,
76063
+ `
76064
+ `,
76065
+ " ",
76066
+ ""
76067
+ ];
76087
76068
  constructor(fields) {
76088
76069
  super(fields);
76089
- Object.defineProperty(this, "separators", {
76090
- enumerable: true,
76091
- configurable: true,
76092
- writable: true,
76093
- value: [`
76094
-
76095
- `, `
76096
- `, " ", ""]
76097
- });
76098
76070
  this.separators = fields?.separators ?? this.separators;
76099
76071
  this.keepSeparator = fields?.keepSeparator ?? true;
76100
76072
  }
@@ -76117,23 +76089,22 @@ class RecursiveCharacterTextSplitter extends TextSplitter {
76117
76089
  const splits = this.splitOnSeparator(text, separator);
76118
76090
  let goodSplits = [];
76119
76091
  const _separator = this.keepSeparator ? "" : separator;
76120
- for (const s2 of splits) {
76121
- if (await this.lengthFunction(s2) < this.chunkSize) {
76092
+ for (const s2 of splits)
76093
+ if (await this.lengthFunction(s2) < this.chunkSize)
76122
76094
  goodSplits.push(s2);
76123
- } else {
76095
+ else {
76124
76096
  if (goodSplits.length) {
76125
76097
  const mergedText = await this.mergeSplits(goodSplits, _separator);
76126
76098
  finalChunks.push(...mergedText);
76127
76099
  goodSplits = [];
76128
76100
  }
76129
- if (!newSeparators) {
76101
+ if (!newSeparators)
76130
76102
  finalChunks.push(s2);
76131
- } else {
76103
+ else {
76132
76104
  const otherInfo = await this._splitText(s2, newSeparators);
76133
76105
  finalChunks.push(...otherInfo);
76134
76106
  }
76135
76107
  }
76136
- }
76137
76108
  if (goodSplits.length) {
76138
76109
  const mergedText = await this.mergeSplits(goodSplits, _separator);
76139
76110
  finalChunks.push(...mergedText);
@@ -76144,13 +76115,13 @@ class RecursiveCharacterTextSplitter extends TextSplitter {
76144
76115
  return this._splitText(text, this.separators);
76145
76116
  }
76146
76117
  static fromLanguage(language, options3) {
76147
- return new RecursiveCharacterTextSplitter({
76118
+ return new RecursiveCharacterTextSplitter2({
76148
76119
  ...options3,
76149
- separators: RecursiveCharacterTextSplitter.getSeparatorsForLanguage(language)
76120
+ separators: RecursiveCharacterTextSplitter2.getSeparatorsForLanguage(language)
76150
76121
  });
76151
76122
  }
76152
76123
  static getSeparatorsForLanguage(language) {
76153
- if (language === "cpp") {
76124
+ if (language === "cpp")
76154
76125
  return [
76155
76126
  `
76156
76127
  class `,
@@ -76180,7 +76151,7 @@ case `,
76180
76151
  " ",
76181
76152
  ""
76182
76153
  ];
76183
- } else if (language === "go") {
76154
+ else if (language === "go")
76184
76155
  return [
76185
76156
  `
76186
76157
  func `,
@@ -76206,7 +76177,7 @@ case `,
76206
76177
  " ",
76207
76178
  ""
76208
76179
  ];
76209
- } else if (language === "java") {
76180
+ else if (language === "java")
76210
76181
  return [
76211
76182
  `
76212
76183
  class `,
@@ -76236,7 +76207,7 @@ case `,
76236
76207
  " ",
76237
76208
  ""
76238
76209
  ];
76239
- } else if (language === "js") {
76210
+ else if (language === "js")
76240
76211
  return [
76241
76212
  `
76242
76213
  function `,
@@ -76268,7 +76239,7 @@ default `,
76268
76239
  " ",
76269
76240
  ""
76270
76241
  ];
76271
- } else if (language === "php") {
76242
+ else if (language === "php")
76272
76243
  return [
76273
76244
  `
76274
76245
  function `,
@@ -76294,7 +76265,7 @@ case `,
76294
76265
  " ",
76295
76266
  ""
76296
76267
  ];
76297
- } else if (language === "proto") {
76268
+ else if (language === "proto")
76298
76269
  return [
76299
76270
  `
76300
76271
  message `,
@@ -76316,7 +76287,7 @@ syntax `,
76316
76287
  " ",
76317
76288
  ""
76318
76289
  ];
76319
- } else if (language === "python") {
76290
+ else if (language === "python")
76320
76291
  return [
76321
76292
  `
76322
76293
  class `,
@@ -76332,7 +76303,7 @@ def `,
76332
76303
  " ",
76333
76304
  ""
76334
76305
  ];
76335
- } else if (language === "rst") {
76306
+ else if (language === "rst")
76336
76307
  return [
76337
76308
  `
76338
76309
  ===
@@ -76353,7 +76324,7 @@ def `,
76353
76324
  " ",
76354
76325
  ""
76355
76326
  ];
76356
- } else if (language === "ruby") {
76327
+ else if (language === "ruby")
76357
76328
  return [
76358
76329
  `
76359
76330
  def `,
@@ -76381,7 +76352,7 @@ rescue `,
76381
76352
  " ",
76382
76353
  ""
76383
76354
  ];
76384
- } else if (language === "rust") {
76355
+ else if (language === "rust")
76385
76356
  return [
76386
76357
  `
76387
76358
  fn `,
@@ -76409,7 +76380,7 @@ const `,
76409
76380
  " ",
76410
76381
  ""
76411
76382
  ];
76412
- } else if (language === "scala") {
76383
+ else if (language === "scala")
76413
76384
  return [
76414
76385
  `
76415
76386
  class `,
@@ -76439,7 +76410,7 @@ case `,
76439
76410
  " ",
76440
76411
  ""
76441
76412
  ];
76442
- } else if (language === "swift") {
76413
+ else if (language === "swift")
76443
76414
  return [
76444
76415
  `
76445
76416
  func `,
@@ -76469,7 +76440,7 @@ case `,
76469
76440
  " ",
76470
76441
  ""
76471
76442
  ];
76472
- } else if (language === "markdown") {
76443
+ else if (language === "markdown")
76473
76444
  return [
76474
76445
  `
76475
76446
  ## `,
@@ -76505,7 +76476,7 @@ ___
76505
76476
  " ",
76506
76477
  ""
76507
76478
  ];
76508
- } else if (language === "latex") {
76479
+ else if (language === "latex")
76509
76480
  return [
76510
76481
  `
76511
76482
  \\chapter{`,
@@ -76543,7 +76514,7 @@ ___
76543
76514
  " ",
76544
76515
  ""
76545
76516
  ];
76546
- } else if (language === "html") {
76517
+ else if (language === "html")
76547
76518
  return [
76548
76519
  "<body>",
76549
76520
  "<div>",
@@ -76574,7 +76545,7 @@ ___
76574
76545
  " ",
76575
76546
  ""
76576
76547
  ];
76577
- } else if (language === "sol") {
76548
+ else if (language === "sol")
76578
76549
  return [
76579
76550
  `
76580
76551
  pragma `,
@@ -76620,11 +76591,11 @@ assembly `,
76620
76591
  " ",
76621
76592
  ""
76622
76593
  ];
76623
- } else {
76594
+ else
76624
76595
  throw new Error(`Language ${language} is not supported.`);
76625
- }
76626
76596
  }
76627
- }
76597
+ };
76598
+
76628
76599
  // src/functions/recursiveCharacterTextSplitter.ts
76629
76600
  async function recursiveCharacterTextSplitter(text, options3 = { chunkSize: 200, chunkOverlap: 60 }) {
76630
76601
  let textToSplit;
@@ -76892,4 +76863,4 @@ export {
76892
76863
  trutoJsonata as default
76893
76864
  };
76894
76865
 
76895
- //# debugId=6DD9A5186EEBCF8964756E2164756E21
76866
+ //# debugId=F1B366A39391A4F164756E2164756E21