@realtimex/node-llama-cpp 0.1.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.
Files changed (876) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +108 -0
  3. package/dist/ChatWrapper.d.ts +27 -0
  4. package/dist/ChatWrapper.js +233 -0
  5. package/dist/ChatWrapper.js.map +1 -0
  6. package/dist/apiDocsIndex.d.ts +1 -0
  7. package/dist/apiDocsIndex.js +7 -0
  8. package/dist/apiDocsIndex.js.map +1 -0
  9. package/dist/bindings/AddonTypes.d.ts +203 -0
  10. package/dist/bindings/AddonTypes.js +2 -0
  11. package/dist/bindings/AddonTypes.js.map +1 -0
  12. package/dist/bindings/Llama.d.ts +104 -0
  13. package/dist/bindings/Llama.js +570 -0
  14. package/dist/bindings/Llama.js.map +1 -0
  15. package/dist/bindings/consts.d.ts +2 -0
  16. package/dist/bindings/consts.js +13 -0
  17. package/dist/bindings/consts.js.map +1 -0
  18. package/dist/bindings/getLlama.d.ts +297 -0
  19. package/dist/bindings/getLlama.js +569 -0
  20. package/dist/bindings/getLlama.js.map +1 -0
  21. package/dist/bindings/types.d.ts +72 -0
  22. package/dist/bindings/types.js +105 -0
  23. package/dist/bindings/types.js.map +1 -0
  24. package/dist/bindings/utils/MemoryOrchestrator.d.ts +23 -0
  25. package/dist/bindings/utils/MemoryOrchestrator.js +50 -0
  26. package/dist/bindings/utils/MemoryOrchestrator.js.map +1 -0
  27. package/dist/bindings/utils/NoBinaryFoundError.d.ts +2 -0
  28. package/dist/bindings/utils/NoBinaryFoundError.js +7 -0
  29. package/dist/bindings/utils/NoBinaryFoundError.js.map +1 -0
  30. package/dist/bindings/utils/asyncEvery.d.ts +5 -0
  31. package/dist/bindings/utils/asyncEvery.js +15 -0
  32. package/dist/bindings/utils/asyncEvery.js.map +1 -0
  33. package/dist/bindings/utils/asyncSome.d.ts +5 -0
  34. package/dist/bindings/utils/asyncSome.js +29 -0
  35. package/dist/bindings/utils/asyncSome.js.map +1 -0
  36. package/dist/bindings/utils/binariesGithubRelease.d.ts +6 -0
  37. package/dist/bindings/utils/binariesGithubRelease.js +15 -0
  38. package/dist/bindings/utils/binariesGithubRelease.js.map +1 -0
  39. package/dist/bindings/utils/clearAllLocalBuilds.d.ts +1 -0
  40. package/dist/bindings/utils/clearAllLocalBuilds.js +47 -0
  41. package/dist/bindings/utils/clearAllLocalBuilds.js.map +1 -0
  42. package/dist/bindings/utils/cloneLlamaCppRepo.d.ts +11 -0
  43. package/dist/bindings/utils/cloneLlamaCppRepo.js +166 -0
  44. package/dist/bindings/utils/cloneLlamaCppRepo.js.map +1 -0
  45. package/dist/bindings/utils/compileLLamaCpp.d.ts +22 -0
  46. package/dist/bindings/utils/compileLLamaCpp.js +526 -0
  47. package/dist/bindings/utils/compileLLamaCpp.js.map +1 -0
  48. package/dist/bindings/utils/detectAvailableComputeLayers.d.ts +18 -0
  49. package/dist/bindings/utils/detectAvailableComputeLayers.js +311 -0
  50. package/dist/bindings/utils/detectAvailableComputeLayers.js.map +1 -0
  51. package/dist/bindings/utils/detectBuildTools.d.ts +14 -0
  52. package/dist/bindings/utils/detectBuildTools.js +149 -0
  53. package/dist/bindings/utils/detectBuildTools.js.map +1 -0
  54. package/dist/bindings/utils/detectGlibc.d.ts +4 -0
  55. package/dist/bindings/utils/detectGlibc.js +74 -0
  56. package/dist/bindings/utils/detectGlibc.js.map +1 -0
  57. package/dist/bindings/utils/disposeBeforeExit.d.ts +8 -0
  58. package/dist/bindings/utils/disposeBeforeExit.js +36 -0
  59. package/dist/bindings/utils/disposeBeforeExit.js.map +1 -0
  60. package/dist/bindings/utils/getBestComputeLayersAvailable.d.ts +9 -0
  61. package/dist/bindings/utils/getBestComputeLayersAvailable.js +29 -0
  62. package/dist/bindings/utils/getBestComputeLayersAvailable.js.map +1 -0
  63. package/dist/bindings/utils/getBuildFolderNameForBuildOptions.d.ts +6 -0
  64. package/dist/bindings/utils/getBuildFolderNameForBuildOptions.js +105 -0
  65. package/dist/bindings/utils/getBuildFolderNameForBuildOptions.js.map +1 -0
  66. package/dist/bindings/utils/getCanUsePrebuiltBinaries.d.ts +1 -0
  67. package/dist/bindings/utils/getCanUsePrebuiltBinaries.js +8 -0
  68. package/dist/bindings/utils/getCanUsePrebuiltBinaries.js.map +1 -0
  69. package/dist/bindings/utils/getExampleUsageCodeOfGetLlama.d.ts +2 -0
  70. package/dist/bindings/utils/getExampleUsageCodeOfGetLlama.js +21 -0
  71. package/dist/bindings/utils/getExampleUsageCodeOfGetLlama.js.map +1 -0
  72. package/dist/bindings/utils/getGpuTypesToUseForOption.d.ts +12 -0
  73. package/dist/bindings/utils/getGpuTypesToUseForOption.js +39 -0
  74. package/dist/bindings/utils/getGpuTypesToUseForOption.js.map +1 -0
  75. package/dist/bindings/utils/getLinuxDistroInfo.d.ts +9 -0
  76. package/dist/bindings/utils/getLinuxDistroInfo.js +46 -0
  77. package/dist/bindings/utils/getLinuxDistroInfo.js.map +1 -0
  78. package/dist/bindings/utils/getLlamaGpuTypes.d.ts +13 -0
  79. package/dist/bindings/utils/getLlamaGpuTypes.js +36 -0
  80. package/dist/bindings/utils/getLlamaGpuTypes.js.map +1 -0
  81. package/dist/bindings/utils/getLlamaWithoutBackend.d.ts +5 -0
  82. package/dist/bindings/utils/getLlamaWithoutBackend.js +40 -0
  83. package/dist/bindings/utils/getLlamaWithoutBackend.js.map +1 -0
  84. package/dist/bindings/utils/getPlatform.d.ts +2 -0
  85. package/dist/bindings/utils/getPlatform.js +15 -0
  86. package/dist/bindings/utils/getPlatform.js.map +1 -0
  87. package/dist/bindings/utils/getPlatformInfo.d.ts +5 -0
  88. package/dist/bindings/utils/getPlatformInfo.js +28 -0
  89. package/dist/bindings/utils/getPlatformInfo.js.map +1 -0
  90. package/dist/bindings/utils/hasBuildingFromSourceDependenciesInstalled.d.ts +3 -0
  91. package/dist/bindings/utils/hasBuildingFromSourceDependenciesInstalled.js +27 -0
  92. package/dist/bindings/utils/hasBuildingFromSourceDependenciesInstalled.js.map +1 -0
  93. package/dist/bindings/utils/hasFileInPath.d.ts +2 -0
  94. package/dist/bindings/utils/hasFileInPath.js +34 -0
  95. package/dist/bindings/utils/hasFileInPath.js.map +1 -0
  96. package/dist/bindings/utils/lastBuildInfo.d.ts +6 -0
  97. package/dist/bindings/utils/lastBuildInfo.js +17 -0
  98. package/dist/bindings/utils/lastBuildInfo.js.map +1 -0
  99. package/dist/bindings/utils/logBinaryUsageExampleToConsole.d.ts +2 -0
  100. package/dist/bindings/utils/logBinaryUsageExampleToConsole.js +22 -0
  101. package/dist/bindings/utils/logBinaryUsageExampleToConsole.js.map +1 -0
  102. package/dist/bindings/utils/logDistroInstallInstruction.d.ts +14 -0
  103. package/dist/bindings/utils/logDistroInstallInstruction.js +48 -0
  104. package/dist/bindings/utils/logDistroInstallInstruction.js.map +1 -0
  105. package/dist/bindings/utils/resolveActualBindingBinaryPath.d.ts +1 -0
  106. package/dist/bindings/utils/resolveActualBindingBinaryPath.js +18 -0
  107. package/dist/bindings/utils/resolveActualBindingBinaryPath.js.map +1 -0
  108. package/dist/bindings/utils/resolveCustomCmakeOptions.d.ts +1 -0
  109. package/dist/bindings/utils/resolveCustomCmakeOptions.js +43 -0
  110. package/dist/bindings/utils/resolveCustomCmakeOptions.js.map +1 -0
  111. package/dist/bindings/utils/testBindingBinary.d.ts +2 -0
  112. package/dist/bindings/utils/testBindingBinary.js +269 -0
  113. package/dist/bindings/utils/testBindingBinary.js.map +1 -0
  114. package/dist/bindings/utils/testCmakeBinary.d.ts +5 -0
  115. package/dist/bindings/utils/testCmakeBinary.js +32 -0
  116. package/dist/bindings/utils/testCmakeBinary.js.map +1 -0
  117. package/dist/chatWrappers/AlpacaChatWrapper.d.ts +17 -0
  118. package/dist/chatWrappers/AlpacaChatWrapper.js +33 -0
  119. package/dist/chatWrappers/AlpacaChatWrapper.js.map +1 -0
  120. package/dist/chatWrappers/ChatMLChatWrapper.d.ts +6 -0
  121. package/dist/chatWrappers/ChatMLChatWrapper.js +85 -0
  122. package/dist/chatWrappers/ChatMLChatWrapper.js.map +1 -0
  123. package/dist/chatWrappers/DeepSeekChatWrapper.d.ts +37 -0
  124. package/dist/chatWrappers/DeepSeekChatWrapper.js +294 -0
  125. package/dist/chatWrappers/DeepSeekChatWrapper.js.map +1 -0
  126. package/dist/chatWrappers/EmptyChatWrapper.d.ts +4 -0
  127. package/dist/chatWrappers/EmptyChatWrapper.js +5 -0
  128. package/dist/chatWrappers/EmptyChatWrapper.js.map +1 -0
  129. package/dist/chatWrappers/FalconChatWrapper.d.ts +19 -0
  130. package/dist/chatWrappers/FalconChatWrapper.js +126 -0
  131. package/dist/chatWrappers/FalconChatWrapper.js.map +1 -0
  132. package/dist/chatWrappers/FunctionaryChatWrapper.d.ts +17 -0
  133. package/dist/chatWrappers/FunctionaryChatWrapper.js +622 -0
  134. package/dist/chatWrappers/FunctionaryChatWrapper.js.map +1 -0
  135. package/dist/chatWrappers/GemmaChatWrapper.d.ts +7 -0
  136. package/dist/chatWrappers/GemmaChatWrapper.js +96 -0
  137. package/dist/chatWrappers/GemmaChatWrapper.js.map +1 -0
  138. package/dist/chatWrappers/GeneralChatWrapper.d.ts +19 -0
  139. package/dist/chatWrappers/GeneralChatWrapper.js +140 -0
  140. package/dist/chatWrappers/GeneralChatWrapper.js.map +1 -0
  141. package/dist/chatWrappers/HarmonyChatWrapper.d.ts +78 -0
  142. package/dist/chatWrappers/HarmonyChatWrapper.js +539 -0
  143. package/dist/chatWrappers/HarmonyChatWrapper.js.map +1 -0
  144. package/dist/chatWrappers/Llama2ChatWrapper.d.ts +12 -0
  145. package/dist/chatWrappers/Llama2ChatWrapper.js +95 -0
  146. package/dist/chatWrappers/Llama2ChatWrapper.js.map +1 -0
  147. package/dist/chatWrappers/Llama3ChatWrapper.d.ts +16 -0
  148. package/dist/chatWrappers/Llama3ChatWrapper.js +173 -0
  149. package/dist/chatWrappers/Llama3ChatWrapper.js.map +1 -0
  150. package/dist/chatWrappers/Llama3_1ChatWrapper.d.ts +32 -0
  151. package/dist/chatWrappers/Llama3_1ChatWrapper.js +290 -0
  152. package/dist/chatWrappers/Llama3_1ChatWrapper.js.map +1 -0
  153. package/dist/chatWrappers/Llama3_2LightweightChatWrapper.d.ts +35 -0
  154. package/dist/chatWrappers/Llama3_2LightweightChatWrapper.js +264 -0
  155. package/dist/chatWrappers/Llama3_2LightweightChatWrapper.js.map +1 -0
  156. package/dist/chatWrappers/MistralChatWrapper.d.ts +16 -0
  157. package/dist/chatWrappers/MistralChatWrapper.js +180 -0
  158. package/dist/chatWrappers/MistralChatWrapper.js.map +1 -0
  159. package/dist/chatWrappers/QwenChatWrapper.d.ts +36 -0
  160. package/dist/chatWrappers/QwenChatWrapper.js +344 -0
  161. package/dist/chatWrappers/QwenChatWrapper.js.map +1 -0
  162. package/dist/chatWrappers/SeedChatWrapper.d.ts +25 -0
  163. package/dist/chatWrappers/SeedChatWrapper.js +183 -0
  164. package/dist/chatWrappers/SeedChatWrapper.js.map +1 -0
  165. package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.d.ts +138 -0
  166. package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.js +665 -0
  167. package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.js.map +1 -0
  168. package/dist/chatWrappers/generic/TemplateChatWrapper.d.ts +76 -0
  169. package/dist/chatWrappers/generic/TemplateChatWrapper.js +212 -0
  170. package/dist/chatWrappers/generic/TemplateChatWrapper.js.map +1 -0
  171. package/dist/chatWrappers/generic/utils/UniqueIdGenerator.d.ts +7 -0
  172. package/dist/chatWrappers/generic/utils/UniqueIdGenerator.js +30 -0
  173. package/dist/chatWrappers/generic/utils/UniqueIdGenerator.js.map +1 -0
  174. package/dist/chatWrappers/generic/utils/chatHistoryFunctionCallMessageTemplate.d.ts +24 -0
  175. package/dist/chatWrappers/generic/utils/chatHistoryFunctionCallMessageTemplate.js +45 -0
  176. package/dist/chatWrappers/generic/utils/chatHistoryFunctionCallMessageTemplate.js.map +1 -0
  177. package/dist/chatWrappers/generic/utils/extractFunctionCallSettingsFromJinjaTemplate.d.ts +25 -0
  178. package/dist/chatWrappers/generic/utils/extractFunctionCallSettingsFromJinjaTemplate.js +690 -0
  179. package/dist/chatWrappers/generic/utils/extractFunctionCallSettingsFromJinjaTemplate.js.map +1 -0
  180. package/dist/chatWrappers/generic/utils/extractSegmentSettingsFromTokenizerAndChatTemplate.d.ts +2 -0
  181. package/dist/chatWrappers/generic/utils/extractSegmentSettingsFromTokenizerAndChatTemplate.js +66 -0
  182. package/dist/chatWrappers/generic/utils/extractSegmentSettingsFromTokenizerAndChatTemplate.js.map +1 -0
  183. package/dist/chatWrappers/generic/utils/getFirstValidResult.d.ts +6 -0
  184. package/dist/chatWrappers/generic/utils/getFirstValidResult.js +19 -0
  185. package/dist/chatWrappers/generic/utils/getFirstValidResult.js.map +1 -0
  186. package/dist/chatWrappers/generic/utils/squashChatHistoryItems.d.ts +2 -0
  187. package/dist/chatWrappers/generic/utils/squashChatHistoryItems.js +35 -0
  188. package/dist/chatWrappers/generic/utils/squashChatHistoryItems.js.map +1 -0
  189. package/dist/chatWrappers/generic/utils/templateSegmentOptionsToChatWrapperSettings.d.ts +22 -0
  190. package/dist/chatWrappers/generic/utils/templateSegmentOptionsToChatWrapperSettings.js +28 -0
  191. package/dist/chatWrappers/generic/utils/templateSegmentOptionsToChatWrapperSettings.js.map +1 -0
  192. package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.d.ts +76 -0
  193. package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.js +177 -0
  194. package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.js.map +1 -0
  195. package/dist/chatWrappers/utils/chunkChatItems.d.ts +10 -0
  196. package/dist/chatWrappers/utils/chunkChatItems.js +44 -0
  197. package/dist/chatWrappers/utils/chunkChatItems.js.map +1 -0
  198. package/dist/chatWrappers/utils/getModelLinageNames.d.ts +2 -0
  199. package/dist/chatWrappers/utils/getModelLinageNames.js +18 -0
  200. package/dist/chatWrappers/utils/getModelLinageNames.js.map +1 -0
  201. package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.d.ts +4 -0
  202. package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.js +394 -0
  203. package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.js.map +1 -0
  204. package/dist/chatWrappers/utils/isLlama3_2LightweightModel.d.ts +2 -0
  205. package/dist/chatWrappers/utils/isLlama3_2LightweightModel.js +9 -0
  206. package/dist/chatWrappers/utils/isLlama3_2LightweightModel.js.map +1 -0
  207. package/dist/chatWrappers/utils/jsonDumps.d.ts +7 -0
  208. package/dist/chatWrappers/utils/jsonDumps.js +18 -0
  209. package/dist/chatWrappers/utils/jsonDumps.js.map +1 -0
  210. package/dist/chatWrappers/utils/resolveChatWrapper.d.ts +148 -0
  211. package/dist/chatWrappers/utils/resolveChatWrapper.js +325 -0
  212. package/dist/chatWrappers/utils/resolveChatWrapper.js.map +1 -0
  213. package/dist/cli/cli.d.ts +2 -0
  214. package/dist/cli/cli.js +45 -0
  215. package/dist/cli/cli.js.map +1 -0
  216. package/dist/cli/commands/ChatCommand.d.ts +59 -0
  217. package/dist/cli/commands/ChatCommand.js +856 -0
  218. package/dist/cli/commands/ChatCommand.js.map +1 -0
  219. package/dist/cli/commands/CompleteCommand.d.ts +47 -0
  220. package/dist/cli/commands/CompleteCommand.js +658 -0
  221. package/dist/cli/commands/CompleteCommand.js.map +1 -0
  222. package/dist/cli/commands/DebugCommand.d.ts +7 -0
  223. package/dist/cli/commands/DebugCommand.js +55 -0
  224. package/dist/cli/commands/DebugCommand.js.map +1 -0
  225. package/dist/cli/commands/InfillCommand.d.ts +49 -0
  226. package/dist/cli/commands/InfillCommand.js +693 -0
  227. package/dist/cli/commands/InfillCommand.js.map +1 -0
  228. package/dist/cli/commands/InitCommand.d.ts +12 -0
  229. package/dist/cli/commands/InitCommand.js +230 -0
  230. package/dist/cli/commands/InitCommand.js.map +1 -0
  231. package/dist/cli/commands/OnPostInstallCommand.d.ts +4 -0
  232. package/dist/cli/commands/OnPostInstallCommand.js +62 -0
  233. package/dist/cli/commands/OnPostInstallCommand.js.map +1 -0
  234. package/dist/cli/commands/PullCommand.d.ts +13 -0
  235. package/dist/cli/commands/PullCommand.js +158 -0
  236. package/dist/cli/commands/PullCommand.js.map +1 -0
  237. package/dist/cli/commands/inspect/InspectCommand.d.ts +4 -0
  238. package/dist/cli/commands/inspect/InspectCommand.js +21 -0
  239. package/dist/cli/commands/inspect/InspectCommand.js.map +1 -0
  240. package/dist/cli/commands/inspect/commands/InspectEstimateCommand.d.ts +17 -0
  241. package/dist/cli/commands/inspect/commands/InspectEstimateCommand.js +275 -0
  242. package/dist/cli/commands/inspect/commands/InspectEstimateCommand.js.map +1 -0
  243. package/dist/cli/commands/inspect/commands/InspectGgufCommand.d.ts +13 -0
  244. package/dist/cli/commands/inspect/commands/InspectGgufCommand.js +230 -0
  245. package/dist/cli/commands/inspect/commands/InspectGgufCommand.js.map +1 -0
  246. package/dist/cli/commands/inspect/commands/InspectGpuCommand.d.ts +4 -0
  247. package/dist/cli/commands/inspect/commands/InspectGpuCommand.js +296 -0
  248. package/dist/cli/commands/inspect/commands/InspectGpuCommand.js.map +1 -0
  249. package/dist/cli/commands/inspect/commands/InspectMeasureCommand.d.ts +26 -0
  250. package/dist/cli/commands/inspect/commands/InspectMeasureCommand.js +869 -0
  251. package/dist/cli/commands/inspect/commands/InspectMeasureCommand.js.map +1 -0
  252. package/dist/cli/commands/source/SourceCommand.d.ts +4 -0
  253. package/dist/cli/commands/source/SourceCommand.js +19 -0
  254. package/dist/cli/commands/source/SourceCommand.js.map +1 -0
  255. package/dist/cli/commands/source/commands/BuildCommand.d.ts +16 -0
  256. package/dist/cli/commands/source/commands/BuildCommand.js +148 -0
  257. package/dist/cli/commands/source/commands/BuildCommand.js.map +1 -0
  258. package/dist/cli/commands/source/commands/ClearCommand.d.ts +7 -0
  259. package/dist/cli/commands/source/commands/ClearCommand.js +54 -0
  260. package/dist/cli/commands/source/commands/ClearCommand.js.map +1 -0
  261. package/dist/cli/commands/source/commands/DownloadCommand.d.ts +16 -0
  262. package/dist/cli/commands/source/commands/DownloadCommand.js +219 -0
  263. package/dist/cli/commands/source/commands/DownloadCommand.js.map +1 -0
  264. package/dist/cli/projectTemplates.d.ts +7 -0
  265. package/dist/cli/projectTemplates.js +10 -0
  266. package/dist/cli/projectTemplates.js.map +1 -0
  267. package/dist/cli/recommendedModels.d.ts +2 -0
  268. package/dist/cli/recommendedModels.js +428 -0
  269. package/dist/cli/recommendedModels.js.map +1 -0
  270. package/dist/cli/startCreateCli.d.ts +2 -0
  271. package/dist/cli/startCreateCli.js +26 -0
  272. package/dist/cli/startCreateCli.js.map +1 -0
  273. package/dist/cli/utils/ConsoleInteraction.d.ts +22 -0
  274. package/dist/cli/utils/ConsoleInteraction.js +122 -0
  275. package/dist/cli/utils/ConsoleInteraction.js.map +1 -0
  276. package/dist/cli/utils/ConsoleTable.d.ts +24 -0
  277. package/dist/cli/utils/ConsoleTable.js +90 -0
  278. package/dist/cli/utils/ConsoleTable.js.map +1 -0
  279. package/dist/cli/utils/basicChooseFromListConsoleInteraction.d.ts +13 -0
  280. package/dist/cli/utils/basicChooseFromListConsoleInteraction.js +111 -0
  281. package/dist/cli/utils/basicChooseFromListConsoleInteraction.js.map +1 -0
  282. package/dist/cli/utils/consolePromptQuestion.d.ts +6 -0
  283. package/dist/cli/utils/consolePromptQuestion.js +81 -0
  284. package/dist/cli/utils/consolePromptQuestion.js.map +1 -0
  285. package/dist/cli/utils/getReadablePath.d.ts +1 -0
  286. package/dist/cli/utils/getReadablePath.js +14 -0
  287. package/dist/cli/utils/getReadablePath.js.map +1 -0
  288. package/dist/cli/utils/interactivelyAskForModel.d.ts +13 -0
  289. package/dist/cli/utils/interactivelyAskForModel.js +485 -0
  290. package/dist/cli/utils/interactivelyAskForModel.js.map +1 -0
  291. package/dist/cli/utils/isRunningUnderRosetta.d.ts +1 -0
  292. package/dist/cli/utils/isRunningUnderRosetta.js +20 -0
  293. package/dist/cli/utils/isRunningUnderRosetta.js.map +1 -0
  294. package/dist/cli/utils/logUsedGpuTypeOption.d.ts +2 -0
  295. package/dist/cli/utils/logUsedGpuTypeOption.js +9 -0
  296. package/dist/cli/utils/logUsedGpuTypeOption.js.map +1 -0
  297. package/dist/cli/utils/packageJsonConfig.d.ts +6 -0
  298. package/dist/cli/utils/packageJsonConfig.js +51 -0
  299. package/dist/cli/utils/packageJsonConfig.js.map +1 -0
  300. package/dist/cli/utils/packageManager.d.ts +1 -0
  301. package/dist/cli/utils/packageManager.js +15 -0
  302. package/dist/cli/utils/packageManager.js.map +1 -0
  303. package/dist/cli/utils/parseXtcArg.d.ts +5 -0
  304. package/dist/cli/utils/parseXtcArg.js +16 -0
  305. package/dist/cli/utils/parseXtcArg.js.map +1 -0
  306. package/dist/cli/utils/printCommonInfoLines.d.ts +12 -0
  307. package/dist/cli/utils/printCommonInfoLines.js +163 -0
  308. package/dist/cli/utils/printCommonInfoLines.js.map +1 -0
  309. package/dist/cli/utils/printInfoLine.d.ts +12 -0
  310. package/dist/cli/utils/printInfoLine.js +54 -0
  311. package/dist/cli/utils/printInfoLine.js.map +1 -0
  312. package/dist/cli/utils/printModelDestination.d.ts +2 -0
  313. package/dist/cli/utils/printModelDestination.js +11 -0
  314. package/dist/cli/utils/printModelDestination.js.map +1 -0
  315. package/dist/cli/utils/projectTemplates.d.ts +19 -0
  316. package/dist/cli/utils/projectTemplates.js +47 -0
  317. package/dist/cli/utils/projectTemplates.js.map +1 -0
  318. package/dist/cli/utils/renderModelCompatibilityPercentageWithColors.d.ts +6 -0
  319. package/dist/cli/utils/renderModelCompatibilityPercentageWithColors.js +14 -0
  320. package/dist/cli/utils/renderModelCompatibilityPercentageWithColors.js.map +1 -0
  321. package/dist/cli/utils/resolveCommandGgufPath.d.ts +19 -0
  322. package/dist/cli/utils/resolveCommandGgufPath.js +123 -0
  323. package/dist/cli/utils/resolveCommandGgufPath.js.map +1 -0
  324. package/dist/cli/utils/resolveHeaderFlag.d.ts +1 -0
  325. package/dist/cli/utils/resolveHeaderFlag.js +21 -0
  326. package/dist/cli/utils/resolveHeaderFlag.js.map +1 -0
  327. package/dist/cli/utils/resolveModelRecommendationFileOptions.d.ts +14 -0
  328. package/dist/cli/utils/resolveModelRecommendationFileOptions.js +12 -0
  329. package/dist/cli/utils/resolveModelRecommendationFileOptions.js.map +1 -0
  330. package/dist/cli/utils/resolveNpmrcConfig.d.ts +18 -0
  331. package/dist/cli/utils/resolveNpmrcConfig.js +129 -0
  332. package/dist/cli/utils/resolveNpmrcConfig.js.map +1 -0
  333. package/dist/cli/utils/splitAnsiToLines.d.ts +1 -0
  334. package/dist/cli/utils/splitAnsiToLines.js +32 -0
  335. package/dist/cli/utils/splitAnsiToLines.js.map +1 -0
  336. package/dist/cli/utils/toBytes.d.ts +1 -0
  337. package/dist/cli/utils/toBytes.js +5 -0
  338. package/dist/cli/utils/toBytes.js.map +1 -0
  339. package/dist/cli/utils/withCliCommandDescriptionDocsUrl.d.ts +2 -0
  340. package/dist/cli/utils/withCliCommandDescriptionDocsUrl.js +23 -0
  341. package/dist/cli/utils/withCliCommandDescriptionDocsUrl.js.map +1 -0
  342. package/dist/commands.d.ts +6 -0
  343. package/dist/commands.js +9 -0
  344. package/dist/commands.js.map +1 -0
  345. package/dist/config.d.ts +79 -0
  346. package/dist/config.js +127 -0
  347. package/dist/config.js.map +1 -0
  348. package/dist/consts.d.ts +4 -0
  349. package/dist/consts.js +11 -0
  350. package/dist/consts.js.map +1 -0
  351. package/dist/evaluator/LlamaChat/LlamaChat.d.ts +500 -0
  352. package/dist/evaluator/LlamaChat/LlamaChat.js +2696 -0
  353. package/dist/evaluator/LlamaChat/LlamaChat.js.map +1 -0
  354. package/dist/evaluator/LlamaChat/utils/FunctionCallNameGrammar.d.ts +11 -0
  355. package/dist/evaluator/LlamaChat/utils/FunctionCallNameGrammar.js +55 -0
  356. package/dist/evaluator/LlamaChat/utils/FunctionCallNameGrammar.js.map +1 -0
  357. package/dist/evaluator/LlamaChat/utils/FunctionCallParamsGrammar.d.ts +16 -0
  358. package/dist/evaluator/LlamaChat/utils/FunctionCallParamsGrammar.js +45 -0
  359. package/dist/evaluator/LlamaChat/utils/FunctionCallParamsGrammar.js.map +1 -0
  360. package/dist/evaluator/LlamaChat/utils/LlamaFunctionCallValidationError.d.ts +8 -0
  361. package/dist/evaluator/LlamaChat/utils/LlamaFunctionCallValidationError.js +12 -0
  362. package/dist/evaluator/LlamaChat/utils/LlamaFunctionCallValidationError.js.map +1 -0
  363. package/dist/evaluator/LlamaChat/utils/contextShiftStrategies/eraseFirstResponseAndKeepFirstSystemChatContextShiftStrategy.d.ts +16 -0
  364. package/dist/evaluator/LlamaChat/utils/contextShiftStrategies/eraseFirstResponseAndKeepFirstSystemChatContextShiftStrategy.js +260 -0
  365. package/dist/evaluator/LlamaChat/utils/contextShiftStrategies/eraseFirstResponseAndKeepFirstSystemChatContextShiftStrategy.js.map +1 -0
  366. package/dist/evaluator/LlamaChatSession/LlamaChatSession.d.ts +520 -0
  367. package/dist/evaluator/LlamaChatSession/LlamaChatSession.js +628 -0
  368. package/dist/evaluator/LlamaChatSession/LlamaChatSession.js.map +1 -0
  369. package/dist/evaluator/LlamaChatSession/utils/LlamaChatSessionPromptCompletionEngine.d.ts +45 -0
  370. package/dist/evaluator/LlamaChatSession/utils/LlamaChatSessionPromptCompletionEngine.js +191 -0
  371. package/dist/evaluator/LlamaChatSession/utils/LlamaChatSessionPromptCompletionEngine.js.map +1 -0
  372. package/dist/evaluator/LlamaChatSession/utils/defineChatSessionFunction.d.ts +15 -0
  373. package/dist/evaluator/LlamaChatSession/utils/defineChatSessionFunction.js +16 -0
  374. package/dist/evaluator/LlamaChatSession/utils/defineChatSessionFunction.js.map +1 -0
  375. package/dist/evaluator/LlamaCompletion.d.ts +219 -0
  376. package/dist/evaluator/LlamaCompletion.js +498 -0
  377. package/dist/evaluator/LlamaCompletion.js.map +1 -0
  378. package/dist/evaluator/LlamaContext/LlamaContext.d.ts +336 -0
  379. package/dist/evaluator/LlamaContext/LlamaContext.js +1919 -0
  380. package/dist/evaluator/LlamaContext/LlamaContext.js.map +1 -0
  381. package/dist/evaluator/LlamaContext/LlamaContextSequenceCheckpoints.d.ts +27 -0
  382. package/dist/evaluator/LlamaContext/LlamaContextSequenceCheckpoints.js +130 -0
  383. package/dist/evaluator/LlamaContext/LlamaContextSequenceCheckpoints.js.map +1 -0
  384. package/dist/evaluator/LlamaContext/LlamaSampler.d.ts +1 -0
  385. package/dist/evaluator/LlamaContext/LlamaSampler.js +39 -0
  386. package/dist/evaluator/LlamaContext/LlamaSampler.js.map +1 -0
  387. package/dist/evaluator/LlamaContext/TokenPredictor.d.ts +55 -0
  388. package/dist/evaluator/LlamaContext/TokenPredictor.js +20 -0
  389. package/dist/evaluator/LlamaContext/TokenPredictor.js.map +1 -0
  390. package/dist/evaluator/LlamaContext/tokenPredictors/DraftSequenceTokenPredictor.d.ts +56 -0
  391. package/dist/evaluator/LlamaContext/tokenPredictors/DraftSequenceTokenPredictor.js +266 -0
  392. package/dist/evaluator/LlamaContext/tokenPredictors/DraftSequenceTokenPredictor.js.map +1 -0
  393. package/dist/evaluator/LlamaContext/tokenPredictors/InputLookupTokenPredictor.d.ts +58 -0
  394. package/dist/evaluator/LlamaContext/tokenPredictors/InputLookupTokenPredictor.js +138 -0
  395. package/dist/evaluator/LlamaContext/tokenPredictors/InputLookupTokenPredictor.js.map +1 -0
  396. package/dist/evaluator/LlamaContext/types.d.ts +602 -0
  397. package/dist/evaluator/LlamaContext/types.js +2 -0
  398. package/dist/evaluator/LlamaContext/types.js.map +1 -0
  399. package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/firstInFirstOutStrategy.d.ts +5 -0
  400. package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/firstInFirstOutStrategy.js +16 -0
  401. package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/firstInFirstOutStrategy.js.map +1 -0
  402. package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/maximumParallelismStrategy.d.ts +5 -0
  403. package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/maximumParallelismStrategy.js +42 -0
  404. package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/maximumParallelismStrategy.js.map +1 -0
  405. package/dist/evaluator/LlamaContext/utils/padSafeContextSize.d.ts +1 -0
  406. package/dist/evaluator/LlamaContext/utils/padSafeContextSize.js +18 -0
  407. package/dist/evaluator/LlamaContext/utils/padSafeContextSize.js.map +1 -0
  408. package/dist/evaluator/LlamaContext/utils/resolveBatchItemsPrioritizationStrategy.d.ts +2 -0
  409. package/dist/evaluator/LlamaContext/utils/resolveBatchItemsPrioritizationStrategy.js +13 -0
  410. package/dist/evaluator/LlamaContext/utils/resolveBatchItemsPrioritizationStrategy.js.map +1 -0
  411. package/dist/evaluator/LlamaEmbedding.d.ts +21 -0
  412. package/dist/evaluator/LlamaEmbedding.js +53 -0
  413. package/dist/evaluator/LlamaEmbedding.js.map +1 -0
  414. package/dist/evaluator/LlamaEmbeddingContext.d.ts +52 -0
  415. package/dist/evaluator/LlamaEmbeddingContext.js +86 -0
  416. package/dist/evaluator/LlamaEmbeddingContext.js.map +1 -0
  417. package/dist/evaluator/LlamaGrammar.d.ts +39 -0
  418. package/dist/evaluator/LlamaGrammar.js +72 -0
  419. package/dist/evaluator/LlamaGrammar.js.map +1 -0
  420. package/dist/evaluator/LlamaGrammarEvaluationState.d.ts +19 -0
  421. package/dist/evaluator/LlamaGrammarEvaluationState.js +29 -0
  422. package/dist/evaluator/LlamaGrammarEvaluationState.js.map +1 -0
  423. package/dist/evaluator/LlamaJsonSchemaGrammar.d.ts +17 -0
  424. package/dist/evaluator/LlamaJsonSchemaGrammar.js +35 -0
  425. package/dist/evaluator/LlamaJsonSchemaGrammar.js.map +1 -0
  426. package/dist/evaluator/LlamaModel/LlamaModel.d.ts +344 -0
  427. package/dist/evaluator/LlamaModel/LlamaModel.js +853 -0
  428. package/dist/evaluator/LlamaModel/LlamaModel.js.map +1 -0
  429. package/dist/evaluator/LlamaModel/utils/TokenAttributes.d.ts +29 -0
  430. package/dist/evaluator/LlamaModel/utils/TokenAttributes.js +65 -0
  431. package/dist/evaluator/LlamaModel/utils/TokenAttributes.js.map +1 -0
  432. package/dist/evaluator/LlamaRankingContext.d.ts +91 -0
  433. package/dist/evaluator/LlamaRankingContext.js +178 -0
  434. package/dist/evaluator/LlamaRankingContext.js.map +1 -0
  435. package/dist/evaluator/TokenBias.d.ts +37 -0
  436. package/dist/evaluator/TokenBias.js +68 -0
  437. package/dist/evaluator/TokenBias.js.map +1 -0
  438. package/dist/evaluator/TokenMeter.d.ts +45 -0
  439. package/dist/evaluator/TokenMeter.js +74 -0
  440. package/dist/evaluator/TokenMeter.js.map +1 -0
  441. package/dist/evaluator/utils/chunkDocument.d.ts +86 -0
  442. package/dist/evaluator/utils/chunkDocument.js +212 -0
  443. package/dist/evaluator/utils/chunkDocument.js.map +1 -0
  444. package/dist/gguf/consts.d.ts +4 -0
  445. package/dist/gguf/consts.js +12 -0
  446. package/dist/gguf/consts.js.map +1 -0
  447. package/dist/gguf/errors/InvalidGgufMagicError.d.ts +3 -0
  448. package/dist/gguf/errors/InvalidGgufMagicError.js +6 -0
  449. package/dist/gguf/errors/InvalidGgufMagicError.js.map +1 -0
  450. package/dist/gguf/errors/UnsupportedGgufValueTypeError.d.ts +4 -0
  451. package/dist/gguf/errors/UnsupportedGgufValueTypeError.js +9 -0
  452. package/dist/gguf/errors/UnsupportedGgufValueTypeError.js.map +1 -0
  453. package/dist/gguf/fileReaders/GgufFileReader.d.ts +36 -0
  454. package/dist/gguf/fileReaders/GgufFileReader.js +106 -0
  455. package/dist/gguf/fileReaders/GgufFileReader.js.map +1 -0
  456. package/dist/gguf/fileReaders/GgufFsFileReader.d.ts +16 -0
  457. package/dist/gguf/fileReaders/GgufFsFileReader.js +62 -0
  458. package/dist/gguf/fileReaders/GgufFsFileReader.js.map +1 -0
  459. package/dist/gguf/fileReaders/GgufNetworkFetchFileReader.d.ts +28 -0
  460. package/dist/gguf/fileReaders/GgufNetworkFetchFileReader.js +94 -0
  461. package/dist/gguf/fileReaders/GgufNetworkFetchFileReader.js.map +1 -0
  462. package/dist/gguf/insights/GgufInsights.d.ts +78 -0
  463. package/dist/gguf/insights/GgufInsights.js +854 -0
  464. package/dist/gguf/insights/GgufInsights.js.map +1 -0
  465. package/dist/gguf/insights/GgufInsightsConfigurationResolver.d.ts +203 -0
  466. package/dist/gguf/insights/GgufInsightsConfigurationResolver.js +284 -0
  467. package/dist/gguf/insights/GgufInsightsConfigurationResolver.js.map +1 -0
  468. package/dist/gguf/insights/GgufInsightsTokens.d.ts +5 -0
  469. package/dist/gguf/insights/GgufInsightsTokens.js +40 -0
  470. package/dist/gguf/insights/GgufInsightsTokens.js.map +1 -0
  471. package/dist/gguf/insights/utils/getRamUsageFromUnifiedVram.d.ts +5 -0
  472. package/dist/gguf/insights/utils/getRamUsageFromUnifiedVram.js +7 -0
  473. package/dist/gguf/insights/utils/getRamUsageFromUnifiedVram.js.map +1 -0
  474. package/dist/gguf/insights/utils/resolveContextContextSizeOption.d.ts +33 -0
  475. package/dist/gguf/insights/utils/resolveContextContextSizeOption.js +117 -0
  476. package/dist/gguf/insights/utils/resolveContextContextSizeOption.js.map +1 -0
  477. package/dist/gguf/insights/utils/resolveModelGpuLayersOption.d.ts +20 -0
  478. package/dist/gguf/insights/utils/resolveModelGpuLayersOption.js +251 -0
  479. package/dist/gguf/insights/utils/resolveModelGpuLayersOption.js.map +1 -0
  480. package/dist/gguf/insights/utils/scoreLevels.d.ts +5 -0
  481. package/dist/gguf/insights/utils/scoreLevels.js +16 -0
  482. package/dist/gguf/insights/utils/scoreLevels.js.map +1 -0
  483. package/dist/gguf/parser/GgufV2Parser.d.ts +20 -0
  484. package/dist/gguf/parser/GgufV2Parser.js +184 -0
  485. package/dist/gguf/parser/GgufV2Parser.js.map +1 -0
  486. package/dist/gguf/parser/GgufV3Parser.d.ts +3 -0
  487. package/dist/gguf/parser/GgufV3Parser.js +4 -0
  488. package/dist/gguf/parser/GgufV3Parser.js.map +1 -0
  489. package/dist/gguf/parser/parseGguf.d.ts +8 -0
  490. package/dist/gguf/parser/parseGguf.js +61 -0
  491. package/dist/gguf/parser/parseGguf.js.map +1 -0
  492. package/dist/gguf/readGgufFileInfo.d.ts +54 -0
  493. package/dist/gguf/readGgufFileInfo.js +82 -0
  494. package/dist/gguf/readGgufFileInfo.js.map +1 -0
  495. package/dist/gguf/types/GgufFileInfoTypes.d.ts +85 -0
  496. package/dist/gguf/types/GgufFileInfoTypes.js +18 -0
  497. package/dist/gguf/types/GgufFileInfoTypes.js.map +1 -0
  498. package/dist/gguf/types/GgufMetadataTypes.d.ts +480 -0
  499. package/dist/gguf/types/GgufMetadataTypes.js +194 -0
  500. package/dist/gguf/types/GgufMetadataTypes.js.map +1 -0
  501. package/dist/gguf/types/GgufTensorInfoTypes.d.ts +63 -0
  502. package/dist/gguf/types/GgufTensorInfoTypes.js +54 -0
  503. package/dist/gguf/types/GgufTensorInfoTypes.js.map +1 -0
  504. package/dist/gguf/utils/GgufReadOffset.d.ts +6 -0
  505. package/dist/gguf/utils/GgufReadOffset.js +18 -0
  506. package/dist/gguf/utils/GgufReadOffset.js.map +1 -0
  507. package/dist/gguf/utils/convertMetadataKeyValueRecordToNestedObject.d.ts +6 -0
  508. package/dist/gguf/utils/convertMetadataKeyValueRecordToNestedObject.js +76 -0
  509. package/dist/gguf/utils/convertMetadataKeyValueRecordToNestedObject.js.map +1 -0
  510. package/dist/gguf/utils/getGgufFileTypeName.d.ts +4 -0
  511. package/dist/gguf/utils/getGgufFileTypeName.js +13 -0
  512. package/dist/gguf/utils/getGgufFileTypeName.js.map +1 -0
  513. package/dist/gguf/utils/getGgufMetadataArchitectureData.d.ts +3 -0
  514. package/dist/gguf/utils/getGgufMetadataArchitectureData.js +4 -0
  515. package/dist/gguf/utils/getGgufMetadataArchitectureData.js.map +1 -0
  516. package/dist/gguf/utils/getGgufMetadataKeyValue.d.ts +1 -0
  517. package/dist/gguf/utils/getGgufMetadataKeyValue.js +27 -0
  518. package/dist/gguf/utils/getGgufMetadataKeyValue.js.map +1 -0
  519. package/dist/gguf/utils/ggufQuantNames.d.ts +2 -0
  520. package/dist/gguf/utils/ggufQuantNames.js +42 -0
  521. package/dist/gguf/utils/ggufQuantNames.js.map +1 -0
  522. package/dist/gguf/utils/normalizeGgufDownloadUrl.d.ts +2 -0
  523. package/dist/gguf/utils/normalizeGgufDownloadUrl.js +18 -0
  524. package/dist/gguf/utils/normalizeGgufDownloadUrl.js.map +1 -0
  525. package/dist/gguf/utils/resolveBinarySplitGgufPartUrls.d.ts +2 -0
  526. package/dist/gguf/utils/resolveBinarySplitGgufPartUrls.js +38 -0
  527. package/dist/gguf/utils/resolveBinarySplitGgufPartUrls.js.map +1 -0
  528. package/dist/gguf/utils/resolveSplitGgufParts.d.ts +7 -0
  529. package/dist/gguf/utils/resolveSplitGgufParts.js +64 -0
  530. package/dist/gguf/utils/resolveSplitGgufParts.js.map +1 -0
  531. package/dist/index.d.ts +71 -0
  532. package/dist/index.js +64 -0
  533. package/dist/index.js.map +1 -0
  534. package/dist/state.d.ts +6 -0
  535. package/dist/state.js +22 -0
  536. package/dist/state.js.map +1 -0
  537. package/dist/tsconfig.tsbuildinfo +1 -0
  538. package/dist/types.d.ts +408 -0
  539. package/dist/types.js +13 -0
  540. package/dist/types.js.map +1 -0
  541. package/dist/utils/DisposeGuard.d.ts +13 -0
  542. package/dist/utils/DisposeGuard.js +120 -0
  543. package/dist/utils/DisposeGuard.js.map +1 -0
  544. package/dist/utils/InsufficientMemoryError.d.ts +3 -0
  545. package/dist/utils/InsufficientMemoryError.js +6 -0
  546. package/dist/utils/InsufficientMemoryError.js.map +1 -0
  547. package/dist/utils/LlamaText.d.ts +92 -0
  548. package/dist/utils/LlamaText.js +527 -0
  549. package/dist/utils/LlamaText.js.map +1 -0
  550. package/dist/utils/LruCache.d.ts +12 -0
  551. package/dist/utils/LruCache.js +44 -0
  552. package/dist/utils/LruCache.js.map +1 -0
  553. package/dist/utils/OpenAIFormat.d.ts +177 -0
  554. package/dist/utils/OpenAIFormat.js +488 -0
  555. package/dist/utils/OpenAIFormat.js.map +1 -0
  556. package/dist/utils/OverridesObject.d.ts +7 -0
  557. package/dist/utils/OverridesObject.js +2 -0
  558. package/dist/utils/OverridesObject.js.map +1 -0
  559. package/dist/utils/ReplHistory.d.ts +9 -0
  560. package/dist/utils/ReplHistory.js +72 -0
  561. package/dist/utils/ReplHistory.js.map +1 -0
  562. package/dist/utils/StopGenerationDetector.d.ts +47 -0
  563. package/dist/utils/StopGenerationDetector.js +291 -0
  564. package/dist/utils/StopGenerationDetector.js.map +1 -0
  565. package/dist/utils/ThreadsSplitter.d.ts +32 -0
  566. package/dist/utils/ThreadsSplitter.js +177 -0
  567. package/dist/utils/ThreadsSplitter.js.map +1 -0
  568. package/dist/utils/TokenStreamRegulator.d.ts +38 -0
  569. package/dist/utils/TokenStreamRegulator.js +200 -0
  570. package/dist/utils/TokenStreamRegulator.js.map +1 -0
  571. package/dist/utils/UnsupportedError.d.ts +2 -0
  572. package/dist/utils/UnsupportedError.js +7 -0
  573. package/dist/utils/UnsupportedError.js.map +1 -0
  574. package/dist/utils/appendUserMessageToChatHistory.d.ts +6 -0
  575. package/dist/utils/appendUserMessageToChatHistory.js +22 -0
  576. package/dist/utils/appendUserMessageToChatHistory.js.map +1 -0
  577. package/dist/utils/clearTempFolder.d.ts +1 -0
  578. package/dist/utils/clearTempFolder.js +16 -0
  579. package/dist/utils/clearTempFolder.js.map +1 -0
  580. package/dist/utils/cmake.d.ts +10 -0
  581. package/dist/utils/cmake.js +146 -0
  582. package/dist/utils/cmake.js.map +1 -0
  583. package/dist/utils/compareTokens.d.ts +2 -0
  584. package/dist/utils/compareTokens.js +4 -0
  585. package/dist/utils/compareTokens.js.map +1 -0
  586. package/dist/utils/createModelDownloader.d.ts +262 -0
  587. package/dist/utils/createModelDownloader.js +486 -0
  588. package/dist/utils/createModelDownloader.js.map +1 -0
  589. package/dist/utils/findBestOption.d.ts +4 -0
  590. package/dist/utils/findBestOption.js +15 -0
  591. package/dist/utils/findBestOption.js.map +1 -0
  592. package/dist/utils/findCharacterRemovalCountToFitChatHistoryInContext.d.ts +20 -0
  593. package/dist/utils/findCharacterRemovalCountToFitChatHistoryInContext.js +85 -0
  594. package/dist/utils/findCharacterRemovalCountToFitChatHistoryInContext.js.map +1 -0
  595. package/dist/utils/gbnfJson/GbnfGrammarGenerator.d.ts +19 -0
  596. package/dist/utils/gbnfJson/GbnfGrammarGenerator.js +60 -0
  597. package/dist/utils/gbnfJson/GbnfGrammarGenerator.js.map +1 -0
  598. package/dist/utils/gbnfJson/GbnfTerminal.d.ts +11 -0
  599. package/dist/utils/gbnfJson/GbnfTerminal.js +54 -0
  600. package/dist/utils/gbnfJson/GbnfTerminal.js.map +1 -0
  601. package/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.d.ts +5 -0
  602. package/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.js +11 -0
  603. package/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.js.map +1 -0
  604. package/dist/utils/gbnfJson/terminals/GbnfAnyJson.d.ts +9 -0
  605. package/dist/utils/gbnfJson/terminals/GbnfAnyJson.js +53 -0
  606. package/dist/utils/gbnfJson/terminals/GbnfAnyJson.js.map +1 -0
  607. package/dist/utils/gbnfJson/terminals/GbnfArray.d.ts +18 -0
  608. package/dist/utils/gbnfJson/terminals/GbnfArray.js +83 -0
  609. package/dist/utils/gbnfJson/terminals/GbnfArray.js.map +1 -0
  610. package/dist/utils/gbnfJson/terminals/GbnfBoolean.d.ts +7 -0
  611. package/dist/utils/gbnfJson/terminals/GbnfBoolean.js +22 -0
  612. package/dist/utils/gbnfJson/terminals/GbnfBoolean.js.map +1 -0
  613. package/dist/utils/gbnfJson/terminals/GbnfBooleanValue.d.ts +7 -0
  614. package/dist/utils/gbnfJson/terminals/GbnfBooleanValue.js +17 -0
  615. package/dist/utils/gbnfJson/terminals/GbnfBooleanValue.js.map +1 -0
  616. package/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.d.ts +11 -0
  617. package/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.js +28 -0
  618. package/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.js.map +1 -0
  619. package/dist/utils/gbnfJson/terminals/GbnfFormatString.d.ts +11 -0
  620. package/dist/utils/gbnfJson/terminals/GbnfFormatString.js +90 -0
  621. package/dist/utils/gbnfJson/terminals/GbnfFormatString.js.map +1 -0
  622. package/dist/utils/gbnfJson/terminals/GbnfGrammar.d.ts +9 -0
  623. package/dist/utils/gbnfJson/terminals/GbnfGrammar.js +23 -0
  624. package/dist/utils/gbnfJson/terminals/GbnfGrammar.js.map +1 -0
  625. package/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.d.ts +5 -0
  626. package/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.js +24 -0
  627. package/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.js.map +1 -0
  628. package/dist/utils/gbnfJson/terminals/GbnfNull.d.ts +5 -0
  629. package/dist/utils/gbnfJson/terminals/GbnfNull.js +11 -0
  630. package/dist/utils/gbnfJson/terminals/GbnfNull.js.map +1 -0
  631. package/dist/utils/gbnfJson/terminals/GbnfNumber.d.ts +9 -0
  632. package/dist/utils/gbnfJson/terminals/GbnfNumber.js +22 -0
  633. package/dist/utils/gbnfJson/terminals/GbnfNumber.js.map +1 -0
  634. package/dist/utils/gbnfJson/terminals/GbnfNumberValue.d.ts +9 -0
  635. package/dist/utils/gbnfJson/terminals/GbnfNumberValue.js +21 -0
  636. package/dist/utils/gbnfJson/terminals/GbnfNumberValue.js.map +1 -0
  637. package/dist/utils/gbnfJson/terminals/GbnfObjectMap.d.ts +28 -0
  638. package/dist/utils/gbnfJson/terminals/GbnfObjectMap.js +88 -0
  639. package/dist/utils/gbnfJson/terminals/GbnfObjectMap.js.map +1 -0
  640. package/dist/utils/gbnfJson/terminals/GbnfOr.d.ts +9 -0
  641. package/dist/utils/gbnfJson/terminals/GbnfOr.js +34 -0
  642. package/dist/utils/gbnfJson/terminals/GbnfOr.js.map +1 -0
  643. package/dist/utils/gbnfJson/terminals/GbnfRef.d.ts +15 -0
  644. package/dist/utils/gbnfJson/terminals/GbnfRef.js +34 -0
  645. package/dist/utils/gbnfJson/terminals/GbnfRef.js.map +1 -0
  646. package/dist/utils/gbnfJson/terminals/GbnfRepetition.d.ts +15 -0
  647. package/dist/utils/gbnfJson/terminals/GbnfRepetition.js +86 -0
  648. package/dist/utils/gbnfJson/terminals/GbnfRepetition.js.map +1 -0
  649. package/dist/utils/gbnfJson/terminals/GbnfString.d.ts +12 -0
  650. package/dist/utils/gbnfJson/terminals/GbnfString.js +43 -0
  651. package/dist/utils/gbnfJson/terminals/GbnfString.js.map +1 -0
  652. package/dist/utils/gbnfJson/terminals/GbnfStringValue.d.ts +8 -0
  653. package/dist/utils/gbnfJson/terminals/GbnfStringValue.js +26 -0
  654. package/dist/utils/gbnfJson/terminals/GbnfStringValue.js.map +1 -0
  655. package/dist/utils/gbnfJson/terminals/GbnfVerbatimText.d.ts +6 -0
  656. package/dist/utils/gbnfJson/terminals/GbnfVerbatimText.js +21 -0
  657. package/dist/utils/gbnfJson/terminals/GbnfVerbatimText.js.map +1 -0
  658. package/dist/utils/gbnfJson/terminals/GbnfWhitespace.d.ts +13 -0
  659. package/dist/utils/gbnfJson/terminals/GbnfWhitespace.js +67 -0
  660. package/dist/utils/gbnfJson/terminals/GbnfWhitespace.js.map +1 -0
  661. package/dist/utils/gbnfJson/terminals/gbnfConsts.d.ts +30 -0
  662. package/dist/utils/gbnfJson/terminals/gbnfConsts.js +72 -0
  663. package/dist/utils/gbnfJson/terminals/gbnfConsts.js.map +1 -0
  664. package/dist/utils/gbnfJson/types.d.ts +213 -0
  665. package/dist/utils/gbnfJson/types.js +30 -0
  666. package/dist/utils/gbnfJson/types.js.map +1 -0
  667. package/dist/utils/gbnfJson/utils/GbnfJsonScopeState.d.ts +10 -0
  668. package/dist/utils/gbnfJson/utils/GbnfJsonScopeState.js +15 -0
  669. package/dist/utils/gbnfJson/utils/GbnfJsonScopeState.js.map +1 -0
  670. package/dist/utils/gbnfJson/utils/defsScope.d.ts +7 -0
  671. package/dist/utils/gbnfJson/utils/defsScope.js +17 -0
  672. package/dist/utils/gbnfJson/utils/defsScope.js.map +1 -0
  673. package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.d.ts +5 -0
  674. package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js +143 -0
  675. package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js.map +1 -0
  676. package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.d.ts +5 -0
  677. package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.js +16 -0
  678. package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.js.map +1 -0
  679. package/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.d.ts +8 -0
  680. package/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js +242 -0
  681. package/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js.map +1 -0
  682. package/dist/utils/getBuildDefaults.d.ts +5 -0
  683. package/dist/utils/getBuildDefaults.js +9 -0
  684. package/dist/utils/getBuildDefaults.js.map +1 -0
  685. package/dist/utils/getChatWrapperSegmentDefinition.d.ts +2 -0
  686. package/dist/utils/getChatWrapperSegmentDefinition.js +9 -0
  687. package/dist/utils/getChatWrapperSegmentDefinition.js.map +1 -0
  688. package/dist/utils/getConsoleLogPrefix.d.ts +1 -0
  689. package/dist/utils/getConsoleLogPrefix.js +10 -0
  690. package/dist/utils/getConsoleLogPrefix.js.map +1 -0
  691. package/dist/utils/getFirstWritableDir.d.ts +8 -0
  692. package/dist/utils/getFirstWritableDir.js +60 -0
  693. package/dist/utils/getFirstWritableDir.js.map +1 -0
  694. package/dist/utils/getGrammarsFolder.d.ts +2 -0
  695. package/dist/utils/getGrammarsFolder.js +19 -0
  696. package/dist/utils/getGrammarsFolder.js.map +1 -0
  697. package/dist/utils/getLlamaClasses.d.ts +9 -0
  698. package/dist/utils/getLlamaClasses.js +14 -0
  699. package/dist/utils/getLlamaClasses.js.map +1 -0
  700. package/dist/utils/getModuleVersion.d.ts +1 -0
  701. package/dist/utils/getModuleVersion.js +13 -0
  702. package/dist/utils/getModuleVersion.js.map +1 -0
  703. package/dist/utils/getQueuedTokensBeforeStopTrigger.d.ts +6 -0
  704. package/dist/utils/getQueuedTokensBeforeStopTrigger.js +22 -0
  705. package/dist/utils/getQueuedTokensBeforeStopTrigger.js.map +1 -0
  706. package/dist/utils/getReadableContextSize.d.ts +1 -0
  707. package/dist/utils/getReadableContextSize.js +7 -0
  708. package/dist/utils/getReadableContextSize.js.map +1 -0
  709. package/dist/utils/getTempDir.d.ts +10 -0
  710. package/dist/utils/getTempDir.js +121 -0
  711. package/dist/utils/getTempDir.js.map +1 -0
  712. package/dist/utils/getTypeScriptTypeStringForGbnfJsonSchema.d.ts +2 -0
  713. package/dist/utils/getTypeScriptTypeStringForGbnfJsonSchema.js +205 -0
  714. package/dist/utils/getTypeScriptTypeStringForGbnfJsonSchema.js.map +1 -0
  715. package/dist/utils/gitReleaseBundles.d.ts +2 -0
  716. package/dist/utils/gitReleaseBundles.js +132 -0
  717. package/dist/utils/gitReleaseBundles.js.map +1 -0
  718. package/dist/utils/hashString.d.ts +1 -0
  719. package/dist/utils/hashString.js +8 -0
  720. package/dist/utils/hashString.js.map +1 -0
  721. package/dist/utils/includesText.d.ts +1 -0
  722. package/dist/utils/includesText.js +12 -0
  723. package/dist/utils/includesText.js.map +1 -0
  724. package/dist/utils/isLockfileActive.d.ts +4 -0
  725. package/dist/utils/isLockfileActive.js +12 -0
  726. package/dist/utils/isLockfileActive.js.map +1 -0
  727. package/dist/utils/isToken.d.ts +2 -0
  728. package/dist/utils/isToken.js +4 -0
  729. package/dist/utils/isToken.js.map +1 -0
  730. package/dist/utils/isUrl.d.ts +1 -0
  731. package/dist/utils/isUrl.js +15 -0
  732. package/dist/utils/isUrl.js.map +1 -0
  733. package/dist/utils/mergeUnionTypes.d.ts +10 -0
  734. package/dist/utils/mergeUnionTypes.js +2 -0
  735. package/dist/utils/mergeUnionTypes.js.map +1 -0
  736. package/dist/utils/modelDownloadEndpoints.d.ts +13 -0
  737. package/dist/utils/modelDownloadEndpoints.js +27 -0
  738. package/dist/utils/modelDownloadEndpoints.js.map +1 -0
  739. package/dist/utils/modelFileAccessTokens.d.ts +5 -0
  740. package/dist/utils/modelFileAccessTokens.js +41 -0
  741. package/dist/utils/modelFileAccessTokens.js.map +1 -0
  742. package/dist/utils/optionsMatrix.d.ts +58 -0
  743. package/dist/utils/optionsMatrix.js +97 -0
  744. package/dist/utils/optionsMatrix.js.map +1 -0
  745. package/dist/utils/parseModelFileName.d.ts +15 -0
  746. package/dist/utils/parseModelFileName.js +132 -0
  747. package/dist/utils/parseModelFileName.js.map +1 -0
  748. package/dist/utils/parseModelUri.d.ts +40 -0
  749. package/dist/utils/parseModelUri.js +346 -0
  750. package/dist/utils/parseModelUri.js.map +1 -0
  751. package/dist/utils/parseTextTemplate.d.ts +66 -0
  752. package/dist/utils/parseTextTemplate.js +116 -0
  753. package/dist/utils/parseTextTemplate.js.map +1 -0
  754. package/dist/utils/prettyPrintObject.d.ts +10 -0
  755. package/dist/utils/prettyPrintObject.js +84 -0
  756. package/dist/utils/prettyPrintObject.js.map +1 -0
  757. package/dist/utils/pushAll.d.ts +6 -0
  758. package/dist/utils/pushAll.js +11 -0
  759. package/dist/utils/pushAll.js.map +1 -0
  760. package/dist/utils/removeNullFields.d.ts +2 -0
  761. package/dist/utils/removeNullFields.js +17 -0
  762. package/dist/utils/removeNullFields.js.map +1 -0
  763. package/dist/utils/resolveGithubRelease.d.ts +2 -0
  764. package/dist/utils/resolveGithubRelease.js +77 -0
  765. package/dist/utils/resolveGithubRelease.js.map +1 -0
  766. package/dist/utils/resolveLastTokens.d.ts +2 -0
  767. package/dist/utils/resolveLastTokens.js +12 -0
  768. package/dist/utils/resolveLastTokens.js.map +1 -0
  769. package/dist/utils/resolveModelDestination.d.ts +16 -0
  770. package/dist/utils/resolveModelDestination.js +54 -0
  771. package/dist/utils/resolveModelDestination.js.map +1 -0
  772. package/dist/utils/resolveModelFile.d.ts +142 -0
  773. package/dist/utils/resolveModelFile.js +201 -0
  774. package/dist/utils/resolveModelFile.js.map +1 -0
  775. package/dist/utils/runtime.d.ts +4 -0
  776. package/dist/utils/runtime.js +8 -0
  777. package/dist/utils/runtime.js.map +1 -0
  778. package/dist/utils/safeEventCallback.d.ts +6 -0
  779. package/dist/utils/safeEventCallback.js +29 -0
  780. package/dist/utils/safeEventCallback.js.map +1 -0
  781. package/dist/utils/signalSleep.d.ts +1 -0
  782. package/dist/utils/signalSleep.js +20 -0
  783. package/dist/utils/signalSleep.js.map +1 -0
  784. package/dist/utils/spawnCommand.d.ts +11 -0
  785. package/dist/utils/spawnCommand.js +89 -0
  786. package/dist/utils/spawnCommand.js.map +1 -0
  787. package/dist/utils/tokenizeInput.d.ts +3 -0
  788. package/dist/utils/tokenizeInput.js +14 -0
  789. package/dist/utils/tokenizeInput.js.map +1 -0
  790. package/dist/utils/tokenizerUtils.d.ts +12 -0
  791. package/dist/utils/tokenizerUtils.js +32 -0
  792. package/dist/utils/tokenizerUtils.js.map +1 -0
  793. package/dist/utils/transformPromisable.d.ts +54 -0
  794. package/dist/utils/transformPromisable.js +95 -0
  795. package/dist/utils/transformPromisable.js.map +1 -0
  796. package/dist/utils/truncateTextAndRoundToWords.d.ts +11 -0
  797. package/dist/utils/truncateTextAndRoundToWords.js +110 -0
  798. package/dist/utils/truncateTextAndRoundToWords.js.map +1 -0
  799. package/dist/utils/utilTypes.d.ts +18 -0
  800. package/dist/utils/utilTypes.js +2 -0
  801. package/dist/utils/utilTypes.js.map +1 -0
  802. package/dist/utils/waitForLockfileRelease.d.ts +5 -0
  803. package/dist/utils/waitForLockfileRelease.js +19 -0
  804. package/dist/utils/waitForLockfileRelease.js.map +1 -0
  805. package/dist/utils/withLockfile.d.ts +7 -0
  806. package/dist/utils/withLockfile.js +44 -0
  807. package/dist/utils/withLockfile.js.map +1 -0
  808. package/dist/utils/withOra.d.ts +7 -0
  809. package/dist/utils/withOra.js +37 -0
  810. package/dist/utils/withOra.js.map +1 -0
  811. package/dist/utils/withProgressLog.d.ts +22 -0
  812. package/dist/utils/withProgressLog.js +211 -0
  813. package/dist/utils/withProgressLog.js.map +1 -0
  814. package/dist/utils/withStatusLogs.d.ts +6 -0
  815. package/dist/utils/withStatusLogs.js +25 -0
  816. package/dist/utils/withStatusLogs.js.map +1 -0
  817. package/dist/utils/wrapAbortSignal.d.ts +1 -0
  818. package/dist/utils/wrapAbortSignal.js +14 -0
  819. package/dist/utils/wrapAbortSignal.js.map +1 -0
  820. package/llama/.clang-format +46 -0
  821. package/llama/CMakeLists.txt +141 -0
  822. package/llama/addon/AddonContext.cpp +1181 -0
  823. package/llama/addon/AddonContext.h +85 -0
  824. package/llama/addon/AddonGrammar.cpp +92 -0
  825. package/llama/addon/AddonGrammar.h +22 -0
  826. package/llama/addon/AddonGrammarEvaluationState.cpp +36 -0
  827. package/llama/addon/AddonGrammarEvaluationState.h +17 -0
  828. package/llama/addon/AddonModel.cpp +691 -0
  829. package/llama/addon/AddonModel.h +64 -0
  830. package/llama/addon/AddonModelData.cpp +25 -0
  831. package/llama/addon/AddonModelData.h +15 -0
  832. package/llama/addon/AddonModelLora.cpp +103 -0
  833. package/llama/addon/AddonModelLora.h +28 -0
  834. package/llama/addon/AddonSampler.cpp +669 -0
  835. package/llama/addon/AddonSampler.h +75 -0
  836. package/llama/addon/RingBuffer.h +109 -0
  837. package/llama/addon/addon.cpp +330 -0
  838. package/llama/addon/addonGlobals.cpp +22 -0
  839. package/llama/addon/addonGlobals.h +12 -0
  840. package/llama/addon/globals/addonLog.cpp +143 -0
  841. package/llama/addon/globals/addonLog.h +24 -0
  842. package/llama/addon/globals/addonProgress.cpp +15 -0
  843. package/llama/addon/globals/addonProgress.h +15 -0
  844. package/llama/addon/globals/getGpuInfo.cpp +146 -0
  845. package/llama/addon/globals/getGpuInfo.h +11 -0
  846. package/llama/addon/globals/getMemoryInfo.cpp +63 -0
  847. package/llama/addon/globals/getMemoryInfo.h +4 -0
  848. package/llama/addon/globals/getSwapInfo.cpp +69 -0
  849. package/llama/addon/globals/getSwapInfo.h +4 -0
  850. package/llama/binariesGithubRelease.json +3 -0
  851. package/llama/cmake/addVariantSuffix.cmake +21 -0
  852. package/llama/cmake/win32.ensureNinjaPath.cmake +68 -0
  853. package/llama/cmake/win32.ensureNodeLib.cmake +34 -0
  854. package/llama/cmake/win32.llvmApplyGnuModeAdaptations.cmake +12 -0
  855. package/llama/cmake/win32.llvmEnsureCmakeAr.cmake +37 -0
  856. package/llama/cmake/win32.llvmUseGnuModeCompilers.cmake +87 -0
  857. package/llama/cmake/win32.programFilesPaths.cmake +35 -0
  858. package/llama/gpuInfo/vulkan-gpu-info.cpp +207 -0
  859. package/llama/gpuInfo/vulkan-gpu-info.h +9 -0
  860. package/llama/package.json +5 -0
  861. package/llama/profiles/llvm.win32.host-arm64.target-arm64.cmake +14 -0
  862. package/llama/profiles/llvm.win32.host-x64.target-arm64.cmake +14 -0
  863. package/llama/profiles/llvm.win32.host-x64.target-x64.cmake +14 -0
  864. package/llama/toolchains/darwin.host-x64.target-arm64.cmake +8 -0
  865. package/llama/toolchains/linux.host-arm64.target-x64.cmake +5 -0
  866. package/llama/toolchains/linux.host-x64.target-arm64.cmake +5 -0
  867. package/llama/toolchains/linux.host-x64.target-arm71.cmake +5 -0
  868. package/llama/toolchains/llvm.win32.host-x64.target-x64.cmake +20 -0
  869. package/llama/toolchains/win32.host-arm64.target-arm64.cmake +21 -0
  870. package/llama/toolchains/win32.host-x64.target-arm64.cmake +21 -0
  871. package/llama/xpack/package.json +10 -0
  872. package/package.json +241 -0
  873. package/templates/README.md +6 -0
  874. package/templates/package.json +10 -0
  875. package/templates/packed/electron-typescript-react.json +1 -0
  876. package/templates/packed/node-typescript.json +1 -0
@@ -0,0 +1,520 @@
1
+ import { EventRelay } from "lifecycle-utils";
2
+ import { ChatWrapper } from "../../ChatWrapper.js";
3
+ import { ChatHistoryItem, ChatModelFunctionCall, ChatSessionModelFunctions, Token } from "../../types.js";
4
+ import { LlamaContextSequence } from "../LlamaContext/LlamaContext.js";
5
+ import { LlamaGrammar } from "../LlamaGrammar.js";
6
+ import { LLamaChatContextShiftOptions, LlamaChatResponseChunk, LlamaChatResponseFunctionCallParamsChunk } from "../LlamaChat/LlamaChat.js";
7
+ import { EvaluationPriority } from "../LlamaContext/types.js";
8
+ import { TokenBias } from "../TokenBias.js";
9
+ import { LlamaText } from "../../utils/LlamaText.js";
10
+ import { LLamaChatPromptCompletionEngineOptions, LlamaChatSessionPromptCompletionEngine } from "./utils/LlamaChatSessionPromptCompletionEngine.js";
11
+ export type LlamaChatSessionOptions = {
12
+ contextSequence: LlamaContextSequence;
13
+ /** `"auto"` is used by default */
14
+ chatWrapper?: "auto" | ChatWrapper;
15
+ systemPrompt?: string;
16
+ /**
17
+ * Add the system prompt even on models that don't support a system prompt.
18
+ *
19
+ * Each chat wrapper has its own workaround for adding a system prompt to a model that doesn't support it,
20
+ * but forcing the system prompt on unsupported models may not always work as expected.
21
+ *
22
+ * Use with caution.
23
+ */
24
+ forceAddSystemPrompt?: boolean;
25
+ /**
26
+ * Automatically dispose the sequence when the session is disposed.
27
+ *
28
+ * Defaults to `false`.
29
+ */
30
+ autoDisposeSequence?: boolean;
31
+ contextShift?: LlamaChatSessionContextShiftOptions;
32
+ };
33
+ export type LlamaChatSessionContextShiftOptions = {
34
+ /**
35
+ * The number of tokens to delete from the context window to make space for new ones.
36
+ * Defaults to 10% of the context size.
37
+ */
38
+ size?: LLamaChatContextShiftOptions["size"];
39
+ /**
40
+ * The strategy to use when deleting tokens from the context window.
41
+ *
42
+ * Defaults to `"eraseFirstResponseAndKeepFirstSystem"`.
43
+ */
44
+ strategy?: LLamaChatContextShiftOptions["strategy"];
45
+ };
46
+ export type LLamaChatPromptOptions<Functions extends ChatSessionModelFunctions | undefined = ChatSessionModelFunctions | undefined> = {
47
+ /**
48
+ * Called as the model generates the main response with the generated text chunk.
49
+ *
50
+ * Useful for streaming the generated response as it's being generated.
51
+ *
52
+ * Includes only the main response without any text segments (like thoughts).
53
+ * For streaming the response with segments, use {@link onResponseChunk `onResponseChunk`}.
54
+ */
55
+ onTextChunk?: (text: string) => void;
56
+ /**
57
+ * Called as the model generates the main response with the generated tokens.
58
+ *
59
+ * Preferably, you'd want to use {@link onTextChunk `onTextChunk`} instead of this.
60
+ *
61
+ * Includes only the main response without any segments (like thoughts).
62
+ * For streaming the response with segments, use {@link onResponseChunk `onResponseChunk`}.
63
+ */
64
+ onToken?: (tokens: Token[]) => void;
65
+ /**
66
+ * Called as the model generates a response with the generated text and tokens,
67
+ * including segment information (when the generated output is part of a segment).
68
+ *
69
+ * Useful for streaming the generated response as it's being generated, including the main response and all segments.
70
+ *
71
+ * Only use this function when you need the segmented texts, like thought segments (chain of thought text).
72
+ */
73
+ onResponseChunk?: (chunk: LlamaChatResponseChunk) => void;
74
+ /**
75
+ * An AbortSignal to later abort the generation.
76
+ *
77
+ * When the signal is aborted, the generation will stop and throw `signal.reason` as the error.
78
+ *
79
+ * > To stop an ongoing generation without throwing an error, also set `stopOnAbortSignal` to `true`.
80
+ */
81
+ signal?: AbortSignal;
82
+ /**
83
+ * When a response already started being generated and then the signal is aborted,
84
+ * the generation will stop and the response will be returned as is instead of throwing an error.
85
+ *
86
+ * Defaults to `false`.
87
+ */
88
+ stopOnAbortSignal?: boolean;
89
+ /** Maximum number of tokens to generate */
90
+ maxTokens?: number;
91
+ /**
92
+ * Temperature is a hyperparameter that controls the randomness of the generated text.
93
+ * It affects the probability distribution of the model's output tokens.
94
+ *
95
+ * A higher temperature (e.g., 1.5) makes the output more random and creative,
96
+ * while a lower temperature (e.g., 0.5) makes the output more focused, deterministic, and conservative.
97
+ *
98
+ * The suggested temperature is 0.8, which provides a balance between randomness and determinism.
99
+ *
100
+ * At the extreme, a temperature of 0 will always pick the most likely next token, leading to identical outputs in each run.
101
+ *
102
+ * Set to `0` to disable.
103
+ * Disabled by default (set to `0`).
104
+ */
105
+ temperature?: number;
106
+ /**
107
+ * From the next token candidates, discard the percentage of tokens with the lowest probability.
108
+ * For example, if set to `0.05`, 5% of the lowest probability tokens will be discarded.
109
+ * This is useful for generating more high-quality results when using a high temperature.
110
+ * Set to a value between `0` and `1` to enable.
111
+ *
112
+ * Only relevant when `temperature` is set to a value greater than `0`.
113
+ * Disabled by default.
114
+ */
115
+ minP?: number;
116
+ /**
117
+ * Limits the model to consider only the K most likely next tokens for sampling at each step of sequence generation.
118
+ * An integer number between `1` and the size of the vocabulary.
119
+ * Set to `0` to disable (which uses the full vocabulary).
120
+ *
121
+ * Only relevant when `temperature` is set to a value greater than 0.
122
+ */
123
+ topK?: number;
124
+ /**
125
+ * Dynamically selects the smallest set of tokens whose cumulative probability exceeds the threshold P,
126
+ * and samples the next token only from this set.
127
+ * A float number between `0` and `1`.
128
+ * Set to `1` to disable.
129
+ *
130
+ * Only relevant when `temperature` is set to a value greater than `0`.
131
+ */
132
+ topP?: number;
133
+ /**
134
+ * Used to control the randomness of the generated text.
135
+ *
136
+ * Change the seed to get different results.
137
+ *
138
+ * Only relevant when using `temperature`.
139
+ */
140
+ seed?: number;
141
+ /**
142
+ * Exclude Top Choices (XTC) removes the top tokens from consideration and avoids more obvious and repetitive generations.
143
+ * Using it leads to more creative responses, but also to increased hallucinations.
144
+ *
145
+ * The `probability` value controls the chance that the top tokens will be removed in the next token generation step.
146
+ * The `threshold` value control the minimum probability of a token for it to be removed.
147
+ *
148
+ * Start with `{probability: 0.5, threshold: 0.1}` and adjust from there.
149
+ *
150
+ * Disabled by default.
151
+ */
152
+ xtc?: {
153
+ /**
154
+ * A number between `0` and `1` representing the probability of applying Exclude Top Choices (XTC) at each token generation step.
155
+ */
156
+ probability: number;
157
+ /**
158
+ * A number between `0` and `1` representing the minimum probability
159
+ * of a token for it to be removed when applying Exclude Top Choices (XTC).
160
+ */
161
+ threshold: number;
162
+ };
163
+ /**
164
+ * Trim whitespace from the end of the generated text
165
+ * Disabled by default.
166
+ */
167
+ trimWhitespaceSuffix?: boolean;
168
+ /**
169
+ * Force a given text prefix to be the start of the model response, to make the model follow a certain direction.
170
+ *
171
+ * May cause some models to not use the given functions in some scenarios where they would have been used otherwise,
172
+ * so avoid using it together with function calling if you notice unexpected behavior.
173
+ */
174
+ responsePrefix?: string;
175
+ /**
176
+ * See the parameter `evaluationPriority` on the `LlamaContextSequence.evaluate()` function for more information.
177
+ */
178
+ evaluationPriority?: EvaluationPriority;
179
+ repeatPenalty?: false | LlamaChatSessionRepeatPenalty;
180
+ /**
181
+ * DRY (Don't Repeat Yourself) penalty is a technique to reduce repetitions in the generated text
182
+ * by penalizing tokens based on recent token usage patterns.
183
+ *
184
+ * With the right parameters choice, it makes it impossible for the model to
185
+ * repeat itself verbatim with the same tokens in the same order (the model can still repeat itself by
186
+ * using different tokens or by paraphrasing, but that is far less of an issue than a broken-record looping).
187
+ *
188
+ * Disabled by default.
189
+ */
190
+ dryRepeatPenalty?: LlamaChatSessionDryRepeatPenalty;
191
+ /**
192
+ * Adjust the probability of tokens being generated.
193
+ * Can be used to bias the model to generate tokens that you want it to lean towards,
194
+ * or to avoid generating tokens that you want it to avoid.
195
+ */
196
+ tokenBias?: TokenBias | (() => TokenBias);
197
+ /**
198
+ * Custom stop triggers to stop the generation of the response when any of the provided triggers are found.
199
+ */
200
+ customStopTriggers?: (LlamaText | string | (string | Token)[])[];
201
+ /**
202
+ * Called as the model generates function calls with the generated parameters chunk for each function call.
203
+ *
204
+ * Useful for streaming the generated function call parameters as they're being generated.
205
+ * Only useful in specific use cases,
206
+ * such as showing the generated textual file content as it's being generated (note that doing this requires parsing incomplete JSON).
207
+ *
208
+ * The constructed text from all the params chunks of a given function call can be parsed as a JSON object,
209
+ * according to the function parameters schema.
210
+ *
211
+ * Each function call has its own `callIndex` you can use to distinguish between them.
212
+ *
213
+ * Only relevant when using function calling (via passing the `functions` option).
214
+ */
215
+ onFunctionCallParamsChunk?: (chunk: LlamaChatResponseFunctionCallParamsChunk) => void;
216
+ /**
217
+ * Set the maximum number of tokens that the model is allowed to spend on various segmented responses.
218
+ */
219
+ budgets?: {
220
+ /**
221
+ * Budget for thought tokens.
222
+ *
223
+ * Set to `Infinity` for unlimited budget.
224
+ *
225
+ * Defaults to 75% of the context size.
226
+ * When the context size is smaller than `8192`, defaults to 50% of the context size.
227
+ */
228
+ thoughtTokens?: number;
229
+ /**
230
+ * Budget for comment tokens.
231
+ *
232
+ * Set to `Infinity` for unlimited budget.
233
+ *
234
+ * Defaults to 75% of the context size.
235
+ * When the context size is smaller than `8192`, defaults to 50% of the context size.
236
+ */
237
+ commentTokens?: number;
238
+ };
239
+ } & ({
240
+ grammar?: LlamaGrammar;
241
+ functions?: never;
242
+ documentFunctionParams?: never;
243
+ maxParallelFunctionCalls?: never;
244
+ onFunctionCallParamsChunk?: never;
245
+ } | {
246
+ grammar?: never;
247
+ functions?: Functions | ChatSessionModelFunctions;
248
+ documentFunctionParams?: boolean;
249
+ maxParallelFunctionCalls?: number;
250
+ onFunctionCallParamsChunk?: (chunk: LlamaChatResponseFunctionCallParamsChunk) => void;
251
+ });
252
+ export type LLamaChatCompletePromptOptions = {
253
+ /**
254
+ * Generate a completion for the given user prompt up to the given number of tokens.
255
+ *
256
+ * Defaults to `256` or half the context size, whichever is smaller.
257
+ */
258
+ maxTokens?: LLamaChatPromptOptions["maxTokens"];
259
+ /**
260
+ * When a completion already started being generated and then the given `signal` is aborted,
261
+ * the generation will stop and the completion will be returned as-is instead of throwing an error.
262
+ *
263
+ * Defaults to `false`.
264
+ */
265
+ stopOnAbortSignal?: LLamaChatPromptOptions["stopOnAbortSignal"];
266
+ /**
267
+ * Called as the model generates a completion with the generated text chunk.
268
+ *
269
+ * Useful for streaming the generated completion as it's being generated.
270
+ */
271
+ onTextChunk?: LLamaChatPromptOptions["onTextChunk"];
272
+ /**
273
+ * Called as the model generates a completion with the generated tokens.
274
+ *
275
+ * Preferably, you'd want to use `onTextChunk` instead of this.
276
+ */
277
+ onToken?: LLamaChatPromptOptions["onToken"];
278
+ signal?: LLamaChatPromptOptions["signal"];
279
+ temperature?: LLamaChatPromptOptions["temperature"];
280
+ minP?: LLamaChatPromptOptions["minP"];
281
+ topK?: LLamaChatPromptOptions["topK"];
282
+ topP?: LLamaChatPromptOptions["topP"];
283
+ seed?: LLamaChatPromptOptions["seed"];
284
+ xtc?: LLamaChatPromptOptions["xtc"];
285
+ trimWhitespaceSuffix?: LLamaChatPromptOptions["trimWhitespaceSuffix"];
286
+ evaluationPriority?: LLamaChatPromptOptions["evaluationPriority"];
287
+ repeatPenalty?: LLamaChatPromptOptions["repeatPenalty"];
288
+ dryRepeatPenalty?: LLamaChatPromptOptions["dryRepeatPenalty"];
289
+ tokenBias?: LLamaChatPromptOptions["tokenBias"];
290
+ customStopTriggers?: LLamaChatPromptOptions["customStopTriggers"];
291
+ grammar?: LlamaGrammar;
292
+ /**
293
+ * Functions are not used by the model here,
294
+ * but are used for keeping the instructions given to the model about the functions in the current context state,
295
+ * to avoid context shifts.
296
+ *
297
+ * It's best to provide the same functions that were used for the previous prompt here.
298
+ */
299
+ functions?: ChatSessionModelFunctions;
300
+ /**
301
+ * Functions are not used by the model here,
302
+ * but are used for keeping the instructions given to the model about the functions in the current context state,
303
+ * to avoid context shifts.
304
+ *
305
+ * It's best to provide the same value that was used for the previous prompt here.
306
+ */
307
+ documentFunctionParams?: boolean;
308
+ /**
309
+ * Whether to complete the prompt as a model response.
310
+ *
311
+ * - **`"auto"`**: Automatically determine whether to complete as a model response based on the model used.
312
+ * This is a good option to workaround some models that don't support used prompt completions.
313
+ * - **`true`**: Always complete as a model response
314
+ * - **`false`**: Never complete as a model response
315
+ *
316
+ * Defaults to `"auto"`.
317
+ */
318
+ completeAsModel?: "auto" | boolean | {
319
+ /**
320
+ * Whether to complete the prompt as a model response.
321
+ *
322
+ * - **`"auto"`**: Automatically determine whether to complete as a model response based on the model used.
323
+ * This is a good option to workaround some models that don't support used prompt completions.
324
+ * - **`true`**: Always complete as a model response
325
+ * - **`false`**: Never complete as a model response
326
+ *
327
+ * Defaults to `"auto"`.
328
+ */
329
+ enabled?: "auto" | boolean;
330
+ /**
331
+ * The messages to append to the chat history to generate a completion as a model response.
332
+ *
333
+ * If the last message is a model message, the prompt will be pushed to it for the completion,
334
+ * otherwise a new model message will be added with the prompt.
335
+ *
336
+ * It must contain a user message or a system message before the model message.
337
+ *
338
+ * Default to:
339
+ * ```ts
340
+ * [
341
+ * {
342
+ * type: "system",
343
+ * text: "For your next response predict what the user may send next. " +
344
+ * "No yapping, no whitespace. Match the user's language and tone."
345
+ * },
346
+ * {type: "user", text: ""},
347
+ * {type: "model", response: [""]}
348
+ * ]
349
+ * ```
350
+ */
351
+ appendedMessages?: ChatHistoryItem[];
352
+ };
353
+ };
354
+ export type LLamaChatPreloadPromptOptions = {
355
+ signal?: LLamaChatCompletePromptOptions["signal"];
356
+ evaluationPriority?: LLamaChatCompletePromptOptions["evaluationPriority"];
357
+ functions?: LLamaChatCompletePromptOptions["functions"];
358
+ documentFunctionParams?: LLamaChatCompletePromptOptions["documentFunctionParams"];
359
+ };
360
+ export type LlamaChatSessionRepeatPenalty = {
361
+ /**
362
+ * Number of recent tokens generated by the model to apply penalties to repetition of.
363
+ * Defaults to `64`.
364
+ */
365
+ lastTokens?: number;
366
+ punishTokensFilter?: (tokens: Token[]) => Token[];
367
+ /**
368
+ * Penalize new line tokens.
369
+ * Enabled by default.
370
+ */
371
+ penalizeNewLine?: boolean;
372
+ /**
373
+ * The relative amount to lower the probability of the tokens in `punishTokens` by
374
+ * Defaults to `1.1`.
375
+ * Set to `1` to disable.
376
+ */
377
+ penalty?: number;
378
+ /**
379
+ * For n time a token is in the `punishTokens` array, lower its probability by `n * frequencyPenalty`
380
+ * Disabled by default (`0`).
381
+ * Set to a value between `0` and `1` to enable.
382
+ */
383
+ frequencyPenalty?: number;
384
+ /**
385
+ * Lower the probability of all the tokens in the `punishTokens` array by `presencePenalty`
386
+ * Disabled by default (`0`).
387
+ * Set to a value between `0` and `1` to enable.
388
+ */
389
+ presencePenalty?: number;
390
+ };
391
+ export type LlamaChatSessionDryRepeatPenalty = {
392
+ /**
393
+ * A number between `0` and `1` representing the strength of the DRY (Don't Repeat Yourself) effect.
394
+ *
395
+ * Setting this to `0` will disable the DRY penalty completely.
396
+ *
397
+ * The recommended value is `0.8`.
398
+ */
399
+ strength: number;
400
+ /**
401
+ * The base value for the exponential penality calculation.
402
+ *
403
+ * A higher value will lead to more aggressive penalization of repetitions.
404
+ *
405
+ * Defaults to `1.75`.
406
+ */
407
+ base?: number;
408
+ /**
409
+ * The maximum sequence length (in tokens) that will be allowed to be repeated without being penalized.
410
+ *
411
+ * Repetitions shorter than or equal to this length will not be penalized,
412
+ * allowing for natural repetitions of short phrases and common words.
413
+ *
414
+ * Defaults to `2`.
415
+ */
416
+ allowedLength?: number;
417
+ /**
418
+ * Number of recent tokens generated by the model to consider for sequence repetition matching.
419
+ *
420
+ * When set to `null`, the entire context sequence history will be considered for repetition matching.
421
+ * Setting to `0` will disable DRY (Don't Repeat Yourself) penalty.
422
+ *
423
+ * Defaults to `null`.
424
+ */
425
+ lastTokens?: number | null;
426
+ /**
427
+ * Text sequences that will be considered as breakers for the repeated sequences.
428
+ * These will never be penalized for being repeated, and are used to mark the boundaries of the repeated sequences.
429
+ *
430
+ * For example, setting this to `["\n", "*"]` will allow the model to make as many lists as it wants,
431
+ * without being penalized for repeating the list item marker (like `*`).
432
+ *
433
+ * Defaults to `["\n", ":", '"', "*"]`.
434
+ */
435
+ sequenceBreakers?: string[];
436
+ };
437
+ /**
438
+ * @see [Using `LlamaChatSession`](https://node-llama-cpp.withcat.ai/guide/chat-session) tutorial
439
+ */
440
+ export declare class LlamaChatSession {
441
+ readonly onDispose: EventRelay<void>;
442
+ constructor(options: LlamaChatSessionOptions);
443
+ dispose({ disposeSequence }?: {
444
+ disposeSequence?: boolean;
445
+ }): void;
446
+ /** @hidden */
447
+ [Symbol.dispose](): void;
448
+ get disposed(): boolean;
449
+ get chatWrapper(): ChatWrapper;
450
+ get sequence(): LlamaContextSequence;
451
+ get context(): import("../LlamaContext/LlamaContext.js").LlamaContext;
452
+ get model(): import("../LlamaModel/LlamaModel.js").LlamaModel;
453
+ prompt<const Functions extends ChatSessionModelFunctions | undefined = undefined>(prompt: string, options?: LLamaChatPromptOptions<Functions>): Promise<string>;
454
+ /**
455
+ * @param prompt
456
+ * @param [options]
457
+ */
458
+ promptWithMeta<const Functions extends ChatSessionModelFunctions | undefined = undefined>(prompt: string, { functions, documentFunctionParams, maxParallelFunctionCalls, onTextChunk, onToken, onResponseChunk, onFunctionCallParamsChunk, budgets, signal, stopOnAbortSignal, maxTokens, temperature, minP, topK, topP, seed, xtc, grammar, trimWhitespaceSuffix, responsePrefix, repeatPenalty, dryRepeatPenalty, tokenBias, customStopTriggers, evaluationPriority }?: LLamaChatPromptOptions<Functions>): Promise<{
459
+ response: (string | ChatModelFunctionCall | import("../../types.js").ChatModelSegment)[];
460
+ responseText: string;
461
+ stopReason: "customStopTrigger";
462
+ customStopTrigger: (string | Token)[];
463
+ remainingGenerationAfterStop: string | Token[] | undefined;
464
+ } | {
465
+ response: (string | ChatModelFunctionCall | import("../../types.js").ChatModelSegment)[];
466
+ responseText: string;
467
+ stopReason: "abort" | "maxTokens" | "eogToken" | "stopGenerationTrigger" | "functionCalls";
468
+ remainingGenerationAfterStop: string | Token[] | undefined;
469
+ customStopTrigger?: undefined;
470
+ }>;
471
+ /**
472
+ * Preload a user prompt into the current context sequence state to make later inference of the model response begin sooner
473
+ * and feel faster.
474
+ *
475
+ * > **Note:** Preloading a long user prompt can incur context shifts, so consider limiting the length of prompts you preload
476
+ * @param prompt - the prompt to preload
477
+ * @param [options]
478
+ */
479
+ preloadPrompt(prompt: string, options?: LLamaChatPreloadPromptOptions): Promise<void>;
480
+ /**
481
+ * Preload a user prompt into the current context sequence state and generate a completion for it.
482
+ *
483
+ * > **Note:** Preloading a long user prompt and completing a user prompt with a high number of `maxTokens` can incur context shifts,
484
+ * > so consider limiting the length of prompts you preload.
485
+ * >
486
+ * > Also, it's recommended to limit the number of tokens generated to a reasonable amount by configuring `maxTokens`.
487
+ * @param prompt - the prompt to preload
488
+ * @param [options]
489
+ */
490
+ completePrompt(prompt: string, options?: LLamaChatCompletePromptOptions): Promise<string>;
491
+ /**
492
+ * Create a smart completion engine that caches the prompt completions
493
+ * and reuses them when the user prompt matches the beginning of the cached prompt or completion.
494
+ *
495
+ * All completions are made and cache is used only for the current chat session state.
496
+ * You can create a single completion engine for an entire chat session.
497
+ */
498
+ createPromptCompletionEngine(options?: LLamaChatPromptCompletionEngineOptions): LlamaChatSessionPromptCompletionEngine;
499
+ /**
500
+ * See `completePrompt` for more information.
501
+ * @param prompt
502
+ * @param [options]
503
+ */
504
+ completePromptWithMeta(prompt: string, { maxTokens, stopOnAbortSignal, functions, documentFunctionParams, onTextChunk, onToken, signal, temperature, minP, topK, topP, seed, xtc, grammar, trimWhitespaceSuffix, repeatPenalty, dryRepeatPenalty, tokenBias, customStopTriggers, evaluationPriority, completeAsModel }?: LLamaChatCompletePromptOptions): Promise<{
505
+ completion: string;
506
+ stopReason: "customStopTrigger";
507
+ customStopTrigger: (string | Token)[];
508
+ remainingGenerationAfterStop: string | Token[] | undefined;
509
+ } | {
510
+ completion: string;
511
+ stopReason: "abort" | "maxTokens" | "eogToken" | "stopGenerationTrigger" | "functionCalls";
512
+ remainingGenerationAfterStop: string | Token[] | undefined;
513
+ customStopTrigger?: undefined;
514
+ }>;
515
+ getChatHistory(): ChatHistoryItem[];
516
+ getLastEvaluationContextWindow(): ChatHistoryItem[] | null;
517
+ setChatHistory(chatHistory: ChatHistoryItem[]): void;
518
+ /** Clear the chat history and reset it to the initial state. */
519
+ resetChatHistory(): void;
520
+ }