node-llama-cpp 3.0.0-beta.17 → 3.0.0-beta.19

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.
Files changed (167) hide show
  1. package/README.md +8 -5
  2. package/dist/ChatWrapper.js +3 -3
  3. package/dist/ChatWrapper.js.map +1 -1
  4. package/dist/apiDocsOverrides.d.ts +1 -0
  5. package/dist/apiDocsOverrides.js +5 -0
  6. package/dist/apiDocsOverrides.js.map +1 -0
  7. package/dist/bindings/AddonTypes.d.ts +1 -0
  8. package/dist/bindings/Llama.d.ts +6 -0
  9. package/dist/bindings/Llama.js +11 -0
  10. package/dist/bindings/Llama.js.map +1 -1
  11. package/dist/bindings/getLlama.d.ts +6 -2
  12. package/dist/bindings/getLlama.js +11 -4
  13. package/dist/bindings/getLlama.js.map +1 -1
  14. package/dist/bindings/utils/hasBuildingFromSourceDependenciesInstalled.d.ts +3 -0
  15. package/dist/bindings/utils/hasBuildingFromSourceDependenciesInstalled.js +27 -0
  16. package/dist/bindings/utils/hasBuildingFromSourceDependenciesInstalled.js.map +1 -0
  17. package/dist/chatWrappers/generic/TemplateChatWrapper.d.ts +1 -2
  18. package/dist/chatWrappers/generic/TemplateChatWrapper.js +1 -2
  19. package/dist/chatWrappers/generic/TemplateChatWrapper.js.map +1 -1
  20. package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.js +2 -2
  21. package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.js.map +1 -1
  22. package/dist/cli/cli.js +5 -3
  23. package/dist/cli/cli.js.map +1 -1
  24. package/dist/cli/commands/DebugCommand.js +3 -5
  25. package/dist/cli/commands/DebugCommand.js.map +1 -1
  26. package/dist/cli/commands/DownloadCommand.d.ts +1 -1
  27. package/dist/cli/commands/DownloadCommand.js +2 -1
  28. package/dist/cli/commands/DownloadCommand.js.map +1 -1
  29. package/dist/cli/commands/PullCommand.d.ts +12 -0
  30. package/dist/cli/commands/PullCommand.js +109 -0
  31. package/dist/cli/commands/PullCommand.js.map +1 -0
  32. package/dist/cli/commands/inspect/commands/InspectGgufCommand.d.ts +1 -0
  33. package/dist/cli/commands/inspect/commands/InspectGgufCommand.js +23 -11
  34. package/dist/cli/commands/inspect/commands/InspectGgufCommand.js.map +1 -1
  35. package/dist/cli/commands/inspect/commands/InspectMeasureCommand.js +2 -1
  36. package/dist/cli/commands/inspect/commands/InspectMeasureCommand.js.map +1 -1
  37. package/dist/cli/recommendedModels.js +12 -20
  38. package/dist/cli/recommendedModels.js.map +1 -1
  39. package/dist/cli/utils/resolveCommandGgufPath.d.ts +3 -1
  40. package/dist/cli/utils/resolveCommandGgufPath.js +41 -97
  41. package/dist/cli/utils/resolveCommandGgufPath.js.map +1 -1
  42. package/dist/cli/utils/resolveModelRecommendationFileOptions.d.ts +2 -2
  43. package/dist/cli/utils/resolveModelRecommendationFileOptions.js +1 -4
  44. package/dist/cli/utils/resolveModelRecommendationFileOptions.js.map +1 -1
  45. package/dist/evaluator/LlamaChat/LlamaChat.d.ts +18 -2
  46. package/dist/evaluator/LlamaChat/LlamaChat.js +258 -205
  47. package/dist/evaluator/LlamaChat/LlamaChat.js.map +1 -1
  48. package/dist/evaluator/LlamaChat/utils/FunctionCallGrammar.js +1 -2
  49. package/dist/evaluator/LlamaChat/utils/FunctionCallGrammar.js.map +1 -1
  50. package/dist/evaluator/LlamaChatSession/LlamaChatSession.d.ts +22 -3
  51. package/dist/evaluator/LlamaChatSession/LlamaChatSession.js +18 -7
  52. package/dist/evaluator/LlamaChatSession/LlamaChatSession.js.map +1 -1
  53. package/dist/evaluator/LlamaCompletion.js +2 -2
  54. package/dist/evaluator/LlamaCompletion.js.map +1 -1
  55. package/dist/evaluator/LlamaContext/LlamaContext.d.ts +2 -7
  56. package/dist/evaluator/LlamaContext/LlamaContext.js +12 -12
  57. package/dist/evaluator/LlamaContext/LlamaContext.js.map +1 -1
  58. package/dist/evaluator/LlamaEmbeddingContext.d.ts +2 -10
  59. package/dist/evaluator/LlamaEmbeddingContext.js +9 -23
  60. package/dist/evaluator/LlamaEmbeddingContext.js.map +1 -1
  61. package/dist/evaluator/LlamaGrammar.d.ts +3 -3
  62. package/dist/evaluator/LlamaGrammar.js +3 -3
  63. package/dist/evaluator/LlamaGrammar.js.map +1 -1
  64. package/dist/evaluator/LlamaJsonSchemaGrammar.js +2 -3
  65. package/dist/evaluator/LlamaJsonSchemaGrammar.js.map +1 -1
  66. package/dist/evaluator/LlamaModel.d.ts +9 -0
  67. package/dist/evaluator/LlamaModel.js +2 -1
  68. package/dist/evaluator/LlamaModel.js.map +1 -1
  69. package/dist/gguf/insights/GgufInsights.js +12 -12
  70. package/dist/gguf/insights/GgufInsights.js.map +1 -1
  71. package/dist/gguf/insights/utils/resolveContextContextSizeOption.js +27 -3
  72. package/dist/gguf/insights/utils/resolveContextContextSizeOption.js.map +1 -1
  73. package/dist/gguf/parser/parseGguf.js +5 -0
  74. package/dist/gguf/parser/parseGguf.js.map +1 -1
  75. package/dist/gguf/readGgufFileInfo.d.ts +5 -2
  76. package/dist/gguf/readGgufFileInfo.js +38 -10
  77. package/dist/gguf/readGgufFileInfo.js.map +1 -1
  78. package/dist/gguf/types/GgufFileInfoTypes.d.ts +32 -0
  79. package/dist/gguf/types/GgufFileInfoTypes.js.map +1 -1
  80. package/dist/gguf/utils/getGgufMetadataArchitectureData.js +1 -1
  81. package/dist/gguf/utils/getGgufMetadataArchitectureData.js.map +1 -1
  82. package/dist/gguf/utils/resolveBinarySplitGgufPartUrls.d.ts +2 -0
  83. package/dist/gguf/utils/resolveBinarySplitGgufPartUrls.js +39 -0
  84. package/dist/gguf/utils/resolveBinarySplitGgufPartUrls.js.map +1 -0
  85. package/dist/gguf/utils/resolveSplitGgufParts.d.ts +7 -0
  86. package/dist/gguf/utils/resolveSplitGgufParts.js +55 -0
  87. package/dist/gguf/utils/resolveSplitGgufParts.js.map +1 -0
  88. package/dist/index.d.ts +6 -4
  89. package/dist/index.js +4 -2
  90. package/dist/index.js.map +1 -1
  91. package/dist/utils/LlamaText.d.ts +29 -20
  92. package/dist/utils/LlamaText.js +253 -243
  93. package/dist/utils/LlamaText.js.map +1 -1
  94. package/dist/utils/StopGenerationDetector.d.ts +1 -1
  95. package/dist/utils/StopGenerationDetector.js +2 -0
  96. package/dist/utils/StopGenerationDetector.js.map +1 -1
  97. package/dist/utils/TokenStreamRegulator.d.ts +4 -2
  98. package/dist/utils/TokenStreamRegulator.js +56 -4
  99. package/dist/utils/TokenStreamRegulator.js.map +1 -1
  100. package/dist/utils/createModelDownloader.d.ts +99 -0
  101. package/dist/utils/createModelDownloader.js +226 -0
  102. package/dist/utils/createModelDownloader.js.map +1 -0
  103. package/dist/utils/findCharacterRemovalCountToFitChatHistoryInContext.js +18 -8
  104. package/dist/utils/findCharacterRemovalCountToFitChatHistoryInContext.js.map +1 -1
  105. package/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.d.ts +5 -0
  106. package/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.js +11 -0
  107. package/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.js.map +1 -0
  108. package/dist/utils/gbnfJson/terminals/GbnfArray.d.ts +3 -1
  109. package/dist/utils/gbnfJson/terminals/GbnfArray.js +10 -5
  110. package/dist/utils/gbnfJson/terminals/GbnfArray.js.map +1 -1
  111. package/dist/utils/gbnfJson/terminals/GbnfObjectMap.d.ts +3 -1
  112. package/dist/utils/gbnfJson/terminals/GbnfObjectMap.js +9 -4
  113. package/dist/utils/gbnfJson/terminals/GbnfObjectMap.js.map +1 -1
  114. package/dist/utils/gbnfJson/terminals/GbnfRepetition.d.ts +9 -0
  115. package/dist/utils/gbnfJson/terminals/GbnfRepetition.js +37 -0
  116. package/dist/utils/gbnfJson/terminals/GbnfRepetition.js.map +1 -0
  117. package/dist/utils/gbnfJson/terminals/GbnfString.js +23 -5
  118. package/dist/utils/gbnfJson/terminals/GbnfString.js.map +1 -1
  119. package/dist/utils/gbnfJson/terminals/GbnfWhitespace.d.ts +6 -3
  120. package/dist/utils/gbnfJson/terminals/GbnfWhitespace.js +37 -9
  121. package/dist/utils/gbnfJson/terminals/GbnfWhitespace.js.map +1 -1
  122. package/dist/utils/gbnfJson/terminals/gbnfConsts.d.ts +5 -4
  123. package/dist/utils/gbnfJson/terminals/gbnfConsts.js +14 -3
  124. package/dist/utils/gbnfJson/terminals/gbnfConsts.js.map +1 -1
  125. package/dist/utils/gbnfJson/utils/GbnfJsonScopeState.d.ts +10 -0
  126. package/dist/utils/gbnfJson/utils/GbnfJsonScopeState.js +15 -0
  127. package/dist/utils/gbnfJson/utils/GbnfJsonScopeState.js.map +1 -0
  128. package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.d.ts +2 -1
  129. package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js +6 -5
  130. package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js.map +1 -1
  131. package/dist/utils/parseTextTemplate.d.ts +2 -2
  132. package/dist/utils/parseTextTemplate.js +2 -2
  133. package/dist/utils/runtime.d.ts +4 -0
  134. package/dist/utils/runtime.js +8 -0
  135. package/dist/utils/runtime.js.map +1 -0
  136. package/llama/addon.cpp +18 -7
  137. package/llama/binariesGithubRelease.json +1 -1
  138. package/llama/gitRelease.bundle +0 -0
  139. package/llama/grammars/README.md +1 -1
  140. package/llama/llama.cpp.info.json +1 -1
  141. package/llamaBins/linux-arm64/_nlcBuildMetadata.json +1 -1
  142. package/llamaBins/linux-arm64/llama-addon.node +0 -0
  143. package/llamaBins/linux-armv7l/_nlcBuildMetadata.json +1 -1
  144. package/llamaBins/linux-armv7l/llama-addon.node +0 -0
  145. package/llamaBins/linux-x64/_nlcBuildMetadata.json +1 -1
  146. package/llamaBins/linux-x64/llama-addon.node +0 -0
  147. package/llamaBins/linux-x64-cuda/_nlcBuildMetadata.json +1 -1
  148. package/llamaBins/linux-x64-cuda/llama-addon.node +0 -0
  149. package/llamaBins/linux-x64-vulkan/_nlcBuildMetadata.json +1 -1
  150. package/llamaBins/linux-x64-vulkan/llama-addon.node +0 -0
  151. package/llamaBins/mac-arm64-metal/_nlcBuildMetadata.json +1 -1
  152. package/llamaBins/mac-arm64-metal/default.metallib +0 -0
  153. package/llamaBins/mac-arm64-metal/llama-addon.node +0 -0
  154. package/llamaBins/mac-x64/_nlcBuildMetadata.json +1 -1
  155. package/llamaBins/mac-x64/llama-addon.node +0 -0
  156. package/llamaBins/win-arm64/_nlcBuildMetadata.json +1 -1
  157. package/llamaBins/win-arm64/llama-addon.node +0 -0
  158. package/llamaBins/win-x64/_nlcBuildMetadata.json +1 -1
  159. package/llamaBins/win-x64/llama-addon.node +0 -0
  160. package/llamaBins/win-x64-cuda/_nlcBuildMetadata.json +1 -1
  161. package/llamaBins/win-x64-cuda/llama-addon.node +0 -0
  162. package/llamaBins/win-x64-vulkan/_nlcBuildMetadata.json +1 -1
  163. package/llamaBins/win-x64-vulkan/llama-addon.node +0 -0
  164. package/package.json +11 -8
  165. package/dist/utils/getGbnfGrammarForGbnfJsonSchema.d.ts +0 -2
  166. package/dist/utils/getGbnfGrammarForGbnfJsonSchema.js +0 -9
  167. package/dist/utils/getGbnfGrammarForGbnfJsonSchema.js.map +0 -1
@@ -32,7 +32,9 @@ export function resolveContextContextSizeOption({ contextSize, batchSize, sequen
32
32
  const minContextSize = contextSize === "auto"
33
33
  ? minAllowedContextSizeInCalculations
34
34
  : Math.max(contextSize.min ?? minAllowedContextSizeInCalculations, minAllowedContextSizeInCalculations);
35
- for (let testContextSize = maxContextSize; testContextSize >= minContextSize; testContextSize--) {
35
+ let highestCompatibleContextSize = null;
36
+ let step = -Math.max(1, Math.floor((maxContextSize - minContextSize) / 4));
37
+ for (let testContextSize = maxContextSize; testContextSize >= minContextSize && testContextSize <= maxContextSize;) {
36
38
  const contextVram = modelFileInsights.estimateContextResourceRequirements({
37
39
  contextSize: testContextSize,
38
40
  batchSize: batchSize ?? getDefaultContextBatchSize({ contextSize: testContextSize, sequences }),
@@ -40,9 +42,31 @@ export function resolveContextContextSizeOption({ contextSize, batchSize, sequen
40
42
  sequences,
41
43
  isEmbeddingContext
42
44
  }).gpuVram;
43
- if (contextVram <= freeVram)
44
- return testContextSize;
45
+ if (contextVram <= freeVram) {
46
+ if (highestCompatibleContextSize == null || testContextSize > highestCompatibleContextSize) {
47
+ highestCompatibleContextSize = testContextSize;
48
+ if (step === -1)
49
+ break;
50
+ else if (step < 0)
51
+ step = Math.max(1, Math.floor(-step / 2));
52
+ }
53
+ }
54
+ else if (step > 0)
55
+ step = -Math.max(1, Math.floor(step / 2));
56
+ if (testContextSize == minContextSize && step === -1)
57
+ break;
58
+ testContextSize += step;
59
+ if (testContextSize < minContextSize) {
60
+ testContextSize = minContextSize;
61
+ step = Math.max(1, Math.floor(Math.abs(step) / 2));
62
+ }
63
+ else if (testContextSize > maxContextSize) {
64
+ testContextSize = maxContextSize;
65
+ step = -Math.max(1, Math.floor(Math.abs(step) / 2));
66
+ }
45
67
  }
68
+ if (highestCompatibleContextSize != null)
69
+ return highestCompatibleContextSize;
46
70
  if (ignoreMemorySafetyChecks)
47
71
  return minContextSize;
48
72
  throw new Error(`The available VRAM is too small to fit the context size of ${maxContextSize}${sequences > 1 ? ` with ${sequences} sequences` : ""}`);
@@ -1 +1 @@
1
- {"version":3,"file":"resolveContextContextSizeOption.js","sourceRoot":"","sources":["../../../../src/gguf/insights/utils/resolveContextContextSizeOption.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,mCAAmC,EAAC,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAC,0BAA0B,EAAE,0BAA0B,EAAC,MAAM,iDAAiD,CAAC;AAEvH,MAAM,UAAU,+BAA+B,CAAC,EAC5C,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,iBAAiB,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,EAAE,QAAQ,EACnH,wBAAwB,GAAG,KAA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YACvE,CAAC,CAAC,IAAI,CAAC,GAAG,CACN,WAAW,CAAC,GAAG,IAAI,0BAA0B,CAAC,EAAC,gBAAgB,EAAE,qBAAqB,EAAC,CAAC,EACxF,0BAA0B,CAAC,EAAC,gBAAgB,EAAE,qBAAqB,EAAC,CAAC,CACxE,CAAC;QAEN,MAAM,cAAc,GAAG,WAAW,KAAK,MAAM;YACzC,CAAC,CAAC,mCAAmC;YACrC,CAAC,CAAC,IAAI,CAAC,GAAG,CACN,WAAW,CAAC,GAAG,IAAI,mCAAmC,EACtD,mCAAmC,CACtC,CAAC;QAEN,KAAK,IAAI,eAAe,GAAG,cAAc,EAAE,eAAe,IAAI,cAAc,EAAE,eAAe,EAAE,EAAE;YAC7F,MAAM,WAAW,GAAG,iBAAiB,CAAC,mCAAmC,CAAC;gBACtE,WAAW,EAAE,eAAe;gBAC5B,SAAS,EAAE,SAAS,IAAI,0BAA0B,CAAC,EAAC,WAAW,EAAE,eAAe,EAAE,SAAS,EAAC,CAAC;gBAC7F,cAAc,EAAE,cAAc;gBAC9B,SAAS;gBACT,kBAAkB;aACrB,CAAC,CAAC,OAAO,CAAC;YAEX,IAAI,WAAW,IAAI,QAAQ;gBACvB,OAAO,eAAe,CAAC;SAC9B;QAED,IAAI,wBAAwB;YACxB,OAAO,cAAc,CAAC;QAE1B,MAAM,IAAI,KAAK,CAAC,8DAA8D,cAAc,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,SAAS,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;KACzJ;IAED,MAAM,IAAI,KAAK,CAAC,0BAA0B,WAAW,GAAG,CAAC,CAAC;AAC9D,CAAC"}
1
+ {"version":3,"file":"resolveContextContextSizeOption.js","sourceRoot":"","sources":["../../../../src/gguf/insights/utils/resolveContextContextSizeOption.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,mCAAmC,EAAC,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAC,0BAA0B,EAA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G,CAAC,CAAC;AAC9D,CAAC"}
@@ -26,6 +26,11 @@ export async function parseGguf({ fileReader, readTensorInfo = true, ignoreKeys
26
26
  architectureMetadata: architectureMetadata,
27
27
  tensorInfo: gguifInfo.tensorInfo,
28
28
  metadataSize: gguifInfo.metadataSize,
29
+ splicedParts: 1,
30
+ totalTensorInfoSize: gguifInfo.tensorInfoSize,
31
+ totalTensorCount: gguifInfo.tensorCount,
32
+ totalMetadataSize: gguifInfo.metadataSize,
33
+ fullTensorInfo: gguifInfo.tensorInfo,
29
34
  tensorInfoSize: gguifInfo.tensorInfoSize
30
35
  };
31
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parseGguf.js","sourceRoot":"","sources":["../../../src/gguf/parser/parseGguf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,qBAAqB,EAAC,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAC,mBAAmB,EAAC,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAiB,sBAAsB,EAAC,MAAM,kCAAkC,CAAC;AAExF,OAAO,EAAC,+BAA+B,EAAC,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAC,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAE/C,MAAM,SAAS,GAAG,MAAM,CAAC;AAEzB,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,EAC5B,UAAU,EACV,cAAc,GAAG,IAAI,EACrB,UAAU,GAAG,EAAE,EACf,WAAW,GAAG,IAAI,EAMrB;IACG,MAAM,UAAU,GAAG,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;IACzC,MAAM,eAAe,GAAG,MAAM,oBAAoB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC3E,MAAM,SAAS,GAAG,MA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D,CAAC,CAAC;QAEvF,KAAK,CAAC;YACF,OAAO,MAAM,CAAC,IAAI,YAAY,CAAC,4BAA4B,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;QAE1E,KAAK,CAAC;YACF,OAAO,MAAM,CAAC,IAAI,YAAY,CAAC,4BAA4B,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;QAE1E;YACI,IAAI,4BAA4B,CAAC,WAAW;gBACxC,OAAO,CAAC,IAAI,CACR,mBAAmB,EAAE;oBACrB,6BAA6B,4BAA4B,CAAC,OAAO,uCAAuC,CAC3G,CAAC;YAEN,OAAO,MAAM,CAAC,IAAI,YAAY,CAAC,4BAA4B,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;KAC7E;AACL,CAAC"}
@@ -1,10 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  import retry from "async-retry";
3
+ import { GgufFileInfo } from "./types/GgufFileInfoTypes.js";
3
4
  /**
4
5
  * Read a GGUF file and return its metadata and tensor info (unless `readTensorInfo` is set to `false`).
5
6
  * Only the parts of the file required for the metadata and tensor info are read.
6
7
  */
7
- export declare function readGgufFileInfo(pathOrUrl: string, { readTensorInfo, sourceType, ignoreKeys, logWarnings, fetchRetryOptions, fetchHeaders, signal }?: {
8
+ export declare function readGgufFileInfo(pathOrUrl: string, { readTensorInfo, sourceType, ignoreKeys, logWarnings, fetchRetryOptions, fetchHeaders, spliceSplitFiles, signal }?: {
8
9
  /**
9
10
  * Whether to read the tensor info from the file's header
10
11
  * Enabled by default.
@@ -26,5 +27,7 @@ export declare function readGgufFileInfo(pathOrUrl: string, { readTensorInfo, so
26
27
  fetchRetryOptions?: retry.Options;
27
28
  /** Relevant only when fetching from a network */
28
29
  fetchHeaders?: Record<string, string>;
30
+ /** When split files are detected, read the metadata of the first file and splice the tensor info from all the parts */
31
+ spliceSplitFiles?: boolean;
29
32
  signal?: AbortSignal;
30
- }): Promise<import("./types/GgufFileInfoTypes.js").GgufFileInfo>;
33
+ }): Promise<GgufFileInfo>;
@@ -4,13 +4,15 @@ import { GgufNetworkFetchFileReader } from "./fileReaders/GgufNetworkFetchFileRe
4
4
  import { GgufFsFileReader } from "./fileReaders/GgufFsFileReader.js";
5
5
  import { ggufDefaultFetchRetryOptions } from "./consts.js";
6
6
  import { normalizeGgufDownloadUrl } from "./utils/normalizeGgufDownloadUrl.js";
7
+ import { resolveSplitGgufParts } from "./utils/resolveSplitGgufParts.js";
7
8
  /**
8
9
  * Read a GGUF file and return its metadata and tensor info (unless `readTensorInfo` is set to `false`).
9
10
  * Only the parts of the file required for the metadata and tensor info are read.
10
11
  */
11
- export async function readGgufFileInfo(pathOrUrl, { readTensorInfo = true, sourceType, ignoreKeys = [], logWarnings = true, fetchRetryOptions = ggufDefaultFetchRetryOptions, fetchHeaders = {}, signal } = {}) {
12
- function createFileReader() {
13
- if (sourceType === "network" || (sourceType == null && isUrl(pathOrUrl))) {
12
+ export async function readGgufFileInfo(pathOrUrl, { readTensorInfo = true, sourceType, ignoreKeys = [], logWarnings = true, fetchRetryOptions = ggufDefaultFetchRetryOptions, fetchHeaders = {}, spliceSplitFiles = true, signal } = {}) {
13
+ const useNetworkReader = sourceType === "network" || (sourceType == null && isUrl(pathOrUrl));
14
+ function createFileReader(pathOrUrl) {
15
+ if (useNetworkReader) {
14
16
  return new GgufNetworkFetchFileReader({
15
17
  url: normalizeGgufDownloadUrl(pathOrUrl),
16
18
  retryOptions: fetchRetryOptions,
@@ -27,12 +29,38 @@ export async function readGgufFileInfo(pathOrUrl, { readTensorInfo = true, sourc
27
29
  void (sourceType);
28
30
  throw new Error(`Unsupported sourceType: ${sourceType}`);
29
31
  }
30
- const fileReader = createFileReader();
31
- return await parseGguf({
32
- fileReader,
33
- ignoreKeys,
34
- readTensorInfo,
35
- logWarnings
36
- });
32
+ async function readSingleFile(pathOrUrl) {
33
+ const fileReader = createFileReader(pathOrUrl);
34
+ return await parseGguf({
35
+ fileReader,
36
+ ignoreKeys,
37
+ readTensorInfo,
38
+ logWarnings
39
+ });
40
+ }
41
+ if (!spliceSplitFiles)
42
+ return await readSingleFile(pathOrUrl);
43
+ const allSplitPartPaths = resolveSplitGgufParts(pathOrUrl);
44
+ if (allSplitPartPaths.length === 1)
45
+ return await readSingleFile(allSplitPartPaths[0]);
46
+ const [first, ...rest] = await Promise.all(allSplitPartPaths.map((partPath) => readSingleFile(partPath)));
47
+ return {
48
+ version: first.version,
49
+ tensorCount: first.tensorCount,
50
+ metadata: first.metadata,
51
+ architectureMetadata: first.architectureMetadata,
52
+ tensorInfo: first.tensorInfo,
53
+ metadataSize: first.metadataSize,
54
+ splicedParts: allSplitPartPaths.length,
55
+ totalTensorInfoSize: first.totalTensorInfoSize == null
56
+ ? undefined
57
+ : (first.totalTensorInfoSize + rest.reduce((acc, part) => (acc + (part.totalTensorInfoSize ?? 0)), 0)),
58
+ totalTensorCount: Number(first.totalTensorCount) + rest.reduce((acc, part) => acc + Number(part.totalTensorCount), 0),
59
+ totalMetadataSize: first.totalMetadataSize + rest.reduce((acc, part) => acc + part.totalMetadataSize, 0),
60
+ fullTensorInfo: first.fullTensorInfo == null
61
+ ? undefined
62
+ : [first, ...rest].flatMap(part => (part.fullTensorInfo ?? [])),
63
+ tensorInfoSize: first.tensorInfoSize
64
+ };
37
65
  }
38
66
  //# sourceMappingURL=readGgufFileInfo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"readGgufFileInfo.js","sourceRoot":"","sources":["../../src/gguf/readGgufFileInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAC,0BAA0B,EAAC,MAAM,6CAA6C,CAAC;AACvF,OAAO,EAAC,gBAAgB,EAAC,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAC,4BAA4B,EAAC,MAAM,aAAa,CAAC;AACzD,OAAO,EAAC,wBAAwB,EAAC,MAAM,qCAAqC,CAAC;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,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;QACxG,cAAc,EAAE,KAAK,CAAC,cAAc,IAAI,IAAI;YACxC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;QACnE,cAAc,EAAE,KAAK,CAAC,cAAc;KAChB,CAAC;AAC7B,CAAC"}
@@ -19,6 +19,38 @@ export type GgufFileInfo = {
19
19
  readonly tensorInfo?: GgufTensorInfo[];
20
20
  /** can be null if `readTensorInfo` is set to `false` */
21
21
  readonly tensorInfoSize?: number;
22
+ /**
23
+ * For spliced metadata of multiple file parts,
24
+ * this will be the number of files parts read and spliced into this metadata.
25
+ *
26
+ * Whe no splicing is done, this will be `1`.
27
+ */
28
+ readonly splicedParts: number;
29
+ /**
30
+ * For spliced metadata of multiple file parts, this will be the total tensor count from all the parts
31
+ *
32
+ * When no splicing is done, this will be the same as `tensorCount`.
33
+ */
34
+ readonly totalTensorCount: number | bigint;
35
+ /**
36
+ * For spliced metadata of multiple file parts, this will be the total metadata size from all the parts
37
+ *
38
+ * When no splicing is done, this will be the same as `metadataSize`.
39
+ */
40
+ readonly totalMetadataSize: number;
41
+ /**
42
+ * For spliced metadata of multiple file parts, this will be the spliced tensorInfo from all the parts.
43
+ * Can be null if `readTensorInfo` is set to `false`
44
+ *
45
+ * When no splicing is done, this will be the same as `tensorInfo`.
46
+ */
47
+ readonly fullTensorInfo?: GgufTensorInfo[];
48
+ /**
49
+ * For spliced metadata of multiple file parts, this will be the total tensor info size from all the parts
50
+ *
51
+ * When no splicing is done, this will be the same as `tensorInfoSize`.
52
+ */
53
+ readonly totalTensorInfoSize?: number;
22
54
  };
23
55
  export declare const enum GgufValueType {
24
56
  Uint8 = 0,
@@ -1 +1 @@
1
- {"version":3,"file":"GgufFileInfoTypes.js","sourceRoot":"","sources":["../../../src/gguf/types/GgufFileInfoTypes.ts"],"names":[],"mappings":"AA6BA,sEAAsE;AACtE,MAAM,CAAN,IAAkB,aAcjB;AAdD,WAAkB,aAAa;IAC3B,mDAAS,CAAA;IACT,iDAAQ,CAAA;IACR,qDAAU,CAAA;IACV,mDAAS,CAAA;IACT,qDAAU,CAAA;IACV,mDAAS,CAAA;IACT,uDAAW,CAAA;IACX,iDAAQ,CAAA;IACR,qDAAU,CAAA;IACV,mDAAS,CAAA;IACT,sDAAW,CAAA;IACX,oDAAU,CAAA;IACV,wDAAY,CAAA;AAChB,CAAC,EAdiB,aAAa,KAAb,aAAa,QAc9B"}
1
+ {"version":3,"file":"GgufFileInfoTypes.js","sourceRoot":"","sources":["../../../src/gguf/types/GgufFileInfoTypes.ts"],"names":[],"mappings":"AAkEA,sEAAsE;AACtE,MAAM,CAAN,IAAkB,aAcjB;AAdD,WAAkB,aAAa;IAC3B,mDAAS,CAAA;IACT,iDAAQ,CAAA;IACR,qDAAU,CAAA;IACV,mDAAS,CAAA;IACT,qDAAU,CAAA;IACV,mDAAS,CAAA;IACT,uDAAW,CAAA;IACX,iDAAQ,CAAA;IACR,qDAAU,CAAA;IACV,mDAAS,CAAA;IACT,sDAAW,CAAA;IACX,oDAAU,CAAA;IACV,wDAAY,CAAA;AAChB,CAAC,EAdiB,aAAa,KAAb,aAAa,QAc9B"}
@@ -1,4 +1,4 @@
1
1
  export function getGgufMetadataArchitectureData(ggufMetadata) {
2
- return ggufMetadata[ggufMetadata.general.architecture] ?? {};
2
+ return ggufMetadata[ggufMetadata.general?.architecture] ?? {};
3
3
  }
4
4
  //# sourceMappingURL=getGgufMetadataArchitectureData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"getGgufMetadataArchitectureData.js","sourceRoot":"","sources":["../../../src/gguf/utils/getGgufMetadataArchitectureData.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,+BAA+B,CAAuC,YAA6B;IAK/G,OAAO,YAAY,CAAC,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAS,CAAC;AACxE,CAAC"}
1
+ {"version":3,"file":"getGgufMetadataArchitectureData.js","sourceRoot":"","sources":["../../../src/gguf/utils/getGgufMetadataArchitectureData.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,+BAA+B,CAAuC,YAA6B;IAK/G,OAAO,YAAY,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,IAAI,EAAS,CAAC;AACzE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function resolveBinarySplitGgufPartUrls(ggufUrl: string): string | string[];
2
+ export declare function getFilenameForBinarySplitGgufPartUrls(urls: string[]): string | undefined;
@@ -0,0 +1,39 @@
1
+ import filenamify from "filenamify";
2
+ const binarySplitGgufPartsRegex = /\.gguf\.part(?<part>\d+)of(?<parts>\d+)$/;
3
+ export function resolveBinarySplitGgufPartUrls(ggufUrl) {
4
+ const parsedGgufUrl = new URL(ggufUrl);
5
+ const binaryPartsMatch = parsedGgufUrl.pathname.match(binarySplitGgufPartsRegex);
6
+ if (binaryPartsMatch != null) {
7
+ const partString = binaryPartsMatch.groups?.part;
8
+ const part = Number(partString);
9
+ const partsString = binaryPartsMatch.groups?.parts;
10
+ const parts = Number(partsString);
11
+ if (partString == null || !Number.isFinite(part) || partsString == null || !Number.isFinite(parts) || part > parts || part === 0 ||
12
+ parts === 0)
13
+ return ggufUrl;
14
+ const ggufIndex = parsedGgufUrl.pathname.indexOf(".gguf");
15
+ const pathnameWithoutPart = parsedGgufUrl.pathname.slice(0, ggufIndex + ".gguf".length);
16
+ const res = [];
17
+ for (let i = 1; i <= parts; i++) {
18
+ const url = new URL(parsedGgufUrl.href);
19
+ url.pathname = pathnameWithoutPart + `.part${String(i)
20
+ .padStart(partString.length, "0")}of${partsString}`;
21
+ res.push(url.href);
22
+ }
23
+ return res;
24
+ }
25
+ return ggufUrl;
26
+ }
27
+ export function getFilenameForBinarySplitGgufPartUrls(urls) {
28
+ if (urls.length === 0)
29
+ return undefined;
30
+ const firstParsedUrl = new URL(urls[0]);
31
+ if (binarySplitGgufPartsRegex.test(firstParsedUrl.pathname)) {
32
+ const ggufIndex = firstParsedUrl.pathname.indexOf(".gguf");
33
+ const urlWithoutPart = firstParsedUrl.pathname.slice(0, ggufIndex + ".gguf".length);
34
+ const filename = decodeURIComponent(urlWithoutPart.split("/").slice(-1)[0]);
35
+ return filenamify(filename);
36
+ }
37
+ return undefined;
38
+ }
39
+ //# sourceMappingURL=resolveBinarySplitGgufPartUrls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveBinarySplitGgufPartUrls.js","sourceRoot":"","sources":["../../../src/gguf/utils/resolveBinarySplitGgufPartUrls.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,MAAM,yBAAyB,GAAG,0CAA0C,CAAC;AAE7E,MAAM,UAAU,8BAA8B,CAAC,OAAe;IAC1D,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,gBAAgB,GAAG,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACjF,IAAI,gBAAgB,IAAI,IAAI,EAAE;QAC1B,MAAM,UAAU,GAAG,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC;QACjD,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QAChC,MAAM,WAAW,GAAG,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC;QACnD,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QAElC,IAAI,UAAU,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,WAAW,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,GA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AAG,kBAAkB,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5E,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;KAC/B;IAED,OAAO,SAAS,CAAC;AACrB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare function resolveSplitGgufParts(ggufPathOrUrl: string): string[];
2
+ export declare function getGgufSplitPartsInfo(ggufPath: string): {
3
+ part: number;
4
+ parts: number;
5
+ matchLength: number;
6
+ } | null;
7
+ export declare function createSplitPartFilename(filename: string, part: number, parts: number): string;
@@ -0,0 +1,55 @@
1
+ import { isUrl } from "../../utils/isUrl.js";
2
+ const splitGgufPartRegex = /-(?<part>\d{5})-of-(?<parts>\d{5})\.gguf$/;
3
+ export function resolveSplitGgufParts(ggufPathOrUrl) {
4
+ if (isUrl(ggufPathOrUrl)) {
5
+ const parsedUrl = new URL(ggufPathOrUrl);
6
+ return resolveParts(parsedUrl.pathname).map((part) => {
7
+ const url = new URL(ggufPathOrUrl);
8
+ url.pathname = part;
9
+ return url.href;
10
+ });
11
+ }
12
+ return resolveParts(ggufPathOrUrl);
13
+ }
14
+ function resolveParts(ggufPath) {
15
+ const splitPartMatch = ggufPath.match(splitGgufPartRegex);
16
+ if (splitPartMatch != null) {
17
+ const partsInfo = getGgufSplitPartsInfo(ggufPath);
18
+ if (partsInfo == null)
19
+ return [ggufPath];
20
+ const { parts, matchLength } = partsInfo;
21
+ const commonPath = ggufPath.slice(0, ggufPath.length - matchLength);
22
+ const res = [];
23
+ for (let i = 1; i <= parts; i++)
24
+ res.push(commonPath + `-${String(i).padStart(5, "0")}-of-${String(parts).padStart(5, "0")}.gguf`);
25
+ return res;
26
+ }
27
+ return [ggufPath];
28
+ }
29
+ export function getGgufSplitPartsInfo(ggufPath) {
30
+ let checkPath = ggufPath;
31
+ if (isUrl(checkPath)) {
32
+ const parsedUrl = new URL(checkPath);
33
+ checkPath = parsedUrl.pathname;
34
+ }
35
+ const splitPartMatch = checkPath.match(splitGgufPartRegex);
36
+ if (splitPartMatch != null) {
37
+ const part = Number(splitPartMatch.groups?.part);
38
+ const parts = Number(splitPartMatch.groups?.parts);
39
+ const matchLength = splitPartMatch[0]?.length;
40
+ if (matchLength == null || !Number.isFinite(part) || !Number.isFinite(parts) || part > parts || part === 0 || parts === 0)
41
+ return null;
42
+ return {
43
+ part,
44
+ parts,
45
+ matchLength
46
+ };
47
+ }
48
+ return null;
49
+ }
50
+ export function createSplitPartFilename(filename, part, parts) {
51
+ if (filename.endsWith(".gguf"))
52
+ filename = filename.slice(0, -".gguf".length);
53
+ return `${filename}-${String(part).padStart(5, "0")}-of-${String(parts).padStart(5, "0")}.gguf`;
54
+ }
55
+ //# sourceMappingURL=resolveSplitGgufParts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveSplitGgufParts.js","sourceRoot":"","sources":["../../../src/gguf/utils/resolveSplitGgufParts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,sBAAsB,CAAC;AAE3C,MAAM,kBAAkB,GAAG,2CAA2C,CAAC;AAEvE,MAAM,UAAU,qBAAqB,CAAC,aAAqB;IACvD,IAAI,KAAK,CAAC,aAAa,CAAC,EAAE;QACtB,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;QAEzC,OAAO,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YACjD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;YACnC,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC;YACpB,OAAO,GAAG,CAAC,IAAI,CAAC;QACpB,CAAC,CAAC,CAAC;KACN;IAED,OAAO,YAAY,CAAC,aAAa,CAAC,CAAC;AACvC,CAAC;AAED,SAAS,YAAY,CAAC,QAAgB;IAClC,MAAM,cAAc,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AAc,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACnD,MAAM,WAAW,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC;QAE9C,IAAI,WAAW,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC;YACrH,OAAO,IAAI,CAAC;QAEhB,OAAO;YACH,IAAI;YACJ,KAAK;YACL,WAAW;SACd,CAAC;KACL;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,QAAgB,EAAE,IAAY,EAAE,KAAa;IACjF,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;QAC1B,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAElD,OAAO,GAAG,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;AACpG,CAAC"}
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ import { LlamaJsonSchemaGrammar } from "./evaluator/LlamaJsonSchemaGrammar.js";
9
9
  import { LlamaJsonSchemaValidationError } from "./utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js";
10
10
  import { LlamaGrammarEvaluationState, LlamaGrammarEvaluationStateOptions } from "./evaluator/LlamaGrammarEvaluationState.js";
11
11
  import { LlamaContext, LlamaContextSequence } from "./evaluator/LlamaContext/LlamaContext.js";
12
- import { LlamaEmbeddingContext, type LlamaEmbeddingContextOptions, LlamaEmbedding, type LlamaEmbeddingJSON } from "./evaluator/LlamaEmbeddingContext.js";
12
+ import { LlamaEmbeddingContext, type LlamaEmbeddingContextOptions, type LlamaEmbedding } from "./evaluator/LlamaEmbeddingContext.js";
13
13
  import { type LlamaContextOptions, type BatchingOptions, type LlamaContextSequenceRepeatPenalty, type CustomBatchingDispatchSchedule, type CustomBatchingPrioritizationStrategy, type BatchItem, type PrioritizedBatchItem, type ContextShiftOptions, type ContextTokensDeleteRange, type EvaluationPriority } from "./evaluator/LlamaContext/types.js";
14
14
  import { TokenBias } from "./evaluator/TokenBias.js";
15
15
  import { LlamaChatSession, type LlamaChatSessionOptions, type LlamaChatSessionContextShiftOptions, type LLamaChatPromptOptions, type LlamaChatSessionRepeatPenalty } from "./evaluator/LlamaChatSession/LlamaChatSession.js";
@@ -33,13 +33,15 @@ import { TemplateChatWrapper, type TemplateChatWrapperOptions } from "./chatWrap
33
33
  import { JinjaTemplateChatWrapper, type JinjaTemplateChatWrapperOptions } from "./chatWrappers/generic/JinjaTemplateChatWrapper.js";
34
34
  import { resolvableChatWrapperTypeNames, type ResolvableChatWrapperTypeName, specializedChatWrapperTypeNames, type SpecializedChatWrapperTypeName, templateChatWrapperTypeNames, type TemplateChatWrapperTypeName, resolveChatWrapper, type ResolveChatWrapperOptions } from "./chatWrappers/utils/resolveChatWrapper.js";
35
35
  import { ChatModelFunctionsDocumentationGenerator } from "./chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.js";
36
- import { LlamaText, SpecialTokensText, SpecialToken, isLlamaText, tokenizeText, type LlamaTextJSON, type LlamaTextJSONValue, type LlamaTextSpecialTokensTextJSON, type LlamaTextSpecialTokenJSON } from "./utils/LlamaText.js";
36
+ import { LlamaText, SpecialTokensText, SpecialToken, isLlamaText, tokenizeText, type LlamaTextValue, type LlamaTextInputValue, type LlamaTextJSON, type LlamaTextJSONValue, type LlamaTextSpecialTokensTextJSON, type LlamaTextSpecialTokenJSON } from "./utils/LlamaText.js";
37
37
  import { appendUserMessageToChatHistory } from "./utils/appendUserMessageToChatHistory.js";
38
38
  import { getModuleVersion } from "./utils/getModuleVersion.js";
39
39
  import { readGgufFileInfo } from "./gguf/readGgufFileInfo.js";
40
- import { type ChatHistoryItem, type ChatModelFunctionCall, type ChatModelFunctions, type ChatModelResponse, type ChatSessionModelFunction, type ChatSessionModelFunctions, type ChatSystemMessage, type ChatUserMessage, type Token, isChatModelResponseFunctionCall, type LLamaContextualRepeatPenalty, type ChatWrapperSettings } from "./types.js";
40
+ import { GgufInsights } from "./gguf/insights/GgufInsights.js";
41
+ import { createModelDownloader, ModelDownloader, type ModelDownloaderOptions } from "./utils/createModelDownloader.js";
42
+ import { type ChatHistoryItem, type ChatModelFunctionCall, type ChatModelFunctions, type ChatModelResponse, type ChatSessionModelFunction, type ChatSessionModelFunctions, type ChatSystemMessage, type ChatUserMessage, type Token, type Tokenizer, type Detokenizer, isChatModelResponseFunctionCall, type LLamaContextualRepeatPenalty, type ChatWrapperSettings } from "./types.js";
41
43
  import { type GbnfJsonArraySchema, type GbnfJsonBasicSchema, type GbnfJsonConstSchema, type GbnfJsonEnumSchema, type GbnfJsonObjectSchema, type GbnfJsonOneOfSchema, type GbnfJsonSchema, type GbnfJsonSchemaImmutableType, type GbnfJsonSchemaToType } from "./utils/gbnfJson/types.js";
42
44
  import { type GgufFileInfo } from "./gguf/types/GgufFileInfoTypes.js";
43
45
  import { type GgufMetadata, type GgufMetadataLlmToType, GgufArchitectureType, GgufFileType, GgufMetadataTokenizerTokenType, GgufMetadataArchitecturePoolingType, type GgufMetadataGeneral, type GgufMetadataTokenizer, type GgufMetadataDefaultArchitectureType, type GgufMetadataLlmLLaMA, type GgufMetadataMPT, type GgufMetadataGPTNeoX, type GgufMetadataGPTJ, type GgufMetadataGPT2, type GgufMetadataBloom, type GgufMetadataFalcon, type GgufMetadataMamba, type GgufMetadataRWKV, isGgufMetadataOfArchitectureType } from "./gguf/types/GgufMetadataTypes.js";
44
46
  import { GgmlType, type GgufTensorInfo } from "./gguf/types/GgufTensorInfoTypes.js";
45
- export { Llama, getLlama, type LlamaOptions, LlamaLogLevel, NoBinaryFoundError, LlamaModel, LlamaModelTokens, LlamaModelInfillTokens, type LlamaModelOptions, LlamaGrammar, type LlamaGrammarOptions, LlamaJsonSchemaGrammar, LlamaJsonSchemaValidationError, LlamaGrammarEvaluationState, type LlamaGrammarEvaluationStateOptions, LlamaContext, LlamaContextSequence, type LlamaContextOptions, type BatchingOptions, type CustomBatchingDispatchSchedule, type CustomBatchingPrioritizationStrategy, type BatchItem, type PrioritizedBatchItem, type ContextShiftOptions, type ContextTokensDeleteRange, type EvaluationPriority, type LlamaContextSequenceRepeatPenalty, TokenBias, LlamaEmbeddingContext, type LlamaEmbeddingContextOptions, LlamaEmbedding, type LlamaEmbeddingJSON, LlamaChatSession, defineChatSessionFunction, type LlamaChatSessionOptions, type LlamaChatSessionContextShiftOptions, type LLamaChatPromptOptions, type LlamaChatSessionRepeatPenalty, LlamaChat, type LlamaChatOptions, type LLamaChatGenerateResponseOptions, type LLamaChatContextShiftOptions, type LLamaContextualRepeatPenalty, type LlamaChatResponse, type LlamaChatResponseFunctionCall, LlamaCompletion, type LlamaCompletionOptions, type LlamaCompletionGenerationOptions, type LlamaInfillGenerationOptions, TokenMeter, type TokenMeterState, UnsupportedError, InsufficientMemoryError, DisposedError, ChatWrapper, type ChatWrapperSettings, EmptyChatWrapper, Llama3ChatWrapper, Llama2ChatWrapper, GeneralChatWrapper, ChatMLChatWrapper, FalconChatWrapper, AlpacaChatWrapper, FunctionaryChatWrapper, GemmaChatWrapper, TemplateChatWrapper, type TemplateChatWrapperOptions, JinjaTemplateChatWrapper, type JinjaTemplateChatWrapperOptions, resolveChatWrapper, type ResolveChatWrapperOptions, resolvableChatWrapperTypeNames, type ResolvableChatWrapperTypeName, specializedChatWrapperTypeNames, type SpecializedChatWrapperTypeName, templateChatWrapperTypeNames, type TemplateChatWrapperTypeName, ChatModelFunctionsDocumentationGenerator, LlamaText, SpecialTokensText, SpecialToken, isLlamaText, tokenizeText, type LlamaTextJSON, type LlamaTextJSONValue, type LlamaTextSpecialTokensTextJSON, type LlamaTextSpecialTokenJSON, appendUserMessageToChatHistory, getModuleVersion, type ChatHistoryItem, type ChatModelFunctionCall, type ChatModelFunctions, type ChatModelResponse, type ChatSessionModelFunction, type ChatSessionModelFunctions, type ChatSystemMessage, type ChatUserMessage, type Token, isChatModelResponseFunctionCall, type GbnfJsonSchema, type GbnfJsonSchemaToType, type GbnfJsonSchemaImmutableType, type GbnfJsonBasicSchema, type GbnfJsonConstSchema, type GbnfJsonEnumSchema, type GbnfJsonOneOfSchema, type GbnfJsonObjectSchema, type GbnfJsonArraySchema, LlamaVocabularyType, LlamaLogLevelGreaterThan, LlamaLogLevelGreaterThanOrEqual, readGgufFileInfo, type GgufFileInfo, type GgufMetadata, type GgufTensorInfo, type GgufMetadataLlmToType, GgufArchitectureType, GgufFileType, GgufMetadataTokenizerTokenType, GgufMetadataArchitecturePoolingType, type GgufMetadataGeneral, type GgufMetadataTokenizer, type GgufMetadataDefaultArchitectureType, type GgufMetadataLlmLLaMA, type GgufMetadataMPT, type GgufMetadataGPTNeoX, type GgufMetadataGPTJ, type GgufMetadataGPT2, type GgufMetadataBloom, type GgufMetadataFalcon, type GgufMetadataMamba, type GgufMetadataRWKV, GgmlType, isGgufMetadataOfArchitectureType };
47
+ export { Llama, getLlama, type LlamaOptions, LlamaLogLevel, NoBinaryFoundError, LlamaModel, LlamaModelTokens, LlamaModelInfillTokens, type LlamaModelOptions, LlamaGrammar, type LlamaGrammarOptions, LlamaJsonSchemaGrammar, LlamaJsonSchemaValidationError, LlamaGrammarEvaluationState, type LlamaGrammarEvaluationStateOptions, LlamaContext, LlamaContextSequence, type LlamaContextOptions, type BatchingOptions, type CustomBatchingDispatchSchedule, type CustomBatchingPrioritizationStrategy, type BatchItem, type PrioritizedBatchItem, type ContextShiftOptions, type ContextTokensDeleteRange, type EvaluationPriority, type LlamaContextSequenceRepeatPenalty, TokenBias, LlamaEmbeddingContext, type LlamaEmbeddingContextOptions, type LlamaEmbedding, LlamaChatSession, defineChatSessionFunction, type LlamaChatSessionOptions, type LlamaChatSessionContextShiftOptions, type LLamaChatPromptOptions, type LlamaChatSessionRepeatPenalty, LlamaChat, type LlamaChatOptions, type LLamaChatGenerateResponseOptions, type LLamaChatContextShiftOptions, type LLamaContextualRepeatPenalty, type LlamaChatResponse, type LlamaChatResponseFunctionCall, LlamaCompletion, type LlamaCompletionOptions, type LlamaCompletionGenerationOptions, type LlamaInfillGenerationOptions, TokenMeter, type TokenMeterState, UnsupportedError, InsufficientMemoryError, DisposedError, ChatWrapper, type ChatWrapperSettings, EmptyChatWrapper, Llama3ChatWrapper, Llama2ChatWrapper, GeneralChatWrapper, ChatMLChatWrapper, FalconChatWrapper, AlpacaChatWrapper, FunctionaryChatWrapper, GemmaChatWrapper, TemplateChatWrapper, type TemplateChatWrapperOptions, JinjaTemplateChatWrapper, type JinjaTemplateChatWrapperOptions, resolveChatWrapper, type ResolveChatWrapperOptions, resolvableChatWrapperTypeNames, type ResolvableChatWrapperTypeName, specializedChatWrapperTypeNames, type SpecializedChatWrapperTypeName, templateChatWrapperTypeNames, type TemplateChatWrapperTypeName, ChatModelFunctionsDocumentationGenerator, LlamaText, SpecialTokensText, SpecialToken, isLlamaText, tokenizeText, type LlamaTextValue, type LlamaTextInputValue, type LlamaTextJSON, type LlamaTextJSONValue, type LlamaTextSpecialTokensTextJSON, type LlamaTextSpecialTokenJSON, appendUserMessageToChatHistory, getModuleVersion, type ChatHistoryItem, type ChatModelFunctionCall, type ChatModelFunctions, type ChatModelResponse, type ChatSessionModelFunction, type ChatSessionModelFunctions, type ChatSystemMessage, type ChatUserMessage, type Token, type Tokenizer, type Detokenizer, isChatModelResponseFunctionCall, type GbnfJsonSchema, type GbnfJsonSchemaToType, type GbnfJsonSchemaImmutableType, type GbnfJsonBasicSchema, type GbnfJsonConstSchema, type GbnfJsonEnumSchema, type GbnfJsonOneOfSchema, type GbnfJsonObjectSchema, type GbnfJsonArraySchema, LlamaVocabularyType, LlamaLogLevelGreaterThan, LlamaLogLevelGreaterThanOrEqual, readGgufFileInfo, type GgufFileInfo, type GgufMetadata, type GgufTensorInfo, type GgufMetadataLlmToType, GgufArchitectureType, GgufFileType, GgufMetadataTokenizerTokenType, GgufMetadataArchitecturePoolingType, type GgufMetadataGeneral, type GgufMetadataTokenizer, type GgufMetadataDefaultArchitectureType, type GgufMetadataLlmLLaMA, type GgufMetadataMPT, type GgufMetadataGPTNeoX, type GgufMetadataGPTJ, type GgufMetadataGPT2, type GgufMetadataBloom, type GgufMetadataFalcon, type GgufMetadataMamba, type GgufMetadataRWKV, GgmlType, isGgufMetadataOfArchitectureType, GgufInsights, createModelDownloader, ModelDownloader, type ModelDownloaderOptions };
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { LlamaJsonSchemaGrammar } from "./evaluator/LlamaJsonSchemaGrammar.js";
9
9
  import { LlamaJsonSchemaValidationError } from "./utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js";
10
10
  import { LlamaGrammarEvaluationState } from "./evaluator/LlamaGrammarEvaluationState.js";
11
11
  import { LlamaContext, LlamaContextSequence } from "./evaluator/LlamaContext/LlamaContext.js";
12
- import { LlamaEmbeddingContext, LlamaEmbedding } from "./evaluator/LlamaEmbeddingContext.js";
12
+ import { LlamaEmbeddingContext } from "./evaluator/LlamaEmbeddingContext.js";
13
13
  import { TokenBias } from "./evaluator/TokenBias.js";
14
14
  import { LlamaChatSession } from "./evaluator/LlamaChatSession/LlamaChatSession.js";
15
15
  import { defineChatSessionFunction } from "./evaluator/LlamaChatSession/utils/defineChatSessionFunction.js";
@@ -36,8 +36,10 @@ import { LlamaText, SpecialTokensText, SpecialToken, isLlamaText, tokenizeText }
36
36
  import { appendUserMessageToChatHistory } from "./utils/appendUserMessageToChatHistory.js";
37
37
  import { getModuleVersion } from "./utils/getModuleVersion.js";
38
38
  import { readGgufFileInfo } from "./gguf/readGgufFileInfo.js";
39
+ import { GgufInsights } from "./gguf/insights/GgufInsights.js";
40
+ import { createModelDownloader, ModelDownloader } from "./utils/createModelDownloader.js";
39
41
  import { isChatModelResponseFunctionCall } from "./types.js";
40
42
  import { GgufArchitectureType, GgufFileType, GgufMetadataTokenizerTokenType, GgufMetadataArchitecturePoolingType, isGgufMetadataOfArchitectureType } from "./gguf/types/GgufMetadataTypes.js";
41
43
  import { GgmlType } from "./gguf/types/GgufTensorInfoTypes.js";
42
- export { Llama, getLlama, LlamaLogLevel, NoBinaryFoundError, LlamaModel, LlamaModelTokens, LlamaModelInfillTokens, LlamaGrammar, LlamaJsonSchemaGrammar, LlamaJsonSchemaValidationError, LlamaGrammarEvaluationState, LlamaContext, LlamaContextSequence, TokenBias, LlamaEmbeddingContext, LlamaEmbedding, LlamaChatSession, defineChatSessionFunction, LlamaChat, LlamaCompletion, TokenMeter, UnsupportedError, InsufficientMemoryError, DisposedError, ChatWrapper, EmptyChatWrapper, Llama3ChatWrapper, Llama2ChatWrapper, GeneralChatWrapper, ChatMLChatWrapper, FalconChatWrapper, AlpacaChatWrapper, FunctionaryChatWrapper, GemmaChatWrapper, TemplateChatWrapper, JinjaTemplateChatWrapper, resolveChatWrapper, resolvableChatWrapperTypeNames, specializedChatWrapperTypeNames, templateChatWrapperTypeNames, ChatModelFunctionsDocumentationGenerator, LlamaText, SpecialTokensText, SpecialToken, isLlamaText, tokenizeText, appendUserMessageToChatHistory, getModuleVersion, isChatModelResponseFunctionCall, LlamaVocabularyType, LlamaLogLevelGreaterThan, LlamaLogLevelGreaterThanOrEqual, readGgufFileInfo, GgufArchitectureType, GgufFileType, GgufMetadataTokenizerTokenType, GgufMetadataArchitecturePoolingType, GgmlType, isGgufMetadataOfArchitectureType };
44
+ export { Llama, getLlama, LlamaLogLevel, NoBinaryFoundError, LlamaModel, LlamaModelTokens, LlamaModelInfillTokens, LlamaGrammar, LlamaJsonSchemaGrammar, LlamaJsonSchemaValidationError, LlamaGrammarEvaluationState, LlamaContext, LlamaContextSequence, TokenBias, LlamaEmbeddingContext, LlamaChatSession, defineChatSessionFunction, LlamaChat, LlamaCompletion, TokenMeter, UnsupportedError, InsufficientMemoryError, DisposedError, ChatWrapper, EmptyChatWrapper, Llama3ChatWrapper, Llama2ChatWrapper, GeneralChatWrapper, ChatMLChatWrapper, FalconChatWrapper, AlpacaChatWrapper, FunctionaryChatWrapper, GemmaChatWrapper, TemplateChatWrapper, JinjaTemplateChatWrapper, resolveChatWrapper, resolvableChatWrapperTypeNames, specializedChatWrapperTypeNames, templateChatWrapperTypeNames, ChatModelFunctionsDocumentationGenerator, LlamaText, SpecialTokensText, SpecialToken, isLlamaText, tokenizeText, appendUserMessageToChatHistory, getModuleVersion, isChatModelResponseFunctionCall, LlamaVocabularyType, LlamaLogLevelGreaterThan, LlamaLogLevelGreaterThanOrEqual, readGgufFileInfo, GgufArchitectureType, GgufFileType, GgufMetadataTokenizerTokenType, GgufMetadataArchitecturePoolingType, GgmlType, isGgufMetadataOfArchitectureType, GgufInsights, createModelDownloader, ModelDownloader };
43
45
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,KAAK,EAAC,MAAM,qBAAqB,CAAC;AAC1C,OAAO,EAAC,QAAQ,EAAe,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAC,kBAAkB,EAAC,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAC,aAAa,EAAE,wBAAwB,EAAE,+BAA+B,EAAE,mBAAmB,EAAC,MAAM,qBAAqB,CAAC;AAClI,OAAO,EAAC,UAAU,EAAE,sBAAsB,EAA0B,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AACvH,OAAO,EAAC,YAAY,EAA2B,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAC,sBAAsB,EAAC,MAAM,uCAAuC,CAAC;AAC7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EAanC,QAAQ,EACR,gCAAgC,EAChC,YAAY,EACZ,qBAAqB,EACrB,eAAe,EAElB,CAAC"}
@@ -1,24 +1,6 @@
1
1
  import { Token, Tokenizer } from "../types.js";
2
- export type LlamaTextClass = {
3
- <const V extends LlamaTextValue = LlamaTextValue, const V2 extends LlamaTextValue = LlamaTextValue>(strings: TemplateStringsArray | V | LlamaText<V> | readonly (LlamaText<V> | V)[], ...values: readonly (V | LlamaText<V> | V2 | LlamaText<V2> | number | boolean | readonly (LlamaText<V> | V | LlamaText<V2> | V2)[])[]): LlamaText<V | V2>;
4
- fromJSON(json: LlamaTextJSON): LlamaText;
5
- compare(a: LlamaText, b: LlamaText): boolean;
6
- };
7
- export type LlamaText<T extends LlamaTextValue = LlamaTextValue> = {
8
- <const V extends LlamaTextValue = LlamaTextValue, const V2 extends LlamaTextValue = LlamaTextValue>(strings: TemplateStringsArray | V | LlamaText | readonly (LlamaText | V)[], ...values: readonly (V | V2 | LlamaText | number | boolean | readonly (LlamaText | V | V2)[])[]): LlamaText<T | V>;
9
- readonly type: "LlamaText";
10
- readonly values: readonly T[];
11
- mapValues<V extends LlamaTextValue = LlamaTextValue>(mapper: (value: T) => V): LlamaText<V>;
12
- joinValues<V extends LlamaTextValue = LlamaTextValue>(separator: LlamaText<V> | V): LlamaText<T | V>;
13
- toString(): string;
14
- toJSON(): LlamaTextJSON;
15
- tokenize(tokenizer: Tokenizer, options?: "trimLeadingSpace"): Token[];
16
- compare(other: LlamaText): boolean;
17
- trimStart(): LlamaText<T>;
18
- trimEnd(): LlamaText<T>;
19
- includes(value: LlamaText): boolean;
20
- };
21
2
  export type LlamaTextValue = string | SpecialTokensText | SpecialToken;
3
+ export type LlamaTextInputValue = LlamaTextValue | LlamaText | number | boolean | readonly LlamaTextInputValue[];
22
4
  export type LlamaTextJSON = Array<LlamaTextJSONValue>;
23
5
  export type LlamaTextJSONValue = string | LlamaTextSpecialTokensTextJSON | LlamaTextSpecialTokenJSON;
24
6
  export type LlamaTextSpecialTokensTextJSON = {
@@ -29,7 +11,34 @@ export type LlamaTextSpecialTokenJSON = {
29
11
  type: "specialToken";
30
12
  value: string;
31
13
  };
32
- export declare const LlamaText: LlamaTextClass;
14
+ declare class LlamaText {
15
+ readonly values: readonly LlamaTextValue[];
16
+ /**
17
+ * Can also be called without `new`
18
+ */
19
+ constructor(...values: readonly LlamaTextInputValue[]);
20
+ concat(value: LlamaTextInputValue): LlamaText;
21
+ mapValues(mapper: (value: LlamaTextValue) => LlamaTextInputValue): LlamaText;
22
+ joinValues(separator: LlamaText | LlamaTextValue): LlamaText;
23
+ toString(): string;
24
+ toJSON(): LlamaTextJSON;
25
+ tokenize(tokenizer: Tokenizer, options?: "trimLeadingSpace"): Token[];
26
+ compare(other: LlamaText): boolean;
27
+ trimStart(): LlamaText;
28
+ trimEnd(): LlamaText;
29
+ includes(value: LlamaText): boolean;
30
+ static fromJSON(json: LlamaTextJSON): LlamaText;
31
+ static compare(a: LlamaText, b: LlamaText): boolean;
32
+ }
33
+ type LlamaTextConstructor = Omit<typeof LlamaText, "prototype"> & {
34
+ new (...values: readonly LlamaTextInputValue[]): LlamaText;
35
+ (...values: readonly LlamaTextInputValue[]): LlamaText;
36
+ readonly prototype: typeof LlamaText.prototype;
37
+ };
38
+ declare const LlamaTextConstructor: LlamaTextConstructor;
39
+ declare const _LlamaText: LlamaTextConstructor;
40
+ type _LlamaText = LlamaText;
41
+ export { _LlamaText as LlamaText, LlamaText as _LlamaText };
33
42
  export declare class SpecialTokensText {
34
43
  readonly value: string;
35
44
  constructor(value: string);