node-llama-cpp 3.0.0-beta.4 → 3.0.0-beta.41
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/README.md +14 -11
- package/bins/_linux-x64-cuda.moved.txt +1 -0
- package/bins/_win-x64-cuda.moved.txt +1 -0
- package/bins/linux-arm64/_nlcBuildMetadata.json +1 -0
- package/bins/linux-arm64/libggml.so +0 -0
- package/bins/linux-arm64/libllama.so +0 -0
- package/bins/linux-arm64/llama-addon.node +0 -0
- package/bins/linux-armv7l/_nlcBuildMetadata.json +1 -0
- package/bins/linux-armv7l/libggml.so +0 -0
- package/bins/linux-armv7l/libllama.so +0 -0
- package/bins/linux-armv7l/llama-addon.node +0 -0
- package/bins/linux-x64/_nlcBuildMetadata.json +1 -0
- package/bins/linux-x64/libggml.so +0 -0
- package/bins/linux-x64/libllama.so +0 -0
- package/bins/linux-x64/llama-addon.node +0 -0
- package/bins/linux-x64-vulkan/_nlcBuildMetadata.json +1 -0
- package/bins/linux-x64-vulkan/libggml.so +0 -0
- package/bins/linux-x64-vulkan/libllama.so +0 -0
- package/bins/linux-x64-vulkan/llama-addon.node +0 -0
- package/bins/linux-x64-vulkan/vulkan-shaders-gen +0 -0
- package/bins/mac-arm64-metal/_nlcBuildMetadata.json +1 -0
- package/bins/mac-arm64-metal/ggml-common.h +1833 -0
- package/bins/mac-arm64-metal/ggml-metal.metal +6168 -0
- package/bins/mac-arm64-metal/libggml.dylib +0 -0
- package/bins/mac-arm64-metal/libllama.dylib +0 -0
- package/bins/mac-arm64-metal/llama-addon.node +0 -0
- package/bins/mac-x64/_nlcBuildMetadata.json +1 -0
- package/bins/mac-x64/libggml.dylib +0 -0
- package/bins/mac-x64/libllama.dylib +0 -0
- package/bins/mac-x64/llama-addon.node +0 -0
- package/bins/win-arm64/_nlcBuildMetadata.json +1 -0
- package/bins/win-arm64/ggml.dll +0 -0
- package/bins/win-arm64/llama-addon.exp +0 -0
- package/bins/win-arm64/llama-addon.lib +0 -0
- package/bins/win-arm64/llama-addon.node +0 -0
- package/bins/win-arm64/llama.dll +0 -0
- package/bins/win-x64/_nlcBuildMetadata.json +1 -0
- package/bins/win-x64/ggml.dll +0 -0
- package/bins/win-x64/llama-addon.exp +0 -0
- package/bins/win-x64/llama-addon.lib +0 -0
- package/bins/win-x64/llama-addon.node +0 -0
- package/bins/win-x64/llama.dll +0 -0
- package/bins/win-x64-vulkan/_nlcBuildMetadata.json +1 -0
- package/bins/win-x64-vulkan/ggml.dll +0 -0
- package/bins/win-x64-vulkan/llama-addon.exp +0 -0
- package/bins/win-x64-vulkan/llama-addon.lib +0 -0
- package/bins/win-x64-vulkan/llama-addon.node +0 -0
- package/bins/win-x64-vulkan/llama.dll +0 -0
- package/bins/win-x64-vulkan/vulkan-shaders-gen.exe +0 -0
- package/dist/ChatWrapper.d.ts +9 -39
- package/dist/ChatWrapper.js +129 -72
- package/dist/ChatWrapper.js.map +1 -1
- package/dist/apiDocsIndex.d.ts +1 -0
- package/dist/apiDocsIndex.js +7 -0
- package/dist/apiDocsIndex.js.map +1 -0
- package/dist/{utils/getBin.d.ts → bindings/AddonTypes.d.ts} +66 -9
- package/dist/bindings/AddonTypes.js +2 -0
- package/dist/bindings/AddonTypes.js.map +1 -0
- package/dist/bindings/Llama.d.ts +47 -0
- package/dist/bindings/Llama.js +356 -0
- package/dist/bindings/Llama.js.map +1 -0
- package/dist/bindings/consts.d.ts +2 -0
- package/dist/bindings/consts.js +11 -0
- package/dist/bindings/consts.js.map +1 -0
- package/dist/bindings/getLlama.d.ts +152 -0
- package/dist/bindings/getLlama.js +403 -0
- package/dist/bindings/getLlama.js.map +1 -0
- package/dist/bindings/types.d.ts +57 -0
- package/dist/bindings/types.js +77 -0
- package/dist/bindings/types.js.map +1 -0
- package/dist/bindings/utils/MemoryOrchestrator.d.ts +21 -0
- package/dist/bindings/utils/MemoryOrchestrator.js +49 -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 +27 -0
- package/dist/bindings/utils/asyncSome.js.map +1 -0
- package/dist/{utils → bindings/utils}/binariesGithubRelease.js +1 -1
- 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 +21 -0
- package/dist/bindings/utils/compileLLamaCpp.js +288 -0
- package/dist/bindings/utils/compileLLamaCpp.js.map +1 -0
- package/dist/bindings/utils/detectAvailableComputeLayers.d.ts +14 -0
- package/dist/bindings/utils/detectAvailableComputeLayers.js +305 -0
- package/dist/bindings/utils/detectAvailableComputeLayers.js.map +1 -0
- package/dist/bindings/utils/detectGlibc.d.ts +4 -0
- package/dist/bindings/utils/detectGlibc.js +46 -0
- package/dist/bindings/utils/detectGlibc.js.map +1 -0
- package/dist/bindings/utils/getBestComputeLayersAvailable.d.ts +10 -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 +5 -0
- package/dist/bindings/utils/getBuildFolderNameForBuildOptions.js +93 -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 +13 -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/getLlamaWithoutBackend.d.ts +5 -0
- package/dist/bindings/utils/getLlamaWithoutBackend.js +27 -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/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 +1 -0
- package/dist/bindings/utils/testBindingBinary.js +100 -0
- package/dist/bindings/utils/testBindingBinary.js.map +1 -0
- package/dist/bindings/utils/testCmakeBinary.d.ts +6 -0
- package/dist/bindings/utils/testCmakeBinary.js +32 -0
- package/dist/bindings/utils/testCmakeBinary.js.map +1 -0
- package/dist/chatWrappers/AlpacaChatWrapper.d.ts +2 -1
- package/dist/chatWrappers/AlpacaChatWrapper.js +9 -2
- package/dist/chatWrappers/AlpacaChatWrapper.js.map +1 -1
- package/dist/chatWrappers/ChatMLChatWrapper.d.ts +2 -9
- package/dist/chatWrappers/ChatMLChatWrapper.js +23 -21
- package/dist/chatWrappers/ChatMLChatWrapper.js.map +1 -1
- package/dist/chatWrappers/FalconChatWrapper.d.ts +4 -10
- package/dist/chatWrappers/FalconChatWrapper.js +38 -21
- package/dist/chatWrappers/FalconChatWrapper.js.map +1 -1
- package/dist/chatWrappers/FunctionaryChatWrapper.d.ts +8 -32
- package/dist/chatWrappers/FunctionaryChatWrapper.js +326 -118
- package/dist/chatWrappers/FunctionaryChatWrapper.js.map +1 -1
- 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 +4 -10
- package/dist/chatWrappers/GeneralChatWrapper.js +45 -22
- package/dist/chatWrappers/GeneralChatWrapper.js.map +1 -1
- package/dist/chatWrappers/Llama2ChatWrapper.d.ts +12 -0
- package/dist/chatWrappers/{LlamaChatWrapper.js → Llama2ChatWrapper.js} +38 -20
- 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 +31 -0
- package/dist/chatWrappers/Llama3_1ChatWrapper.js +223 -0
- package/dist/chatWrappers/Llama3_1ChatWrapper.js.map +1 -0
- package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.d.ts +76 -0
- package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.js +371 -0
- package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.js.map +1 -0
- package/dist/chatWrappers/generic/TemplateChatWrapper.d.ts +54 -0
- package/dist/chatWrappers/generic/TemplateChatWrapper.js +200 -0
- package/dist/chatWrappers/generic/TemplateChatWrapper.js.map +1 -0
- package/dist/chatWrappers/generic/utils/chatHistoryFunctionCallMessageTemplate.d.ts +23 -0
- package/dist/chatWrappers/generic/utils/chatHistoryFunctionCallMessageTemplate.js +45 -0
- package/dist/chatWrappers/generic/utils/chatHistoryFunctionCallMessageTemplate.js.map +1 -0
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.d.ts +57 -0
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.js +119 -0
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.js.map +1 -0
- package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.d.ts +4 -0
- package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.js +210 -0
- package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.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 +71 -0
- package/dist/chatWrappers/utils/resolveChatWrapper.js +289 -0
- package/dist/chatWrappers/utils/resolveChatWrapper.js.map +1 -0
- package/dist/cli/cli.js +21 -7
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/commands/BuildCommand.d.ts +11 -4
- package/dist/cli/commands/BuildCommand.js +114 -41
- package/dist/cli/commands/BuildCommand.js.map +1 -1
- package/dist/cli/commands/ChatCommand.d.ts +19 -7
- package/dist/cli/commands/ChatCommand.js +306 -150
- package/dist/cli/commands/ChatCommand.js.map +1 -1
- package/dist/cli/commands/ClearCommand.d.ts +1 -1
- package/dist/cli/commands/ClearCommand.js +11 -12
- package/dist/cli/commands/ClearCommand.js.map +1 -1
- package/dist/cli/commands/CompleteCommand.d.ts +30 -0
- package/dist/cli/commands/CompleteCommand.js +374 -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 +54 -0
- package/dist/cli/commands/DebugCommand.js.map +1 -0
- package/dist/cli/commands/DownloadCommand.d.ts +7 -4
- package/dist/cli/commands/DownloadCommand.js +121 -70
- package/dist/cli/commands/DownloadCommand.js.map +1 -1
- package/dist/cli/commands/InfillCommand.d.ts +32 -0
- package/dist/cli/commands/InfillCommand.js +410 -0
- package/dist/cli/commands/InfillCommand.js.map +1 -0
- package/dist/cli/commands/InitCommand.d.ts +11 -0
- package/dist/cli/commands/InitCommand.js +195 -0
- package/dist/cli/commands/InitCommand.js.map +1 -0
- package/dist/cli/commands/OnPostInstallCommand.js +9 -10
- package/dist/cli/commands/OnPostInstallCommand.js.map +1 -1
- package/dist/cli/commands/PullCommand.d.ts +12 -0
- package/dist/cli/commands/PullCommand.js +117 -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 +19 -0
- package/dist/cli/commands/inspect/InspectCommand.js.map +1 -0
- package/dist/cli/commands/inspect/commands/InspectGgufCommand.d.ts +12 -0
- package/dist/cli/commands/inspect/commands/InspectGgufCommand.js +136 -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 +180 -0
- package/dist/cli/commands/inspect/commands/InspectGpuCommand.js.map +1 -0
- package/dist/cli/commands/inspect/commands/InspectMeasureCommand.d.ts +18 -0
- package/dist/cli/commands/inspect/commands/InspectMeasureCommand.js +626 -0
- package/dist/cli/commands/inspect/commands/InspectMeasureCommand.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 +376 -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 +23 -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 +23 -0
- package/dist/cli/utils/ConsoleTable.js +86 -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 +82 -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 +8 -0
- package/dist/cli/utils/interactivelyAskForModel.js +461 -0
- package/dist/cli/utils/interactivelyAskForModel.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/printCommonInfoLines.d.ts +9 -0
- package/dist/cli/utils/printCommonInfoLines.js +79 -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/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/resolveCommandGgufPath.d.ts +5 -0
- package/dist/cli/utils/resolveCommandGgufPath.js +72 -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 +19 -0
- package/dist/cli/utils/resolveModelRecommendationFileOptions.js +7 -0
- package/dist/cli/utils/resolveModelRecommendationFileOptions.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/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 +1 -0
- package/dist/commands.js +3 -0
- package/dist/commands.js.map +1 -1
- package/dist/config.d.ts +38 -5
- package/dist/config.js +61 -16
- package/dist/config.js.map +1 -1
- 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 +270 -0
- package/dist/evaluator/LlamaChat/LlamaChat.js +1544 -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/{llamaEvaluator → evaluator}/LlamaChat/utils/contextShiftStrategies/eraseFirstResponseAndKeepFirstSystemChatContextShiftStrategy.js +42 -16
- package/dist/evaluator/LlamaChat/utils/contextShiftStrategies/eraseFirstResponseAndKeepFirstSystemChatContextShiftStrategy.js.map +1 -0
- package/dist/evaluator/LlamaChatSession/LlamaChatSession.d.ts +310 -0
- package/dist/evaluator/LlamaChatSession/LlamaChatSession.js +425 -0
- package/dist/evaluator/LlamaChatSession/LlamaChatSession.js.map +1 -0
- package/dist/evaluator/LlamaChatSession/utils/LlamaChatSessionPromptCompletionEngine.d.ts +39 -0
- package/dist/evaluator/LlamaChatSession/utils/LlamaChatSessionPromptCompletionEngine.js +186 -0
- package/dist/evaluator/LlamaChatSession/utils/LlamaChatSessionPromptCompletionEngine.js.map +1 -0
- package/dist/{llamaEvaluator → evaluator}/LlamaChatSession/utils/defineChatSessionFunction.d.ts +3 -0
- package/dist/{llamaEvaluator → evaluator}/LlamaChatSession/utils/defineChatSessionFunction.js +3 -0
- package/dist/evaluator/LlamaChatSession/utils/defineChatSessionFunction.js.map +1 -0
- package/dist/evaluator/LlamaCompletion.d.ts +154 -0
- package/dist/evaluator/LlamaCompletion.js +424 -0
- package/dist/evaluator/LlamaCompletion.js.map +1 -0
- package/dist/{llamaEvaluator → evaluator}/LlamaContext/LlamaContext.d.ts +42 -22
- package/dist/{llamaEvaluator → evaluator}/LlamaContext/LlamaContext.js +338 -81
- package/dist/evaluator/LlamaContext/LlamaContext.js.map +1 -0
- package/dist/evaluator/LlamaContext/types.d.ts +175 -0
- package/dist/evaluator/LlamaContext/types.js.map +1 -0
- package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/firstInFirstOutStrategy.js.map +1 -0
- package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/maximumParallelismStrategy.js.map +1 -0
- package/dist/evaluator/LlamaContext/utils/resolveBatchItemsPrioritizationStrategy.d.ts +2 -0
- package/dist/{llamaEvaluator/LlamaContext/utils/resolveBatchItemsPrioritizingStrategy.js → evaluator/LlamaContext/utils/resolveBatchItemsPrioritizationStrategy.js} +4 -4
- package/dist/evaluator/LlamaContext/utils/resolveBatchItemsPrioritizationStrategy.js.map +1 -0
- package/dist/evaluator/LlamaEmbeddingContext.d.ts +51 -0
- package/dist/evaluator/LlamaEmbeddingContext.js +73 -0
- package/dist/evaluator/LlamaEmbeddingContext.js.map +1 -0
- package/dist/evaluator/LlamaGrammar.d.ts +34 -0
- package/dist/{llamaEvaluator → evaluator}/LlamaGrammar.js +15 -12
- package/dist/evaluator/LlamaGrammar.js.map +1 -0
- package/dist/{llamaEvaluator → evaluator}/LlamaGrammarEvaluationState.js +4 -4
- package/dist/evaluator/LlamaGrammarEvaluationState.js.map +1 -0
- package/dist/{llamaEvaluator → evaluator}/LlamaJsonSchemaGrammar.d.ts +2 -1
- package/dist/{llamaEvaluator → evaluator}/LlamaJsonSchemaGrammar.js +3 -3
- package/dist/evaluator/LlamaJsonSchemaGrammar.js.map +1 -0
- package/dist/evaluator/LlamaModel/LlamaModel.d.ts +242 -0
- package/dist/evaluator/LlamaModel/LlamaModel.js +765 -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/TokenBias.d.ts +22 -0
- package/dist/evaluator/TokenBias.js +33 -0
- package/dist/evaluator/TokenBias.js.map +1 -0
- package/dist/evaluator/TokenMeter.d.ts +54 -0
- package/dist/evaluator/TokenMeter.js +86 -0
- package/dist/evaluator/TokenMeter.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 +37 -0
- package/dist/gguf/fileReaders/GgufFileReader.js +109 -0
- package/dist/gguf/fileReaders/GgufFileReader.js.map +1 -0
- package/dist/gguf/fileReaders/GgufFsFileReader.d.ts +18 -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 +23 -0
- package/dist/gguf/fileReaders/GgufNetworkFetchFileReader.js +79 -0
- package/dist/gguf/fileReaders/GgufNetworkFetchFileReader.js.map +1 -0
- package/dist/gguf/insights/GgufInsights.d.ts +50 -0
- package/dist/gguf/insights/GgufInsights.js +401 -0
- package/dist/gguf/insights/GgufInsights.js.map +1 -0
- package/dist/gguf/insights/GgufInsightsConfigurationResolver.d.ts +90 -0
- package/dist/gguf/insights/GgufInsightsConfigurationResolver.js +144 -0
- package/dist/gguf/insights/GgufInsightsConfigurationResolver.js.map +1 -0
- package/dist/gguf/insights/utils/resolveContextContextSizeOption.d.ts +19 -0
- package/dist/gguf/insights/utils/resolveContextContextSizeOption.js +78 -0
- package/dist/gguf/insights/utils/resolveContextContextSizeOption.js.map +1 -0
- package/dist/gguf/insights/utils/resolveModelGpuLayersOption.d.ts +15 -0
- package/dist/gguf/insights/utils/resolveModelGpuLayersOption.js +183 -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 +156 -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 +33 -0
- package/dist/gguf/readGgufFileInfo.js +66 -0
- package/dist/gguf/readGgufFileInfo.js.map +1 -0
- package/dist/gguf/types/GgufFileInfoTypes.d.ts +84 -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 +356 -0
- package/dist/gguf/types/GgufMetadataTypes.js +99 -0
- package/dist/gguf/types/GgufMetadataTypes.js.map +1 -0
- package/dist/gguf/types/GgufTensorInfoTypes.d.ts +37 -0
- package/dist/gguf/types/GgufTensorInfoTypes.js +33 -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 +74 -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/normalizeGgufDownloadUrl.d.ts +1 -0
- package/dist/gguf/utils/normalizeGgufDownloadUrl.js +16 -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 +39 -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 +55 -0
- package/dist/gguf/utils/resolveSplitGgufParts.js.map +1 -0
- package/dist/index.d.ts +43 -18
- package/dist/index.js +38 -15
- package/dist/index.js.map +1 -1
- package/dist/state.d.ts +4 -0
- package/dist/state.js +14 -0
- package/dist/state.js.map +1 -1
- package/dist/types.d.ts +130 -5
- package/dist/types.js.map +1 -1
- package/dist/utils/DeepPartialObject.d.ts +3 -0
- package/dist/utils/DeepPartialObject.js +2 -0
- package/dist/utils/DeepPartialObject.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 +70 -26
- package/dist/utils/LlamaText.js +472 -157
- package/dist/utils/LlamaText.js.map +1 -1
- 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/ReplHistory.js +5 -1
- package/dist/utils/ReplHistory.js.map +1 -1
- package/dist/utils/StopGenerationDetector.d.ts +27 -8
- package/dist/utils/StopGenerationDetector.js +108 -22
- package/dist/utils/StopGenerationDetector.js.map +1 -1
- package/dist/utils/TokenStreamRegulator.d.ts +10 -4
- package/dist/utils/TokenStreamRegulator.js +102 -10
- package/dist/utils/TokenStreamRegulator.js.map +1 -1
- 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.js.map +1 -1
- package/dist/utils/clearTempFolder.js.map +1 -1
- package/dist/utils/cmake.js +38 -20
- package/dist/utils/cmake.js.map +1 -1
- package/dist/utils/createModelDownloader.d.ts +111 -0
- package/dist/utils/createModelDownloader.js +273 -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 +1 -0
- package/dist/utils/findCharacterRemovalCountToFitChatHistoryInContext.js +23 -12
- package/dist/utils/findCharacterRemovalCountToFitChatHistoryInContext.js.map +1 -1
- package/dist/utils/gbnfJson/GbnfGrammarGenerator.js.map +1 -1
- 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/GbnfArray.d.ts +3 -1
- package/dist/utils/gbnfJson/terminals/GbnfArray.js +10 -5
- package/dist/utils/gbnfJson/terminals/GbnfArray.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfBoolean.d.ts +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfBoolean.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfBooleanValue.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfGrammar.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfNull.d.ts +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfNull.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfNumber.d.ts +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfNumber.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfNumberValue.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfObjectMap.d.ts +3 -1
- package/dist/utils/gbnfJson/terminals/GbnfObjectMap.js +9 -4
- package/dist/utils/gbnfJson/terminals/GbnfObjectMap.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfOr.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfRepetition.d.ts +9 -0
- package/dist/utils/gbnfJson/terminals/GbnfRepetition.js +37 -0
- package/dist/utils/gbnfJson/terminals/GbnfRepetition.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfString.d.ts +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfString.js +23 -5
- package/dist/utils/gbnfJson/terminals/GbnfString.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfStringValue.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfVerbatimText.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/GbnfWhitespace.d.ts +7 -4
- package/dist/utils/gbnfJson/terminals/GbnfWhitespace.js +37 -9
- package/dist/utils/gbnfJson/terminals/GbnfWhitespace.js.map +1 -1
- package/dist/utils/gbnfJson/terminals/gbnfConsts.d.ts +5 -4
- package/dist/utils/gbnfJson/terminals/gbnfConsts.js +14 -3
- package/dist/utils/gbnfJson/terminals/gbnfConsts.js.map +1 -1
- package/dist/utils/gbnfJson/types.d.ts +3 -0
- package/dist/utils/gbnfJson/types.js.map +1 -1
- 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/getGbnfJsonTerminalForGbnfJsonSchema.d.ts +2 -1
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js +6 -5
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js.map +1 -1
- package/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js +2 -2
- package/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js.map +1 -1
- package/dist/utils/getBuildDefaults.d.ts +1 -2
- package/dist/utils/getBuildDefaults.js +2 -3
- package/dist/utils/getBuildDefaults.js.map +1 -1
- 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/getGrammarsFolder.d.ts +2 -1
- package/dist/utils/getGrammarsFolder.js +8 -7
- package/dist/utils/getGrammarsFolder.js.map +1 -1
- 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/getTypeScriptTypeStringForGbnfJsonSchema.js +15 -11
- package/dist/utils/getTypeScriptTypeStringForGbnfJsonSchema.js.map +1 -1
- package/dist/utils/gitReleaseBundles.js +73 -5
- package/dist/utils/gitReleaseBundles.js.map +1 -1
- 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/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/parseModelFileName.d.ts +1 -0
- package/dist/utils/parseModelFileName.js +6 -1
- package/dist/utils/parseModelFileName.js.map +1 -1
- 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 -1
- package/dist/utils/removeNullFields.js +8 -0
- package/dist/utils/removeNullFields.js.map +1 -1
- package/dist/utils/resolveGithubRelease.d.ts +2 -0
- package/dist/utils/resolveGithubRelease.js +36 -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/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/spawnCommand.d.ts +11 -1
- package/dist/utils/spawnCommand.js +56 -6
- package/dist/utils/spawnCommand.js.map +1 -1
- package/dist/utils/tokenizeInput.d.ts +3 -0
- package/dist/utils/tokenizeInput.js +12 -0
- package/dist/utils/tokenizeInput.js.map +1 -0
- package/dist/utils/transformPromisable.d.ts +40 -0
- package/dist/utils/transformPromisable.js +64 -0
- package/dist/utils/transformPromisable.js.map +1 -0
- package/dist/utils/truncateTextAndRoundToWords.d.ts +2 -0
- package/dist/utils/truncateTextAndRoundToWords.js +30 -0
- package/dist/utils/truncateTextAndRoundToWords.js.map +1 -1
- package/dist/utils/utilTypes.d.ts +3 -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 +20 -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 +2 -0
- package/dist/utils/withOra.js +22 -6
- package/dist/utils/withOra.js.map +1 -1
- package/dist/utils/withProgressLog.d.ts +23 -0
- package/dist/utils/withProgressLog.js +211 -0
- package/dist/utils/withProgressLog.js.map +1 -0
- package/dist/utils/withStatusLogs.d.ts +2 -1
- package/dist/utils/withStatusLogs.js +12 -9
- package/dist/utils/withStatusLogs.js.map +1 -1
- package/dist/utils/wrapAbortSignal.d.ts +2 -0
- package/dist/utils/wrapAbortSignal.js +9 -0
- package/dist/utils/wrapAbortSignal.js.map +1 -0
- package/llama/.clang-format +1 -2
- package/llama/CMakeLists.txt +126 -5
- package/llama/addon/AddonContext.cpp +762 -0
- package/llama/addon/AddonContext.h +53 -0
- package/llama/addon/AddonGrammar.cpp +42 -0
- package/llama/addon/AddonGrammar.h +18 -0
- package/llama/addon/AddonGrammarEvaluationState.cpp +26 -0
- package/llama/addon/AddonGrammarEvaluationState.h +15 -0
- package/llama/addon/AddonModel.cpp +671 -0
- package/llama/addon/AddonModel.h +61 -0
- package/llama/addon/AddonModelData.cpp +25 -0
- package/llama/addon/AddonModelData.h +15 -0
- package/llama/addon/AddonModelLora.cpp +105 -0
- package/llama/addon/AddonModelLora.h +28 -0
- package/llama/addon/addon.cpp +216 -0
- package/llama/addon/addonGlobals.cpp +22 -0
- package/llama/addon/addonGlobals.h +12 -0
- package/llama/addon/globals/addonLog.cpp +135 -0
- package/llama/addon/globals/addonLog.h +21 -0
- package/llama/addon/globals/addonProgress.cpp +15 -0
- package/llama/addon/globals/addonProgress.h +15 -0
- package/llama/addon/globals/getGpuInfo.cpp +108 -0
- package/llama/addon/globals/getGpuInfo.h +6 -0
- package/llama/binariesGithubRelease.json +1 -1
- package/llama/gitRelease.bundle +0 -0
- package/llama/gpuInfo/cuda-gpu-info.cu +120 -0
- package/llama/gpuInfo/cuda-gpu-info.h +10 -0
- package/llama/gpuInfo/metal-gpu-info.h +8 -0
- package/llama/gpuInfo/metal-gpu-info.mm +30 -0
- package/llama/gpuInfo/vulkan-gpu-info.cpp +83 -0
- package/llama/gpuInfo/vulkan-gpu-info.h +9 -0
- package/llama/grammars/README.md +297 -6
- package/llama/grammars/json.gbnf +4 -4
- package/llama/grammars/json_arr.gbnf +4 -4
- package/llama/llama.cpp.info.json +4 -0
- package/llama/toolchains/win32.host-x64.target-arm64.cmake +41 -0
- package/package.json +85 -54
- package/templates/packed/electron-typescript-react.json +1 -0
- package/templates/packed/node-typescript.json +1 -0
- package/dist/AbortError.d.ts +0 -2
- package/dist/AbortError.js +0 -7
- package/dist/AbortError.js.map +0 -1
- package/dist/chatWrappers/LlamaChatWrapper.d.ts +0 -13
- package/dist/chatWrappers/LlamaChatWrapper.js.map +0 -1
- package/dist/chatWrappers/resolveChatWrapperBasedOnModel.d.ts +0 -13
- package/dist/chatWrappers/resolveChatWrapperBasedOnModel.js +0 -57
- package/dist/chatWrappers/resolveChatWrapperBasedOnModel.js.map +0 -1
- package/dist/llamaEvaluator/LlamaBins.d.ts +0 -18
- package/dist/llamaEvaluator/LlamaBins.js +0 -5
- package/dist/llamaEvaluator/LlamaBins.js.map +0 -1
- package/dist/llamaEvaluator/LlamaChat/LlamaChat.d.ts +0 -175
- package/dist/llamaEvaluator/LlamaChat/LlamaChat.js +0 -704
- package/dist/llamaEvaluator/LlamaChat/LlamaChat.js.map +0 -1
- package/dist/llamaEvaluator/LlamaChat/utils/FunctionCallGrammar.d.ts +0 -21
- package/dist/llamaEvaluator/LlamaChat/utils/FunctionCallGrammar.js +0 -120
- package/dist/llamaEvaluator/LlamaChat/utils/FunctionCallGrammar.js.map +0 -1
- package/dist/llamaEvaluator/LlamaChat/utils/contextShiftStrategies/eraseFirstResponseAndKeepFirstSystemChatContextShiftStrategy.js.map +0 -1
- package/dist/llamaEvaluator/LlamaChatSession/LlamaChatSession.d.ts +0 -146
- package/dist/llamaEvaluator/LlamaChatSession/LlamaChatSession.js +0 -211
- package/dist/llamaEvaluator/LlamaChatSession/LlamaChatSession.js.map +0 -1
- package/dist/llamaEvaluator/LlamaChatSession/utils/defineChatSessionFunction.js.map +0 -1
- package/dist/llamaEvaluator/LlamaContext/LlamaContext.js.map +0 -1
- package/dist/llamaEvaluator/LlamaContext/types.d.ts +0 -82
- package/dist/llamaEvaluator/LlamaContext/types.js.map +0 -1
- package/dist/llamaEvaluator/LlamaContext/utils/batchItemsPrioritizingStrategies/firstInFirstOutStrategy.js.map +0 -1
- package/dist/llamaEvaluator/LlamaContext/utils/batchItemsPrioritizingStrategies/maximumParallelismStrategy.js.map +0 -1
- package/dist/llamaEvaluator/LlamaContext/utils/resolveBatchItemsPrioritizingStrategy.d.ts +0 -2
- package/dist/llamaEvaluator/LlamaContext/utils/resolveBatchItemsPrioritizingStrategy.js.map +0 -1
- package/dist/llamaEvaluator/LlamaEmbeddingContext.d.ts +0 -35
- package/dist/llamaEvaluator/LlamaEmbeddingContext.js +0 -73
- package/dist/llamaEvaluator/LlamaEmbeddingContext.js.map +0 -1
- package/dist/llamaEvaluator/LlamaGrammar.d.ts +0 -28
- package/dist/llamaEvaluator/LlamaGrammar.js.map +0 -1
- package/dist/llamaEvaluator/LlamaGrammarEvaluationState.js.map +0 -1
- package/dist/llamaEvaluator/LlamaJsonSchemaGrammar.js.map +0 -1
- package/dist/llamaEvaluator/LlamaModel.d.ts +0 -119
- package/dist/llamaEvaluator/LlamaModel.js +0 -322
- package/dist/llamaEvaluator/LlamaModel.js.map +0 -1
- package/dist/utils/binariesGithubRelease.js.map +0 -1
- package/dist/utils/clearLlamaBuild.d.ts +0 -1
- package/dist/utils/clearLlamaBuild.js +0 -12
- package/dist/utils/clearLlamaBuild.js.map +0 -1
- package/dist/utils/cloneLlamaCppRepo.d.ts +0 -2
- package/dist/utils/cloneLlamaCppRepo.js +0 -102
- package/dist/utils/cloneLlamaCppRepo.js.map +0 -1
- package/dist/utils/compileLLamaCpp.d.ts +0 -8
- package/dist/utils/compileLLamaCpp.js +0 -132
- package/dist/utils/compileLLamaCpp.js.map +0 -1
- package/dist/utils/getBin.js +0 -78
- package/dist/utils/getBin.js.map +0 -1
- package/dist/utils/getGbnfGrammarForGbnfJsonSchema.d.ts +0 -2
- package/dist/utils/getGbnfGrammarForGbnfJsonSchema.js +0 -9
- package/dist/utils/getGbnfGrammarForGbnfJsonSchema.js.map +0 -1
- package/dist/utils/getReleaseInfo.d.ts +0 -7
- package/dist/utils/getReleaseInfo.js +0 -30
- package/dist/utils/getReleaseInfo.js.map +0 -1
- package/dist/utils/parseModelTypeDescription.d.ts +0 -6
- package/dist/utils/parseModelTypeDescription.js +0 -9
- package/dist/utils/parseModelTypeDescription.js.map +0 -1
- package/dist/utils/resolveChatWrapper.d.ts +0 -4
- package/dist/utils/resolveChatWrapper.js +0 -16
- package/dist/utils/resolveChatWrapper.js.map +0 -1
- package/dist/utils/usedBinFlag.d.ts +0 -6
- package/dist/utils/usedBinFlag.js +0 -15
- package/dist/utils/usedBinFlag.js.map +0 -1
- package/llama/addon.cpp +0 -814
- package/llama/usedBin.json +0 -3
- package/llamaBins/linux-arm64/llama-addon.node +0 -0
- package/llamaBins/linux-armv7l/llama-addon.node +0 -0
- package/llamaBins/linux-x64/llama-addon.node +0 -0
- package/llamaBins/mac-arm64/llama-addon.node +0 -0
- package/llamaBins/mac-x64/llama-addon.node +0 -0
- package/llamaBins/win-x64/llama-addon.exp +0 -0
- package/llamaBins/win-x64/llama-addon.lib +0 -0
- package/llamaBins/win-x64/llama-addon.node +0 -0
- /package/dist/{utils → bindings/utils}/binariesGithubRelease.d.ts +0 -0
- /package/dist/{llamaEvaluator → evaluator}/LlamaChat/utils/contextShiftStrategies/eraseFirstResponseAndKeepFirstSystemChatContextShiftStrategy.d.ts +0 -0
- /package/dist/{llamaEvaluator → evaluator}/LlamaContext/types.js +0 -0
- /package/dist/{llamaEvaluator/LlamaContext/utils/batchItemsPrioritizingStrategies → evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies}/firstInFirstOutStrategy.d.ts +0 -0
- /package/dist/{llamaEvaluator/LlamaContext/utils/batchItemsPrioritizingStrategies → evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies}/firstInFirstOutStrategy.js +0 -0
- /package/dist/{llamaEvaluator/LlamaContext/utils/batchItemsPrioritizingStrategies → evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies}/maximumParallelismStrategy.d.ts +0 -0
- /package/dist/{llamaEvaluator/LlamaContext/utils/batchItemsPrioritizingStrategies → evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies}/maximumParallelismStrategy.js +0 -0
- /package/dist/{llamaEvaluator → evaluator}/LlamaGrammarEvaluationState.d.ts +0 -0
|
@@ -3,257 +3,411 @@ import process from "process";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import fs from "fs-extra";
|
|
6
|
-
import { chatCommandHistoryFilePath, defaultChatSystemPrompt } from "../../config.js";
|
|
7
|
-
import { LlamaChatWrapper } from "../../chatWrappers/LlamaChatWrapper.js";
|
|
8
|
-
import { GeneralChatWrapper } from "../../chatWrappers/GeneralChatWrapper.js";
|
|
9
|
-
import { ChatMLChatWrapper } from "../../chatWrappers/ChatMLChatWrapper.js";
|
|
10
|
-
import { resolveChatWrapperBasedOnModel } from "../../chatWrappers/resolveChatWrapperBasedOnModel.js";
|
|
11
|
-
import { FalconChatWrapper } from "../../chatWrappers/FalconChatWrapper.js";
|
|
6
|
+
import { chatCommandHistoryFilePath, defaultChatSystemPrompt, documentationPageUrls } from "../../config.js";
|
|
12
7
|
import { getIsInDocumentationMode } from "../../state.js";
|
|
13
8
|
import { ReplHistory } from "../../utils/ReplHistory.js";
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
9
|
+
import { defineChatSessionFunction } from "../../evaluator/LlamaChatSession/utils/defineChatSessionFunction.js";
|
|
10
|
+
import { getLlama } from "../../bindings/getLlama.js";
|
|
11
|
+
import { LlamaGrammar } from "../../evaluator/LlamaGrammar.js";
|
|
12
|
+
import { LlamaChatSession } from "../../evaluator/LlamaChatSession/LlamaChatSession.js";
|
|
13
|
+
import { LlamaJsonSchemaGrammar } from "../../evaluator/LlamaJsonSchemaGrammar.js";
|
|
14
|
+
import { LlamaLogLevel, LlamaLogLevelGreaterThan, nodeLlamaCppGpuOptions, parseNodeLlamaCppGpuOption } from "../../bindings/types.js";
|
|
15
|
+
import withOra from "../../utils/withOra.js";
|
|
16
|
+
import { TokenMeter } from "../../evaluator/TokenMeter.js";
|
|
17
|
+
import { printInfoLine } from "../utils/printInfoLine.js";
|
|
18
|
+
import { resolveChatWrapper, specializedChatWrapperTypeNames } from "../../chatWrappers/utils/resolveChatWrapper.js";
|
|
19
|
+
import { GeneralChatWrapper } from "../../chatWrappers/GeneralChatWrapper.js";
|
|
20
|
+
import { printCommonInfoLines } from "../utils/printCommonInfoLines.js";
|
|
21
|
+
import { resolveCommandGgufPath } from "../utils/resolveCommandGgufPath.js";
|
|
22
|
+
import { withProgressLog } from "../../utils/withProgressLog.js";
|
|
23
|
+
import { resolveHeaderFlag } from "../utils/resolveHeaderFlag.js";
|
|
24
|
+
import { withCliCommandDescriptionDocsUrl } from "../utils/withCliCommandDescriptionDocsUrl.js";
|
|
19
25
|
export const ChatCommand = {
|
|
20
|
-
command: "chat",
|
|
21
|
-
describe: "Chat with a Llama model",
|
|
26
|
+
command: "chat [modelPath]",
|
|
27
|
+
describe: withCliCommandDescriptionDocsUrl("Chat with a Llama model", documentationPageUrls.CLI.Chat),
|
|
22
28
|
builder(yargs) {
|
|
23
29
|
const isInDocumentationMode = getIsInDocumentationMode();
|
|
24
30
|
return yargs
|
|
25
|
-
.option("
|
|
26
|
-
alias: "m",
|
|
31
|
+
.option("modelPath", {
|
|
32
|
+
alias: ["m", "model", "path", "url"],
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "Llama model file to use for the chat. Can be a path to a local file or a URL of a model file to download"
|
|
35
|
+
})
|
|
36
|
+
.option("header", {
|
|
37
|
+
alias: ["H"],
|
|
27
38
|
type: "string",
|
|
28
|
-
|
|
29
|
-
description: "
|
|
30
|
-
|
|
39
|
+
array: true,
|
|
40
|
+
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."
|
|
41
|
+
})
|
|
42
|
+
.option("gpu", {
|
|
43
|
+
type: "string",
|
|
44
|
+
// yargs types don't support passing `false` as a choice, although it is supported by yargs
|
|
45
|
+
choices: nodeLlamaCppGpuOptions,
|
|
46
|
+
coerce: (value) => {
|
|
47
|
+
if (value == null || value == "")
|
|
48
|
+
return undefined;
|
|
49
|
+
return parseNodeLlamaCppGpuOption(value);
|
|
50
|
+
},
|
|
51
|
+
defaultDescription: "Uses the latest local build, and fallbacks to \"auto\"",
|
|
52
|
+
description: "Compute layer implementation type to use for llama.cpp. If omitted, uses the latest local build, and fallbacks to \"auto\""
|
|
31
53
|
})
|
|
32
54
|
.option("systemInfo", {
|
|
33
55
|
alias: "i",
|
|
34
56
|
type: "boolean",
|
|
35
57
|
default: false,
|
|
36
|
-
description: "Print llama.cpp system info"
|
|
37
|
-
group: "Optional:"
|
|
58
|
+
description: "Print llama.cpp system info"
|
|
38
59
|
})
|
|
39
60
|
.option("systemPrompt", {
|
|
40
61
|
alias: "s",
|
|
41
62
|
type: "string",
|
|
42
|
-
default: defaultChatSystemPrompt,
|
|
43
|
-
defaultDescription: " ",
|
|
44
63
|
description: "System prompt to use against the model" +
|
|
45
|
-
(isInDocumentationMode ? "" : (". [default value: " + defaultChatSystemPrompt.split("\n").join(" ") + "]"))
|
|
46
|
-
|
|
64
|
+
(isInDocumentationMode ? "" : (". [default value: " + defaultChatSystemPrompt.split("\n").join(" ") + "]"))
|
|
65
|
+
})
|
|
66
|
+
.option("systemPromptFile", {
|
|
67
|
+
type: "string",
|
|
68
|
+
description: "Path to a file to load text from and use as as the model system prompt"
|
|
47
69
|
})
|
|
48
70
|
.option("prompt", {
|
|
49
71
|
type: "string",
|
|
50
|
-
description: "First prompt to automatically send to the model when starting the chat"
|
|
51
|
-
|
|
72
|
+
description: "First prompt to automatically send to the model when starting the chat"
|
|
73
|
+
})
|
|
74
|
+
.option("promptFile", {
|
|
75
|
+
type: "string",
|
|
76
|
+
description: "Path to a file to load text from and use as a first prompt to automatically send to the model when starting the chat"
|
|
52
77
|
})
|
|
53
78
|
.option("wrapper", {
|
|
54
79
|
alias: "w",
|
|
55
80
|
type: "string",
|
|
56
81
|
default: "auto",
|
|
57
|
-
choices:
|
|
58
|
-
description: "Chat wrapper to use. Use `auto` to automatically select a wrapper based on the model's BOS token"
|
|
59
|
-
|
|
82
|
+
choices: ["auto", ...specializedChatWrapperTypeNames],
|
|
83
|
+
description: "Chat wrapper to use. Use `auto` to automatically select a wrapper based on the model's BOS token"
|
|
84
|
+
})
|
|
85
|
+
.option("noJinja", {
|
|
86
|
+
type: "boolean",
|
|
87
|
+
default: false,
|
|
88
|
+
description: "Don't use a Jinja wrapper, even if it's the best option for the model"
|
|
60
89
|
})
|
|
61
90
|
.option("contextSize", {
|
|
62
91
|
alias: "c",
|
|
63
92
|
type: "number",
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
93
|
+
description: "Context size to use for the model context",
|
|
94
|
+
default: -1,
|
|
95
|
+
defaultDescription: "Automatically determined based on the available VRAM"
|
|
96
|
+
})
|
|
97
|
+
.option("batchSize", {
|
|
98
|
+
alias: "b",
|
|
99
|
+
type: "number",
|
|
100
|
+
description: "Batch size to use for the model context. The default value is the context size"
|
|
101
|
+
})
|
|
102
|
+
.option("flashAttention", {
|
|
103
|
+
alias: "fa",
|
|
104
|
+
type: "boolean",
|
|
105
|
+
default: false,
|
|
106
|
+
description: "Enable flash attention"
|
|
107
|
+
})
|
|
108
|
+
.option("noTrimWhitespace", {
|
|
109
|
+
type: "boolean",
|
|
110
|
+
alias: ["noTrim"],
|
|
111
|
+
default: false,
|
|
112
|
+
description: "Don't trim whitespaces from the model response"
|
|
67
113
|
})
|
|
68
114
|
.option("grammar", {
|
|
69
115
|
alias: "g",
|
|
70
116
|
type: "string",
|
|
71
117
|
default: "text",
|
|
72
118
|
choices: ["text", "json", "list", "arithmetic", "japanese", "chess"],
|
|
73
|
-
description: "Restrict the model response to a specific grammar, like JSON for example"
|
|
74
|
-
group: "Optional:"
|
|
119
|
+
description: "Restrict the model response to a specific grammar, like JSON for example"
|
|
75
120
|
})
|
|
76
121
|
.option("jsonSchemaGrammarFile", {
|
|
77
122
|
alias: ["jsgf"],
|
|
78
123
|
type: "string",
|
|
79
|
-
description: "File path to a JSON schema file, to restrict the model response to only generate output that conforms to the JSON schema"
|
|
80
|
-
group: "Optional:"
|
|
124
|
+
description: "File path to a JSON schema file, to restrict the model response to only generate output that conforms to the JSON schema"
|
|
81
125
|
})
|
|
82
126
|
.option("threads", {
|
|
83
127
|
type: "number",
|
|
84
128
|
default: 6,
|
|
85
|
-
description: "Number of threads to use for the evaluation of tokens"
|
|
86
|
-
group: "Optional:"
|
|
129
|
+
description: "Number of threads to use for the evaluation of tokens"
|
|
87
130
|
})
|
|
88
131
|
.option("temperature", {
|
|
89
132
|
alias: "t",
|
|
90
133
|
type: "number",
|
|
91
134
|
default: 0,
|
|
92
|
-
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."
|
|
93
|
-
|
|
135
|
+
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."
|
|
136
|
+
})
|
|
137
|
+
.option("minP", {
|
|
138
|
+
alias: "mp",
|
|
139
|
+
type: "number",
|
|
140
|
+
default: 0,
|
|
141
|
+
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`."
|
|
94
142
|
})
|
|
95
143
|
.option("topK", {
|
|
96
144
|
alias: "k",
|
|
97
145
|
type: "number",
|
|
98
146
|
default: 40,
|
|
99
|
-
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."
|
|
100
|
-
group: "Optional:"
|
|
147
|
+
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."
|
|
101
148
|
})
|
|
102
149
|
.option("topP", {
|
|
103
150
|
alias: "p",
|
|
104
151
|
type: "number",
|
|
105
152
|
default: 0.95,
|
|
106
|
-
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`."
|
|
107
|
-
group: "Optional:"
|
|
153
|
+
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`."
|
|
108
154
|
})
|
|
109
155
|
.option("gpuLayers", {
|
|
110
156
|
alias: "gl",
|
|
111
157
|
type: "number",
|
|
112
158
|
description: "number of layers to store in VRAM",
|
|
113
|
-
|
|
159
|
+
default: -1,
|
|
160
|
+
defaultDescription: "Automatically determined based on the available VRAM"
|
|
114
161
|
})
|
|
115
162
|
.option("repeatPenalty", {
|
|
116
163
|
alias: "rp",
|
|
117
164
|
type: "number",
|
|
118
165
|
default: 1.1,
|
|
119
|
-
description: "Prevent the model from repeating the same token too much. Set to `1` to disable."
|
|
120
|
-
group: "Optional:"
|
|
166
|
+
description: "Prevent the model from repeating the same token too much. Set to `1` to disable."
|
|
121
167
|
})
|
|
122
168
|
.option("lastTokensRepeatPenalty", {
|
|
123
169
|
alias: "rpn",
|
|
124
170
|
type: "number",
|
|
125
171
|
default: 64,
|
|
126
|
-
description: "Number of recent tokens generated by the model to apply penalties to repetition of"
|
|
127
|
-
group: "Optional:"
|
|
172
|
+
description: "Number of recent tokens generated by the model to apply penalties to repetition of"
|
|
128
173
|
})
|
|
129
174
|
.option("penalizeRepeatingNewLine", {
|
|
130
175
|
alias: "rpnl",
|
|
131
176
|
type: "boolean",
|
|
132
177
|
default: true,
|
|
133
|
-
description: "Penalize new line tokens. set
|
|
134
|
-
group: "Optional:"
|
|
178
|
+
description: "Penalize new line tokens. set `--no-penalizeRepeatingNewLine` or `--no-rpnl` to disable"
|
|
135
179
|
})
|
|
136
180
|
.option("repeatFrequencyPenalty", {
|
|
137
181
|
alias: "rfp",
|
|
138
182
|
type: "number",
|
|
139
|
-
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."
|
|
140
|
-
group: "Optional:"
|
|
183
|
+
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."
|
|
141
184
|
})
|
|
142
185
|
.option("repeatPresencePenalty", {
|
|
143
186
|
alias: "rpp",
|
|
144
187
|
type: "number",
|
|
145
|
-
description: "Lower the probability of all the tokens in the `punishTokens` array by `repeatPresencePenalty`. Set to a value between `0` and `1` to enable."
|
|
146
|
-
group: "Optional:"
|
|
188
|
+
description: "Lower the probability of all the tokens in the `punishTokens` array by `repeatPresencePenalty`. Set to a value between `0` and `1` to enable."
|
|
147
189
|
})
|
|
148
190
|
.option("maxTokens", {
|
|
149
191
|
alias: "mt",
|
|
150
192
|
type: "number",
|
|
151
193
|
default: 0,
|
|
152
|
-
description: "Maximum number of tokens to generate in responses. Set to `0` to disable. Set to `-1` to set to the context size"
|
|
153
|
-
group: "Optional:"
|
|
194
|
+
description: "Maximum number of tokens to generate in responses. Set to `0` to disable. Set to `-1` to set to the context size"
|
|
154
195
|
})
|
|
155
196
|
.option("noHistory", {
|
|
156
197
|
alias: "nh",
|
|
157
198
|
type: "boolean",
|
|
158
199
|
default: false,
|
|
159
|
-
description: "Don't load or save chat history"
|
|
160
|
-
group: "Optional:"
|
|
200
|
+
description: "Don't load or save chat history"
|
|
161
201
|
})
|
|
162
202
|
.option("environmentFunctions", {
|
|
163
203
|
alias: "ef",
|
|
164
204
|
type: "boolean",
|
|
165
205
|
default: false,
|
|
166
|
-
description: "Provide access to environment functions like `getDate` and `getTime`"
|
|
167
|
-
|
|
206
|
+
description: "Provide access to environment functions like `getDate` and `getTime`"
|
|
207
|
+
})
|
|
208
|
+
.option("debug", {
|
|
209
|
+
alias: "d",
|
|
210
|
+
type: "boolean",
|
|
211
|
+
default: false,
|
|
212
|
+
description: "Print llama.cpp info and debug logs"
|
|
213
|
+
})
|
|
214
|
+
.option("meter", {
|
|
215
|
+
type: "boolean",
|
|
216
|
+
default: false,
|
|
217
|
+
description: "Print how many tokens were used as input and output for each response"
|
|
168
218
|
})
|
|
169
219
|
.option("printTimings", {
|
|
170
220
|
alias: "pt",
|
|
171
221
|
type: "boolean",
|
|
172
222
|
default: false,
|
|
173
|
-
description: "Print llama.cpp timings after each response"
|
|
174
|
-
group: "Optional:"
|
|
223
|
+
description: "Print llama.cpp timings after each response"
|
|
175
224
|
});
|
|
176
225
|
},
|
|
177
|
-
async handler({
|
|
226
|
+
async handler({ modelPath, header, gpu, systemInfo, systemPrompt, systemPromptFile, prompt, promptFile, wrapper, noJinja, contextSize, batchSize, flashAttention, noTrimWhitespace, grammar, jsonSchemaGrammarFile, threads, temperature, minP, topK, topP, gpuLayers, repeatPenalty, lastTokensRepeatPenalty, penalizeRepeatingNewLine, repeatFrequencyPenalty, repeatPresencePenalty, maxTokens, noHistory, environmentFunctions, debug, meter, printTimings }) {
|
|
178
227
|
try {
|
|
179
228
|
await RunChat({
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
229
|
+
modelPath, header, gpu, systemInfo, systemPrompt, systemPromptFile, prompt, promptFile, wrapper, noJinja, contextSize,
|
|
230
|
+
batchSize, flashAttention, noTrimWhitespace, grammar, jsonSchemaGrammarFile, threads, temperature, minP, topK, topP,
|
|
231
|
+
gpuLayers, lastTokensRepeatPenalty, repeatPenalty, penalizeRepeatingNewLine, repeatFrequencyPenalty, repeatPresencePenalty,
|
|
232
|
+
maxTokens, noHistory, environmentFunctions, debug, meter, printTimings
|
|
183
233
|
});
|
|
184
234
|
}
|
|
185
235
|
catch (err) {
|
|
236
|
+
await new Promise((accept) => setTimeout(accept, 0)); // wait for logs to finish printing
|
|
186
237
|
console.error(err);
|
|
187
238
|
process.exit(1);
|
|
188
239
|
}
|
|
189
240
|
}
|
|
190
241
|
};
|
|
191
|
-
async function RunChat({
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const
|
|
242
|
+
async function RunChat({ modelPath: modelArg, header: headerArg, gpu, systemInfo, systemPrompt, systemPromptFile, prompt, promptFile, wrapper, noJinja, contextSize, batchSize, flashAttention, noTrimWhitespace, grammar: grammarArg, jsonSchemaGrammarFile: jsonSchemaGrammarFilePath, threads, temperature, minP, topK, topP, gpuLayers, lastTokensRepeatPenalty, repeatPenalty, penalizeRepeatingNewLine, repeatFrequencyPenalty, repeatPresencePenalty, maxTokens, noHistory, environmentFunctions, debug, meter, printTimings }) {
|
|
243
|
+
if (contextSize === -1)
|
|
244
|
+
contextSize = undefined;
|
|
245
|
+
if (gpuLayers === -1)
|
|
246
|
+
gpuLayers = undefined;
|
|
247
|
+
const headers = resolveHeaderFlag(headerArg);
|
|
248
|
+
const trimWhitespace = !noTrimWhitespace;
|
|
249
|
+
if (debug)
|
|
250
|
+
console.info(`${chalk.yellow("Log level:")} debug`);
|
|
251
|
+
const llamaLogLevel = debug
|
|
252
|
+
? LlamaLogLevel.debug
|
|
253
|
+
: LlamaLogLevel.warn;
|
|
254
|
+
const llama = gpu == null
|
|
255
|
+
? await getLlama("lastBuild", {
|
|
256
|
+
logLevel: llamaLogLevel
|
|
257
|
+
})
|
|
258
|
+
: await getLlama({
|
|
259
|
+
gpu,
|
|
260
|
+
logLevel: llamaLogLevel
|
|
261
|
+
});
|
|
262
|
+
const logBatchSize = batchSize != null;
|
|
263
|
+
const resolvedModelPath = await resolveCommandGgufPath(modelArg, llama, headers, {
|
|
264
|
+
flashAttention
|
|
265
|
+
});
|
|
197
266
|
if (systemInfo)
|
|
198
|
-
console.log(
|
|
267
|
+
console.log(llama.systemInfo);
|
|
268
|
+
if (systemPromptFile != null && systemPromptFile !== "") {
|
|
269
|
+
if (systemPrompt != null && systemPrompt !== "" && systemPrompt !== defaultChatSystemPrompt)
|
|
270
|
+
console.warn(chalk.yellow("Both `systemPrompt` and `systemPromptFile` were specified. `systemPromptFile` will be used."));
|
|
271
|
+
systemPrompt = await fs.readFile(path.resolve(process.cwd(), systemPromptFile), "utf8");
|
|
272
|
+
}
|
|
273
|
+
if (promptFile != null && promptFile !== "") {
|
|
274
|
+
if (prompt != null && prompt !== "")
|
|
275
|
+
console.warn(chalk.yellow("Both `prompt` and `promptFile` were specified. `promptFile` will be used."));
|
|
276
|
+
prompt = await fs.readFile(path.resolve(process.cwd(), promptFile), "utf8");
|
|
277
|
+
}
|
|
278
|
+
if (batchSize != null && contextSize != null && batchSize > contextSize) {
|
|
279
|
+
console.warn(chalk.yellow("Batch size is greater than the context size. Batch size will be set to the context size."));
|
|
280
|
+
batchSize = contextSize;
|
|
281
|
+
}
|
|
199
282
|
let initialPrompt = prompt ?? null;
|
|
200
|
-
const model = await
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
})
|
|
208
|
-
|
|
283
|
+
const model = await withProgressLog({
|
|
284
|
+
loadingText: chalk.blue.bold("Loading model"),
|
|
285
|
+
successText: chalk.blue("Model loaded"),
|
|
286
|
+
failText: chalk.blue("Failed to load model"),
|
|
287
|
+
liveUpdates: !debug,
|
|
288
|
+
noProgress: debug,
|
|
289
|
+
liveCtrlCSendsAbortSignal: true
|
|
290
|
+
}, async (progressUpdater) => {
|
|
291
|
+
try {
|
|
292
|
+
return await llama.loadModel({
|
|
293
|
+
modelPath: resolvedModelPath,
|
|
294
|
+
gpuLayers: gpuLayers != null
|
|
295
|
+
? gpuLayers
|
|
296
|
+
: contextSize != null
|
|
297
|
+
? { fitContext: { contextSize } }
|
|
298
|
+
: undefined,
|
|
299
|
+
defaultContextFlashAttention: flashAttention,
|
|
300
|
+
ignoreMemorySafetyChecks: gpuLayers != null,
|
|
301
|
+
onLoadProgress(loadProgress) {
|
|
302
|
+
progressUpdater.setProgress(loadProgress);
|
|
303
|
+
},
|
|
304
|
+
loadSignal: progressUpdater.abortSignal
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
catch (err) {
|
|
308
|
+
if (err === progressUpdater.abortSignal?.reason)
|
|
309
|
+
process.exit(0);
|
|
310
|
+
throw err;
|
|
311
|
+
}
|
|
312
|
+
finally {
|
|
313
|
+
if (llama.logLevel === LlamaLogLevel.debug) {
|
|
314
|
+
await new Promise((accept) => setTimeout(accept, 0)); // wait for logs to finish printing
|
|
315
|
+
console.info();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
const context = await withOra({
|
|
209
320
|
loading: chalk.blue("Creating context"),
|
|
210
321
|
success: chalk.blue("Context created"),
|
|
211
|
-
fail: chalk.blue("Failed to create context")
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
322
|
+
fail: chalk.blue("Failed to create context"),
|
|
323
|
+
useStatusLogs: debug
|
|
324
|
+
}, async () => {
|
|
325
|
+
try {
|
|
326
|
+
return await model.createContext({
|
|
327
|
+
contextSize: contextSize != null ? contextSize : undefined,
|
|
328
|
+
batchSize: batchSize != null ? batchSize : undefined,
|
|
329
|
+
threads,
|
|
330
|
+
ignoreMemorySafetyChecks: gpuLayers != null || contextSize != null
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
finally {
|
|
334
|
+
if (llama.logLevel === LlamaLogLevel.debug) {
|
|
335
|
+
await new Promise((accept) => setTimeout(accept, 0)); // wait for logs to finish printing
|
|
336
|
+
console.info();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
});
|
|
217
340
|
const grammar = jsonSchemaGrammarFilePath != null
|
|
218
|
-
? new LlamaJsonSchemaGrammar(await fs.readJson(path.resolve(process.cwd(), jsonSchemaGrammarFilePath)))
|
|
341
|
+
? new LlamaJsonSchemaGrammar(llama, await fs.readJson(path.resolve(process.cwd(), jsonSchemaGrammarFilePath)))
|
|
219
342
|
: grammarArg !== "text"
|
|
220
|
-
? await LlamaGrammar.getFor(grammarArg)
|
|
343
|
+
? await LlamaGrammar.getFor(llama, grammarArg)
|
|
221
344
|
: undefined;
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
bosString: bos,
|
|
345
|
+
const chatWrapper = resolveChatWrapper({
|
|
346
|
+
type: wrapper,
|
|
347
|
+
bosString: model.tokens.bosString,
|
|
226
348
|
filename: model.filename,
|
|
227
|
-
|
|
228
|
-
|
|
349
|
+
fileInfo: model.fileInfo,
|
|
350
|
+
tokenizer: model.tokenizer,
|
|
351
|
+
noJinja
|
|
352
|
+
}) ?? new GeneralChatWrapper();
|
|
353
|
+
const contextSequence = context.getSequence();
|
|
229
354
|
const session = new LlamaChatSession({
|
|
230
|
-
contextSequence
|
|
355
|
+
contextSequence,
|
|
231
356
|
systemPrompt,
|
|
232
357
|
chatWrapper: chatWrapper
|
|
233
358
|
});
|
|
359
|
+
let lastTokenMeterState = contextSequence.tokenMeter.getState();
|
|
360
|
+
await new Promise((accept) => setTimeout(accept, 0)); // wait for logs to finish printing
|
|
234
361
|
if (grammarArg != "text" && jsonSchemaGrammarFilePath != null)
|
|
235
362
|
console.warn(chalk.yellow("Both `grammar` and `jsonSchemaGrammarFile` were specified. `jsonSchemaGrammarFile` will be used."));
|
|
236
|
-
console.info(`${chalk.yellow("Context size:")} ${context.contextSize}`);
|
|
237
|
-
console.info(`${chalk.yellow("Train context size:")} ${model.trainContextSize}`);
|
|
238
|
-
console.info(`${chalk.yellow("Model type:")} ${model.typeDescription}`);
|
|
239
|
-
console.info(`${chalk.yellow("BOS:")} ${bos}`);
|
|
240
|
-
console.info(`${chalk.yellow("EOS:")} ${eos}`);
|
|
241
|
-
console.info(`${chalk.yellow("Chat wrapper:")} ${chatWrapper.wrapperName}`);
|
|
242
|
-
console.info(`${chalk.yellow("Repeat penalty:")} ${repeatPenalty} (apply to last ${lastTokensRepeatPenalty} tokens)`);
|
|
243
|
-
if (repeatFrequencyPenalty != null)
|
|
244
|
-
console.info(`${chalk.yellow("Repeat frequency penalty:")} ${repeatFrequencyPenalty}`);
|
|
245
|
-
if (repeatPresencePenalty != null)
|
|
246
|
-
console.info(`${chalk.yellow("Repeat presence penalty:")} ${repeatPresencePenalty}`);
|
|
247
|
-
if (!penalizeRepeatingNewLine)
|
|
248
|
-
console.info(`${chalk.yellow("Penalize repeating new line:")} disabled`);
|
|
249
|
-
if (jsonSchemaGrammarFilePath != null)
|
|
250
|
-
console.info(`${chalk.yellow("JSON schema grammar file:")} ${path.relative(process.cwd(), path.resolve(process.cwd(), jsonSchemaGrammarFilePath))}`);
|
|
251
|
-
else if (grammarArg !== "text")
|
|
252
|
-
console.info(`${chalk.yellow("Grammar:")} ${grammarArg}`);
|
|
253
363
|
if (environmentFunctions && grammar != null) {
|
|
254
364
|
console.warn(chalk.yellow("Environment functions are disabled since a grammar is already specified"));
|
|
255
365
|
environmentFunctions = false;
|
|
256
366
|
}
|
|
367
|
+
const padTitle = "Context".length + 1;
|
|
368
|
+
await printCommonInfoLines({
|
|
369
|
+
context,
|
|
370
|
+
minTitleLength: padTitle,
|
|
371
|
+
printBos: true,
|
|
372
|
+
printEos: true,
|
|
373
|
+
logBatchSize,
|
|
374
|
+
tokenMeterEnabled: meter
|
|
375
|
+
});
|
|
376
|
+
printInfoLine({
|
|
377
|
+
title: "Chat",
|
|
378
|
+
padTitle: padTitle,
|
|
379
|
+
info: [{
|
|
380
|
+
title: "Wrapper",
|
|
381
|
+
value: chatWrapper.wrapperName
|
|
382
|
+
}, {
|
|
383
|
+
title: "Repeat penalty",
|
|
384
|
+
value: `${repeatPenalty} (apply to last ${lastTokensRepeatPenalty} tokens)`
|
|
385
|
+
}, {
|
|
386
|
+
show: repeatFrequencyPenalty != null,
|
|
387
|
+
title: "Repeat frequency penalty",
|
|
388
|
+
value: String(repeatFrequencyPenalty)
|
|
389
|
+
}, {
|
|
390
|
+
show: repeatPresencePenalty != null,
|
|
391
|
+
title: "Repeat presence penalty",
|
|
392
|
+
value: String(repeatPresencePenalty)
|
|
393
|
+
}, {
|
|
394
|
+
show: !penalizeRepeatingNewLine,
|
|
395
|
+
title: "Penalize repeating new line",
|
|
396
|
+
value: "disabled"
|
|
397
|
+
}, {
|
|
398
|
+
show: jsonSchemaGrammarFilePath != null,
|
|
399
|
+
title: "JSON schema grammar file",
|
|
400
|
+
value: () => path.relative(process.cwd(), path.resolve(process.cwd(), jsonSchemaGrammarFilePath ?? ""))
|
|
401
|
+
}, {
|
|
402
|
+
show: jsonSchemaGrammarFilePath == null && grammarArg !== "text",
|
|
403
|
+
title: "Grammar",
|
|
404
|
+
value: grammarArg
|
|
405
|
+
}, {
|
|
406
|
+
show: environmentFunctions,
|
|
407
|
+
title: "Environment functions",
|
|
408
|
+
value: "enabled"
|
|
409
|
+
}]
|
|
410
|
+
});
|
|
257
411
|
// this is for ora to not interfere with readline
|
|
258
412
|
await new Promise(resolve => setTimeout(resolve, 1));
|
|
259
413
|
const replHistory = await ReplHistory.load(chatCommandHistoryFilePath, !noHistory);
|
|
@@ -267,8 +421,12 @@ async function RunChat({ model: modelArg, systemInfo, systemPrompt, prompt, wrap
|
|
|
267
421
|
rl.close();
|
|
268
422
|
return res;
|
|
269
423
|
}
|
|
424
|
+
void session.preloadPrompt("")
|
|
425
|
+
.catch(() => void 0); // don't throw an error if preloading fails because a real prompt is sent early
|
|
270
426
|
// eslint-disable-next-line no-constant-condition
|
|
271
427
|
while (true) {
|
|
428
|
+
let hadNoWhitespaceTextInThisIteration = false;
|
|
429
|
+
let nextPrintLeftovers = "";
|
|
272
430
|
const input = initialPrompt != null
|
|
273
431
|
? initialPrompt
|
|
274
432
|
: await getPrompt();
|
|
@@ -284,8 +442,9 @@ async function RunChat({ model: modelArg, systemInfo, systemPrompt, prompt, wrap
|
|
|
284
442
|
const [startColor, endColor] = chalk.blue("MIDDLE").split("MIDDLE");
|
|
285
443
|
process.stdout.write(startColor);
|
|
286
444
|
await session.prompt(input, {
|
|
287
|
-
grammar: grammar,
|
|
445
|
+
grammar: grammar, // this is a workaround to allow passing both `functions` and `grammar`
|
|
288
446
|
temperature,
|
|
447
|
+
minP,
|
|
289
448
|
topK,
|
|
290
449
|
topP,
|
|
291
450
|
repeatPenalty: {
|
|
@@ -300,17 +459,43 @@ async function RunChat({ model: modelArg, systemInfo, systemPrompt, prompt, wrap
|
|
|
300
459
|
: maxTokens <= 0
|
|
301
460
|
? undefined
|
|
302
461
|
: maxTokens,
|
|
303
|
-
|
|
304
|
-
|
|
462
|
+
onTextChunk(chunk) {
|
|
463
|
+
let text = nextPrintLeftovers + chunk;
|
|
464
|
+
nextPrintLeftovers = "";
|
|
465
|
+
if (trimWhitespace) {
|
|
466
|
+
if (!hadNoWhitespaceTextInThisIteration) {
|
|
467
|
+
text = text.trimStart();
|
|
468
|
+
if (text.length > 0)
|
|
469
|
+
hadNoWhitespaceTextInThisIteration = true;
|
|
470
|
+
}
|
|
471
|
+
const textWithTrimmedEnd = text.trimEnd();
|
|
472
|
+
if (textWithTrimmedEnd.length < text.length) {
|
|
473
|
+
nextPrintLeftovers = text.slice(textWithTrimmedEnd.length);
|
|
474
|
+
text = textWithTrimmedEnd;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
process.stdout.write(text);
|
|
305
478
|
},
|
|
306
479
|
functions: (grammar == null && environmentFunctions)
|
|
307
480
|
? defaultEnvironmentFunctions
|
|
308
|
-
: undefined
|
|
481
|
+
: undefined,
|
|
482
|
+
trimWhitespaceSuffix: trimWhitespace
|
|
309
483
|
});
|
|
310
484
|
process.stdout.write(endColor);
|
|
311
485
|
console.log();
|
|
312
|
-
if (printTimings)
|
|
313
|
-
|
|
486
|
+
if (printTimings) {
|
|
487
|
+
if (LlamaLogLevelGreaterThan(llama.logLevel, LlamaLogLevel.info))
|
|
488
|
+
llama.logLevel = LlamaLogLevel.info;
|
|
489
|
+
await context.printTimings();
|
|
490
|
+
await new Promise((accept) => setTimeout(accept, 0)); // wait for logs to finish printing
|
|
491
|
+
llama.logLevel = llamaLogLevel;
|
|
492
|
+
}
|
|
493
|
+
if (meter) {
|
|
494
|
+
const newTokenMeterState = contextSequence.tokenMeter.getState();
|
|
495
|
+
const tokenMeterDiff = TokenMeter.diff(newTokenMeterState, lastTokenMeterState);
|
|
496
|
+
lastTokenMeterState = newTokenMeterState;
|
|
497
|
+
console.info(`${chalk.dim("Input tokens:")} ${String(tokenMeterDiff.usedInputTokens).padEnd(5, " ")} ${chalk.dim("Output tokens:")} ${tokenMeterDiff.usedOutputTokens}`);
|
|
498
|
+
}
|
|
314
499
|
}
|
|
315
500
|
}
|
|
316
501
|
const defaultEnvironmentFunctions = {
|
|
@@ -327,33 +512,4 @@ const defaultEnvironmentFunctions = {
|
|
|
327
512
|
}
|
|
328
513
|
})
|
|
329
514
|
};
|
|
330
|
-
function getChatWrapper(wrapper, { bosString, filename, typeDescription }) {
|
|
331
|
-
switch (wrapper) {
|
|
332
|
-
case "general":
|
|
333
|
-
return new GeneralChatWrapper();
|
|
334
|
-
case "llamaChat":
|
|
335
|
-
return new LlamaChatWrapper();
|
|
336
|
-
case "alpacaChat":
|
|
337
|
-
return new AlpacaChatWrapper();
|
|
338
|
-
case "functionary":
|
|
339
|
-
return new FunctionaryChatWrapper();
|
|
340
|
-
case "chatML":
|
|
341
|
-
return new ChatMLChatWrapper();
|
|
342
|
-
case "falconChat":
|
|
343
|
-
return new FalconChatWrapper();
|
|
344
|
-
default:
|
|
345
|
-
}
|
|
346
|
-
if (wrapper === "auto") {
|
|
347
|
-
const chatWrapper = resolveChatWrapperBasedOnModel({
|
|
348
|
-
bosString,
|
|
349
|
-
filename,
|
|
350
|
-
typeDescription
|
|
351
|
-
});
|
|
352
|
-
if (chatWrapper != null)
|
|
353
|
-
return new chatWrapper();
|
|
354
|
-
return new GeneralChatWrapper();
|
|
355
|
-
}
|
|
356
|
-
void (wrapper);
|
|
357
|
-
throw new Error("Unknown wrapper: " + wrapper);
|
|
358
|
-
}
|
|
359
515
|
//# sourceMappingURL=ChatCommand.js.map
|