@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
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import { GbnfJsonSchema, GbnfJsonSchemaToType } from "./utils/gbnfJson/types.js";
|
|
2
|
+
import { LlamaText, BuiltinSpecialTokenValue, LlamaTextJSON } from "./utils/LlamaText.js";
|
|
3
|
+
import type { GgufFileInfo } from "./gguf/types/GgufFileInfoTypes.js";
|
|
4
|
+
export type Token = number & {
|
|
5
|
+
__token: never;
|
|
6
|
+
};
|
|
7
|
+
export type Detokenizer = {
|
|
8
|
+
detokenize(tokens: readonly Token[], specialTokens?: boolean, lastTokens?: readonly Token[]): string;
|
|
9
|
+
}["detokenize"];
|
|
10
|
+
export type Tokenizer = {
|
|
11
|
+
tokenize(text: string, specialTokens?: boolean, options?: "trimLeadingSpace"): Token[];
|
|
12
|
+
tokenize(text: BuiltinSpecialTokenValue, specialTokens: "builtin"): Token[];
|
|
13
|
+
}["tokenize"] & {
|
|
14
|
+
readonly detokenize: Detokenizer;
|
|
15
|
+
isSpecialToken(token: Token): boolean;
|
|
16
|
+
isEogToken(token: Token): boolean;
|
|
17
|
+
};
|
|
18
|
+
export type ChatWrapperSettings = {
|
|
19
|
+
readonly supportsSystemMessages: boolean;
|
|
20
|
+
readonly functions: {
|
|
21
|
+
readonly call: {
|
|
22
|
+
readonly optionalPrefixSpace: boolean;
|
|
23
|
+
readonly prefix: string | LlamaText;
|
|
24
|
+
readonly paramsPrefix: string | LlamaText;
|
|
25
|
+
readonly suffix: string | LlamaText;
|
|
26
|
+
/**
|
|
27
|
+
* The value to use when the function has no arguments.
|
|
28
|
+
*
|
|
29
|
+
* Will be stringified using `jsonDumps`.
|
|
30
|
+
*
|
|
31
|
+
* Defaults to `""`.
|
|
32
|
+
*/
|
|
33
|
+
readonly emptyCallParamsPlaceholder?: object | string | number | boolean | null;
|
|
34
|
+
};
|
|
35
|
+
readonly result: {
|
|
36
|
+
/**
|
|
37
|
+
* Supported template parameters:
|
|
38
|
+
* - <span v-pre>`{{functionName}}`</span>
|
|
39
|
+
* - <span v-pre>`{{functionParams}}`</span>
|
|
40
|
+
*
|
|
41
|
+
* Template parameters can only appear in a string or a string in a `LlamaText`.
|
|
42
|
+
*
|
|
43
|
+
* Template parameters inside a `SpecialTokensText` inside a `LlamaText` won't be replaced.
|
|
44
|
+
*
|
|
45
|
+
* Example of supported values:
|
|
46
|
+
* - `"text{{functionName}}text"`
|
|
47
|
+
* - `LlamaText(["text{{functionName}}text"])`
|
|
48
|
+
*
|
|
49
|
+
* Example of unsupported values:
|
|
50
|
+
* - `LlamaText([new SpecialTokensText("text{{functionName}}text")])`
|
|
51
|
+
*/
|
|
52
|
+
readonly prefix: string | LlamaText;
|
|
53
|
+
/**
|
|
54
|
+
* Supported template parameters:
|
|
55
|
+
* - <span v-pre>`{{functionName}}`</span>
|
|
56
|
+
* - <span v-pre>`{{functionParams}}`</span>
|
|
57
|
+
*
|
|
58
|
+
* Template parameters can only appear in a string or a string in a `LlamaText`.
|
|
59
|
+
*
|
|
60
|
+
* Template parameters inside a `SpecialTokensText` inside a `LlamaText` won't be replaced.
|
|
61
|
+
*
|
|
62
|
+
* Example of **supported** values:
|
|
63
|
+
* - `"text{{functionName}}text"`
|
|
64
|
+
* - `LlamaText(["text{{functionName}}text"])`
|
|
65
|
+
*
|
|
66
|
+
* Example of **unsupported** values:
|
|
67
|
+
* - `LlamaText([new SpecialTokensText("text{{functionName}}text")])`
|
|
68
|
+
*/
|
|
69
|
+
readonly suffix: string | LlamaText;
|
|
70
|
+
};
|
|
71
|
+
/** If this field is present, parallel function calling is supported */
|
|
72
|
+
readonly parallelism?: {
|
|
73
|
+
readonly call: {
|
|
74
|
+
readonly sectionPrefix: string | LlamaText;
|
|
75
|
+
/**
|
|
76
|
+
* Alternate section prefixes that can be used to detect a function call section,
|
|
77
|
+
* but won't be used to construct the context when building it from scratch.
|
|
78
|
+
*/
|
|
79
|
+
readonly sectionPrefixAlternateMatches?: Array<string | LlamaText>;
|
|
80
|
+
readonly betweenCalls?: string | LlamaText;
|
|
81
|
+
readonly sectionSuffix?: string | LlamaText;
|
|
82
|
+
};
|
|
83
|
+
readonly result?: {
|
|
84
|
+
readonly sectionPrefix?: string | LlamaText;
|
|
85
|
+
readonly betweenResults?: string | LlamaText;
|
|
86
|
+
readonly sectionSuffix?: string | LlamaText;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
readonly segments?: {
|
|
91
|
+
/** Consider all active segments to be closed when this text is detected */
|
|
92
|
+
readonly closeAllSegments?: string | LlamaText;
|
|
93
|
+
/**
|
|
94
|
+
* After function calls, reiterate the stack of the active segments to remind the model of the context.
|
|
95
|
+
*
|
|
96
|
+
* Defaults to `false`.
|
|
97
|
+
*/
|
|
98
|
+
readonly reiterateStackAfterFunctionCalls?: boolean;
|
|
99
|
+
/** Chain of Thought text segment */
|
|
100
|
+
readonly thought?: ChatWrapperSettingsSegment & {
|
|
101
|
+
reopenAfterFunctionCalls?: boolean;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Comment segment.
|
|
105
|
+
*
|
|
106
|
+
* Used by models such as gpt-oss.
|
|
107
|
+
*/
|
|
108
|
+
readonly comment?: ChatWrapperSettingsSegment;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export type ChatWrapperSettingsSegment = {
|
|
112
|
+
readonly prefix: string | LlamaText;
|
|
113
|
+
readonly suffix?: string | LlamaText;
|
|
114
|
+
};
|
|
115
|
+
export type ChatWrapperGenerateContextStateOptions = {
|
|
116
|
+
chatHistory: readonly ChatHistoryItem[];
|
|
117
|
+
availableFunctions?: ChatModelFunctions;
|
|
118
|
+
documentFunctionParams?: boolean;
|
|
119
|
+
};
|
|
120
|
+
export type ChatWrapperCheckModelCompatibilityParams = {
|
|
121
|
+
tokenizer?: Tokenizer;
|
|
122
|
+
fileInfo?: GgufFileInfo;
|
|
123
|
+
};
|
|
124
|
+
export type ChatWrapperGeneratedContextState = ChatWrapperGeneratedPrefixTriggersContextState | ChatWrapperGeneratedInitiallyEngagedFunctionsContextState;
|
|
125
|
+
export type ChatWrapperGeneratedPrefixTriggersContextState = {
|
|
126
|
+
/**
|
|
127
|
+
* The rendered chat to load into the context sequence state
|
|
128
|
+
*/
|
|
129
|
+
contextText: LlamaText;
|
|
130
|
+
/**
|
|
131
|
+
* Triggers to stop the generation
|
|
132
|
+
*/
|
|
133
|
+
stopGenerationTriggers: LlamaText[];
|
|
134
|
+
/**
|
|
135
|
+
* When this option is set, after evaluating the `contextText`,
|
|
136
|
+
* it'll look for any of the triggers to be the first generated output.
|
|
137
|
+
*
|
|
138
|
+
* When a trigger is matched, its type will determine the mode to enter to, a segment to open,
|
|
139
|
+
* or to continue the generation as a textual output.
|
|
140
|
+
*
|
|
141
|
+
* If all the triggers are unmatched, the `noPrefixTrigger` will take effect.
|
|
142
|
+
*/
|
|
143
|
+
prefixTriggers?: Array<{
|
|
144
|
+
triggers: LlamaText[];
|
|
145
|
+
/**
|
|
146
|
+
* Enter into function calling mode.
|
|
147
|
+
*
|
|
148
|
+
* Entering this mode will put the function calling prefix into the context sequence state
|
|
149
|
+
* and force it to choose a function to call.
|
|
150
|
+
*
|
|
151
|
+
* If no functions are available, this trigger will be ignored.
|
|
152
|
+
*/
|
|
153
|
+
type: "functionCall";
|
|
154
|
+
/**
|
|
155
|
+
* Remove the trigger tokens and replace them with the function call prefix.
|
|
156
|
+
*
|
|
157
|
+
* Defaults to `true`.
|
|
158
|
+
*/
|
|
159
|
+
replaceTrigger?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Text to inject into the context sequence state when this trigger is matched.
|
|
162
|
+
*/
|
|
163
|
+
inject?: LlamaText;
|
|
164
|
+
} | {
|
|
165
|
+
triggers: LlamaText[];
|
|
166
|
+
/**
|
|
167
|
+
* Open a segment of the specified type.
|
|
168
|
+
*
|
|
169
|
+
* If the budget for this segment has exceeded, this trigger will be ignored,
|
|
170
|
+
* so ensure to have a fallback for a response.
|
|
171
|
+
*/
|
|
172
|
+
type: "segment";
|
|
173
|
+
/**
|
|
174
|
+
* Type of the segment to open.
|
|
175
|
+
*/
|
|
176
|
+
segmentType: ChatModelSegmentType;
|
|
177
|
+
/**
|
|
178
|
+
* Text to inject into the context sequence state when this trigger is matched.
|
|
179
|
+
*/
|
|
180
|
+
inject?: LlamaText;
|
|
181
|
+
} | {
|
|
182
|
+
triggers: LlamaText[];
|
|
183
|
+
/**
|
|
184
|
+
* Continue the generation as a textual output.
|
|
185
|
+
*/
|
|
186
|
+
type: "response";
|
|
187
|
+
/**
|
|
188
|
+
* Text to inject into the context sequence state when this trigger is matched.
|
|
189
|
+
*/
|
|
190
|
+
inject?: LlamaText;
|
|
191
|
+
}>;
|
|
192
|
+
/**
|
|
193
|
+
* When no prefix triggers are matched or non are provided, after evaluating the `contextText`,
|
|
194
|
+
* perform the action specified by this option.
|
|
195
|
+
*/
|
|
196
|
+
noPrefixTrigger?: {
|
|
197
|
+
/**
|
|
198
|
+
* Enter into function calling mode.
|
|
199
|
+
*
|
|
200
|
+
* Entering this mode will put the function calling prefix into the context sequence state
|
|
201
|
+
* and force it to choose a function to call.
|
|
202
|
+
*
|
|
203
|
+
* If no functions are available, this action will be ignored.
|
|
204
|
+
*/
|
|
205
|
+
type: "functionCall";
|
|
206
|
+
/**
|
|
207
|
+
* Text to inject into the context sequence state when this action is performed.
|
|
208
|
+
*/
|
|
209
|
+
inject: LlamaText;
|
|
210
|
+
} | {
|
|
211
|
+
/**
|
|
212
|
+
* Open a segment of the specified type.
|
|
213
|
+
*
|
|
214
|
+
* If the budget for this segment has exceeded, this action will be ignored.
|
|
215
|
+
*/
|
|
216
|
+
type: "segment";
|
|
217
|
+
/**
|
|
218
|
+
* Type of the segment to open.
|
|
219
|
+
*/
|
|
220
|
+
segmentType: ChatModelSegmentType;
|
|
221
|
+
/**
|
|
222
|
+
* Text to inject into the context sequence state when this action is performed.
|
|
223
|
+
*/
|
|
224
|
+
inject: LlamaText;
|
|
225
|
+
} | {
|
|
226
|
+
/**
|
|
227
|
+
* Continue the generation as a textual output.
|
|
228
|
+
*/
|
|
229
|
+
type: "response";
|
|
230
|
+
/**
|
|
231
|
+
* Text to inject into the context sequence state when this action is performed.
|
|
232
|
+
*/
|
|
233
|
+
inject: LlamaText;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* Trigger a rerender of the chat template when any of the provided triggers are matched.
|
|
237
|
+
*
|
|
238
|
+
* When a rerender it triggered, the chat template will be rendered again and the next trigger options will come into effect again,
|
|
239
|
+
* so if no prefix triggers are required after the rerender, make sure to not provide any.
|
|
240
|
+
*
|
|
241
|
+
* When a rerender is triggered, the `action` will be performed.
|
|
242
|
+
*/
|
|
243
|
+
rerender?: {
|
|
244
|
+
triggers: LlamaText[];
|
|
245
|
+
/**
|
|
246
|
+
* Action to perform when the rerender is triggered.
|
|
247
|
+
*
|
|
248
|
+
* - **`"closeResponseItem"`**: Close the current segment or stop the textual response generation.
|
|
249
|
+
*/
|
|
250
|
+
action?: "closeResponseItem";
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Whether to detect the function calling prefix syntax in the current text generation to dynamically enter into function calling mode.
|
|
254
|
+
*
|
|
255
|
+
* If it's only possible to enter function calling using a prefix trigger, then set this option to `false`.
|
|
256
|
+
*/
|
|
257
|
+
detectFunctionCalls?: boolean;
|
|
258
|
+
ignoreStartText?: never;
|
|
259
|
+
functionCall?: never;
|
|
260
|
+
};
|
|
261
|
+
export type ChatWrapperGeneratedInitiallyEngagedFunctionsContextState = {
|
|
262
|
+
contextText: LlamaText;
|
|
263
|
+
stopGenerationTriggers: LlamaText[];
|
|
264
|
+
ignoreStartText?: LlamaText[];
|
|
265
|
+
functionCall?: {
|
|
266
|
+
initiallyEngaged: boolean;
|
|
267
|
+
disengageInitiallyEngaged: LlamaText[];
|
|
268
|
+
};
|
|
269
|
+
detectFunctionCalls?: never;
|
|
270
|
+
prefixTriggers?: never;
|
|
271
|
+
noPrefixTrigger?: never;
|
|
272
|
+
rerender?: never;
|
|
273
|
+
};
|
|
274
|
+
export type ChatWrapperGenerateInitialHistoryOptions = {
|
|
275
|
+
systemPrompt?: string;
|
|
276
|
+
};
|
|
277
|
+
export type ChatHistoryItem = ChatSystemMessage | ChatUserMessage | ChatModelResponse;
|
|
278
|
+
export type ChatSystemMessage = {
|
|
279
|
+
type: "system";
|
|
280
|
+
text: string | LlamaTextJSON;
|
|
281
|
+
};
|
|
282
|
+
export type ChatUserMessage = {
|
|
283
|
+
type: "user";
|
|
284
|
+
text: string;
|
|
285
|
+
};
|
|
286
|
+
export type ChatModelResponse = {
|
|
287
|
+
type: "model";
|
|
288
|
+
response: Array<string | ChatModelFunctionCall | ChatModelSegment>;
|
|
289
|
+
};
|
|
290
|
+
export type ChatModelFunctionCall = {
|
|
291
|
+
type: "functionCall";
|
|
292
|
+
name: string;
|
|
293
|
+
description?: string;
|
|
294
|
+
params: any;
|
|
295
|
+
result: any;
|
|
296
|
+
rawCall?: LlamaTextJSON;
|
|
297
|
+
/**
|
|
298
|
+
* Whether this function call starts a new function calling chunk.
|
|
299
|
+
*
|
|
300
|
+
* Relevant only when parallel function calling is supported.
|
|
301
|
+
*/
|
|
302
|
+
startsNewChunk?: boolean;
|
|
303
|
+
};
|
|
304
|
+
export declare const allSegmentTypes: readonly ["thought", "comment"];
|
|
305
|
+
export type ChatModelSegmentType = "thought" | "comment";
|
|
306
|
+
export type ChatModelSegment = {
|
|
307
|
+
type: "segment";
|
|
308
|
+
segmentType: ChatModelSegmentType;
|
|
309
|
+
text: string;
|
|
310
|
+
ended: boolean;
|
|
311
|
+
raw?: LlamaTextJSON;
|
|
312
|
+
startTime?: string;
|
|
313
|
+
endTime?: string;
|
|
314
|
+
};
|
|
315
|
+
export type ChatModelFunctions = {
|
|
316
|
+
readonly [name: string]: {
|
|
317
|
+
readonly description?: string;
|
|
318
|
+
readonly params?: Readonly<GbnfJsonSchema> | undefined | null;
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
export type ChatSessionModelFunctions = {
|
|
322
|
+
readonly [name: string]: ChatSessionModelFunction<any>;
|
|
323
|
+
};
|
|
324
|
+
export type ChatSessionModelFunction<Params extends GbnfJsonSchema | undefined = GbnfJsonSchema | undefined> = {
|
|
325
|
+
readonly description?: string;
|
|
326
|
+
readonly params?: Params;
|
|
327
|
+
readonly handler: (params: GbnfJsonSchemaToType<NoInfer<Params>>) => any;
|
|
328
|
+
};
|
|
329
|
+
export declare function isChatModelResponseFunctionCall(item: ChatModelResponse["response"][number] | undefined): item is ChatModelFunctionCall;
|
|
330
|
+
export declare function isChatModelResponseSegment(item: ChatModelResponse["response"][number] | undefined): item is ChatModelSegment;
|
|
331
|
+
export type LLamaContextualRepeatPenalty = {
|
|
332
|
+
/**
|
|
333
|
+
* Number of recent tokens generated by the model to apply penalties to repetition of.
|
|
334
|
+
* Defaults to `64`.
|
|
335
|
+
*/
|
|
336
|
+
lastTokens?: number;
|
|
337
|
+
punishTokensFilter?: (tokens: Token[]) => Token[];
|
|
338
|
+
/**
|
|
339
|
+
* Penalize new line tokens.
|
|
340
|
+
* Enabled by default.
|
|
341
|
+
*/
|
|
342
|
+
penalizeNewLine?: boolean;
|
|
343
|
+
/**
|
|
344
|
+
* The relative amount to lower the probability of the tokens in `punishTokens` by
|
|
345
|
+
* Defaults to `1.1`.
|
|
346
|
+
* Set to `1` to disable.
|
|
347
|
+
*/
|
|
348
|
+
penalty?: number;
|
|
349
|
+
/**
|
|
350
|
+
* For n time a token is in the `punishTokens` array, lower its probability by `n * frequencyPenalty`
|
|
351
|
+
* Disabled by default (`0`).
|
|
352
|
+
* Set to a value between `0` and `1` to enable.
|
|
353
|
+
*/
|
|
354
|
+
frequencyPenalty?: number;
|
|
355
|
+
/**
|
|
356
|
+
* Lower the probability of all the tokens in the `punishTokens` array by `presencePenalty`
|
|
357
|
+
* Disabled by default (`0`).
|
|
358
|
+
* Set to a value between `0` and `1` to enable.
|
|
359
|
+
*/
|
|
360
|
+
presencePenalty?: number;
|
|
361
|
+
};
|
|
362
|
+
export type LLamaContextualDryRepeatPenalty = {
|
|
363
|
+
/**
|
|
364
|
+
* A number between `0` and `1` representing the strength of the DRY (Don't Repeat Yourself) effect.
|
|
365
|
+
*
|
|
366
|
+
* Setting this to `0` will disable the DRY penalty completely.
|
|
367
|
+
*
|
|
368
|
+
* The recommended value is `0.8`.
|
|
369
|
+
*/
|
|
370
|
+
strength: number;
|
|
371
|
+
/**
|
|
372
|
+
* The base value for the exponential penality calculation.
|
|
373
|
+
*
|
|
374
|
+
* A higher value will lead to more aggressive penalization of repetitions.
|
|
375
|
+
*
|
|
376
|
+
* Defaults to `1.75`.
|
|
377
|
+
*/
|
|
378
|
+
base?: number;
|
|
379
|
+
/**
|
|
380
|
+
* The maximum sequence length (in tokens) that will be allowed to be repeated without being penalized.
|
|
381
|
+
*
|
|
382
|
+
* Repetitions shorter than or equal to this length will not be penalized,
|
|
383
|
+
* allowing for natural repetitions of short phrases and common words.
|
|
384
|
+
*
|
|
385
|
+
* Defaults to `2`.
|
|
386
|
+
*/
|
|
387
|
+
allowedLength?: number;
|
|
388
|
+
/**
|
|
389
|
+
* Number of recent tokens generated by the model to consider for sequence repetition matching.
|
|
390
|
+
*
|
|
391
|
+
* When set to `null`, the entire context sequence history will be considered for repetition matching.
|
|
392
|
+
* Setting to `0` will disable DRY (Don't Repeat Yourself) penalty.
|
|
393
|
+
*
|
|
394
|
+
* Defaults to `null`.
|
|
395
|
+
*/
|
|
396
|
+
lastTokens?: number | null;
|
|
397
|
+
/**
|
|
398
|
+
* Text sequences that will be considered as breakers for the repeated sequences.
|
|
399
|
+
* These will never be penalized for being repeated, and are used to mark the boundaries of the repeated sequences.
|
|
400
|
+
*
|
|
401
|
+
* For example, setting this to `["\n", "*"]` will allow the model to make as many lists as it wants,
|
|
402
|
+
* without being penalized for repeating the list item marker (like `*`).
|
|
403
|
+
*
|
|
404
|
+
* Defaults to `["\n", ":", '"', "*"]`.
|
|
405
|
+
*/
|
|
406
|
+
sequenceBreakers?: string[];
|
|
407
|
+
};
|
|
408
|
+
export type NodeLlamaCppPostinstallBehavior = "auto" | "ignoreFailedBuild" | "skip";
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const allSegmentTypes = ["thought", "comment"];
|
|
2
|
+
void null;
|
|
3
|
+
export function isChatModelResponseFunctionCall(item) {
|
|
4
|
+
if (item == null || typeof item === "string")
|
|
5
|
+
return false;
|
|
6
|
+
return item.type === "functionCall";
|
|
7
|
+
}
|
|
8
|
+
export function isChatModelResponseSegment(item) {
|
|
9
|
+
if (item == null || typeof item === "string")
|
|
10
|
+
return false;
|
|
11
|
+
return item.type === "segment";
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA2VA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,SAAS,CAAoD,CAAC;AACzG,KAAM,IAAsF,CAAC;AA8B7F,MAAM,UAAU,+BAA+B,CAAC,IAAuD;IACnG,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QACxC,OAAO,KAAK,CAAC;IAEjB,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,IAAuD;IAC9F,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QACxC,OAAO,KAAK,CAAC;IAEjB,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class DisposeGuard {
|
|
2
|
+
constructor(parentDisposeGuards?: DisposeGuard[]);
|
|
3
|
+
addParentDisposeGuard(parent: DisposeGuard): void;
|
|
4
|
+
removeParentDisposeGuard(parent: DisposeGuard): void;
|
|
5
|
+
acquireDisposeLock(): Promise<void>;
|
|
6
|
+
createPreventDisposalHandle(ignoreAwaitingDispose?: boolean): DisposalPreventionHandle;
|
|
7
|
+
}
|
|
8
|
+
export declare class DisposalPreventionHandle {
|
|
9
|
+
private constructor();
|
|
10
|
+
dispose(): void;
|
|
11
|
+
[Symbol.dispose](): void;
|
|
12
|
+
get disposed(): boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { DisposedError } from "lifecycle-utils";
|
|
2
|
+
export class DisposeGuard {
|
|
3
|
+
/** @internal */ _preventionHandles = 0;
|
|
4
|
+
/** @internal */ _awaitingDisposeLockCallbacks = [];
|
|
5
|
+
/** @internal */ _disposeActivated = false;
|
|
6
|
+
/** @internal */ _parentDisposeGuardsLocks = new Map();
|
|
7
|
+
constructor(parentDisposeGuards = []) {
|
|
8
|
+
for (const parent of parentDisposeGuards)
|
|
9
|
+
this._parentDisposeGuardsLocks.set(parent, null);
|
|
10
|
+
}
|
|
11
|
+
addParentDisposeGuard(parent) {
|
|
12
|
+
if (this._parentDisposeGuardsLocks.has(parent))
|
|
13
|
+
return;
|
|
14
|
+
this._parentDisposeGuardsLocks.set(parent, null);
|
|
15
|
+
if (this._preventionHandles > 0)
|
|
16
|
+
this._parentDisposeGuardsLocks.set(parent, parent.createPreventDisposalHandle(true));
|
|
17
|
+
}
|
|
18
|
+
removeParentDisposeGuard(parent) {
|
|
19
|
+
const parentLock = this._parentDisposeGuardsLocks.get(parent);
|
|
20
|
+
if (parentLock != null) {
|
|
21
|
+
parentLock.dispose();
|
|
22
|
+
this._parentDisposeGuardsLocks.delete(parent);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async acquireDisposeLock() {
|
|
26
|
+
return new Promise((accept) => {
|
|
27
|
+
if (this._preventionHandles > 0)
|
|
28
|
+
this._awaitingDisposeLockCallbacks.push(accept);
|
|
29
|
+
else {
|
|
30
|
+
this._disposeActivated = true;
|
|
31
|
+
accept();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
createPreventDisposalHandle(ignoreAwaitingDispose = false) {
|
|
36
|
+
if (this._isDisposeActivated() || (!ignoreAwaitingDispose && this._hasAwaitingDisposeLocks()))
|
|
37
|
+
throw new DisposedError();
|
|
38
|
+
this._preventionHandles++;
|
|
39
|
+
try {
|
|
40
|
+
this._updateParentDisposeGuardLocks();
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
this._preventionHandles--;
|
|
44
|
+
if (this._preventionHandles === 0)
|
|
45
|
+
this._updateParentDisposeGuardLocks();
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
return DisposalPreventionHandle._create(() => {
|
|
49
|
+
this._preventionHandles--;
|
|
50
|
+
this._activateLocksIfNeeded();
|
|
51
|
+
this._updateParentDisposeGuardLocks(true);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/** @internal */
|
|
55
|
+
_isDisposeActivated() {
|
|
56
|
+
if (this._disposeActivated)
|
|
57
|
+
return true;
|
|
58
|
+
return [...this._parentDisposeGuardsLocks.keys()].some((parent) => parent._isDisposeActivated());
|
|
59
|
+
}
|
|
60
|
+
/** @internal */
|
|
61
|
+
_activateLocksIfNeeded() {
|
|
62
|
+
if (this._preventionHandles > 0)
|
|
63
|
+
return;
|
|
64
|
+
while (this._awaitingDisposeLockCallbacks.length > 0) {
|
|
65
|
+
this._disposeActivated = true;
|
|
66
|
+
this._awaitingDisposeLockCallbacks.shift()();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** @internal */
|
|
70
|
+
_updateParentDisposeGuardLocks(onlyAllowRemoval = false) {
|
|
71
|
+
if (this._preventionHandles === 0) {
|
|
72
|
+
for (const parent of this._parentDisposeGuardsLocks.keys()) {
|
|
73
|
+
const parentLock = this._parentDisposeGuardsLocks.get(parent);
|
|
74
|
+
if (parentLock == null)
|
|
75
|
+
continue;
|
|
76
|
+
parentLock.dispose();
|
|
77
|
+
this._parentDisposeGuardsLocks.set(parent, null);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else if (!onlyAllowRemoval) {
|
|
81
|
+
for (const parent of this._parentDisposeGuardsLocks.keys()) {
|
|
82
|
+
if (this._parentDisposeGuardsLocks.get(parent) != null)
|
|
83
|
+
continue;
|
|
84
|
+
this._parentDisposeGuardsLocks.set(parent, parent.createPreventDisposalHandle(true));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** @internal */
|
|
89
|
+
_hasAwaitingDisposeLocks() {
|
|
90
|
+
if (this._awaitingDisposeLockCallbacks.length > 0)
|
|
91
|
+
return true;
|
|
92
|
+
return [...this._parentDisposeGuardsLocks.keys()].some((parent) => parent._hasAwaitingDisposeLocks());
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export class DisposalPreventionHandle {
|
|
96
|
+
/** @internal */
|
|
97
|
+
_dispose;
|
|
98
|
+
constructor(dispose) {
|
|
99
|
+
this._dispose = dispose;
|
|
100
|
+
this.dispose = this.dispose.bind(this);
|
|
101
|
+
this[Symbol.dispose] = this[Symbol.dispose].bind(this);
|
|
102
|
+
}
|
|
103
|
+
dispose() {
|
|
104
|
+
if (this._dispose != null) {
|
|
105
|
+
this._dispose();
|
|
106
|
+
this._dispose = null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
[Symbol.dispose]() {
|
|
110
|
+
this.dispose();
|
|
111
|
+
}
|
|
112
|
+
get disposed() {
|
|
113
|
+
return this._dispose == null;
|
|
114
|
+
}
|
|
115
|
+
/** @internal */
|
|
116
|
+
static _create(dispose) {
|
|
117
|
+
return new DisposalPreventionHandle(dispose);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=DisposeGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DisposeGuard.js","sourceRoot":"","sources":["../../src/utils/DisposeGuard.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InsufficientMemoryError.js","sourceRoot":"","sources":["../../src/utils/InsufficientMemoryError.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAC9C,YAAmB,UAAkB,qBAAqB;QACtD,KAAK,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;CACJ"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { Token, Tokenizer } from "../types.js";
|
|
2
|
+
export type LlamaTextValue = string | SpecialTokensText | SpecialToken;
|
|
3
|
+
export type LlamaTextInputValue = LlamaTextValue | LlamaText | number | boolean | readonly LlamaTextInputValue[];
|
|
4
|
+
export type LlamaTextJSON = string | LlamaTextJSONValue[];
|
|
5
|
+
export type LlamaTextJSONValue = string | LlamaTextSpecialTokensTextJSON | LlamaTextSpecialTokenJSON;
|
|
6
|
+
export type LlamaTextSpecialTokensTextJSON = {
|
|
7
|
+
type: "specialTokensText";
|
|
8
|
+
value: string;
|
|
9
|
+
};
|
|
10
|
+
export type LlamaTextSpecialTokenJSON = {
|
|
11
|
+
type: "specialToken";
|
|
12
|
+
value: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @see [Using `LlamaText`](https://node-llama-cpp.withcat.ai/guide/llama-text) tutorial
|
|
16
|
+
*/
|
|
17
|
+
declare class LlamaText {
|
|
18
|
+
readonly values: readonly LlamaTextValue[];
|
|
19
|
+
/**
|
|
20
|
+
* Can also be called without `new`
|
|
21
|
+
*/
|
|
22
|
+
constructor(...values: readonly LlamaTextInputValue[]);
|
|
23
|
+
concat(value: LlamaTextInputValue): LlamaText;
|
|
24
|
+
mapValues(mapper: (this: readonly LlamaTextValue[], value: LlamaTextValue, index: number, values: readonly LlamaTextValue[]) => LlamaTextInputValue): LlamaText;
|
|
25
|
+
/**
|
|
26
|
+
* Joins the values with the given separator.
|
|
27
|
+
*
|
|
28
|
+
* Note that the values are squashed when they are loaded into the `LlamaText`, so the separator is not added between adjacent strings.
|
|
29
|
+
*
|
|
30
|
+
* To add the separator on values before squashing them, use `LlamaText.joinValues` instead.
|
|
31
|
+
*/
|
|
32
|
+
joinValues(separator: LlamaText | LlamaTextValue): LlamaText;
|
|
33
|
+
toString(): string;
|
|
34
|
+
toJSON(): LlamaTextJSON;
|
|
35
|
+
tokenize(tokenizer: Tokenizer, options?: "trimLeadingSpace"): Token[];
|
|
36
|
+
compare(other: LlamaText): boolean;
|
|
37
|
+
trimStart(): LlamaText;
|
|
38
|
+
trimEnd(): LlamaText;
|
|
39
|
+
includes(value: LlamaText): boolean;
|
|
40
|
+
static fromJSON(json: LlamaTextJSON): LlamaText;
|
|
41
|
+
static compare(a: LlamaText, b: LlamaText): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Attempt to convert tokens to a `LlamaText` while preserving special tokens.
|
|
44
|
+
*
|
|
45
|
+
* Non-standard special tokens that don't have a text representation are ignored.
|
|
46
|
+
*/
|
|
47
|
+
static fromTokens(tokenizer: Tokenizer, tokens: Token[]): LlamaText;
|
|
48
|
+
/**
|
|
49
|
+
* Join values with the given separator before squashing adjacent strings inside the values
|
|
50
|
+
*/
|
|
51
|
+
static joinValues(separator: LlamaText | string, values: readonly LlamaTextInputValue[]): LlamaText;
|
|
52
|
+
static isLlamaText(value: unknown): value is LlamaText;
|
|
53
|
+
}
|
|
54
|
+
type LlamaTextConstructor = Omit<typeof LlamaText, "prototype"> & {
|
|
55
|
+
new (...values: readonly LlamaTextInputValue[]): LlamaText;
|
|
56
|
+
(...values: readonly LlamaTextInputValue[]): LlamaText;
|
|
57
|
+
readonly prototype: typeof LlamaText.prototype;
|
|
58
|
+
};
|
|
59
|
+
declare const LlamaTextConstructor: LlamaTextConstructor;
|
|
60
|
+
declare const _LlamaText: LlamaTextConstructor;
|
|
61
|
+
type _LlamaText = LlamaText;
|
|
62
|
+
export { _LlamaText as LlamaText, LlamaText as _LlamaText };
|
|
63
|
+
export declare class SpecialTokensText {
|
|
64
|
+
readonly value: string;
|
|
65
|
+
constructor(value: string);
|
|
66
|
+
toString(): string;
|
|
67
|
+
tokenize(tokenizer: Tokenizer, trimLeadingSpace?: boolean): Token[];
|
|
68
|
+
tokenizeSpecialTokensOnly(tokenizer: Tokenizer): (string | Token)[];
|
|
69
|
+
toJSON(): LlamaTextSpecialTokensTextJSON;
|
|
70
|
+
static fromJSON(json: LlamaTextSpecialTokensTextJSON): SpecialTokensText;
|
|
71
|
+
static isSpecialTokensTextJSON(value: LlamaTextJSONValue): value is LlamaTextSpecialTokensTextJSON;
|
|
72
|
+
/**
|
|
73
|
+
* Wraps the value with a `SpecialTokensText` only if `shouldWrap` is true
|
|
74
|
+
*/
|
|
75
|
+
static wrapIf(shouldWrap: boolean, value: string): SpecialTokensText | string;
|
|
76
|
+
}
|
|
77
|
+
export type BuiltinSpecialTokenValue = "BOS" | "EOS" | "NL" | "EOT" | "SEP";
|
|
78
|
+
export declare class SpecialToken {
|
|
79
|
+
readonly value: BuiltinSpecialTokenValue;
|
|
80
|
+
constructor(value: BuiltinSpecialTokenValue);
|
|
81
|
+
toString(): BuiltinSpecialTokenValue;
|
|
82
|
+
tokenize(tokenizer: Tokenizer): Token[];
|
|
83
|
+
toJSON(): LlamaTextSpecialTokenJSON;
|
|
84
|
+
static fromJSON(json: LlamaTextSpecialTokenJSON): SpecialToken;
|
|
85
|
+
static isSpecialTokenJSON(value: LlamaTextJSONValue): value is LlamaTextSpecialTokenJSON;
|
|
86
|
+
static getTokenToValueMap(tokenizer: Tokenizer): ReadonlyMap<Token | undefined, BuiltinSpecialTokenValue>;
|
|
87
|
+
}
|
|
88
|
+
export declare function isLlamaText(value: unknown): value is LlamaText;
|
|
89
|
+
/**
|
|
90
|
+
* Tokenize the given input using the given tokenizer, whether it's a `string` or a `LlamaText`
|
|
91
|
+
*/
|
|
92
|
+
export declare function tokenizeText(text: string | LlamaText, tokenizer: Tokenizer): Token[];
|