@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,693 @@
|
|
|
1
|
+
import * as readline from "readline";
|
|
2
|
+
import process from "process";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import chalk from "chalk";
|
|
5
|
+
import fs from "fs-extra";
|
|
6
|
+
import prettyMilliseconds from "pretty-ms";
|
|
7
|
+
import { getLlama } from "../../bindings/getLlama.js";
|
|
8
|
+
import { LlamaLogLevel, LlamaLogLevelGreaterThan, llamaNumaOptions, nodeLlamaCppGpuOptions, parseNodeLlamaCppGpuOption, parseNumaOption } from "../../bindings/types.js";
|
|
9
|
+
import { LlamaCompletion } from "../../evaluator/LlamaCompletion.js";
|
|
10
|
+
import withOra from "../../utils/withOra.js";
|
|
11
|
+
import { TokenMeter } from "../../evaluator/TokenMeter.js";
|
|
12
|
+
import { printInfoLine } from "../utils/printInfoLine.js";
|
|
13
|
+
import { printCommonInfoLines } from "../utils/printCommonInfoLines.js";
|
|
14
|
+
import { resolveCommandGgufPath } from "../utils/resolveCommandGgufPath.js";
|
|
15
|
+
import { withProgressLog } from "../../utils/withProgressLog.js";
|
|
16
|
+
import { resolveHeaderFlag } from "../utils/resolveHeaderFlag.js";
|
|
17
|
+
import { withCliCommandDescriptionDocsUrl } from "../utils/withCliCommandDescriptionDocsUrl.js";
|
|
18
|
+
import { documentationPageUrls } from "../../config.js";
|
|
19
|
+
import { ConsoleInteraction, ConsoleInteractionKey } from "../utils/ConsoleInteraction.js";
|
|
20
|
+
import { DraftSequenceTokenPredictor } from "../../evaluator/LlamaContext/tokenPredictors/DraftSequenceTokenPredictor.js";
|
|
21
|
+
import { parseXtcArg } from "../utils/parseXtcArg.js";
|
|
22
|
+
import { GgmlType } from "../../gguf/types/GgufTensorInfoTypes.js";
|
|
23
|
+
export const InfillCommand = {
|
|
24
|
+
command: "infill [modelPath]",
|
|
25
|
+
describe: withCliCommandDescriptionDocsUrl("Generate an infill completion for a given suffix and prefix texts", documentationPageUrls.CLI.Infill),
|
|
26
|
+
builder(yargs) {
|
|
27
|
+
return yargs
|
|
28
|
+
.option("modelPath", {
|
|
29
|
+
alias: ["m", "model", "path", "url", "uri"],
|
|
30
|
+
type: "string",
|
|
31
|
+
description: "Model file to use for the infill. Can be a path to a local file or a URI of a model file to download. Leave empty to choose from a list of recommended models"
|
|
32
|
+
})
|
|
33
|
+
.option("header", {
|
|
34
|
+
alias: ["H"],
|
|
35
|
+
type: "string",
|
|
36
|
+
array: true,
|
|
37
|
+
description: "Headers to use when downloading a model from a URL, in the format `key: value`. You can pass this option multiple times to add multiple headers."
|
|
38
|
+
})
|
|
39
|
+
.option("gpu", {
|
|
40
|
+
type: "string",
|
|
41
|
+
// yargs types don't support passing `false` as a choice, although it is supported by yargs
|
|
42
|
+
choices: nodeLlamaCppGpuOptions,
|
|
43
|
+
coerce: (value) => {
|
|
44
|
+
if (value == null || value == "")
|
|
45
|
+
return undefined;
|
|
46
|
+
return parseNodeLlamaCppGpuOption(value);
|
|
47
|
+
},
|
|
48
|
+
defaultDescription: "Uses the latest local build, and fallbacks to \"auto\"",
|
|
49
|
+
description: "Compute layer implementation type to use for llama.cpp. If omitted, uses the latest local build, and fallbacks to \"auto\""
|
|
50
|
+
})
|
|
51
|
+
.option("systemInfo", {
|
|
52
|
+
alias: "i",
|
|
53
|
+
type: "boolean",
|
|
54
|
+
default: false,
|
|
55
|
+
description: "Print llama.cpp system info"
|
|
56
|
+
})
|
|
57
|
+
.option("prefix", {
|
|
58
|
+
type: "string",
|
|
59
|
+
description: "First prefix text to automatically load"
|
|
60
|
+
})
|
|
61
|
+
.option("prefixFile", {
|
|
62
|
+
type: "string",
|
|
63
|
+
description: "Path to a file to load prefix text from automatically"
|
|
64
|
+
})
|
|
65
|
+
.option("suffix", {
|
|
66
|
+
type: "string",
|
|
67
|
+
description: "First suffix text to automatically load. Requires `prefix` or `prefixFile` to be set"
|
|
68
|
+
})
|
|
69
|
+
.option("suffixFile", {
|
|
70
|
+
type: "string",
|
|
71
|
+
description: "Path to a file to load suffix text from automatically. Requires `prefix` or `prefixFile` to be set"
|
|
72
|
+
})
|
|
73
|
+
.option("contextSize", {
|
|
74
|
+
alias: "c",
|
|
75
|
+
type: "number",
|
|
76
|
+
description: "Context size to use for the model context",
|
|
77
|
+
default: -1,
|
|
78
|
+
defaultDescription: "Automatically determined based on the available VRAM"
|
|
79
|
+
})
|
|
80
|
+
.option("batchSize", {
|
|
81
|
+
alias: "b",
|
|
82
|
+
type: "number",
|
|
83
|
+
description: "Batch size to use for the model context"
|
|
84
|
+
})
|
|
85
|
+
.option("flashAttention", {
|
|
86
|
+
alias: "fa",
|
|
87
|
+
type: "boolean",
|
|
88
|
+
default: false,
|
|
89
|
+
description: "Enable flash attention"
|
|
90
|
+
})
|
|
91
|
+
.option("kvCacheKeyType", {
|
|
92
|
+
alias: "kvckt",
|
|
93
|
+
type: "string",
|
|
94
|
+
choices: [
|
|
95
|
+
"currentQuant",
|
|
96
|
+
...Object.keys(GgmlType).filter((key) => !/^\d+$/i.test(key))
|
|
97
|
+
],
|
|
98
|
+
default: "F16",
|
|
99
|
+
description: "Experimental. The type of the key for the context KV cache tensors. Use `currentQuant` to use the same type as the current quantization of the model weights tensors"
|
|
100
|
+
})
|
|
101
|
+
.option("kvCacheValueType", {
|
|
102
|
+
alias: "kvcvt",
|
|
103
|
+
type: "string",
|
|
104
|
+
choices: [
|
|
105
|
+
"currentQuant",
|
|
106
|
+
...Object.keys(GgmlType).filter((key) => !/^\d+$/i.test(key))
|
|
107
|
+
],
|
|
108
|
+
default: "F16",
|
|
109
|
+
description: "Experimental. The type of the value for the context KV cache tensors. Use `currentQuant` to use the same type as the current quantization of the model weights tensors"
|
|
110
|
+
})
|
|
111
|
+
.option("swaFullCache", {
|
|
112
|
+
alias: "noSwa",
|
|
113
|
+
type: "boolean",
|
|
114
|
+
default: false,
|
|
115
|
+
description: "Disable SWA (Sliding Window Attention) on supported models"
|
|
116
|
+
})
|
|
117
|
+
.option("threads", {
|
|
118
|
+
type: "number",
|
|
119
|
+
defaultDescription: "Number of cores that are useful for math on the current machine",
|
|
120
|
+
description: "Number of threads to use for the evaluation of tokens"
|
|
121
|
+
})
|
|
122
|
+
.option("temperature", {
|
|
123
|
+
alias: "t",
|
|
124
|
+
type: "number",
|
|
125
|
+
default: 0,
|
|
126
|
+
description: "Temperature is a hyperparameter that controls the randomness of the generated text. It affects the probability distribution of the model's output tokens. A higher temperature (e.g., 1.5) makes the output more random and creative, while a lower temperature (e.g., 0.5) makes the output more focused, deterministic, and conservative. The suggested temperature is 0.8, which provides a balance between randomness and determinism. At the extreme, a temperature of 0 will always pick the most likely next token, leading to identical outputs in each run. Set to `0` to disable."
|
|
127
|
+
})
|
|
128
|
+
.option("minP", {
|
|
129
|
+
alias: "mp",
|
|
130
|
+
type: "number",
|
|
131
|
+
default: 0,
|
|
132
|
+
description: "From the next token candidates, discard the percentage of tokens with the lowest probability. For example, if set to `0.05`, 5% of the lowest probability tokens will be discarded. This is useful for generating more high-quality results when using a high temperature. Set to a value between `0` and `1` to enable. Only relevant when `temperature` is set to a value greater than `0`."
|
|
133
|
+
})
|
|
134
|
+
.option("topK", {
|
|
135
|
+
alias: "k",
|
|
136
|
+
type: "number",
|
|
137
|
+
default: 40,
|
|
138
|
+
description: "Limits the model to consider only the K most likely next tokens for sampling at each step of sequence generation. An integer number between `1` and the size of the vocabulary. Set to `0` to disable (which uses the full vocabulary). Only relevant when `temperature` is set to a value greater than 0."
|
|
139
|
+
})
|
|
140
|
+
.option("topP", {
|
|
141
|
+
alias: "p",
|
|
142
|
+
type: "number",
|
|
143
|
+
default: 0.95,
|
|
144
|
+
description: "Dynamically selects the smallest set of tokens whose cumulative probability exceeds the threshold P, and samples the next token only from this set. A float number between `0` and `1`. Set to `1` to disable. Only relevant when `temperature` is set to a value greater than `0`."
|
|
145
|
+
})
|
|
146
|
+
.option("seed", {
|
|
147
|
+
type: "number",
|
|
148
|
+
description: "Used to control the randomness of the generated text. Only relevant when using `temperature`.",
|
|
149
|
+
defaultDescription: "The current epoch time"
|
|
150
|
+
})
|
|
151
|
+
.option("xtc", {
|
|
152
|
+
type: "string",
|
|
153
|
+
description: "Exclude Top Choices (XTC) removes the top tokens from consideration and avoids more obvious and repetitive generations. `probability` (a number between `0` and `1`) controls the chance that the top tokens will be removed in the next token generation step, `threshold` (a number between `0` and `1`) controls the minimum probability of a token for it to be removed. Set this argument to `probability,threshold` to set both values. For example, `0.5,0.1`",
|
|
154
|
+
coerce: parseXtcArg
|
|
155
|
+
})
|
|
156
|
+
.option("gpuLayers", {
|
|
157
|
+
alias: "gl",
|
|
158
|
+
type: "number",
|
|
159
|
+
description: "number of layers to store in VRAM",
|
|
160
|
+
default: -1,
|
|
161
|
+
defaultDescription: "Automatically determined based on the available VRAM"
|
|
162
|
+
})
|
|
163
|
+
.option("repeatPenalty", {
|
|
164
|
+
alias: "rp",
|
|
165
|
+
type: "number",
|
|
166
|
+
default: 1.1,
|
|
167
|
+
description: "Prevent the model from repeating the same token too much. Set to `1` to disable."
|
|
168
|
+
})
|
|
169
|
+
.option("lastTokensRepeatPenalty", {
|
|
170
|
+
alias: "rpn",
|
|
171
|
+
type: "number",
|
|
172
|
+
default: 64,
|
|
173
|
+
description: "Number of recent tokens generated by the model to apply penalties to repetition of"
|
|
174
|
+
})
|
|
175
|
+
.option("penalizeRepeatingNewLine", {
|
|
176
|
+
alias: "rpnl",
|
|
177
|
+
type: "boolean",
|
|
178
|
+
default: true,
|
|
179
|
+
description: "Penalize new line tokens. set `--no-penalizeRepeatingNewLine` or `--no-rpnl` to disable"
|
|
180
|
+
})
|
|
181
|
+
.option("repeatFrequencyPenalty", {
|
|
182
|
+
alias: "rfp",
|
|
183
|
+
type: "number",
|
|
184
|
+
description: "For n time a token is in the `punishTokens` array, lower its probability by `n * repeatFrequencyPenalty`. Set to a value between `0` and `1` to enable."
|
|
185
|
+
})
|
|
186
|
+
.option("repeatPresencePenalty", {
|
|
187
|
+
alias: "rpp",
|
|
188
|
+
type: "number",
|
|
189
|
+
description: "Lower the probability of all the tokens in the `punishTokens` array by `repeatPresencePenalty`. Set to a value between `0` and `1` to enable."
|
|
190
|
+
})
|
|
191
|
+
.option("dryRepeatPenaltyStrength", {
|
|
192
|
+
alias: ["drps", "dryStrength"],
|
|
193
|
+
type: "number",
|
|
194
|
+
default: 0,
|
|
195
|
+
description: "The strength for DRY (Do Repeat Yourself) penalties. A number between `0` and `1`, where `0` means no DRY penalties, and `1` means full strength DRY penalties. The recommended value is `0.8`."
|
|
196
|
+
})
|
|
197
|
+
.option("dryRepeatPenaltyBase", {
|
|
198
|
+
alias: ["drpb", "dryBase"],
|
|
199
|
+
type: "number",
|
|
200
|
+
default: 1.75,
|
|
201
|
+
description: "The base value for the exponential penality calculation for DRY (Do Repeat Yourself) penalties. A higher value will lead to more aggressive penalization of repetitions."
|
|
202
|
+
})
|
|
203
|
+
.option("dryRepeatPenaltyAllowedLength", {
|
|
204
|
+
alias: ["drpal", "dryAllowedLength"],
|
|
205
|
+
type: "number",
|
|
206
|
+
default: 2,
|
|
207
|
+
description: "The maximum sequence length (in tokens) that DRY (Do Repeat Yourself) will allow to be repeated without being penalized. Repetitions shorter than or equal to this length will not be penalized."
|
|
208
|
+
})
|
|
209
|
+
.option("dryRepeatPenaltyLastTokens", {
|
|
210
|
+
alias: ["drplt", "dryLastTokens"],
|
|
211
|
+
type: "number",
|
|
212
|
+
default: -1,
|
|
213
|
+
description: "Number of recent tokens generated by the model for DRY (Do Repeat Yourself) to consider for sequence repetition matching. Set to `-1` to consider all tokens in the context sequence. Setting to `0` will disable DRY penalties."
|
|
214
|
+
})
|
|
215
|
+
.option("maxTokens", {
|
|
216
|
+
alias: "mt",
|
|
217
|
+
type: "number",
|
|
218
|
+
default: 0,
|
|
219
|
+
description: "Maximum number of tokens to generate in responses. Set to `0` to disable. Set to `-1` to set to the context size"
|
|
220
|
+
})
|
|
221
|
+
.option("tokenPredictionDraftModel", {
|
|
222
|
+
alias: ["dm", "draftModel"],
|
|
223
|
+
type: "string",
|
|
224
|
+
description: "Model file to use for draft sequence token prediction (speculative decoding). Can be a path to a local file or a URI of a model file to download"
|
|
225
|
+
})
|
|
226
|
+
.option("tokenPredictionModelContextSize", {
|
|
227
|
+
alias: ["dc", "draftContextSize", "draftContext"],
|
|
228
|
+
type: "number",
|
|
229
|
+
description: "Max context size to use for the draft sequence token prediction model context",
|
|
230
|
+
default: 4096
|
|
231
|
+
})
|
|
232
|
+
.option("debug", {
|
|
233
|
+
alias: "d",
|
|
234
|
+
type: "boolean",
|
|
235
|
+
default: false,
|
|
236
|
+
description: "Print llama.cpp info and debug logs"
|
|
237
|
+
})
|
|
238
|
+
.option("numa", {
|
|
239
|
+
type: "string",
|
|
240
|
+
// yargs types don't support passing `false` as a choice, although it is supported by yargs
|
|
241
|
+
choices: llamaNumaOptions,
|
|
242
|
+
coerce: (value) => {
|
|
243
|
+
if (value == null || value == "")
|
|
244
|
+
return false;
|
|
245
|
+
return parseNumaOption(value);
|
|
246
|
+
},
|
|
247
|
+
defaultDescription: "false",
|
|
248
|
+
description: "NUMA allocation policy. See the `numa` option on the `getLlama` method for more information"
|
|
249
|
+
})
|
|
250
|
+
.option("meter", {
|
|
251
|
+
type: "boolean",
|
|
252
|
+
default: false,
|
|
253
|
+
description: "Log how many tokens were used as input and output for each response"
|
|
254
|
+
})
|
|
255
|
+
.option("timing", {
|
|
256
|
+
type: "boolean",
|
|
257
|
+
default: false,
|
|
258
|
+
description: "Print how how long it took to generate each response"
|
|
259
|
+
})
|
|
260
|
+
.option("noMmap", {
|
|
261
|
+
type: "boolean",
|
|
262
|
+
default: false,
|
|
263
|
+
description: "Disable mmap (memory-mapped file) usage"
|
|
264
|
+
})
|
|
265
|
+
.option("useDirectIo", {
|
|
266
|
+
type: "boolean",
|
|
267
|
+
default: false,
|
|
268
|
+
description: "Use Direct I/O usage when available"
|
|
269
|
+
})
|
|
270
|
+
.option("printTimings", {
|
|
271
|
+
alias: "pt",
|
|
272
|
+
type: "boolean",
|
|
273
|
+
default: false,
|
|
274
|
+
description: "Print llama.cpp's internal timings after each response"
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
async handler({ modelPath, header, gpu, systemInfo, prefix, prefixFile, suffix, suffixFile, contextSize, batchSize, flashAttention, kvCacheKeyType, kvCacheValueType, swaFullCache, threads, temperature, minP, topK, topP, seed, xtc, gpuLayers, repeatPenalty, lastTokensRepeatPenalty, penalizeRepeatingNewLine, repeatFrequencyPenalty, repeatPresencePenalty, dryRepeatPenaltyStrength, dryRepeatPenaltyBase, dryRepeatPenaltyAllowedLength, dryRepeatPenaltyLastTokens, maxTokens, tokenPredictionDraftModel, tokenPredictionModelContextSize, debug, numa, meter, timing, noMmap, useDirectIo, printTimings }) {
|
|
278
|
+
try {
|
|
279
|
+
await RunInfill({
|
|
280
|
+
modelPath, header, gpu, systemInfo, prefix, prefixFile, suffix, suffixFile, contextSize, batchSize, flashAttention,
|
|
281
|
+
kvCacheKeyType, kvCacheValueType, swaFullCache, threads, temperature, minP, topK, topP, seed, xtc, gpuLayers,
|
|
282
|
+
lastTokensRepeatPenalty,
|
|
283
|
+
repeatPenalty, penalizeRepeatingNewLine, repeatFrequencyPenalty, repeatPresencePenalty, dryRepeatPenaltyStrength,
|
|
284
|
+
dryRepeatPenaltyBase, dryRepeatPenaltyAllowedLength, dryRepeatPenaltyLastTokens, maxTokens,
|
|
285
|
+
tokenPredictionDraftModel, tokenPredictionModelContextSize, debug, numa, meter, timing, noMmap, useDirectIo, printTimings
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
catch (err) {
|
|
289
|
+
await new Promise((accept) => setTimeout(accept, 0)); // wait for logs to finish printing
|
|
290
|
+
console.error(err);
|
|
291
|
+
process.exit(1);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
async function RunInfill({ modelPath: modelArg, header: headerArg, gpu, systemInfo, prefix, prefixFile, suffix, suffixFile, contextSize, batchSize, flashAttention, kvCacheKeyType, kvCacheValueType, swaFullCache, threads, temperature, minP, topK, topP, seed, xtc, gpuLayers, lastTokensRepeatPenalty, repeatPenalty, penalizeRepeatingNewLine, repeatFrequencyPenalty, repeatPresencePenalty, dryRepeatPenaltyStrength, dryRepeatPenaltyBase, dryRepeatPenaltyAllowedLength, dryRepeatPenaltyLastTokens, tokenPredictionDraftModel, tokenPredictionModelContextSize, maxTokens, debug, numa, meter, timing, noMmap, useDirectIo, printTimings }) {
|
|
296
|
+
if (contextSize === -1)
|
|
297
|
+
contextSize = undefined;
|
|
298
|
+
if (gpuLayers === -1)
|
|
299
|
+
gpuLayers = undefined;
|
|
300
|
+
const headers = resolveHeaderFlag(headerArg);
|
|
301
|
+
if (debug)
|
|
302
|
+
console.info(`${chalk.yellow("Log level:")} debug`);
|
|
303
|
+
const llamaLogLevel = debug
|
|
304
|
+
? LlamaLogLevel.debug
|
|
305
|
+
: LlamaLogLevel.warn;
|
|
306
|
+
const llama = gpu == null
|
|
307
|
+
? await getLlama("lastBuild", {
|
|
308
|
+
logLevel: llamaLogLevel,
|
|
309
|
+
numa
|
|
310
|
+
})
|
|
311
|
+
: await getLlama({
|
|
312
|
+
gpu,
|
|
313
|
+
logLevel: llamaLogLevel,
|
|
314
|
+
numa
|
|
315
|
+
});
|
|
316
|
+
const logBatchSize = batchSize != null;
|
|
317
|
+
const useMmap = !noMmap && llama.supportsMmap;
|
|
318
|
+
const resolvedModelPath = await resolveCommandGgufPath(modelArg, llama, headers, {
|
|
319
|
+
flashAttention,
|
|
320
|
+
swaFullCache,
|
|
321
|
+
useMmap,
|
|
322
|
+
kvCacheKeyType,
|
|
323
|
+
kvCacheValueType
|
|
324
|
+
});
|
|
325
|
+
const resolvedDraftModelPath = (tokenPredictionDraftModel != null && tokenPredictionDraftModel !== "")
|
|
326
|
+
? await resolveCommandGgufPath(tokenPredictionDraftModel, llama, headers, {
|
|
327
|
+
flashAttention,
|
|
328
|
+
swaFullCache,
|
|
329
|
+
useMmap,
|
|
330
|
+
kvCacheKeyType,
|
|
331
|
+
kvCacheValueType,
|
|
332
|
+
consoleTitle: "Draft model file"
|
|
333
|
+
})
|
|
334
|
+
: undefined;
|
|
335
|
+
if (systemInfo)
|
|
336
|
+
console.log(llama.systemInfo);
|
|
337
|
+
if (prefixFile != null && prefixFile !== "") {
|
|
338
|
+
if (prefix != null && prefix !== "")
|
|
339
|
+
console.warn(chalk.yellow("Both `prefix` and `prefixFile` were specified. `prefixFile` will be used."));
|
|
340
|
+
prefix = await fs.readFile(path.resolve(process.cwd(), prefixFile), "utf8");
|
|
341
|
+
}
|
|
342
|
+
if (suffixFile != null && suffixFile !== "") {
|
|
343
|
+
if (suffix != null && suffix !== "")
|
|
344
|
+
console.warn(chalk.yellow("Both `suffix` and `suffixFile` were specified. `suffixFile` will be used."));
|
|
345
|
+
suffix = await fs.readFile(path.resolve(process.cwd(), suffixFile), "utf8");
|
|
346
|
+
}
|
|
347
|
+
if (suffix != null && prefix == null) {
|
|
348
|
+
console.warn(chalk.yellow("Suffix was specified but no prefix was specified. Suffix will be ignored."));
|
|
349
|
+
suffix = undefined;
|
|
350
|
+
}
|
|
351
|
+
if (batchSize != null && contextSize != null && batchSize > contextSize) {
|
|
352
|
+
console.warn(chalk.yellow("Batch size is greater than the context size. Batch size will be set to the context size."));
|
|
353
|
+
batchSize = contextSize;
|
|
354
|
+
}
|
|
355
|
+
let initialPrefix = prefix ?? null;
|
|
356
|
+
let initialSuffix = suffix ?? null;
|
|
357
|
+
const model = await withProgressLog({
|
|
358
|
+
loadingText: chalk.blue.bold("Loading model"),
|
|
359
|
+
successText: chalk.blue("Model loaded"),
|
|
360
|
+
failText: chalk.blue("Failed to load model"),
|
|
361
|
+
liveUpdates: !debug,
|
|
362
|
+
noProgress: debug,
|
|
363
|
+
liveCtrlCSendsAbortSignal: true
|
|
364
|
+
}, async (progressUpdater) => {
|
|
365
|
+
try {
|
|
366
|
+
return await llama.loadModel({
|
|
367
|
+
modelPath: resolvedModelPath,
|
|
368
|
+
gpuLayers: gpuLayers != null
|
|
369
|
+
? gpuLayers
|
|
370
|
+
: contextSize != null
|
|
371
|
+
? { fitContext: { contextSize } }
|
|
372
|
+
: undefined,
|
|
373
|
+
defaultContextFlashAttention: flashAttention,
|
|
374
|
+
experimentalDefaultContextKvCacheKeyType: kvCacheKeyType,
|
|
375
|
+
experimentalDefaultContextKvCacheValueType: kvCacheValueType,
|
|
376
|
+
defaultContextSwaFullCache: swaFullCache,
|
|
377
|
+
useMmap,
|
|
378
|
+
useDirectIo,
|
|
379
|
+
ignoreMemorySafetyChecks: gpuLayers != null,
|
|
380
|
+
onLoadProgress(loadProgress) {
|
|
381
|
+
progressUpdater.setProgress(loadProgress);
|
|
382
|
+
},
|
|
383
|
+
loadSignal: progressUpdater.abortSignal
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
catch (err) {
|
|
387
|
+
if (err === progressUpdater.abortSignal?.reason)
|
|
388
|
+
process.exit(0);
|
|
389
|
+
throw err;
|
|
390
|
+
}
|
|
391
|
+
finally {
|
|
392
|
+
if (llama.logLevel === LlamaLogLevel.debug) {
|
|
393
|
+
await new Promise((accept) => setTimeout(accept, 0)); // wait for logs to finish printing
|
|
394
|
+
console.info();
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
const draftModel = resolvedDraftModelPath == null
|
|
399
|
+
? undefined
|
|
400
|
+
: await withProgressLog({
|
|
401
|
+
loadingText: chalk.blue.bold("Loading draft model"),
|
|
402
|
+
successText: chalk.blue("Draft model loaded"),
|
|
403
|
+
failText: chalk.blue("Failed to load draft model"),
|
|
404
|
+
liveUpdates: !debug,
|
|
405
|
+
noProgress: debug,
|
|
406
|
+
liveCtrlCSendsAbortSignal: true
|
|
407
|
+
}, async (progressUpdater) => {
|
|
408
|
+
try {
|
|
409
|
+
return await llama.loadModel({
|
|
410
|
+
modelPath: resolvedDraftModelPath,
|
|
411
|
+
defaultContextFlashAttention: flashAttention,
|
|
412
|
+
experimentalDefaultContextKvCacheKeyType: kvCacheKeyType,
|
|
413
|
+
experimentalDefaultContextKvCacheValueType: kvCacheValueType,
|
|
414
|
+
defaultContextSwaFullCache: swaFullCache,
|
|
415
|
+
useMmap,
|
|
416
|
+
useDirectIo,
|
|
417
|
+
onLoadProgress(loadProgress) {
|
|
418
|
+
progressUpdater.setProgress(loadProgress);
|
|
419
|
+
},
|
|
420
|
+
loadSignal: progressUpdater.abortSignal
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
catch (err) {
|
|
424
|
+
if (err === progressUpdater.abortSignal?.reason)
|
|
425
|
+
process.exit(0);
|
|
426
|
+
throw err;
|
|
427
|
+
}
|
|
428
|
+
finally {
|
|
429
|
+
if (llama.logLevel === LlamaLogLevel.debug) {
|
|
430
|
+
await new Promise((accept) => setTimeout(accept, 0)); // wait for logs to finish printing
|
|
431
|
+
console.info();
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
const draftContext = draftModel == null
|
|
436
|
+
? undefined
|
|
437
|
+
: await withOra({
|
|
438
|
+
loading: chalk.blue("Creating draft context"),
|
|
439
|
+
success: chalk.blue("Draft context created"),
|
|
440
|
+
fail: chalk.blue("Failed to create draft context"),
|
|
441
|
+
useStatusLogs: debug
|
|
442
|
+
}, async () => {
|
|
443
|
+
try {
|
|
444
|
+
return await draftModel.createContext({
|
|
445
|
+
contextSize: { max: tokenPredictionModelContextSize }
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
finally {
|
|
449
|
+
if (llama.logLevel === LlamaLogLevel.debug) {
|
|
450
|
+
await new Promise((accept) => setTimeout(accept, 0)); // wait for logs to finish printing
|
|
451
|
+
console.info();
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
const context = await withOra({
|
|
456
|
+
loading: chalk.blue("Creating context"),
|
|
457
|
+
success: chalk.blue("Context created"),
|
|
458
|
+
fail: chalk.blue("Failed to create context"),
|
|
459
|
+
useStatusLogs: debug
|
|
460
|
+
}, async () => {
|
|
461
|
+
try {
|
|
462
|
+
return await model.createContext({
|
|
463
|
+
contextSize: contextSize != null ? contextSize : undefined,
|
|
464
|
+
batchSize: batchSize != null ? batchSize : undefined,
|
|
465
|
+
threads: threads === null ? undefined : threads,
|
|
466
|
+
ignoreMemorySafetyChecks: gpuLayers != null || contextSize != null,
|
|
467
|
+
performanceTracking: printTimings
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
finally {
|
|
471
|
+
if (llama.logLevel === LlamaLogLevel.debug) {
|
|
472
|
+
await new Promise((accept) => setTimeout(accept, 0)); // wait for logs to finish printing
|
|
473
|
+
console.info();
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
const draftContextSequence = draftContext?.getSequence();
|
|
478
|
+
const contextSequence = draftContextSequence != null
|
|
479
|
+
? context.getSequence({
|
|
480
|
+
tokenPredictor: new DraftSequenceTokenPredictor(draftContextSequence)
|
|
481
|
+
})
|
|
482
|
+
: context.getSequence();
|
|
483
|
+
const completion = new LlamaCompletion({
|
|
484
|
+
contextSequence
|
|
485
|
+
});
|
|
486
|
+
let lastDraftTokenMeterState = draftContextSequence?.tokenMeter.getState();
|
|
487
|
+
let lastTokenMeterState = contextSequence.tokenMeter.getState();
|
|
488
|
+
let lastTokenPredictionsStats = contextSequence.tokenPredictions;
|
|
489
|
+
await new Promise((accept) => setTimeout(accept, 0)); // wait for logs to finish printing
|
|
490
|
+
const padTitle = await printCommonInfoLines({
|
|
491
|
+
context,
|
|
492
|
+
draftContext,
|
|
493
|
+
useMmap,
|
|
494
|
+
useDirectIo,
|
|
495
|
+
logBatchSize,
|
|
496
|
+
tokenMeterEnabled: meter
|
|
497
|
+
});
|
|
498
|
+
printInfoLine({
|
|
499
|
+
title: "Infill",
|
|
500
|
+
padTitle: padTitle,
|
|
501
|
+
info: [{
|
|
502
|
+
title: "Repeat penalty",
|
|
503
|
+
value: `${repeatPenalty} (apply to last ${lastTokensRepeatPenalty} tokens)`
|
|
504
|
+
}, {
|
|
505
|
+
show: repeatFrequencyPenalty != null,
|
|
506
|
+
title: "Repeat frequency penalty",
|
|
507
|
+
value: String(repeatFrequencyPenalty)
|
|
508
|
+
}, {
|
|
509
|
+
show: repeatPresencePenalty != null,
|
|
510
|
+
title: "Repeat presence penalty",
|
|
511
|
+
value: String(repeatPresencePenalty)
|
|
512
|
+
}, {
|
|
513
|
+
show: !penalizeRepeatingNewLine,
|
|
514
|
+
title: "Penalize repeating new line",
|
|
515
|
+
value: "disabled"
|
|
516
|
+
}, {
|
|
517
|
+
show: dryRepeatPenaltyStrength != null && dryRepeatPenaltyStrength !== 0,
|
|
518
|
+
title: "DRY strength",
|
|
519
|
+
value: String(dryRepeatPenaltyStrength) + " (apply to " + (dryRepeatPenaltyLastTokens === -1
|
|
520
|
+
? "the entire context sequence"
|
|
521
|
+
: ("last " + dryRepeatPenaltyLastTokens + " tokens")) + ")"
|
|
522
|
+
}, {
|
|
523
|
+
show: dryRepeatPenaltyStrength != null && dryRepeatPenaltyStrength !== 0,
|
|
524
|
+
title: "DRY base",
|
|
525
|
+
value: String(dryRepeatPenaltyBase)
|
|
526
|
+
}, {
|
|
527
|
+
show: dryRepeatPenaltyStrength != null && dryRepeatPenaltyStrength !== 0,
|
|
528
|
+
title: "DRY allow length",
|
|
529
|
+
value: String(dryRepeatPenaltyAllowedLength)
|
|
530
|
+
}, {
|
|
531
|
+
show: xtc != null,
|
|
532
|
+
title: "XTC probability",
|
|
533
|
+
value: String(xtc?.probability)
|
|
534
|
+
}, {
|
|
535
|
+
show: xtc != null,
|
|
536
|
+
title: "XTC threshold",
|
|
537
|
+
value: String(xtc?.threshold)
|
|
538
|
+
}, {
|
|
539
|
+
show: timing,
|
|
540
|
+
title: "Response timing",
|
|
541
|
+
value: "enabled"
|
|
542
|
+
}]
|
|
543
|
+
});
|
|
544
|
+
// this is for ora to not interfere with readline
|
|
545
|
+
await new Promise((resolve) => setTimeout(resolve, 1));
|
|
546
|
+
if (!completion.infillSupported) {
|
|
547
|
+
console.log(chalk.red("Infill is not supported for this model"));
|
|
548
|
+
process.exit(1);
|
|
549
|
+
}
|
|
550
|
+
const replPrefixHistory = [];
|
|
551
|
+
const replSuffixHistory = [];
|
|
552
|
+
async function getInput(name) {
|
|
553
|
+
const rl = readline.createInterface({
|
|
554
|
+
input: process.stdin,
|
|
555
|
+
output: process.stdout,
|
|
556
|
+
history: name === "Prefix"
|
|
557
|
+
? replPrefixHistory.slice()
|
|
558
|
+
: replSuffixHistory.slice()
|
|
559
|
+
});
|
|
560
|
+
const res = await new Promise((accept) => rl.question(chalk.yellow(name + "> "), accept));
|
|
561
|
+
rl.close();
|
|
562
|
+
return res;
|
|
563
|
+
}
|
|
564
|
+
while (true) {
|
|
565
|
+
const prefixInput = initialPrefix != null
|
|
566
|
+
? initialPrefix
|
|
567
|
+
: await getInput("Prefix");
|
|
568
|
+
if (initialPrefix != null) {
|
|
569
|
+
console.log(chalk.green("Prefix> ") + initialPrefix);
|
|
570
|
+
initialPrefix = null;
|
|
571
|
+
}
|
|
572
|
+
else
|
|
573
|
+
await replPrefixHistory.push(prefixInput);
|
|
574
|
+
if (prefixInput === ".exit")
|
|
575
|
+
break;
|
|
576
|
+
const suffixInput = initialSuffix != null
|
|
577
|
+
? initialSuffix
|
|
578
|
+
: await getInput("Suffix");
|
|
579
|
+
if (initialSuffix != null) {
|
|
580
|
+
console.log(chalk.green("Suffix> ") + initialSuffix);
|
|
581
|
+
initialSuffix = null;
|
|
582
|
+
}
|
|
583
|
+
else
|
|
584
|
+
await replSuffixHistory.push(suffixInput);
|
|
585
|
+
if (suffixInput === ".exit")
|
|
586
|
+
break;
|
|
587
|
+
process.stdout.write(chalk.yellow("Infill: "));
|
|
588
|
+
const [startColor, endColor] = chalk.blue("MIDDLE").split("MIDDLE");
|
|
589
|
+
const abortController = new AbortController();
|
|
590
|
+
const consoleInteraction = new ConsoleInteraction();
|
|
591
|
+
consoleInteraction.onKey(ConsoleInteractionKey.ctrlC, async () => {
|
|
592
|
+
abortController.abort();
|
|
593
|
+
consoleInteraction.stop();
|
|
594
|
+
});
|
|
595
|
+
const timeBeforePrompt = Date.now();
|
|
596
|
+
try {
|
|
597
|
+
process.stdout.write(startColor);
|
|
598
|
+
consoleInteraction.start();
|
|
599
|
+
await completion.generateInfillCompletion(prefixInput, suffixInput, {
|
|
600
|
+
temperature,
|
|
601
|
+
minP,
|
|
602
|
+
topK,
|
|
603
|
+
topP,
|
|
604
|
+
seed: seed ?? undefined,
|
|
605
|
+
xtc,
|
|
606
|
+
signal: abortController.signal,
|
|
607
|
+
repeatPenalty: {
|
|
608
|
+
penalty: repeatPenalty,
|
|
609
|
+
frequencyPenalty: repeatFrequencyPenalty != null ? repeatFrequencyPenalty : undefined,
|
|
610
|
+
presencePenalty: repeatPresencePenalty != null ? repeatPresencePenalty : undefined,
|
|
611
|
+
penalizeNewLine: penalizeRepeatingNewLine,
|
|
612
|
+
lastTokens: lastTokensRepeatPenalty
|
|
613
|
+
},
|
|
614
|
+
dryRepeatPenalty: dryRepeatPenaltyStrength == null ? undefined : {
|
|
615
|
+
strength: dryRepeatPenaltyStrength,
|
|
616
|
+
base: dryRepeatPenaltyBase,
|
|
617
|
+
allowedLength: dryRepeatPenaltyAllowedLength,
|
|
618
|
+
lastTokens: dryRepeatPenaltyLastTokens === -1
|
|
619
|
+
? null
|
|
620
|
+
: dryRepeatPenaltyLastTokens
|
|
621
|
+
},
|
|
622
|
+
maxTokens: maxTokens === -1
|
|
623
|
+
? context.contextSize
|
|
624
|
+
: maxTokens <= 0
|
|
625
|
+
? undefined
|
|
626
|
+
: maxTokens,
|
|
627
|
+
onTextChunk(chunk) {
|
|
628
|
+
process.stdout.write(chunk);
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
catch (err) {
|
|
633
|
+
if (!(abortController.signal.aborted && err === abortController.signal.reason))
|
|
634
|
+
throw err;
|
|
635
|
+
}
|
|
636
|
+
finally {
|
|
637
|
+
consoleInteraction.stop();
|
|
638
|
+
if (abortController.signal.aborted)
|
|
639
|
+
process.stdout.write(endColor + chalk.yellow("[generation aborted by user]"));
|
|
640
|
+
else
|
|
641
|
+
process.stdout.write(endColor);
|
|
642
|
+
console.log();
|
|
643
|
+
}
|
|
644
|
+
const timeAfterPrompt = Date.now();
|
|
645
|
+
if (printTimings) {
|
|
646
|
+
if (LlamaLogLevelGreaterThan(llama.logLevel, LlamaLogLevel.info))
|
|
647
|
+
llama.logLevel = LlamaLogLevel.info;
|
|
648
|
+
await context.printTimings();
|
|
649
|
+
await new Promise((accept) => setTimeout(accept, 0)); // wait for logs to finish printing
|
|
650
|
+
llama.logLevel = llamaLogLevel;
|
|
651
|
+
}
|
|
652
|
+
if (timing)
|
|
653
|
+
console.info(chalk.dim("Response duration: ") +
|
|
654
|
+
prettyMilliseconds(timeAfterPrompt - timeBeforePrompt, {
|
|
655
|
+
keepDecimalsOnWholeSeconds: true,
|
|
656
|
+
secondsDecimalDigits: 2,
|
|
657
|
+
separateMilliseconds: true,
|
|
658
|
+
compact: false
|
|
659
|
+
}));
|
|
660
|
+
if (meter) {
|
|
661
|
+
const newTokenMeterState = contextSequence.tokenMeter.getState();
|
|
662
|
+
const tokenMeterDiff = TokenMeter.diff(newTokenMeterState, lastTokenMeterState);
|
|
663
|
+
lastTokenMeterState = newTokenMeterState;
|
|
664
|
+
const showDraftTokenMeterDiff = lastDraftTokenMeterState != null && draftContextSequence != null;
|
|
665
|
+
const tokenPredictionsStats = contextSequence.tokenPredictions;
|
|
666
|
+
const validatedTokenPredictions = tokenPredictionsStats.validated - lastTokenPredictionsStats.validated;
|
|
667
|
+
const refutedTokenPredictions = tokenPredictionsStats.refuted - lastTokenPredictionsStats.refuted;
|
|
668
|
+
const usedTokenPredictions = tokenPredictionsStats.used - lastTokenPredictionsStats.used;
|
|
669
|
+
const unusedTokenPredictions = tokenPredictionsStats.unused - lastTokenPredictionsStats.unused;
|
|
670
|
+
lastTokenPredictionsStats = tokenPredictionsStats;
|
|
671
|
+
console.info([
|
|
672
|
+
showDraftTokenMeterDiff && (chalk.yellow("Main".padEnd("Drafter".length))),
|
|
673
|
+
chalk.dim("Input tokens:") + " " + String(tokenMeterDiff.usedInputTokens).padEnd(5, " "),
|
|
674
|
+
chalk.dim("Output tokens:") + " " + String(tokenMeterDiff.usedOutputTokens).padEnd(5, " "),
|
|
675
|
+
showDraftTokenMeterDiff && (chalk.dim("Validated predictions:") + " " + String(validatedTokenPredictions).padEnd(5, " ")),
|
|
676
|
+
showDraftTokenMeterDiff && (chalk.dim("Refuted predictions:") + " " + String(refutedTokenPredictions).padEnd(5, " ")),
|
|
677
|
+
showDraftTokenMeterDiff && (chalk.dim("Used predictions:") + " " + String(usedTokenPredictions).padEnd(5, " ")),
|
|
678
|
+
showDraftTokenMeterDiff && (chalk.dim("Unused predictions:") + " " + String(unusedTokenPredictions).padEnd(5, " "))
|
|
679
|
+
].filter(Boolean).join(" "));
|
|
680
|
+
if (lastDraftTokenMeterState != null && draftContextSequence != null) {
|
|
681
|
+
const newDraftTokenMeterState = draftContextSequence.tokenMeter.getState();
|
|
682
|
+
const draftTokenMeterDiff = TokenMeter.diff(newDraftTokenMeterState, lastDraftTokenMeterState);
|
|
683
|
+
lastDraftTokenMeterState = newDraftTokenMeterState;
|
|
684
|
+
console.info([
|
|
685
|
+
chalk.yellow("Drafter"),
|
|
686
|
+
chalk.dim("Input tokens:") + " " + String(draftTokenMeterDiff.usedInputTokens).padEnd(5, " "),
|
|
687
|
+
chalk.dim("Output tokens:") + " " + String(draftTokenMeterDiff.usedOutputTokens).padEnd(5, " ")
|
|
688
|
+
].join(" "));
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
//# sourceMappingURL=InfillCommand.js.map
|