@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.
- package/LICENSE +21 -0
- package/README.md +108 -0
- package/dist/ChatWrapper.d.ts +27 -0
- package/dist/ChatWrapper.js +233 -0
- package/dist/ChatWrapper.js.map +1 -0
- package/dist/apiDocsIndex.d.ts +1 -0
- package/dist/apiDocsIndex.js +7 -0
- package/dist/apiDocsIndex.js.map +1 -0
- package/dist/bindings/AddonTypes.d.ts +203 -0
- package/dist/bindings/AddonTypes.js +2 -0
- package/dist/bindings/AddonTypes.js.map +1 -0
- package/dist/bindings/Llama.d.ts +104 -0
- package/dist/bindings/Llama.js +570 -0
- package/dist/bindings/Llama.js.map +1 -0
- package/dist/bindings/consts.d.ts +2 -0
- package/dist/bindings/consts.js +13 -0
- package/dist/bindings/consts.js.map +1 -0
- package/dist/bindings/getLlama.d.ts +297 -0
- package/dist/bindings/getLlama.js +569 -0
- package/dist/bindings/getLlama.js.map +1 -0
- package/dist/bindings/types.d.ts +72 -0
- package/dist/bindings/types.js +105 -0
- package/dist/bindings/types.js.map +1 -0
- package/dist/bindings/utils/MemoryOrchestrator.d.ts +23 -0
- package/dist/bindings/utils/MemoryOrchestrator.js +50 -0
- package/dist/bindings/utils/MemoryOrchestrator.js.map +1 -0
- package/dist/bindings/utils/NoBinaryFoundError.d.ts +2 -0
- package/dist/bindings/utils/NoBinaryFoundError.js +7 -0
- package/dist/bindings/utils/NoBinaryFoundError.js.map +1 -0
- package/dist/bindings/utils/asyncEvery.d.ts +5 -0
- package/dist/bindings/utils/asyncEvery.js +15 -0
- package/dist/bindings/utils/asyncEvery.js.map +1 -0
- package/dist/bindings/utils/asyncSome.d.ts +5 -0
- package/dist/bindings/utils/asyncSome.js +29 -0
- package/dist/bindings/utils/asyncSome.js.map +1 -0
- package/dist/bindings/utils/binariesGithubRelease.d.ts +6 -0
- package/dist/bindings/utils/binariesGithubRelease.js +15 -0
- package/dist/bindings/utils/binariesGithubRelease.js.map +1 -0
- package/dist/bindings/utils/clearAllLocalBuilds.d.ts +1 -0
- package/dist/bindings/utils/clearAllLocalBuilds.js +47 -0
- package/dist/bindings/utils/clearAllLocalBuilds.js.map +1 -0
- package/dist/bindings/utils/cloneLlamaCppRepo.d.ts +11 -0
- package/dist/bindings/utils/cloneLlamaCppRepo.js +166 -0
- package/dist/bindings/utils/cloneLlamaCppRepo.js.map +1 -0
- package/dist/bindings/utils/compileLLamaCpp.d.ts +22 -0
- package/dist/bindings/utils/compileLLamaCpp.js +526 -0
- package/dist/bindings/utils/compileLLamaCpp.js.map +1 -0
- package/dist/bindings/utils/detectAvailableComputeLayers.d.ts +18 -0
- package/dist/bindings/utils/detectAvailableComputeLayers.js +311 -0
- package/dist/bindings/utils/detectAvailableComputeLayers.js.map +1 -0
- package/dist/bindings/utils/detectBuildTools.d.ts +14 -0
- package/dist/bindings/utils/detectBuildTools.js +149 -0
- package/dist/bindings/utils/detectBuildTools.js.map +1 -0
- package/dist/bindings/utils/detectGlibc.d.ts +4 -0
- package/dist/bindings/utils/detectGlibc.js +74 -0
- package/dist/bindings/utils/detectGlibc.js.map +1 -0
- package/dist/bindings/utils/disposeBeforeExit.d.ts +8 -0
- package/dist/bindings/utils/disposeBeforeExit.js +36 -0
- package/dist/bindings/utils/disposeBeforeExit.js.map +1 -0
- package/dist/bindings/utils/getBestComputeLayersAvailable.d.ts +9 -0
- package/dist/bindings/utils/getBestComputeLayersAvailable.js +29 -0
- package/dist/bindings/utils/getBestComputeLayersAvailable.js.map +1 -0
- package/dist/bindings/utils/getBuildFolderNameForBuildOptions.d.ts +6 -0
- package/dist/bindings/utils/getBuildFolderNameForBuildOptions.js +105 -0
- package/dist/bindings/utils/getBuildFolderNameForBuildOptions.js.map +1 -0
- package/dist/bindings/utils/getCanUsePrebuiltBinaries.d.ts +1 -0
- package/dist/bindings/utils/getCanUsePrebuiltBinaries.js +8 -0
- package/dist/bindings/utils/getCanUsePrebuiltBinaries.js.map +1 -0
- package/dist/bindings/utils/getExampleUsageCodeOfGetLlama.d.ts +2 -0
- package/dist/bindings/utils/getExampleUsageCodeOfGetLlama.js +21 -0
- package/dist/bindings/utils/getExampleUsageCodeOfGetLlama.js.map +1 -0
- package/dist/bindings/utils/getGpuTypesToUseForOption.d.ts +12 -0
- package/dist/bindings/utils/getGpuTypesToUseForOption.js +39 -0
- package/dist/bindings/utils/getGpuTypesToUseForOption.js.map +1 -0
- package/dist/bindings/utils/getLinuxDistroInfo.d.ts +9 -0
- package/dist/bindings/utils/getLinuxDistroInfo.js +46 -0
- package/dist/bindings/utils/getLinuxDistroInfo.js.map +1 -0
- package/dist/bindings/utils/getLlamaGpuTypes.d.ts +13 -0
- package/dist/bindings/utils/getLlamaGpuTypes.js +36 -0
- package/dist/bindings/utils/getLlamaGpuTypes.js.map +1 -0
- package/dist/bindings/utils/getLlamaWithoutBackend.d.ts +5 -0
- package/dist/bindings/utils/getLlamaWithoutBackend.js +40 -0
- package/dist/bindings/utils/getLlamaWithoutBackend.js.map +1 -0
- package/dist/bindings/utils/getPlatform.d.ts +2 -0
- package/dist/bindings/utils/getPlatform.js +15 -0
- package/dist/bindings/utils/getPlatform.js.map +1 -0
- package/dist/bindings/utils/getPlatformInfo.d.ts +5 -0
- package/dist/bindings/utils/getPlatformInfo.js +28 -0
- package/dist/bindings/utils/getPlatformInfo.js.map +1 -0
- package/dist/bindings/utils/hasBuildingFromSourceDependenciesInstalled.d.ts +3 -0
- package/dist/bindings/utils/hasBuildingFromSourceDependenciesInstalled.js +27 -0
- package/dist/bindings/utils/hasBuildingFromSourceDependenciesInstalled.js.map +1 -0
- package/dist/bindings/utils/hasFileInPath.d.ts +2 -0
- package/dist/bindings/utils/hasFileInPath.js +34 -0
- package/dist/bindings/utils/hasFileInPath.js.map +1 -0
- package/dist/bindings/utils/lastBuildInfo.d.ts +6 -0
- package/dist/bindings/utils/lastBuildInfo.js +17 -0
- package/dist/bindings/utils/lastBuildInfo.js.map +1 -0
- package/dist/bindings/utils/logBinaryUsageExampleToConsole.d.ts +2 -0
- package/dist/bindings/utils/logBinaryUsageExampleToConsole.js +22 -0
- package/dist/bindings/utils/logBinaryUsageExampleToConsole.js.map +1 -0
- package/dist/bindings/utils/logDistroInstallInstruction.d.ts +14 -0
- package/dist/bindings/utils/logDistroInstallInstruction.js +48 -0
- package/dist/bindings/utils/logDistroInstallInstruction.js.map +1 -0
- package/dist/bindings/utils/resolveActualBindingBinaryPath.d.ts +1 -0
- package/dist/bindings/utils/resolveActualBindingBinaryPath.js +18 -0
- package/dist/bindings/utils/resolveActualBindingBinaryPath.js.map +1 -0
- package/dist/bindings/utils/resolveCustomCmakeOptions.d.ts +1 -0
- package/dist/bindings/utils/resolveCustomCmakeOptions.js +43 -0
- package/dist/bindings/utils/resolveCustomCmakeOptions.js.map +1 -0
- package/dist/bindings/utils/testBindingBinary.d.ts +2 -0
- package/dist/bindings/utils/testBindingBinary.js +269 -0
- package/dist/bindings/utils/testBindingBinary.js.map +1 -0
- package/dist/bindings/utils/testCmakeBinary.d.ts +5 -0
- package/dist/bindings/utils/testCmakeBinary.js +32 -0
- package/dist/bindings/utils/testCmakeBinary.js.map +1 -0
- package/dist/chatWrappers/AlpacaChatWrapper.d.ts +17 -0
- package/dist/chatWrappers/AlpacaChatWrapper.js +33 -0
- package/dist/chatWrappers/AlpacaChatWrapper.js.map +1 -0
- package/dist/chatWrappers/ChatMLChatWrapper.d.ts +6 -0
- package/dist/chatWrappers/ChatMLChatWrapper.js +85 -0
- package/dist/chatWrappers/ChatMLChatWrapper.js.map +1 -0
- package/dist/chatWrappers/DeepSeekChatWrapper.d.ts +37 -0
- package/dist/chatWrappers/DeepSeekChatWrapper.js +294 -0
- package/dist/chatWrappers/DeepSeekChatWrapper.js.map +1 -0
- package/dist/chatWrappers/EmptyChatWrapper.d.ts +4 -0
- package/dist/chatWrappers/EmptyChatWrapper.js +5 -0
- package/dist/chatWrappers/EmptyChatWrapper.js.map +1 -0
- package/dist/chatWrappers/FalconChatWrapper.d.ts +19 -0
- package/dist/chatWrappers/FalconChatWrapper.js +126 -0
- package/dist/chatWrappers/FalconChatWrapper.js.map +1 -0
- package/dist/chatWrappers/FunctionaryChatWrapper.d.ts +17 -0
- package/dist/chatWrappers/FunctionaryChatWrapper.js +622 -0
- package/dist/chatWrappers/FunctionaryChatWrapper.js.map +1 -0
- package/dist/chatWrappers/GemmaChatWrapper.d.ts +7 -0
- package/dist/chatWrappers/GemmaChatWrapper.js +96 -0
- package/dist/chatWrappers/GemmaChatWrapper.js.map +1 -0
- package/dist/chatWrappers/GeneralChatWrapper.d.ts +19 -0
- package/dist/chatWrappers/GeneralChatWrapper.js +140 -0
- package/dist/chatWrappers/GeneralChatWrapper.js.map +1 -0
- package/dist/chatWrappers/HarmonyChatWrapper.d.ts +78 -0
- package/dist/chatWrappers/HarmonyChatWrapper.js +539 -0
- package/dist/chatWrappers/HarmonyChatWrapper.js.map +1 -0
- package/dist/chatWrappers/Llama2ChatWrapper.d.ts +12 -0
- package/dist/chatWrappers/Llama2ChatWrapper.js +95 -0
- package/dist/chatWrappers/Llama2ChatWrapper.js.map +1 -0
- package/dist/chatWrappers/Llama3ChatWrapper.d.ts +16 -0
- package/dist/chatWrappers/Llama3ChatWrapper.js +173 -0
- package/dist/chatWrappers/Llama3ChatWrapper.js.map +1 -0
- package/dist/chatWrappers/Llama3_1ChatWrapper.d.ts +32 -0
- package/dist/chatWrappers/Llama3_1ChatWrapper.js +290 -0
- package/dist/chatWrappers/Llama3_1ChatWrapper.js.map +1 -0
- package/dist/chatWrappers/Llama3_2LightweightChatWrapper.d.ts +35 -0
- package/dist/chatWrappers/Llama3_2LightweightChatWrapper.js +264 -0
- package/dist/chatWrappers/Llama3_2LightweightChatWrapper.js.map +1 -0
- package/dist/chatWrappers/MistralChatWrapper.d.ts +16 -0
- package/dist/chatWrappers/MistralChatWrapper.js +180 -0
- package/dist/chatWrappers/MistralChatWrapper.js.map +1 -0
- package/dist/chatWrappers/QwenChatWrapper.d.ts +36 -0
- package/dist/chatWrappers/QwenChatWrapper.js +344 -0
- package/dist/chatWrappers/QwenChatWrapper.js.map +1 -0
- package/dist/chatWrappers/SeedChatWrapper.d.ts +25 -0
- package/dist/chatWrappers/SeedChatWrapper.js +183 -0
- package/dist/chatWrappers/SeedChatWrapper.js.map +1 -0
- package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.d.ts +138 -0
- package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.js +665 -0
- package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.js.map +1 -0
- package/dist/chatWrappers/generic/TemplateChatWrapper.d.ts +76 -0
- package/dist/chatWrappers/generic/TemplateChatWrapper.js +212 -0
- package/dist/chatWrappers/generic/TemplateChatWrapper.js.map +1 -0
- package/dist/chatWrappers/generic/utils/UniqueIdGenerator.d.ts +7 -0
- package/dist/chatWrappers/generic/utils/UniqueIdGenerator.js +30 -0
- package/dist/chatWrappers/generic/utils/UniqueIdGenerator.js.map +1 -0
- package/dist/chatWrappers/generic/utils/chatHistoryFunctionCallMessageTemplate.d.ts +24 -0
- package/dist/chatWrappers/generic/utils/chatHistoryFunctionCallMessageTemplate.js +45 -0
- package/dist/chatWrappers/generic/utils/chatHistoryFunctionCallMessageTemplate.js.map +1 -0
- package/dist/chatWrappers/generic/utils/extractFunctionCallSettingsFromJinjaTemplate.d.ts +25 -0
- package/dist/chatWrappers/generic/utils/extractFunctionCallSettingsFromJinjaTemplate.js +690 -0
- package/dist/chatWrappers/generic/utils/extractFunctionCallSettingsFromJinjaTemplate.js.map +1 -0
- package/dist/chatWrappers/generic/utils/extractSegmentSettingsFromTokenizerAndChatTemplate.d.ts +2 -0
- package/dist/chatWrappers/generic/utils/extractSegmentSettingsFromTokenizerAndChatTemplate.js +66 -0
- package/dist/chatWrappers/generic/utils/extractSegmentSettingsFromTokenizerAndChatTemplate.js.map +1 -0
- package/dist/chatWrappers/generic/utils/getFirstValidResult.d.ts +6 -0
- package/dist/chatWrappers/generic/utils/getFirstValidResult.js +19 -0
- package/dist/chatWrappers/generic/utils/getFirstValidResult.js.map +1 -0
- package/dist/chatWrappers/generic/utils/squashChatHistoryItems.d.ts +2 -0
- package/dist/chatWrappers/generic/utils/squashChatHistoryItems.js +35 -0
- package/dist/chatWrappers/generic/utils/squashChatHistoryItems.js.map +1 -0
- package/dist/chatWrappers/generic/utils/templateSegmentOptionsToChatWrapperSettings.d.ts +22 -0
- package/dist/chatWrappers/generic/utils/templateSegmentOptionsToChatWrapperSettings.js +28 -0
- package/dist/chatWrappers/generic/utils/templateSegmentOptionsToChatWrapperSettings.js.map +1 -0
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.d.ts +76 -0
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.js +177 -0
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.js.map +1 -0
- package/dist/chatWrappers/utils/chunkChatItems.d.ts +10 -0
- package/dist/chatWrappers/utils/chunkChatItems.js +44 -0
- package/dist/chatWrappers/utils/chunkChatItems.js.map +1 -0
- package/dist/chatWrappers/utils/getModelLinageNames.d.ts +2 -0
- package/dist/chatWrappers/utils/getModelLinageNames.js +18 -0
- package/dist/chatWrappers/utils/getModelLinageNames.js.map +1 -0
- package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.d.ts +4 -0
- package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.js +394 -0
- package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.js.map +1 -0
- package/dist/chatWrappers/utils/isLlama3_2LightweightModel.d.ts +2 -0
- package/dist/chatWrappers/utils/isLlama3_2LightweightModel.js +9 -0
- package/dist/chatWrappers/utils/isLlama3_2LightweightModel.js.map +1 -0
- package/dist/chatWrappers/utils/jsonDumps.d.ts +7 -0
- package/dist/chatWrappers/utils/jsonDumps.js +18 -0
- package/dist/chatWrappers/utils/jsonDumps.js.map +1 -0
- package/dist/chatWrappers/utils/resolveChatWrapper.d.ts +148 -0
- package/dist/chatWrappers/utils/resolveChatWrapper.js +325 -0
- package/dist/chatWrappers/utils/resolveChatWrapper.js.map +1 -0
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.js +45 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/commands/ChatCommand.d.ts +59 -0
- package/dist/cli/commands/ChatCommand.js +856 -0
- package/dist/cli/commands/ChatCommand.js.map +1 -0
- package/dist/cli/commands/CompleteCommand.d.ts +47 -0
- package/dist/cli/commands/CompleteCommand.js +658 -0
- package/dist/cli/commands/CompleteCommand.js.map +1 -0
- package/dist/cli/commands/DebugCommand.d.ts +7 -0
- package/dist/cli/commands/DebugCommand.js +55 -0
- package/dist/cli/commands/DebugCommand.js.map +1 -0
- package/dist/cli/commands/InfillCommand.d.ts +49 -0
- package/dist/cli/commands/InfillCommand.js +693 -0
- package/dist/cli/commands/InfillCommand.js.map +1 -0
- package/dist/cli/commands/InitCommand.d.ts +12 -0
- package/dist/cli/commands/InitCommand.js +230 -0
- package/dist/cli/commands/InitCommand.js.map +1 -0
- package/dist/cli/commands/OnPostInstallCommand.d.ts +4 -0
- package/dist/cli/commands/OnPostInstallCommand.js +62 -0
- package/dist/cli/commands/OnPostInstallCommand.js.map +1 -0
- package/dist/cli/commands/PullCommand.d.ts +13 -0
- package/dist/cli/commands/PullCommand.js +158 -0
- package/dist/cli/commands/PullCommand.js.map +1 -0
- package/dist/cli/commands/inspect/InspectCommand.d.ts +4 -0
- package/dist/cli/commands/inspect/InspectCommand.js +21 -0
- package/dist/cli/commands/inspect/InspectCommand.js.map +1 -0
- package/dist/cli/commands/inspect/commands/InspectEstimateCommand.d.ts +17 -0
- package/dist/cli/commands/inspect/commands/InspectEstimateCommand.js +275 -0
- package/dist/cli/commands/inspect/commands/InspectEstimateCommand.js.map +1 -0
- package/dist/cli/commands/inspect/commands/InspectGgufCommand.d.ts +13 -0
- package/dist/cli/commands/inspect/commands/InspectGgufCommand.js +230 -0
- package/dist/cli/commands/inspect/commands/InspectGgufCommand.js.map +1 -0
- package/dist/cli/commands/inspect/commands/InspectGpuCommand.d.ts +4 -0
- package/dist/cli/commands/inspect/commands/InspectGpuCommand.js +296 -0
- package/dist/cli/commands/inspect/commands/InspectGpuCommand.js.map +1 -0
- package/dist/cli/commands/inspect/commands/InspectMeasureCommand.d.ts +26 -0
- package/dist/cli/commands/inspect/commands/InspectMeasureCommand.js +869 -0
- package/dist/cli/commands/inspect/commands/InspectMeasureCommand.js.map +1 -0
- package/dist/cli/commands/source/SourceCommand.d.ts +4 -0
- package/dist/cli/commands/source/SourceCommand.js +19 -0
- package/dist/cli/commands/source/SourceCommand.js.map +1 -0
- package/dist/cli/commands/source/commands/BuildCommand.d.ts +16 -0
- package/dist/cli/commands/source/commands/BuildCommand.js +148 -0
- package/dist/cli/commands/source/commands/BuildCommand.js.map +1 -0
- package/dist/cli/commands/source/commands/ClearCommand.d.ts +7 -0
- package/dist/cli/commands/source/commands/ClearCommand.js +54 -0
- package/dist/cli/commands/source/commands/ClearCommand.js.map +1 -0
- package/dist/cli/commands/source/commands/DownloadCommand.d.ts +16 -0
- package/dist/cli/commands/source/commands/DownloadCommand.js +219 -0
- package/dist/cli/commands/source/commands/DownloadCommand.js.map +1 -0
- package/dist/cli/projectTemplates.d.ts +7 -0
- package/dist/cli/projectTemplates.js +10 -0
- package/dist/cli/projectTemplates.js.map +1 -0
- package/dist/cli/recommendedModels.d.ts +2 -0
- package/dist/cli/recommendedModels.js +428 -0
- package/dist/cli/recommendedModels.js.map +1 -0
- package/dist/cli/startCreateCli.d.ts +2 -0
- package/dist/cli/startCreateCli.js +26 -0
- package/dist/cli/startCreateCli.js.map +1 -0
- package/dist/cli/utils/ConsoleInteraction.d.ts +22 -0
- package/dist/cli/utils/ConsoleInteraction.js +122 -0
- package/dist/cli/utils/ConsoleInteraction.js.map +1 -0
- package/dist/cli/utils/ConsoleTable.d.ts +24 -0
- package/dist/cli/utils/ConsoleTable.js +90 -0
- package/dist/cli/utils/ConsoleTable.js.map +1 -0
- package/dist/cli/utils/basicChooseFromListConsoleInteraction.d.ts +13 -0
- package/dist/cli/utils/basicChooseFromListConsoleInteraction.js +111 -0
- package/dist/cli/utils/basicChooseFromListConsoleInteraction.js.map +1 -0
- package/dist/cli/utils/consolePromptQuestion.d.ts +6 -0
- package/dist/cli/utils/consolePromptQuestion.js +81 -0
- package/dist/cli/utils/consolePromptQuestion.js.map +1 -0
- package/dist/cli/utils/getReadablePath.d.ts +1 -0
- package/dist/cli/utils/getReadablePath.js +14 -0
- package/dist/cli/utils/getReadablePath.js.map +1 -0
- package/dist/cli/utils/interactivelyAskForModel.d.ts +13 -0
- package/dist/cli/utils/interactivelyAskForModel.js +485 -0
- package/dist/cli/utils/interactivelyAskForModel.js.map +1 -0
- package/dist/cli/utils/isRunningUnderRosetta.d.ts +1 -0
- package/dist/cli/utils/isRunningUnderRosetta.js +20 -0
- package/dist/cli/utils/isRunningUnderRosetta.js.map +1 -0
- package/dist/cli/utils/logUsedGpuTypeOption.d.ts +2 -0
- package/dist/cli/utils/logUsedGpuTypeOption.js +9 -0
- package/dist/cli/utils/logUsedGpuTypeOption.js.map +1 -0
- package/dist/cli/utils/packageJsonConfig.d.ts +6 -0
- package/dist/cli/utils/packageJsonConfig.js +51 -0
- package/dist/cli/utils/packageJsonConfig.js.map +1 -0
- package/dist/cli/utils/packageManager.d.ts +1 -0
- package/dist/cli/utils/packageManager.js +15 -0
- package/dist/cli/utils/packageManager.js.map +1 -0
- package/dist/cli/utils/parseXtcArg.d.ts +5 -0
- package/dist/cli/utils/parseXtcArg.js +16 -0
- package/dist/cli/utils/parseXtcArg.js.map +1 -0
- package/dist/cli/utils/printCommonInfoLines.d.ts +12 -0
- package/dist/cli/utils/printCommonInfoLines.js +163 -0
- package/dist/cli/utils/printCommonInfoLines.js.map +1 -0
- package/dist/cli/utils/printInfoLine.d.ts +12 -0
- package/dist/cli/utils/printInfoLine.js +54 -0
- package/dist/cli/utils/printInfoLine.js.map +1 -0
- package/dist/cli/utils/printModelDestination.d.ts +2 -0
- package/dist/cli/utils/printModelDestination.js +11 -0
- package/dist/cli/utils/printModelDestination.js.map +1 -0
- package/dist/cli/utils/projectTemplates.d.ts +19 -0
- package/dist/cli/utils/projectTemplates.js +47 -0
- package/dist/cli/utils/projectTemplates.js.map +1 -0
- package/dist/cli/utils/renderModelCompatibilityPercentageWithColors.d.ts +6 -0
- package/dist/cli/utils/renderModelCompatibilityPercentageWithColors.js +14 -0
- package/dist/cli/utils/renderModelCompatibilityPercentageWithColors.js.map +1 -0
- package/dist/cli/utils/resolveCommandGgufPath.d.ts +19 -0
- package/dist/cli/utils/resolveCommandGgufPath.js +123 -0
- package/dist/cli/utils/resolveCommandGgufPath.js.map +1 -0
- package/dist/cli/utils/resolveHeaderFlag.d.ts +1 -0
- package/dist/cli/utils/resolveHeaderFlag.js +21 -0
- package/dist/cli/utils/resolveHeaderFlag.js.map +1 -0
- package/dist/cli/utils/resolveModelRecommendationFileOptions.d.ts +14 -0
- package/dist/cli/utils/resolveModelRecommendationFileOptions.js +12 -0
- package/dist/cli/utils/resolveModelRecommendationFileOptions.js.map +1 -0
- package/dist/cli/utils/resolveNpmrcConfig.d.ts +18 -0
- package/dist/cli/utils/resolveNpmrcConfig.js +129 -0
- package/dist/cli/utils/resolveNpmrcConfig.js.map +1 -0
- package/dist/cli/utils/splitAnsiToLines.d.ts +1 -0
- package/dist/cli/utils/splitAnsiToLines.js +32 -0
- package/dist/cli/utils/splitAnsiToLines.js.map +1 -0
- package/dist/cli/utils/toBytes.d.ts +1 -0
- package/dist/cli/utils/toBytes.js +5 -0
- package/dist/cli/utils/toBytes.js.map +1 -0
- package/dist/cli/utils/withCliCommandDescriptionDocsUrl.d.ts +2 -0
- package/dist/cli/utils/withCliCommandDescriptionDocsUrl.js +23 -0
- package/dist/cli/utils/withCliCommandDescriptionDocsUrl.js.map +1 -0
- package/dist/commands.d.ts +6 -0
- package/dist/commands.js +9 -0
- package/dist/commands.js.map +1 -0
- package/dist/config.d.ts +79 -0
- package/dist/config.js +127 -0
- package/dist/config.js.map +1 -0
- package/dist/consts.d.ts +4 -0
- package/dist/consts.js +11 -0
- package/dist/consts.js.map +1 -0
- package/dist/evaluator/LlamaChat/LlamaChat.d.ts +500 -0
- package/dist/evaluator/LlamaChat/LlamaChat.js +2696 -0
- package/dist/evaluator/LlamaChat/LlamaChat.js.map +1 -0
- package/dist/evaluator/LlamaChat/utils/FunctionCallNameGrammar.d.ts +11 -0
- package/dist/evaluator/LlamaChat/utils/FunctionCallNameGrammar.js +55 -0
- package/dist/evaluator/LlamaChat/utils/FunctionCallNameGrammar.js.map +1 -0
- package/dist/evaluator/LlamaChat/utils/FunctionCallParamsGrammar.d.ts +16 -0
- package/dist/evaluator/LlamaChat/utils/FunctionCallParamsGrammar.js +45 -0
- package/dist/evaluator/LlamaChat/utils/FunctionCallParamsGrammar.js.map +1 -0
- package/dist/evaluator/LlamaChat/utils/LlamaFunctionCallValidationError.d.ts +8 -0
- package/dist/evaluator/LlamaChat/utils/LlamaFunctionCallValidationError.js +12 -0
- package/dist/evaluator/LlamaChat/utils/LlamaFunctionCallValidationError.js.map +1 -0
- package/dist/evaluator/LlamaChat/utils/contextShiftStrategies/eraseFirstResponseAndKeepFirstSystemChatContextShiftStrategy.d.ts +16 -0
- package/dist/evaluator/LlamaChat/utils/contextShiftStrategies/eraseFirstResponseAndKeepFirstSystemChatContextShiftStrategy.js +260 -0
- package/dist/evaluator/LlamaChat/utils/contextShiftStrategies/eraseFirstResponseAndKeepFirstSystemChatContextShiftStrategy.js.map +1 -0
- package/dist/evaluator/LlamaChatSession/LlamaChatSession.d.ts +520 -0
- package/dist/evaluator/LlamaChatSession/LlamaChatSession.js +628 -0
- package/dist/evaluator/LlamaChatSession/LlamaChatSession.js.map +1 -0
- package/dist/evaluator/LlamaChatSession/utils/LlamaChatSessionPromptCompletionEngine.d.ts +45 -0
- package/dist/evaluator/LlamaChatSession/utils/LlamaChatSessionPromptCompletionEngine.js +191 -0
- package/dist/evaluator/LlamaChatSession/utils/LlamaChatSessionPromptCompletionEngine.js.map +1 -0
- package/dist/evaluator/LlamaChatSession/utils/defineChatSessionFunction.d.ts +15 -0
- package/dist/evaluator/LlamaChatSession/utils/defineChatSessionFunction.js +16 -0
- package/dist/evaluator/LlamaChatSession/utils/defineChatSessionFunction.js.map +1 -0
- package/dist/evaluator/LlamaCompletion.d.ts +219 -0
- package/dist/evaluator/LlamaCompletion.js +498 -0
- package/dist/evaluator/LlamaCompletion.js.map +1 -0
- package/dist/evaluator/LlamaContext/LlamaContext.d.ts +336 -0
- package/dist/evaluator/LlamaContext/LlamaContext.js +1919 -0
- package/dist/evaluator/LlamaContext/LlamaContext.js.map +1 -0
- package/dist/evaluator/LlamaContext/LlamaContextSequenceCheckpoints.d.ts +27 -0
- package/dist/evaluator/LlamaContext/LlamaContextSequenceCheckpoints.js +130 -0
- package/dist/evaluator/LlamaContext/LlamaContextSequenceCheckpoints.js.map +1 -0
- package/dist/evaluator/LlamaContext/LlamaSampler.d.ts +1 -0
- package/dist/evaluator/LlamaContext/LlamaSampler.js +39 -0
- package/dist/evaluator/LlamaContext/LlamaSampler.js.map +1 -0
- package/dist/evaluator/LlamaContext/TokenPredictor.d.ts +55 -0
- package/dist/evaluator/LlamaContext/TokenPredictor.js +20 -0
- package/dist/evaluator/LlamaContext/TokenPredictor.js.map +1 -0
- package/dist/evaluator/LlamaContext/tokenPredictors/DraftSequenceTokenPredictor.d.ts +56 -0
- package/dist/evaluator/LlamaContext/tokenPredictors/DraftSequenceTokenPredictor.js +266 -0
- package/dist/evaluator/LlamaContext/tokenPredictors/DraftSequenceTokenPredictor.js.map +1 -0
- package/dist/evaluator/LlamaContext/tokenPredictors/InputLookupTokenPredictor.d.ts +58 -0
- package/dist/evaluator/LlamaContext/tokenPredictors/InputLookupTokenPredictor.js +138 -0
- package/dist/evaluator/LlamaContext/tokenPredictors/InputLookupTokenPredictor.js.map +1 -0
- package/dist/evaluator/LlamaContext/types.d.ts +602 -0
- package/dist/evaluator/LlamaContext/types.js +2 -0
- package/dist/evaluator/LlamaContext/types.js.map +1 -0
- package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/firstInFirstOutStrategy.d.ts +5 -0
- package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/firstInFirstOutStrategy.js +16 -0
- package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/firstInFirstOutStrategy.js.map +1 -0
- package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/maximumParallelismStrategy.d.ts +5 -0
- package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/maximumParallelismStrategy.js +42 -0
- package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/maximumParallelismStrategy.js.map +1 -0
- package/dist/evaluator/LlamaContext/utils/padSafeContextSize.d.ts +1 -0
- package/dist/evaluator/LlamaContext/utils/padSafeContextSize.js +18 -0
- package/dist/evaluator/LlamaContext/utils/padSafeContextSize.js.map +1 -0
- package/dist/evaluator/LlamaContext/utils/resolveBatchItemsPrioritizationStrategy.d.ts +2 -0
- package/dist/evaluator/LlamaContext/utils/resolveBatchItemsPrioritizationStrategy.js +13 -0
- package/dist/evaluator/LlamaContext/utils/resolveBatchItemsPrioritizationStrategy.js.map +1 -0
- package/dist/evaluator/LlamaEmbedding.d.ts +21 -0
- package/dist/evaluator/LlamaEmbedding.js +53 -0
- package/dist/evaluator/LlamaEmbedding.js.map +1 -0
- package/dist/evaluator/LlamaEmbeddingContext.d.ts +52 -0
- package/dist/evaluator/LlamaEmbeddingContext.js +86 -0
- package/dist/evaluator/LlamaEmbeddingContext.js.map +1 -0
- package/dist/evaluator/LlamaGrammar.d.ts +39 -0
- package/dist/evaluator/LlamaGrammar.js +72 -0
- package/dist/evaluator/LlamaGrammar.js.map +1 -0
- package/dist/evaluator/LlamaGrammarEvaluationState.d.ts +19 -0
- package/dist/evaluator/LlamaGrammarEvaluationState.js +29 -0
- package/dist/evaluator/LlamaGrammarEvaluationState.js.map +1 -0
- package/dist/evaluator/LlamaJsonSchemaGrammar.d.ts +17 -0
- package/dist/evaluator/LlamaJsonSchemaGrammar.js +35 -0
- package/dist/evaluator/LlamaJsonSchemaGrammar.js.map +1 -0
- package/dist/evaluator/LlamaModel/LlamaModel.d.ts +344 -0
- package/dist/evaluator/LlamaModel/LlamaModel.js +853 -0
- package/dist/evaluator/LlamaModel/LlamaModel.js.map +1 -0
- package/dist/evaluator/LlamaModel/utils/TokenAttributes.d.ts +29 -0
- package/dist/evaluator/LlamaModel/utils/TokenAttributes.js +65 -0
- package/dist/evaluator/LlamaModel/utils/TokenAttributes.js.map +1 -0
- package/dist/evaluator/LlamaRankingContext.d.ts +91 -0
- package/dist/evaluator/LlamaRankingContext.js +178 -0
- package/dist/evaluator/LlamaRankingContext.js.map +1 -0
- package/dist/evaluator/TokenBias.d.ts +37 -0
- package/dist/evaluator/TokenBias.js +68 -0
- package/dist/evaluator/TokenBias.js.map +1 -0
- package/dist/evaluator/TokenMeter.d.ts +45 -0
- package/dist/evaluator/TokenMeter.js +74 -0
- package/dist/evaluator/TokenMeter.js.map +1 -0
- package/dist/evaluator/utils/chunkDocument.d.ts +86 -0
- package/dist/evaluator/utils/chunkDocument.js +212 -0
- package/dist/evaluator/utils/chunkDocument.js.map +1 -0
- package/dist/gguf/consts.d.ts +4 -0
- package/dist/gguf/consts.js +12 -0
- package/dist/gguf/consts.js.map +1 -0
- package/dist/gguf/errors/InvalidGgufMagicError.d.ts +3 -0
- package/dist/gguf/errors/InvalidGgufMagicError.js +6 -0
- package/dist/gguf/errors/InvalidGgufMagicError.js.map +1 -0
- package/dist/gguf/errors/UnsupportedGgufValueTypeError.d.ts +4 -0
- package/dist/gguf/errors/UnsupportedGgufValueTypeError.js +9 -0
- package/dist/gguf/errors/UnsupportedGgufValueTypeError.js.map +1 -0
- package/dist/gguf/fileReaders/GgufFileReader.d.ts +36 -0
- package/dist/gguf/fileReaders/GgufFileReader.js +106 -0
- package/dist/gguf/fileReaders/GgufFileReader.js.map +1 -0
- package/dist/gguf/fileReaders/GgufFsFileReader.d.ts +16 -0
- package/dist/gguf/fileReaders/GgufFsFileReader.js +62 -0
- package/dist/gguf/fileReaders/GgufFsFileReader.js.map +1 -0
- package/dist/gguf/fileReaders/GgufNetworkFetchFileReader.d.ts +28 -0
- package/dist/gguf/fileReaders/GgufNetworkFetchFileReader.js +94 -0
- package/dist/gguf/fileReaders/GgufNetworkFetchFileReader.js.map +1 -0
- package/dist/gguf/insights/GgufInsights.d.ts +78 -0
- package/dist/gguf/insights/GgufInsights.js +854 -0
- package/dist/gguf/insights/GgufInsights.js.map +1 -0
- package/dist/gguf/insights/GgufInsightsConfigurationResolver.d.ts +203 -0
- package/dist/gguf/insights/GgufInsightsConfigurationResolver.js +284 -0
- package/dist/gguf/insights/GgufInsightsConfigurationResolver.js.map +1 -0
- package/dist/gguf/insights/GgufInsightsTokens.d.ts +5 -0
- package/dist/gguf/insights/GgufInsightsTokens.js +40 -0
- package/dist/gguf/insights/GgufInsightsTokens.js.map +1 -0
- package/dist/gguf/insights/utils/getRamUsageFromUnifiedVram.d.ts +5 -0
- package/dist/gguf/insights/utils/getRamUsageFromUnifiedVram.js +7 -0
- package/dist/gguf/insights/utils/getRamUsageFromUnifiedVram.js.map +1 -0
- package/dist/gguf/insights/utils/resolveContextContextSizeOption.d.ts +33 -0
- package/dist/gguf/insights/utils/resolveContextContextSizeOption.js +117 -0
- package/dist/gguf/insights/utils/resolveContextContextSizeOption.js.map +1 -0
- package/dist/gguf/insights/utils/resolveModelGpuLayersOption.d.ts +20 -0
- package/dist/gguf/insights/utils/resolveModelGpuLayersOption.js +251 -0
- package/dist/gguf/insights/utils/resolveModelGpuLayersOption.js.map +1 -0
- package/dist/gguf/insights/utils/scoreLevels.d.ts +5 -0
- package/dist/gguf/insights/utils/scoreLevels.js +16 -0
- package/dist/gguf/insights/utils/scoreLevels.js.map +1 -0
- package/dist/gguf/parser/GgufV2Parser.d.ts +20 -0
- package/dist/gguf/parser/GgufV2Parser.js +184 -0
- package/dist/gguf/parser/GgufV2Parser.js.map +1 -0
- package/dist/gguf/parser/GgufV3Parser.d.ts +3 -0
- package/dist/gguf/parser/GgufV3Parser.js +4 -0
- package/dist/gguf/parser/GgufV3Parser.js.map +1 -0
- package/dist/gguf/parser/parseGguf.d.ts +8 -0
- package/dist/gguf/parser/parseGguf.js +61 -0
- package/dist/gguf/parser/parseGguf.js.map +1 -0
- package/dist/gguf/readGgufFileInfo.d.ts +54 -0
- package/dist/gguf/readGgufFileInfo.js +82 -0
- package/dist/gguf/readGgufFileInfo.js.map +1 -0
- package/dist/gguf/types/GgufFileInfoTypes.d.ts +85 -0
- package/dist/gguf/types/GgufFileInfoTypes.js +18 -0
- package/dist/gguf/types/GgufFileInfoTypes.js.map +1 -0
- package/dist/gguf/types/GgufMetadataTypes.d.ts +480 -0
- package/dist/gguf/types/GgufMetadataTypes.js +194 -0
- package/dist/gguf/types/GgufMetadataTypes.js.map +1 -0
- package/dist/gguf/types/GgufTensorInfoTypes.d.ts +63 -0
- package/dist/gguf/types/GgufTensorInfoTypes.js +54 -0
- package/dist/gguf/types/GgufTensorInfoTypes.js.map +1 -0
- package/dist/gguf/utils/GgufReadOffset.d.ts +6 -0
- package/dist/gguf/utils/GgufReadOffset.js +18 -0
- package/dist/gguf/utils/GgufReadOffset.js.map +1 -0
- package/dist/gguf/utils/convertMetadataKeyValueRecordToNestedObject.d.ts +6 -0
- package/dist/gguf/utils/convertMetadataKeyValueRecordToNestedObject.js +76 -0
- package/dist/gguf/utils/convertMetadataKeyValueRecordToNestedObject.js.map +1 -0
- package/dist/gguf/utils/getGgufFileTypeName.d.ts +4 -0
- package/dist/gguf/utils/getGgufFileTypeName.js +13 -0
- package/dist/gguf/utils/getGgufFileTypeName.js.map +1 -0
- package/dist/gguf/utils/getGgufMetadataArchitectureData.d.ts +3 -0
- package/dist/gguf/utils/getGgufMetadataArchitectureData.js +4 -0
- package/dist/gguf/utils/getGgufMetadataArchitectureData.js.map +1 -0
- package/dist/gguf/utils/getGgufMetadataKeyValue.d.ts +1 -0
- package/dist/gguf/utils/getGgufMetadataKeyValue.js +27 -0
- package/dist/gguf/utils/getGgufMetadataKeyValue.js.map +1 -0
- package/dist/gguf/utils/ggufQuantNames.d.ts +2 -0
- package/dist/gguf/utils/ggufQuantNames.js +42 -0
- package/dist/gguf/utils/ggufQuantNames.js.map +1 -0
- package/dist/gguf/utils/normalizeGgufDownloadUrl.d.ts +2 -0
- package/dist/gguf/utils/normalizeGgufDownloadUrl.js +18 -0
- package/dist/gguf/utils/normalizeGgufDownloadUrl.js.map +1 -0
- package/dist/gguf/utils/resolveBinarySplitGgufPartUrls.d.ts +2 -0
- package/dist/gguf/utils/resolveBinarySplitGgufPartUrls.js +38 -0
- package/dist/gguf/utils/resolveBinarySplitGgufPartUrls.js.map +1 -0
- package/dist/gguf/utils/resolveSplitGgufParts.d.ts +7 -0
- package/dist/gguf/utils/resolveSplitGgufParts.js +64 -0
- package/dist/gguf/utils/resolveSplitGgufParts.js.map +1 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/dist/state.d.ts +6 -0
- package/dist/state.js +22 -0
- package/dist/state.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts +408 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/DisposeGuard.d.ts +13 -0
- package/dist/utils/DisposeGuard.js +120 -0
- package/dist/utils/DisposeGuard.js.map +1 -0
- package/dist/utils/InsufficientMemoryError.d.ts +3 -0
- package/dist/utils/InsufficientMemoryError.js +6 -0
- package/dist/utils/InsufficientMemoryError.js.map +1 -0
- package/dist/utils/LlamaText.d.ts +92 -0
- package/dist/utils/LlamaText.js +527 -0
- package/dist/utils/LlamaText.js.map +1 -0
- package/dist/utils/LruCache.d.ts +12 -0
- package/dist/utils/LruCache.js +44 -0
- package/dist/utils/LruCache.js.map +1 -0
- package/dist/utils/OpenAIFormat.d.ts +177 -0
- package/dist/utils/OpenAIFormat.js +488 -0
- package/dist/utils/OpenAIFormat.js.map +1 -0
- package/dist/utils/OverridesObject.d.ts +7 -0
- package/dist/utils/OverridesObject.js +2 -0
- package/dist/utils/OverridesObject.js.map +1 -0
- package/dist/utils/ReplHistory.d.ts +9 -0
- package/dist/utils/ReplHistory.js +72 -0
- package/dist/utils/ReplHistory.js.map +1 -0
- package/dist/utils/StopGenerationDetector.d.ts +47 -0
- package/dist/utils/StopGenerationDetector.js +291 -0
- package/dist/utils/StopGenerationDetector.js.map +1 -0
- package/dist/utils/ThreadsSplitter.d.ts +32 -0
- package/dist/utils/ThreadsSplitter.js +177 -0
- package/dist/utils/ThreadsSplitter.js.map +1 -0
- package/dist/utils/TokenStreamRegulator.d.ts +38 -0
- package/dist/utils/TokenStreamRegulator.js +200 -0
- package/dist/utils/TokenStreamRegulator.js.map +1 -0
- package/dist/utils/UnsupportedError.d.ts +2 -0
- package/dist/utils/UnsupportedError.js +7 -0
- package/dist/utils/UnsupportedError.js.map +1 -0
- package/dist/utils/appendUserMessageToChatHistory.d.ts +6 -0
- package/dist/utils/appendUserMessageToChatHistory.js +22 -0
- package/dist/utils/appendUserMessageToChatHistory.js.map +1 -0
- package/dist/utils/clearTempFolder.d.ts +1 -0
- package/dist/utils/clearTempFolder.js +16 -0
- package/dist/utils/clearTempFolder.js.map +1 -0
- package/dist/utils/cmake.d.ts +10 -0
- package/dist/utils/cmake.js +146 -0
- package/dist/utils/cmake.js.map +1 -0
- package/dist/utils/compareTokens.d.ts +2 -0
- package/dist/utils/compareTokens.js +4 -0
- package/dist/utils/compareTokens.js.map +1 -0
- package/dist/utils/createModelDownloader.d.ts +262 -0
- package/dist/utils/createModelDownloader.js +486 -0
- package/dist/utils/createModelDownloader.js.map +1 -0
- package/dist/utils/findBestOption.d.ts +4 -0
- package/dist/utils/findBestOption.js +15 -0
- package/dist/utils/findBestOption.js.map +1 -0
- package/dist/utils/findCharacterRemovalCountToFitChatHistoryInContext.d.ts +20 -0
- package/dist/utils/findCharacterRemovalCountToFitChatHistoryInContext.js +85 -0
- package/dist/utils/findCharacterRemovalCountToFitChatHistoryInContext.js.map +1 -0
- package/dist/utils/gbnfJson/GbnfGrammarGenerator.d.ts +19 -0
- package/dist/utils/gbnfJson/GbnfGrammarGenerator.js +60 -0
- package/dist/utils/gbnfJson/GbnfGrammarGenerator.js.map +1 -0
- package/dist/utils/gbnfJson/GbnfTerminal.d.ts +11 -0
- package/dist/utils/gbnfJson/GbnfTerminal.js +54 -0
- package/dist/utils/gbnfJson/GbnfTerminal.js.map +1 -0
- package/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.d.ts +5 -0
- package/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.js +11 -0
- package/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfAnyJson.d.ts +9 -0
- package/dist/utils/gbnfJson/terminals/GbnfAnyJson.js +53 -0
- package/dist/utils/gbnfJson/terminals/GbnfAnyJson.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfArray.d.ts +18 -0
- package/dist/utils/gbnfJson/terminals/GbnfArray.js +83 -0
- package/dist/utils/gbnfJson/terminals/GbnfArray.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfBoolean.d.ts +7 -0
- package/dist/utils/gbnfJson/terminals/GbnfBoolean.js +22 -0
- package/dist/utils/gbnfJson/terminals/GbnfBoolean.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfBooleanValue.d.ts +7 -0
- package/dist/utils/gbnfJson/terminals/GbnfBooleanValue.js +17 -0
- package/dist/utils/gbnfJson/terminals/GbnfBooleanValue.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.d.ts +11 -0
- package/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.js +28 -0
- package/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfFormatString.d.ts +11 -0
- package/dist/utils/gbnfJson/terminals/GbnfFormatString.js +90 -0
- package/dist/utils/gbnfJson/terminals/GbnfFormatString.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfGrammar.d.ts +9 -0
- package/dist/utils/gbnfJson/terminals/GbnfGrammar.js +23 -0
- package/dist/utils/gbnfJson/terminals/GbnfGrammar.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.d.ts +5 -0
- package/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.js +24 -0
- package/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfNull.d.ts +5 -0
- package/dist/utils/gbnfJson/terminals/GbnfNull.js +11 -0
- package/dist/utils/gbnfJson/terminals/GbnfNull.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfNumber.d.ts +9 -0
- package/dist/utils/gbnfJson/terminals/GbnfNumber.js +22 -0
- package/dist/utils/gbnfJson/terminals/GbnfNumber.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfNumberValue.d.ts +9 -0
- package/dist/utils/gbnfJson/terminals/GbnfNumberValue.js +21 -0
- package/dist/utils/gbnfJson/terminals/GbnfNumberValue.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfObjectMap.d.ts +28 -0
- package/dist/utils/gbnfJson/terminals/GbnfObjectMap.js +88 -0
- package/dist/utils/gbnfJson/terminals/GbnfObjectMap.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfOr.d.ts +9 -0
- package/dist/utils/gbnfJson/terminals/GbnfOr.js +34 -0
- package/dist/utils/gbnfJson/terminals/GbnfOr.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfRef.d.ts +15 -0
- package/dist/utils/gbnfJson/terminals/GbnfRef.js +34 -0
- package/dist/utils/gbnfJson/terminals/GbnfRef.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfRepetition.d.ts +15 -0
- package/dist/utils/gbnfJson/terminals/GbnfRepetition.js +86 -0
- package/dist/utils/gbnfJson/terminals/GbnfRepetition.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfString.d.ts +12 -0
- package/dist/utils/gbnfJson/terminals/GbnfString.js +43 -0
- package/dist/utils/gbnfJson/terminals/GbnfString.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfStringValue.d.ts +8 -0
- package/dist/utils/gbnfJson/terminals/GbnfStringValue.js +26 -0
- package/dist/utils/gbnfJson/terminals/GbnfStringValue.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfVerbatimText.d.ts +6 -0
- package/dist/utils/gbnfJson/terminals/GbnfVerbatimText.js +21 -0
- package/dist/utils/gbnfJson/terminals/GbnfVerbatimText.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfWhitespace.d.ts +13 -0
- package/dist/utils/gbnfJson/terminals/GbnfWhitespace.js +67 -0
- package/dist/utils/gbnfJson/terminals/GbnfWhitespace.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/gbnfConsts.d.ts +30 -0
- package/dist/utils/gbnfJson/terminals/gbnfConsts.js +72 -0
- package/dist/utils/gbnfJson/terminals/gbnfConsts.js.map +1 -0
- package/dist/utils/gbnfJson/types.d.ts +213 -0
- package/dist/utils/gbnfJson/types.js +30 -0
- package/dist/utils/gbnfJson/types.js.map +1 -0
- package/dist/utils/gbnfJson/utils/GbnfJsonScopeState.d.ts +10 -0
- package/dist/utils/gbnfJson/utils/GbnfJsonScopeState.js +15 -0
- package/dist/utils/gbnfJson/utils/GbnfJsonScopeState.js.map +1 -0
- package/dist/utils/gbnfJson/utils/defsScope.d.ts +7 -0
- package/dist/utils/gbnfJson/utils/defsScope.js +17 -0
- package/dist/utils/gbnfJson/utils/defsScope.js.map +1 -0
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.d.ts +5 -0
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js +143 -0
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js.map +1 -0
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.d.ts +5 -0
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.js +16 -0
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.js.map +1 -0
- package/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.d.ts +8 -0
- package/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js +242 -0
- package/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js.map +1 -0
- package/dist/utils/getBuildDefaults.d.ts +5 -0
- package/dist/utils/getBuildDefaults.js +9 -0
- package/dist/utils/getBuildDefaults.js.map +1 -0
- package/dist/utils/getChatWrapperSegmentDefinition.d.ts +2 -0
- package/dist/utils/getChatWrapperSegmentDefinition.js +9 -0
- package/dist/utils/getChatWrapperSegmentDefinition.js.map +1 -0
- package/dist/utils/getConsoleLogPrefix.d.ts +1 -0
- package/dist/utils/getConsoleLogPrefix.js +10 -0
- package/dist/utils/getConsoleLogPrefix.js.map +1 -0
- package/dist/utils/getFirstWritableDir.d.ts +8 -0
- package/dist/utils/getFirstWritableDir.js +60 -0
- package/dist/utils/getFirstWritableDir.js.map +1 -0
- package/dist/utils/getGrammarsFolder.d.ts +2 -0
- package/dist/utils/getGrammarsFolder.js +19 -0
- package/dist/utils/getGrammarsFolder.js.map +1 -0
- package/dist/utils/getLlamaClasses.d.ts +9 -0
- package/dist/utils/getLlamaClasses.js +14 -0
- package/dist/utils/getLlamaClasses.js.map +1 -0
- package/dist/utils/getModuleVersion.d.ts +1 -0
- package/dist/utils/getModuleVersion.js +13 -0
- package/dist/utils/getModuleVersion.js.map +1 -0
- package/dist/utils/getQueuedTokensBeforeStopTrigger.d.ts +6 -0
- package/dist/utils/getQueuedTokensBeforeStopTrigger.js +22 -0
- package/dist/utils/getQueuedTokensBeforeStopTrigger.js.map +1 -0
- package/dist/utils/getReadableContextSize.d.ts +1 -0
- package/dist/utils/getReadableContextSize.js +7 -0
- package/dist/utils/getReadableContextSize.js.map +1 -0
- package/dist/utils/getTempDir.d.ts +10 -0
- package/dist/utils/getTempDir.js +121 -0
- package/dist/utils/getTempDir.js.map +1 -0
- package/dist/utils/getTypeScriptTypeStringForGbnfJsonSchema.d.ts +2 -0
- package/dist/utils/getTypeScriptTypeStringForGbnfJsonSchema.js +205 -0
- package/dist/utils/getTypeScriptTypeStringForGbnfJsonSchema.js.map +1 -0
- package/dist/utils/gitReleaseBundles.d.ts +2 -0
- package/dist/utils/gitReleaseBundles.js +132 -0
- package/dist/utils/gitReleaseBundles.js.map +1 -0
- package/dist/utils/hashString.d.ts +1 -0
- package/dist/utils/hashString.js +8 -0
- package/dist/utils/hashString.js.map +1 -0
- package/dist/utils/includesText.d.ts +1 -0
- package/dist/utils/includesText.js +12 -0
- package/dist/utils/includesText.js.map +1 -0
- package/dist/utils/isLockfileActive.d.ts +4 -0
- package/dist/utils/isLockfileActive.js +12 -0
- package/dist/utils/isLockfileActive.js.map +1 -0
- package/dist/utils/isToken.d.ts +2 -0
- package/dist/utils/isToken.js +4 -0
- package/dist/utils/isToken.js.map +1 -0
- package/dist/utils/isUrl.d.ts +1 -0
- package/dist/utils/isUrl.js +15 -0
- package/dist/utils/isUrl.js.map +1 -0
- package/dist/utils/mergeUnionTypes.d.ts +10 -0
- package/dist/utils/mergeUnionTypes.js +2 -0
- package/dist/utils/mergeUnionTypes.js.map +1 -0
- package/dist/utils/modelDownloadEndpoints.d.ts +13 -0
- package/dist/utils/modelDownloadEndpoints.js +27 -0
- package/dist/utils/modelDownloadEndpoints.js.map +1 -0
- package/dist/utils/modelFileAccessTokens.d.ts +5 -0
- package/dist/utils/modelFileAccessTokens.js +41 -0
- package/dist/utils/modelFileAccessTokens.js.map +1 -0
- package/dist/utils/optionsMatrix.d.ts +58 -0
- package/dist/utils/optionsMatrix.js +97 -0
- package/dist/utils/optionsMatrix.js.map +1 -0
- package/dist/utils/parseModelFileName.d.ts +15 -0
- package/dist/utils/parseModelFileName.js +132 -0
- package/dist/utils/parseModelFileName.js.map +1 -0
- package/dist/utils/parseModelUri.d.ts +40 -0
- package/dist/utils/parseModelUri.js +346 -0
- package/dist/utils/parseModelUri.js.map +1 -0
- package/dist/utils/parseTextTemplate.d.ts +66 -0
- package/dist/utils/parseTextTemplate.js +116 -0
- package/dist/utils/parseTextTemplate.js.map +1 -0
- package/dist/utils/prettyPrintObject.d.ts +10 -0
- package/dist/utils/prettyPrintObject.js +84 -0
- package/dist/utils/prettyPrintObject.js.map +1 -0
- package/dist/utils/pushAll.d.ts +6 -0
- package/dist/utils/pushAll.js +11 -0
- package/dist/utils/pushAll.js.map +1 -0
- package/dist/utils/removeNullFields.d.ts +2 -0
- package/dist/utils/removeNullFields.js +17 -0
- package/dist/utils/removeNullFields.js.map +1 -0
- package/dist/utils/resolveGithubRelease.d.ts +2 -0
- package/dist/utils/resolveGithubRelease.js +77 -0
- package/dist/utils/resolveGithubRelease.js.map +1 -0
- package/dist/utils/resolveLastTokens.d.ts +2 -0
- package/dist/utils/resolveLastTokens.js +12 -0
- package/dist/utils/resolveLastTokens.js.map +1 -0
- package/dist/utils/resolveModelDestination.d.ts +16 -0
- package/dist/utils/resolveModelDestination.js +54 -0
- package/dist/utils/resolveModelDestination.js.map +1 -0
- package/dist/utils/resolveModelFile.d.ts +142 -0
- package/dist/utils/resolveModelFile.js +201 -0
- package/dist/utils/resolveModelFile.js.map +1 -0
- package/dist/utils/runtime.d.ts +4 -0
- package/dist/utils/runtime.js +8 -0
- package/dist/utils/runtime.js.map +1 -0
- package/dist/utils/safeEventCallback.d.ts +6 -0
- package/dist/utils/safeEventCallback.js +29 -0
- package/dist/utils/safeEventCallback.js.map +1 -0
- package/dist/utils/signalSleep.d.ts +1 -0
- package/dist/utils/signalSleep.js +20 -0
- package/dist/utils/signalSleep.js.map +1 -0
- package/dist/utils/spawnCommand.d.ts +11 -0
- package/dist/utils/spawnCommand.js +89 -0
- package/dist/utils/spawnCommand.js.map +1 -0
- package/dist/utils/tokenizeInput.d.ts +3 -0
- package/dist/utils/tokenizeInput.js +14 -0
- package/dist/utils/tokenizeInput.js.map +1 -0
- package/dist/utils/tokenizerUtils.d.ts +12 -0
- package/dist/utils/tokenizerUtils.js +32 -0
- package/dist/utils/tokenizerUtils.js.map +1 -0
- package/dist/utils/transformPromisable.d.ts +54 -0
- package/dist/utils/transformPromisable.js +95 -0
- package/dist/utils/transformPromisable.js.map +1 -0
- package/dist/utils/truncateTextAndRoundToWords.d.ts +11 -0
- package/dist/utils/truncateTextAndRoundToWords.js +110 -0
- package/dist/utils/truncateTextAndRoundToWords.js.map +1 -0
- package/dist/utils/utilTypes.d.ts +18 -0
- package/dist/utils/utilTypes.js +2 -0
- package/dist/utils/utilTypes.js.map +1 -0
- package/dist/utils/waitForLockfileRelease.d.ts +5 -0
- package/dist/utils/waitForLockfileRelease.js +19 -0
- package/dist/utils/waitForLockfileRelease.js.map +1 -0
- package/dist/utils/withLockfile.d.ts +7 -0
- package/dist/utils/withLockfile.js +44 -0
- package/dist/utils/withLockfile.js.map +1 -0
- package/dist/utils/withOra.d.ts +7 -0
- package/dist/utils/withOra.js +37 -0
- package/dist/utils/withOra.js.map +1 -0
- package/dist/utils/withProgressLog.d.ts +22 -0
- package/dist/utils/withProgressLog.js +211 -0
- package/dist/utils/withProgressLog.js.map +1 -0
- package/dist/utils/withStatusLogs.d.ts +6 -0
- package/dist/utils/withStatusLogs.js +25 -0
- package/dist/utils/withStatusLogs.js.map +1 -0
- package/dist/utils/wrapAbortSignal.d.ts +1 -0
- package/dist/utils/wrapAbortSignal.js +14 -0
- package/dist/utils/wrapAbortSignal.js.map +1 -0
- package/llama/.clang-format +46 -0
- package/llama/CMakeLists.txt +141 -0
- package/llama/addon/AddonContext.cpp +1181 -0
- package/llama/addon/AddonContext.h +85 -0
- package/llama/addon/AddonGrammar.cpp +92 -0
- package/llama/addon/AddonGrammar.h +22 -0
- package/llama/addon/AddonGrammarEvaluationState.cpp +36 -0
- package/llama/addon/AddonGrammarEvaluationState.h +17 -0
- package/llama/addon/AddonModel.cpp +691 -0
- package/llama/addon/AddonModel.h +64 -0
- package/llama/addon/AddonModelData.cpp +25 -0
- package/llama/addon/AddonModelData.h +15 -0
- package/llama/addon/AddonModelLora.cpp +103 -0
- package/llama/addon/AddonModelLora.h +28 -0
- package/llama/addon/AddonSampler.cpp +669 -0
- package/llama/addon/AddonSampler.h +75 -0
- package/llama/addon/RingBuffer.h +109 -0
- package/llama/addon/addon.cpp +330 -0
- package/llama/addon/addonGlobals.cpp +22 -0
- package/llama/addon/addonGlobals.h +12 -0
- package/llama/addon/globals/addonLog.cpp +143 -0
- package/llama/addon/globals/addonLog.h +24 -0
- package/llama/addon/globals/addonProgress.cpp +15 -0
- package/llama/addon/globals/addonProgress.h +15 -0
- package/llama/addon/globals/getGpuInfo.cpp +146 -0
- package/llama/addon/globals/getGpuInfo.h +11 -0
- package/llama/addon/globals/getMemoryInfo.cpp +63 -0
- package/llama/addon/globals/getMemoryInfo.h +4 -0
- package/llama/addon/globals/getSwapInfo.cpp +69 -0
- package/llama/addon/globals/getSwapInfo.h +4 -0
- package/llama/binariesGithubRelease.json +3 -0
- package/llama/cmake/addVariantSuffix.cmake +21 -0
- package/llama/cmake/win32.ensureNinjaPath.cmake +68 -0
- package/llama/cmake/win32.ensureNodeLib.cmake +34 -0
- package/llama/cmake/win32.llvmApplyGnuModeAdaptations.cmake +12 -0
- package/llama/cmake/win32.llvmEnsureCmakeAr.cmake +37 -0
- package/llama/cmake/win32.llvmUseGnuModeCompilers.cmake +87 -0
- package/llama/cmake/win32.programFilesPaths.cmake +35 -0
- package/llama/gpuInfo/vulkan-gpu-info.cpp +207 -0
- package/llama/gpuInfo/vulkan-gpu-info.h +9 -0
- package/llama/package.json +5 -0
- package/llama/profiles/llvm.win32.host-arm64.target-arm64.cmake +14 -0
- package/llama/profiles/llvm.win32.host-x64.target-arm64.cmake +14 -0
- package/llama/profiles/llvm.win32.host-x64.target-x64.cmake +14 -0
- package/llama/toolchains/darwin.host-x64.target-arm64.cmake +8 -0
- package/llama/toolchains/linux.host-arm64.target-x64.cmake +5 -0
- package/llama/toolchains/linux.host-x64.target-arm64.cmake +5 -0
- package/llama/toolchains/linux.host-x64.target-arm71.cmake +5 -0
- package/llama/toolchains/llvm.win32.host-x64.target-x64.cmake +20 -0
- package/llama/toolchains/win32.host-arm64.target-arm64.cmake +21 -0
- package/llama/toolchains/win32.host-x64.target-arm64.cmake +21 -0
- package/llama/xpack/package.json +10 -0
- package/package.json +241 -0
- package/templates/README.md +6 -0
- package/templates/package.json +10 -0
- package/templates/packed/electron-typescript-react.json +1 -0
- package/templates/packed/node-typescript.json +1 -0
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
import process from "process";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { downloadFile, downloadSequence } from "ipull";
|
|
4
|
+
import fs from "fs-extra";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import { createSplitPartFilename, resolveSplitGgufParts } from "../gguf/utils/resolveSplitGgufParts.js";
|
|
7
|
+
import { getFilenameForBinarySplitGgufPartUrls, resolveBinarySplitGgufPartUrls } from "../gguf/utils/resolveBinarySplitGgufPartUrls.js";
|
|
8
|
+
import { cliModelsDirectory, isCI } from "../config.js";
|
|
9
|
+
import { safeEventCallback } from "./safeEventCallback.js";
|
|
10
|
+
import { resolveModelFileAccessTokensTryHeaders } from "./modelFileAccessTokens.js";
|
|
11
|
+
import { pushAll } from "./pushAll.js";
|
|
12
|
+
import { resolveModelDestination } from "./resolveModelDestination.js";
|
|
13
|
+
import { getAuthorizationHeader, resolveParsedModelUri } from "./parseModelUri.js";
|
|
14
|
+
import withOra from "./withOra.js";
|
|
15
|
+
/**
|
|
16
|
+
* Create a model downloader to download a model from a URI.
|
|
17
|
+
* Uses [`ipull`](https://github.com/ido-pluto/ipull) to download a model file as fast as possible with parallel connections
|
|
18
|
+
* and other optimizations.
|
|
19
|
+
*
|
|
20
|
+
* If the uri points to a `.gguf` file that is split into multiple parts (for example, `model-00001-of-00009.gguf`),
|
|
21
|
+
* all the parts will be downloaded to the specified directory.
|
|
22
|
+
*
|
|
23
|
+
* If the uri points to a `.gguf` file that is binary split into multiple parts (for example, `model.gguf.part1of9`),
|
|
24
|
+
* all the parts will be spliced into a single file and be downloaded to the specified directory.
|
|
25
|
+
*
|
|
26
|
+
* If the uri points to a `.gguf` file that is not split or binary spliced (for example, `model.gguf`),
|
|
27
|
+
* the file will be downloaded to the specified directory.
|
|
28
|
+
*
|
|
29
|
+
* The supported URI schemes are:
|
|
30
|
+
* - **HTTP:** `https://`, `http://`
|
|
31
|
+
* - **Hugging Face:** `hf:<user>/<model>:<quant>` (`:<quant>` is optional, but recommended)
|
|
32
|
+
* - **Hugging Face:** `hf:<user>/<model>/<file-path>#<branch>` (`#<branch>` is optional)
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* import {fileURLToPath} from "url";
|
|
36
|
+
* import path from "path";
|
|
37
|
+
* import {createModelDownloader, getLlama} from "node-llama-cpp";
|
|
38
|
+
*
|
|
39
|
+
* const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
40
|
+
*
|
|
41
|
+
* const downloader = await createModelDownloader({
|
|
42
|
+
* modelUri: "https://example.com/model.gguf",
|
|
43
|
+
* dirPath: path.join(__dirname, "models")
|
|
44
|
+
* });
|
|
45
|
+
* const modelPath = await downloader.download();
|
|
46
|
+
*
|
|
47
|
+
* const llama = await getLlama();
|
|
48
|
+
* const model = await llama.loadModel({
|
|
49
|
+
* modelPath
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* import {fileURLToPath} from "url";
|
|
55
|
+
* import path from "path";
|
|
56
|
+
* import {createModelDownloader, getLlama} from "node-llama-cpp";
|
|
57
|
+
*
|
|
58
|
+
* const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
59
|
+
*
|
|
60
|
+
* const downloader = await createModelDownloader({
|
|
61
|
+
* modelUri: "hf:user/model:quant",
|
|
62
|
+
* dirPath: path.join(__dirname, "models")
|
|
63
|
+
* });
|
|
64
|
+
* const modelPath = await downloader.download();
|
|
65
|
+
*
|
|
66
|
+
* const llama = await getLlama();
|
|
67
|
+
* const model = await llama.loadModel({
|
|
68
|
+
* modelPath
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export function createModelDownloader(options) {
|
|
73
|
+
return ModelDownloader._create(options);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Combine multiple models downloaders to a single downloader to download everything using as much parallelism as possible.
|
|
77
|
+
*
|
|
78
|
+
* You can check each individual model downloader for its download progress,
|
|
79
|
+
* but only the `onProgress` passed to the combined downloader will be called during the download.
|
|
80
|
+
*
|
|
81
|
+
* When combining `ModelDownloader` instances, the following options on each individual `ModelDownloader` are ignored:
|
|
82
|
+
* - `showCliProgress`
|
|
83
|
+
* - `onProgress`
|
|
84
|
+
* - `parallelDownloads`
|
|
85
|
+
*
|
|
86
|
+
* To set any of those options for the combined downloader, you have to pass them to the combined downloader instance.
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* import {fileURLToPath} from "url";
|
|
90
|
+
* import path from "path";
|
|
91
|
+
* import {createModelDownloader, combineModelDownloaders, getLlama} from "node-llama-cpp";
|
|
92
|
+
*
|
|
93
|
+
* const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
94
|
+
*
|
|
95
|
+
* const downloaders = [
|
|
96
|
+
* createModelDownloader({
|
|
97
|
+
* modelUri: "https://example.com/model1.gguf",
|
|
98
|
+
* dirPath: path.join(__dirname, "models")
|
|
99
|
+
* }),
|
|
100
|
+
* createModelDownloader({
|
|
101
|
+
* modelUri: "hf:user/model2:quant",
|
|
102
|
+
* dirPath: path.join(__dirname, "models")
|
|
103
|
+
* }),
|
|
104
|
+
* createModelDownloader({
|
|
105
|
+
* modelUri: "hf:user/model/model3.gguf",
|
|
106
|
+
* dirPath: path.join(__dirname, "models")
|
|
107
|
+
* })
|
|
108
|
+
* ];
|
|
109
|
+
* const combinedDownloader = await combineModelDownloaders(downloaders, {
|
|
110
|
+
* showCliProgress: true // show download progress in the CLI
|
|
111
|
+
* });
|
|
112
|
+
* const [
|
|
113
|
+
* model1Path,
|
|
114
|
+
* model2Path,
|
|
115
|
+
* model3Path
|
|
116
|
+
* ] = await combinedDownloader.download();
|
|
117
|
+
*
|
|
118
|
+
* const llama = await getLlama();
|
|
119
|
+
* const model1 = await llama.loadModel({
|
|
120
|
+
* modelPath: model1Path!
|
|
121
|
+
* });
|
|
122
|
+
* const model2 = await llama.loadModel({
|
|
123
|
+
* modelPath: model2Path!
|
|
124
|
+
* });
|
|
125
|
+
* const model3 = await llama.loadModel({
|
|
126
|
+
* modelPath: model3Path!
|
|
127
|
+
* });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export async function combineModelDownloaders(downloaders, options) {
|
|
131
|
+
const downloader = CombinedModelDownloader._create(await Promise.all(downloaders), options);
|
|
132
|
+
await downloader._init();
|
|
133
|
+
return downloader;
|
|
134
|
+
}
|
|
135
|
+
export class ModelDownloader {
|
|
136
|
+
/** @internal */ _modelUrl;
|
|
137
|
+
/** @internal */ _dirPath;
|
|
138
|
+
/** @internal */ _fileName;
|
|
139
|
+
/** @internal */ _headers;
|
|
140
|
+
/** @internal */ _showCliProgress;
|
|
141
|
+
/** @internal */ _onProgress;
|
|
142
|
+
/** @internal */ _tokens;
|
|
143
|
+
/** @internal */ _endpoints;
|
|
144
|
+
/** @internal */ _deleteTempFileOnCancel;
|
|
145
|
+
/** @internal */ _skipExisting;
|
|
146
|
+
/** @internal */ _parallelDownloads;
|
|
147
|
+
/** @internal */ _specificFileDownloaders = [];
|
|
148
|
+
/** @internal */ _downloader;
|
|
149
|
+
/** @internal */ _entrypointFilename;
|
|
150
|
+
/** @internal */ _splitBinaryParts;
|
|
151
|
+
/** @internal */ _totalFiles;
|
|
152
|
+
/** @internal */ _tryHeaders = [];
|
|
153
|
+
constructor(options, { resolvedModelUrl, resolvedFileName }) {
|
|
154
|
+
const { dirPath = cliModelsDirectory, headers, showCliProgress = false, onProgress, deleteTempFileOnCancel = true, skipExisting = true, parallelDownloads = 4, tokens, endpoints } = options;
|
|
155
|
+
this._modelUrl = resolvedModelUrl;
|
|
156
|
+
this._dirPath = path.resolve(process.cwd(), dirPath);
|
|
157
|
+
this._fileName = resolvedFileName;
|
|
158
|
+
this._headers = headers;
|
|
159
|
+
this._showCliProgress = showCliProgress;
|
|
160
|
+
this._onProgress = safeEventCallback(onProgress);
|
|
161
|
+
this._deleteTempFileOnCancel = deleteTempFileOnCancel;
|
|
162
|
+
this._skipExisting = skipExisting;
|
|
163
|
+
this._parallelDownloads = parallelDownloads;
|
|
164
|
+
this._tokens = tokens;
|
|
165
|
+
this._endpoints = endpoints;
|
|
166
|
+
this._onDownloadProgress = this._onDownloadProgress.bind(this);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* The filename of the entrypoint file that should be used to load the model.
|
|
170
|
+
*/
|
|
171
|
+
get entrypointFilename() {
|
|
172
|
+
return this._entrypointFilename;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* The full path to the entrypoint file that should be used to load the model.
|
|
176
|
+
*/
|
|
177
|
+
get entrypointFilePath() {
|
|
178
|
+
return path.join(this._dirPath, this.entrypointFilename);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* If the model is binary spliced from multiple parts, this will return the number of those binary parts.
|
|
182
|
+
*/
|
|
183
|
+
get splitBinaryParts() {
|
|
184
|
+
return this._splitBinaryParts;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The total number of files that will be saved to the directory.
|
|
188
|
+
* For split files, this will be the number of split parts, as multiple files will be saved.
|
|
189
|
+
* For binary-split files, this will be 1, as the parts will be spliced into a single file.
|
|
190
|
+
*/
|
|
191
|
+
get totalFiles() {
|
|
192
|
+
return this._totalFiles;
|
|
193
|
+
}
|
|
194
|
+
get totalSize() {
|
|
195
|
+
return this._specificFileDownloaders
|
|
196
|
+
.map((downloader) => downloader.status.totalBytes)
|
|
197
|
+
.reduce((acc, totalBytes) => acc + totalBytes, 0);
|
|
198
|
+
}
|
|
199
|
+
get downloadedSize() {
|
|
200
|
+
return this._specificFileDownloaders
|
|
201
|
+
.map((downloader) => downloader.status.transferredBytes)
|
|
202
|
+
.reduce((acc, transferredBytes) => acc + transferredBytes, 0);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* @returns The path to the entrypoint file that should be used to load the model
|
|
206
|
+
*/
|
|
207
|
+
async download({ signal } = {}) {
|
|
208
|
+
if (signal?.aborted)
|
|
209
|
+
throw signal.reason;
|
|
210
|
+
const onAbort = () => {
|
|
211
|
+
signal?.removeEventListener("abort", onAbort);
|
|
212
|
+
this.cancel();
|
|
213
|
+
};
|
|
214
|
+
if (signal != null)
|
|
215
|
+
signal.addEventListener("abort", onAbort);
|
|
216
|
+
try {
|
|
217
|
+
if (this._onProgress)
|
|
218
|
+
this._downloader.on("progress", this._onDownloadProgress);
|
|
219
|
+
await this._downloader.download();
|
|
220
|
+
}
|
|
221
|
+
catch (err) {
|
|
222
|
+
if (signal?.aborted)
|
|
223
|
+
throw signal.reason;
|
|
224
|
+
throw err;
|
|
225
|
+
}
|
|
226
|
+
finally {
|
|
227
|
+
if (this._onProgress)
|
|
228
|
+
this._downloader.off("progress", this._onDownloadProgress);
|
|
229
|
+
if (signal != null)
|
|
230
|
+
signal.removeEventListener("abort", onAbort);
|
|
231
|
+
}
|
|
232
|
+
return this.entrypointFilePath;
|
|
233
|
+
}
|
|
234
|
+
async cancel({ deleteTempFile = this._deleteTempFileOnCancel } = {}) {
|
|
235
|
+
for (const downloader of this._specificFileDownloaders)
|
|
236
|
+
await downloader.close({ deleteTempFile });
|
|
237
|
+
if (this._downloader !== this._specificFileDownloaders[0])
|
|
238
|
+
await this._downloader?.close({ deleteTempFile });
|
|
239
|
+
}
|
|
240
|
+
/** @internal */
|
|
241
|
+
_onDownloadProgress() {
|
|
242
|
+
this._onProgress?.({
|
|
243
|
+
totalSize: this.totalSize,
|
|
244
|
+
downloadedSize: this.downloadedSize
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
/** @internal */
|
|
248
|
+
async resolveTryHeaders() {
|
|
249
|
+
if (this._tokens == null)
|
|
250
|
+
return;
|
|
251
|
+
pushAll(this._tryHeaders, await resolveModelFileAccessTokensTryHeaders(this._modelUrl, this._tokens, this._endpoints, this._headers));
|
|
252
|
+
}
|
|
253
|
+
/** @internal */
|
|
254
|
+
async _init() {
|
|
255
|
+
await this.resolveTryHeaders();
|
|
256
|
+
const binarySplitPartUrls = resolveBinarySplitGgufPartUrls(this._modelUrl);
|
|
257
|
+
await fs.ensureDir(this._dirPath);
|
|
258
|
+
if (binarySplitPartUrls instanceof Array) {
|
|
259
|
+
this._downloader = await downloadFile({
|
|
260
|
+
partURLs: binarySplitPartUrls,
|
|
261
|
+
directory: this._dirPath,
|
|
262
|
+
fileName: this._fileName ?? getFilenameForBinarySplitGgufPartUrls(binarySplitPartUrls),
|
|
263
|
+
cliProgress: this._showCliProgress,
|
|
264
|
+
cliStyle: isCI ? "ci" : "fancy",
|
|
265
|
+
headers: this._headers ?? {},
|
|
266
|
+
tryHeaders: this._tryHeaders.slice(),
|
|
267
|
+
skipExisting: this._skipExisting
|
|
268
|
+
});
|
|
269
|
+
this._specificFileDownloaders.push(this._downloader);
|
|
270
|
+
this._entrypointFilename = this._downloader.fileName;
|
|
271
|
+
this._splitBinaryParts = binarySplitPartUrls.length;
|
|
272
|
+
this._totalFiles = 1;
|
|
273
|
+
if (this._downloader.fileName == null || this._downloader.fileName === "")
|
|
274
|
+
throw new Error("Failed to get the file name from the given URL");
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const splitGgufPartUrls = resolveSplitGgufParts(this._modelUrl);
|
|
278
|
+
if (splitGgufPartUrls.length === 1) {
|
|
279
|
+
this._downloader = await downloadFile({
|
|
280
|
+
url: splitGgufPartUrls[0],
|
|
281
|
+
directory: this._dirPath,
|
|
282
|
+
fileName: this._fileName ?? undefined,
|
|
283
|
+
cliProgress: this._showCliProgress,
|
|
284
|
+
cliStyle: isCI ? "ci" : "fancy",
|
|
285
|
+
headers: this._headers ?? {},
|
|
286
|
+
tryHeaders: this._tryHeaders.slice(),
|
|
287
|
+
skipExisting: this._skipExisting
|
|
288
|
+
});
|
|
289
|
+
this._specificFileDownloaders.push(this._downloader);
|
|
290
|
+
this._entrypointFilename = this._downloader.fileName;
|
|
291
|
+
this._totalFiles = 1;
|
|
292
|
+
if (this._downloader.fileName == null || this._downloader.fileName === "")
|
|
293
|
+
throw new Error("Failed to get the file name from the given URL");
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const partDownloads = splitGgufPartUrls.map((url, index) => downloadFile({
|
|
297
|
+
url,
|
|
298
|
+
directory: this._dirPath,
|
|
299
|
+
fileName: this._fileName != null
|
|
300
|
+
? createSplitPartFilename(this._fileName, index + 1, splitGgufPartUrls.length)
|
|
301
|
+
: undefined,
|
|
302
|
+
headers: this._headers ?? {},
|
|
303
|
+
tryHeaders: this._tryHeaders.slice(),
|
|
304
|
+
skipExisting: this._skipExisting
|
|
305
|
+
}));
|
|
306
|
+
this._downloader = await downloadSequence({
|
|
307
|
+
cliProgress: this._showCliProgress,
|
|
308
|
+
cliStyle: isCI ? "ci" : "fancy",
|
|
309
|
+
parallelDownloads: this._parallelDownloads
|
|
310
|
+
}, ...partDownloads);
|
|
311
|
+
const firstDownload = await partDownloads[0];
|
|
312
|
+
this._specificFileDownloaders = await Promise.all(partDownloads);
|
|
313
|
+
this._entrypointFilename = firstDownload.fileName;
|
|
314
|
+
this._totalFiles = partDownloads.length;
|
|
315
|
+
if (this._entrypointFilename == null || this._entrypointFilename === "")
|
|
316
|
+
throw new Error("Failed to get the file name from the given URL");
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
/** @internal */
|
|
320
|
+
static async _create(options) {
|
|
321
|
+
const { modelUri, modelUrl, dirPath = cliModelsDirectory, fileName, _showUriResolvingProgress = false } = options;
|
|
322
|
+
const resolvedModelUri = modelUri || modelUrl;
|
|
323
|
+
if (resolvedModelUri == null || dirPath == null)
|
|
324
|
+
throw new Error("modelUri and dirPath cannot be null");
|
|
325
|
+
async function getModelUrlAndFilename() {
|
|
326
|
+
const resolvedModelDestination = resolveModelDestination(resolvedModelUri, undefined, options.endpoints);
|
|
327
|
+
if (resolvedModelDestination.type == "file")
|
|
328
|
+
return {
|
|
329
|
+
resolvedModelUrl: path.resolve(dirPath, resolvedModelDestination.path),
|
|
330
|
+
resolvedFileName: fileName
|
|
331
|
+
};
|
|
332
|
+
else if (resolvedModelDestination.type === "url")
|
|
333
|
+
return {
|
|
334
|
+
resolvedModelUrl: resolvedModelDestination.url,
|
|
335
|
+
resolvedFileName: fileName
|
|
336
|
+
};
|
|
337
|
+
else if (resolvedModelDestination.parsedUri.type === "resolved")
|
|
338
|
+
return {
|
|
339
|
+
resolvedModelUrl: resolvedModelDestination.parsedUri.resolvedUrl,
|
|
340
|
+
resolvedFileName: fileName || resolvedModelDestination.parsedUri.fullFilename
|
|
341
|
+
};
|
|
342
|
+
const resolvedUri = _showUriResolvingProgress
|
|
343
|
+
? await withOra({
|
|
344
|
+
loading: chalk.blue("Resolving model URI"),
|
|
345
|
+
success: chalk.blue("Resolved model URI"),
|
|
346
|
+
fail: chalk.blue("Failed to resolve model URI"),
|
|
347
|
+
noSuccessLiveStatus: true
|
|
348
|
+
}, () => {
|
|
349
|
+
return resolveParsedModelUri(resolvedModelDestination.parsedUri, {
|
|
350
|
+
tokens: options.tokens,
|
|
351
|
+
endpoints: options.endpoints,
|
|
352
|
+
authorizationHeader: getAuthorizationHeader(options.headers)
|
|
353
|
+
});
|
|
354
|
+
})
|
|
355
|
+
: await resolveParsedModelUri(resolvedModelDestination.parsedUri, {
|
|
356
|
+
tokens: options.tokens,
|
|
357
|
+
endpoints: options.endpoints,
|
|
358
|
+
authorizationHeader: getAuthorizationHeader(options.headers)
|
|
359
|
+
});
|
|
360
|
+
return {
|
|
361
|
+
resolvedModelUrl: resolvedUri.resolvedUrl,
|
|
362
|
+
resolvedFileName: fileName || resolvedUri.fullFilename
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
const modelDownloader = new ModelDownloader(options, await getModelUrlAndFilename());
|
|
366
|
+
await modelDownloader._init();
|
|
367
|
+
return modelDownloader;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
export class CombinedModelDownloader {
|
|
371
|
+
/** @internal */ _downloaders;
|
|
372
|
+
/** @internal */ _showCliProgress;
|
|
373
|
+
/** @internal */ _onProgress;
|
|
374
|
+
/** @internal */ _parallelDownloads;
|
|
375
|
+
/** @internal */ _lock = {};
|
|
376
|
+
/** @internal */ _downloader;
|
|
377
|
+
/**
|
|
378
|
+
* When combining `ModelDownloader` instances, the following options on each individual `ModelDownloader` are ignored:
|
|
379
|
+
* - `showCliProgress`
|
|
380
|
+
* - `onProgress`
|
|
381
|
+
* - `parallelDownloads`
|
|
382
|
+
*
|
|
383
|
+
* To set any of those options for the combined downloader, you have to pass them to the combined downloader instance
|
|
384
|
+
*/
|
|
385
|
+
constructor(downloaders, options) {
|
|
386
|
+
const { showCliProgress = false, onProgress, parallelDownloads = 4 } = options ?? {};
|
|
387
|
+
this._downloaders = Object.freeze(downloaders);
|
|
388
|
+
this._showCliProgress = showCliProgress;
|
|
389
|
+
this._onProgress = onProgress;
|
|
390
|
+
this._parallelDownloads = parallelDownloads;
|
|
391
|
+
this._onDownloadProgress = this._onDownloadProgress.bind(this);
|
|
392
|
+
}
|
|
393
|
+
async cancel() {
|
|
394
|
+
for (const modelDownloader of this._downloaders) {
|
|
395
|
+
if (modelDownloader._specificFileDownloaders.every((downloader) => downloader.status.downloadStatus === "Finished"))
|
|
396
|
+
continue;
|
|
397
|
+
for (const downloader of modelDownloader._specificFileDownloaders)
|
|
398
|
+
await downloader.close({
|
|
399
|
+
deleteTempFile: modelDownloader._deleteTempFileOnCancel
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* @returns The paths to the entrypoint files that should be used to load the models
|
|
405
|
+
*/
|
|
406
|
+
async download({ signal } = {}) {
|
|
407
|
+
if (signal?.aborted)
|
|
408
|
+
throw signal.reason;
|
|
409
|
+
const onAbort = () => {
|
|
410
|
+
signal?.removeEventListener("abort", onAbort);
|
|
411
|
+
this.cancel();
|
|
412
|
+
};
|
|
413
|
+
if (signal != null)
|
|
414
|
+
signal.addEventListener("abort", onAbort);
|
|
415
|
+
try {
|
|
416
|
+
if (this._onProgress)
|
|
417
|
+
this._downloader.on("progress", this._onDownloadProgress);
|
|
418
|
+
await this._downloader.download();
|
|
419
|
+
}
|
|
420
|
+
catch (err) {
|
|
421
|
+
if (signal?.aborted)
|
|
422
|
+
throw signal.reason;
|
|
423
|
+
throw err;
|
|
424
|
+
}
|
|
425
|
+
finally {
|
|
426
|
+
if (this._onProgress)
|
|
427
|
+
this._downloader.off("progress", this._onDownloadProgress);
|
|
428
|
+
if (signal != null)
|
|
429
|
+
signal.removeEventListener("abort", onAbort);
|
|
430
|
+
}
|
|
431
|
+
return this.entrypointFilePaths;
|
|
432
|
+
}
|
|
433
|
+
get modelDownloaders() {
|
|
434
|
+
return this._downloaders;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* The filename of the entrypoint files that should be used to load the models.
|
|
438
|
+
*/
|
|
439
|
+
get entrypointFilenames() {
|
|
440
|
+
return this._downloaders.map((downloader) => downloader.entrypointFilename);
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* The full paths to the entrypoint files that should be used to load the models.
|
|
444
|
+
*/
|
|
445
|
+
get entrypointFilePaths() {
|
|
446
|
+
return this._downloaders.map((downloader) => downloader.entrypointFilePath);
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* The accumulation of `totalFiles` of all the model downloaders
|
|
450
|
+
*/
|
|
451
|
+
get totalFiles() {
|
|
452
|
+
return this._downloaders
|
|
453
|
+
.map((downloader) => downloader.totalFiles)
|
|
454
|
+
.reduce((acc, totalFiles) => acc + totalFiles, 0);
|
|
455
|
+
}
|
|
456
|
+
get totalSize() {
|
|
457
|
+
return this._downloaders
|
|
458
|
+
.map((downloader) => downloader.totalSize)
|
|
459
|
+
.reduce((acc, totalBytes) => acc + totalBytes, 0);
|
|
460
|
+
}
|
|
461
|
+
get downloadedSize() {
|
|
462
|
+
return this._downloaders
|
|
463
|
+
.map((downloader) => downloader.downloadedSize)
|
|
464
|
+
.reduce((acc, transferredBytes) => acc + transferredBytes, 0);
|
|
465
|
+
}
|
|
466
|
+
/** @internal */
|
|
467
|
+
_onDownloadProgress() {
|
|
468
|
+
this._onProgress?.({
|
|
469
|
+
totalSize: this.totalSize,
|
|
470
|
+
downloadedSize: this.downloadedSize
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
/** @internal */
|
|
474
|
+
async _init() {
|
|
475
|
+
this._downloader = await downloadSequence({
|
|
476
|
+
cliProgress: this._showCliProgress,
|
|
477
|
+
cliStyle: isCI ? "ci" : "fancy",
|
|
478
|
+
parallelDownloads: this._parallelDownloads
|
|
479
|
+
}, ...this._downloaders.flatMap((downloader) => downloader._specificFileDownloaders));
|
|
480
|
+
}
|
|
481
|
+
/** @internal */
|
|
482
|
+
static _create(downloaders, options) {
|
|
483
|
+
return new CombinedModelDownloader(downloaders, options);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
//# sourceMappingURL=createModelDown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C1F,OAAO,IAAI,uBAAuB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;CACJ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function findBestOption({ generator, score }) {
|
|
2
|
+
let bestOption = null;
|
|
3
|
+
let bestScore = null;
|
|
4
|
+
for (const option of generator()) {
|
|
5
|
+
const currentScore = score(option);
|
|
6
|
+
if (currentScore === Infinity)
|
|
7
|
+
return option;
|
|
8
|
+
if (currentScore != null && (bestScore == null || currentScore > bestScore)) {
|
|
9
|
+
bestOption = option;
|
|
10
|
+
bestScore = currentScore;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return bestOption;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=findBestOption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findBestOption.js","sourceRoot":"","sources":["../../src/utils/findBestOption.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc,CAAU,EAAC,SAAS,EAAE,KAAK,EAGxD;IACG,IAAI,UAAU,GAAa,IAAI,CAAC;IAChC,IAAI,SAAS,GAAkB,IAAI,CAAC;IAEpC,KAAK,MAAM,MAAM,IAAI,SAAS,EAAE,EAAE,CAAC;QAC/B,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;QAEnC,IAAI,YAAY,KAAK,QAAQ;YACzB,OAAO,MAAM,CAAC;QAElB,IAAI,YAAY,IAAI,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,IAAI,YAAY,GAAG,SAAS,CAAC,EAAE,CAAC;YAC1E,UAAU,GAAG,MAAM,CAAC;YACpB,SAAS,GAAG,YAAY,CAAC;QAC7B,CAAC;IACL,CAAC;IAED,OAAO,UAAU,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ChatHistoryItem, Tokenizer } from "../types.js";
|
|
2
|
+
import { ChatWrapper } from "../ChatWrapper.js";
|
|
3
|
+
export declare function findCharacterRemovalCountToFitChatHistoryInContext({ compressChatHistory, chatHistory, tokensCountToFit, tokenizer, chatWrapper, initialCharactersRemovalCount, estimatedCharactersPerToken, maxDecompressionAttempts, failedCompressionErrorMessage }: {
|
|
4
|
+
compressChatHistory(options: {
|
|
5
|
+
chatHistory: readonly ChatHistoryItem[];
|
|
6
|
+
charactersToRemove: number;
|
|
7
|
+
estimatedCharactersPerToken: number;
|
|
8
|
+
}): ChatHistoryItem[] | Promise<ChatHistoryItem[]>;
|
|
9
|
+
chatHistory: ChatHistoryItem[];
|
|
10
|
+
tokensCountToFit: number;
|
|
11
|
+
tokenizer: Tokenizer;
|
|
12
|
+
chatWrapper: ChatWrapper;
|
|
13
|
+
initialCharactersRemovalCount?: number;
|
|
14
|
+
estimatedCharactersPerToken?: number;
|
|
15
|
+
maxDecompressionAttempts?: number;
|
|
16
|
+
failedCompressionErrorMessage?: string;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
removedCharactersCount: number;
|
|
19
|
+
compressedChatHistory: ChatHistoryItem[];
|
|
20
|
+
}>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const maxSequentialUnhelpfulIterations = 100;
|
|
2
|
+
export async function findCharacterRemovalCountToFitChatHistoryInContext({ compressChatHistory, chatHistory, tokensCountToFit, tokenizer, chatWrapper, initialCharactersRemovalCount = 0, estimatedCharactersPerToken = 5, maxDecompressionAttempts = 2, failedCompressionErrorMessage = "Failed to compress chat history. Consider increasing the context size." }) {
|
|
3
|
+
let currentEstimatedCharactersPerToken = estimatedCharactersPerToken;
|
|
4
|
+
function getTokensCountForChatHistory(chatHistory) {
|
|
5
|
+
const { contextText } = chatWrapper.generateContextState({ chatHistory });
|
|
6
|
+
return contextText.tokenize(tokenizer, "trimLeadingSpace").length;
|
|
7
|
+
}
|
|
8
|
+
async function getResultForCharacterRemovalCount(characterRemovalCount) {
|
|
9
|
+
if (characterRemovalCount === 0)
|
|
10
|
+
return {
|
|
11
|
+
compressedHistory: chatHistory,
|
|
12
|
+
tokensCount: getTokensCountForChatHistory(chatHistory),
|
|
13
|
+
characterRemovalCount
|
|
14
|
+
};
|
|
15
|
+
const compressedHistory = await compressChatHistory({
|
|
16
|
+
chatHistory,
|
|
17
|
+
charactersToRemove: characterRemovalCount,
|
|
18
|
+
estimatedCharactersPerToken: currentEstimatedCharactersPerToken
|
|
19
|
+
});
|
|
20
|
+
return {
|
|
21
|
+
compressedHistory,
|
|
22
|
+
tokensCount: getTokensCountForChatHistory(compressedHistory),
|
|
23
|
+
characterRemovalCount
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
let latestCompressionAttempt = await getResultForCharacterRemovalCount(initialCharactersRemovalCount);
|
|
27
|
+
const firstCompressionAttempt = latestCompressionAttempt;
|
|
28
|
+
let latestCompressionAttemptTokensCount = latestCompressionAttempt.tokensCount;
|
|
29
|
+
let sameTokensCountRepetitions = 0;
|
|
30
|
+
if (latestCompressionAttempt.tokensCount === tokensCountToFit ||
|
|
31
|
+
(latestCompressionAttempt.tokensCount < tokensCountToFit && latestCompressionAttempt.characterRemovalCount === 0))
|
|
32
|
+
return {
|
|
33
|
+
removedCharactersCount: initialCharactersRemovalCount,
|
|
34
|
+
compressedChatHistory: latestCompressionAttempt.compressedHistory
|
|
35
|
+
};
|
|
36
|
+
let bestCompressionAttempt = latestCompressionAttempt;
|
|
37
|
+
for (let compressionAttempts = 0, decompressionAttempts = 0; bestCompressionAttempt.tokensCount !== tokensCountToFit;) {
|
|
38
|
+
if (compressionAttempts > 0) {
|
|
39
|
+
if (latestCompressionAttempt.tokensCount != firstCompressionAttempt.tokensCount &&
|
|
40
|
+
latestCompressionAttempt.characterRemovalCount != firstCompressionAttempt.characterRemovalCount)
|
|
41
|
+
currentEstimatedCharactersPerToken =
|
|
42
|
+
Math.abs(latestCompressionAttempt.characterRemovalCount - firstCompressionAttempt.characterRemovalCount) /
|
|
43
|
+
Math.abs(latestCompressionAttempt.tokensCount - firstCompressionAttempt.tokensCount);
|
|
44
|
+
if (!Number.isFinite(currentEstimatedCharactersPerToken) || currentEstimatedCharactersPerToken === 0)
|
|
45
|
+
currentEstimatedCharactersPerToken = estimatedCharactersPerToken;
|
|
46
|
+
}
|
|
47
|
+
const tokensLeftToRemove = latestCompressionAttempt.tokensCount - tokensCountToFit;
|
|
48
|
+
let additionalCharactersToRemove = Math.round(tokensLeftToRemove * currentEstimatedCharactersPerToken);
|
|
49
|
+
if (additionalCharactersToRemove === 0) {
|
|
50
|
+
if (tokensLeftToRemove > 0)
|
|
51
|
+
additionalCharactersToRemove = 1;
|
|
52
|
+
else if (tokensLeftToRemove < 0)
|
|
53
|
+
additionalCharactersToRemove = -1;
|
|
54
|
+
}
|
|
55
|
+
if (tokensLeftToRemove > 0)
|
|
56
|
+
compressionAttempts++;
|
|
57
|
+
else if (tokensLeftToRemove < 0)
|
|
58
|
+
decompressionAttempts++;
|
|
59
|
+
if (decompressionAttempts >= maxDecompressionAttempts)
|
|
60
|
+
break;
|
|
61
|
+
latestCompressionAttempt = await getResultForCharacterRemovalCount(latestCompressionAttempt.characterRemovalCount + additionalCharactersToRemove);
|
|
62
|
+
if ((bestCompressionAttempt.tokensCount > tokensCountToFit &&
|
|
63
|
+
latestCompressionAttempt.tokensCount <= bestCompressionAttempt.tokensCount) || (bestCompressionAttempt.tokensCount < tokensCountToFit &&
|
|
64
|
+
latestCompressionAttempt.tokensCount < tokensCountToFit &&
|
|
65
|
+
latestCompressionAttempt.tokensCount > bestCompressionAttempt.tokensCount) || (bestCompressionAttempt.tokensCount <= tokensCountToFit &&
|
|
66
|
+
latestCompressionAttempt.tokensCount <= tokensCountToFit &&
|
|
67
|
+
latestCompressionAttempt.characterRemovalCount < bestCompressionAttempt.characterRemovalCount))
|
|
68
|
+
bestCompressionAttempt = latestCompressionAttempt;
|
|
69
|
+
if (latestCompressionAttempt.tokensCount === latestCompressionAttemptTokensCount)
|
|
70
|
+
sameTokensCountRepetitions++;
|
|
71
|
+
else {
|
|
72
|
+
latestCompressionAttemptTokensCount = latestCompressionAttempt.tokensCount;
|
|
73
|
+
sameTokensCountRepetitions = 0;
|
|
74
|
+
}
|
|
75
|
+
if (decompressionAttempts === 0 &&
|
|
76
|
+
compressionAttempts >= maxSequentialUnhelpfulIterations &&
|
|
77
|
+
sameTokensCountRepetitions >= maxSequentialUnhelpfulIterations)
|
|
78
|
+
throw new Error(failedCompressionErrorMessage);
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
removedCharactersCount: bestCompressionAttempt.characterRemovalCount,
|
|
82
|
+
compressedChatHistory: bestCompressionAttempt.compressedHistory
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=findCharacterRemovalCountToFitChatHistoryInContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findCharacterRemovalCountToFitChatHistoryInContext.js","sourceRoot":"","sources":["../../src/utils/findCharacterRemovalCountToFitChatHistoryInContext.ts"],"names":[],"mappings":"AAGA,MAAM,gCAAgC,GAAG,GAAG,CAAC;AAE7C,MAAM,CAAC,KAAK,UAAU,kDAAkD,CAAC,EACrE,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,6BAA6B,GAAG,CAAC,EACjC,2BAA2B,GAAG,CAAC,EAC/B,wBAAwB,GAAG,CAAC,EAC5B,6BAA6B,GAAG,wEAAwE,EAa3G;IAIG,IAAI,kCAAkC,GAAG,2BAA2B,CAAC;IAErE,SAAS,4BAA4B,CAAC,WAAuC;QACzE,MAAM,EAAC,WAAW,EAAC,GAAG,WAAW,CAAC,oBAAoB,CAAC,EAAC,WAAW,EAAC,CAAC,CAAC;QACtE,OAAO,WAAW,CAAC,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC,MAAM,CAAC;IACtE,CAAC;IAED,KAAK,UAAU,iCAAiC,CAAC,qBAA6B;QAC1E,IAAI,qBAAqB,KAAK,CAAC;YAC3B,OAAO;gBACH,i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