node-llama-cpp 3.0.0-beta.3 → 3.0.0-beta.30
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-arm64/_nlcBuildMetadata.json +1 -0
- package/bins/linux-arm64/llama-addon.node +0 -0
- package/bins/linux-armv7l/_nlcBuildMetadata.json +1 -0
- package/bins/linux-armv7l/llama-addon.node +0 -0
- package/bins/linux-x64/_nlcBuildMetadata.json +1 -0
- package/bins/linux-x64/llama-addon.node +0 -0
- package/bins/linux-x64-cuda/_nlcBuildMetadata.json +1 -0
- package/bins/linux-x64-cuda/llama-addon.node +0 -0
- package/bins/linux-x64-vulkan/_nlcBuildMetadata.json +1 -0
- package/bins/linux-x64-vulkan/llama-addon.node +0 -0
- package/bins/mac-arm64-metal/_nlcBuildMetadata.json +1 -0
- package/bins/mac-arm64-metal/default.metallib +0 -0
- package/bins/mac-arm64-metal/llama-addon.node +0 -0
- package/bins/mac-x64/_nlcBuildMetadata.json +1 -0
- package/bins/mac-x64/llama-addon.node +0 -0
- package/bins/win-arm64/_nlcBuildMetadata.json +1 -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-x64/_nlcBuildMetadata.json +1 -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-cuda/_nlcBuildMetadata.json +1 -0
- package/bins/win-x64-cuda/llama-addon.exp +0 -0
- package/bins/win-x64-cuda/llama-addon.lib +0 -0
- package/bins/win-x64-cuda/llama-addon.node +0 -0
- package/bins/win-x64-vulkan/_nlcBuildMetadata.json +1 -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/dist/ChatWrapper.d.ts +8 -39
- package/dist/ChatWrapper.js +115 -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} +54 -8
- 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 +353 -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 +148 -0
- package/dist/bindings/getLlama.js +401 -0
- package/dist/bindings/getLlama.js.map +1 -0
- package/dist/bindings/types.d.ts +56 -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 +17 -0
- package/dist/bindings/utils/compileLLamaCpp.js +226 -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 +12 -0
- package/dist/bindings/utils/getGpuTypesToUseForOption.js +30 -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 +47 -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 +323 -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 +174 -0
- package/dist/chatWrappers/Llama3ChatWrapper.js.map +1 -0
- package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.d.ts +67 -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 +42 -0
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.js +82 -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/resolveChatWrapper.d.ts +69 -0
- package/dist/chatWrappers/utils/resolveChatWrapper.js +243 -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 +18 -6
- package/dist/cli/commands/ChatCommand.js +299 -143
- 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 +29 -0
- package/dist/cli/commands/CompleteCommand.js +365 -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 +31 -0
- package/dist/cli/commands/InfillCommand.js +401 -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 +164 -0
- package/dist/cli/commands/inspect/commands/InspectGpuCommand.js.map +1 -0
- package/dist/cli/commands/inspect/commands/InspectMeasureCommand.d.ts +17 -0
- package/dist/cli/commands/inspect/commands/InspectMeasureCommand.js +613 -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 +363 -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 +7 -0
- package/dist/cli/utils/interactivelyAskForModel.js +451 -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 +75 -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 +4 -0
- package/dist/cli/utils/resolveCommandGgufPath.js +71 -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 +3 -0
- package/dist/consts.js +10 -0
- package/dist/consts.js.map +1 -0
- package/dist/{llamaEvaluator → evaluator}/LlamaChat/LlamaChat.d.ts +112 -39
- package/dist/evaluator/LlamaChat/LlamaChat.js +1512 -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 +288 -0
- package/dist/evaluator/LlamaChatSession/LlamaChatSession.js +419 -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 +143 -0
- package/dist/evaluator/LlamaCompletion.js +418 -0
- package/dist/evaluator/LlamaCompletion.js.map +1 -0
- package/dist/{llamaEvaluator → evaluator}/LlamaContext/LlamaContext.d.ts +41 -21
- package/dist/{llamaEvaluator → evaluator}/LlamaContext/LlamaContext.js +270 -81
- package/dist/evaluator/LlamaContext/LlamaContext.js.map +1 -0
- package/dist/evaluator/LlamaContext/types.d.ts +140 -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/{llamaEvaluator → evaluator}/LlamaGrammar.d.ts +10 -7
- package/dist/{llamaEvaluator → evaluator}/LlamaGrammar.js +14 -11
- 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 +236 -0
- package/dist/evaluator/LlamaModel/LlamaModel.js +679 -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 +3 -0
- package/dist/gguf/consts.js +8 -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 +33 -0
- package/dist/gguf/fileReaders/GgufFileReader.js +76 -0
- package/dist/gguf/fileReaders/GgufFileReader.js.map +1 -0
- package/dist/gguf/fileReaders/GgufFsFileReader.d.ts +17 -0
- package/dist/gguf/fileReaders/GgufFsFileReader.js +46 -0
- package/dist/gguf/fileReaders/GgufFsFileReader.js.map +1 -0
- package/dist/gguf/fileReaders/GgufNetworkFetchFileReader.d.ts +22 -0
- package/dist/gguf/fileReaders/GgufNetworkFetchFileReader.js +63 -0
- package/dist/gguf/fileReaders/GgufNetworkFetchFileReader.js.map +1 -0
- package/dist/gguf/insights/GgufInsights.d.ts +48 -0
- package/dist/gguf/insights/GgufInsights.js +381 -0
- package/dist/gguf/insights/GgufInsights.js.map +1 -0
- package/dist/gguf/insights/GgufInsightsConfigurationResolver.d.ts +87 -0
- package/dist/gguf/insights/GgufInsightsConfigurationResolver.js +141 -0
- package/dist/gguf/insights/GgufInsightsConfigurationResolver.js.map +1 -0
- package/dist/gguf/insights/utils/resolveContextContextSizeOption.d.ts +18 -0
- package/dist/gguf/insights/utils/resolveContextContextSizeOption.js +76 -0
- package/dist/gguf/insights/utils/resolveContextContextSizeOption.js.map +1 -0
- package/dist/gguf/insights/utils/resolveModelGpuLayersOption.d.ts +14 -0
- package/dist/gguf/insights/utils/resolveModelGpuLayersOption.js +177 -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 +19 -0
- package/dist/gguf/parser/GgufV2Parser.js +115 -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 +63 -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 +335 -0
- package/dist/gguf/types/GgufMetadataTypes.js +86 -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 +5 -0
- package/dist/gguf/utils/convertMetadataKeyValueRecordToNestedObject.js +38 -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 +41 -18
- package/dist/index.js +36 -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 +116 -5
- package/dist/types.js.map +1 -1
- 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 +469 -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.map +1 -1
- package/dist/utils/StopGenerationDetector.d.ts +25 -9
- package/dist/utils/StopGenerationDetector.js +93 -22
- package/dist/utils/StopGenerationDetector.js.map +1 -1
- package/dist/utils/TokenStreamRegulator.d.ts +9 -4
- package/dist/utils/TokenStreamRegulator.js +81 -8
- 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 +108 -0
- package/dist/utils/createModelDownloader.js +231 -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/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/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/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 +115 -4
- package/llama/addon.cpp +1300 -97
- 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 +58 -5
- 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 +78 -53
- 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.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.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/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
package/llama/gitRelease.bundle
CHANGED
|
Binary file
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#include <stddef.h>
|
|
2
|
+
#include <vector>
|
|
3
|
+
#include <string>
|
|
4
|
+
|
|
5
|
+
#if defined(GPU_INFO_USE_HIPBLAS)
|
|
6
|
+
#include <hip/hip_runtime.h>
|
|
7
|
+
#include <hipblas/hipblas.h>
|
|
8
|
+
#define cudaGetDevice hipGetDevice
|
|
9
|
+
#define cudaGetDeviceCount hipGetDeviceCount
|
|
10
|
+
#define cudaGetErrorString hipGetErrorString
|
|
11
|
+
#define cudaMemGetInfo hipMemGetInfo
|
|
12
|
+
#define cudaSetDevice hipSetDevice
|
|
13
|
+
#define cudaSuccess hipSuccess
|
|
14
|
+
#else
|
|
15
|
+
#include <cuda_runtime.h>
|
|
16
|
+
#include <cuda.h>
|
|
17
|
+
#endif
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
typedef void (*gpuInfoCudaErrorLogCallback_t)(const char* message);
|
|
21
|
+
|
|
22
|
+
bool gpuInfoSetCudaDevice(const int device, gpuInfoCudaErrorLogCallback_t errorLogCallback) {
|
|
23
|
+
int current_device;
|
|
24
|
+
auto getDeviceResult = cudaGetDevice(¤t_device);
|
|
25
|
+
|
|
26
|
+
if (getDeviceResult != cudaSuccess) {
|
|
27
|
+
errorLogCallback(cudaGetErrorString(getDeviceResult));
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (device == current_device) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const auto setDeviceResult = cudaSetDevice(device);
|
|
36
|
+
|
|
37
|
+
if (setDeviceResult != cudaSuccess) {
|
|
38
|
+
errorLogCallback(cudaGetErrorString(setDeviceResult));
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
bool gpuInfoGetCudaDeviceInfo(int device, size_t * total, size_t * used, gpuInfoCudaErrorLogCallback_t errorLogCallback) {
|
|
46
|
+
gpuInfoSetCudaDevice(device, errorLogCallback);
|
|
47
|
+
|
|
48
|
+
size_t freeMem;
|
|
49
|
+
size_t totalMem;
|
|
50
|
+
auto getMemInfoResult = cudaMemGetInfo(&freeMem, &totalMem);
|
|
51
|
+
|
|
52
|
+
if (getMemInfoResult != cudaSuccess) {
|
|
53
|
+
errorLogCallback(cudaGetErrorString(getMemInfoResult));
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
*total = totalMem;
|
|
58
|
+
*used = totalMem - freeMem;
|
|
59
|
+
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
int gpuInfoGetCudaDeviceCount(gpuInfoCudaErrorLogCallback_t errorLogCallback) {
|
|
64
|
+
int deviceCount;
|
|
65
|
+
auto getDeviceCountResult = cudaGetDeviceCount(&deviceCount);
|
|
66
|
+
|
|
67
|
+
if (getDeviceCountResult != cudaSuccess) {
|
|
68
|
+
errorLogCallback(cudaGetErrorString(getDeviceCountResult));
|
|
69
|
+
return -1;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return deviceCount;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
bool gpuInfoGetTotalCudaDevicesInfo(size_t * total, size_t * used, gpuInfoCudaErrorLogCallback_t errorLogCallback) {
|
|
76
|
+
int deviceCount = gpuInfoGetCudaDeviceCount(errorLogCallback);
|
|
77
|
+
|
|
78
|
+
if (deviceCount < 0) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
size_t usedMem = 0;
|
|
83
|
+
size_t totalMem = 0;
|
|
84
|
+
|
|
85
|
+
for (int i = 0; i < deviceCount; i++) {
|
|
86
|
+
size_t deviceUsedMem;
|
|
87
|
+
size_t deviceTotalMem;
|
|
88
|
+
|
|
89
|
+
if (!gpuInfoGetCudaDeviceInfo(i, &deviceTotalMem, &deviceUsedMem, errorLogCallback)) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
usedMem += deviceUsedMem;
|
|
94
|
+
totalMem += deviceTotalMem;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
*total = totalMem;
|
|
98
|
+
*used = usedMem;
|
|
99
|
+
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
void gpuInfoGetCudaDeviceNames(std::vector<std::string> * deviceNames, gpuInfoCudaErrorLogCallback_t errorLogCallback) {
|
|
104
|
+
int deviceCount = gpuInfoGetCudaDeviceCount(errorLogCallback);
|
|
105
|
+
|
|
106
|
+
if (deviceCount < 0) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
for (int i = 0; i < deviceCount; i++) {
|
|
111
|
+
cudaDeviceProp prop;
|
|
112
|
+
auto getDevicePropertiesResult = cudaGetDeviceProperties(&prop, i);
|
|
113
|
+
|
|
114
|
+
if (getDevicePropertiesResult != cudaSuccess) {
|
|
115
|
+
errorLogCallback(cudaGetErrorString(getDevicePropertiesResult));
|
|
116
|
+
} else {
|
|
117
|
+
(*deviceNames).push_back(std::string(prop.name));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <stddef.h>
|
|
4
|
+
#include <vector>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
typedef void (*gpuInfoCudaErrorLogCallback_t)(const char* message);
|
|
8
|
+
|
|
9
|
+
bool gpuInfoGetTotalCudaDevicesInfo(size_t * total, size_t * used, gpuInfoCudaErrorLogCallback_t errorLogCallback);
|
|
10
|
+
void gpuInfoGetCudaDeviceNames(std::vector<std::string> * deviceNames, gpuInfoCudaErrorLogCallback_t errorLogCallback);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#include <stdint.h>
|
|
2
|
+
#include <vector>
|
|
3
|
+
#include <string>
|
|
4
|
+
#import <Metal/Metal.h>
|
|
5
|
+
|
|
6
|
+
void getMetalGpuInfo(uint64_t * total, uint64_t * used) {
|
|
7
|
+
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
|
|
8
|
+
|
|
9
|
+
if (device) {
|
|
10
|
+
*total = device.recommendedMaxWorkingSetSize;
|
|
11
|
+
*used = device.currentAllocatedSize;
|
|
12
|
+
} else {
|
|
13
|
+
*total = 0;
|
|
14
|
+
*used = 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[device release];
|
|
18
|
+
device = nil;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
void getMetalGpuDeviceNames(std::vector<std::string> * deviceNames) {
|
|
22
|
+
NSArray<id<MTLDevice>> *devices = MTLCopyAllDevices();
|
|
23
|
+
|
|
24
|
+
for (id<MTLDevice> device in devices) {
|
|
25
|
+
(*deviceNames).push_back(std::string(([NSString stringWithUTF8String:device.name.UTF8String]).UTF8String));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
[devices release];
|
|
29
|
+
devices = nil;
|
|
30
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#include <stddef.h>
|
|
2
|
+
#include <vector>
|
|
3
|
+
|
|
4
|
+
#include <vulkan/vulkan.hpp>
|
|
5
|
+
|
|
6
|
+
typedef void (*gpuInfoVulkanWarningLogCallback_t)(const char* message);
|
|
7
|
+
|
|
8
|
+
static bool enumerateVulkanDevices(size_t* total, size_t* used, bool addDeviceNames, std::vector<std::string> * deviceNames, gpuInfoVulkanWarningLogCallback_t warningLogCallback) {
|
|
9
|
+
vk::ApplicationInfo appInfo("node-llama-cpp GPU info", 1, "llama.cpp", 1, VK_API_VERSION_1_2);
|
|
10
|
+
vk::InstanceCreateInfo createInfo(vk::InstanceCreateFlags(), &appInfo, {}, {});
|
|
11
|
+
vk::Instance instance = vk::createInstance(createInfo);
|
|
12
|
+
|
|
13
|
+
auto physicalDevices = instance.enumeratePhysicalDevices();
|
|
14
|
+
|
|
15
|
+
size_t usedMem = 0;
|
|
16
|
+
size_t totalMem = 0;
|
|
17
|
+
|
|
18
|
+
for (size_t i = 0; i < physicalDevices.size(); i++) {
|
|
19
|
+
vk::PhysicalDevice physicalDevice = physicalDevices[i];
|
|
20
|
+
vk::PhysicalDeviceMemoryProperties memProps = physicalDevice.getMemoryProperties();
|
|
21
|
+
vk::PhysicalDeviceProperties deviceProps = physicalDevice.getProperties();
|
|
22
|
+
|
|
23
|
+
if (deviceProps.deviceType == vk::PhysicalDeviceType::eCpu) {
|
|
24
|
+
// ignore CPU devices, as we don't want to count RAM from the CPU as VRAM
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
std::vector<vk::ExtensionProperties> extensionProperties = physicalDevice.enumerateDeviceExtensionProperties();
|
|
29
|
+
bool memoryBudgetExtensionSupported =
|
|
30
|
+
std::any_of(
|
|
31
|
+
extensionProperties.begin(),
|
|
32
|
+
extensionProperties.end(),
|
|
33
|
+
[](const vk::ExtensionProperties& ext) { return std::string(ext.extensionName.data()) == VK_EXT_MEMORY_BUDGET_EXTENSION_NAME;}
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
if (memoryBudgetExtensionSupported) {
|
|
37
|
+
vk::PhysicalDeviceMemoryBudgetPropertiesEXT memoryBudgetProperties;
|
|
38
|
+
vk::PhysicalDeviceMemoryProperties2 memProps2 = {};
|
|
39
|
+
memProps2.pNext = &memoryBudgetProperties;
|
|
40
|
+
|
|
41
|
+
physicalDevice.getMemoryProperties2(&memProps2);
|
|
42
|
+
|
|
43
|
+
for (uint32_t i = 0; i < memProps.memoryHeapCount; ++i) {
|
|
44
|
+
if (memProps.memoryHeaps[i].flags & vk::MemoryHeapFlagBits::eDeviceLocal) {
|
|
45
|
+
const auto size = memProps.memoryHeaps[i].size;
|
|
46
|
+
totalMem += size;
|
|
47
|
+
usedMem += memoryBudgetProperties.heapUsage[i];
|
|
48
|
+
|
|
49
|
+
if (size > 0 && addDeviceNames) {
|
|
50
|
+
(*deviceNames).push_back(std::string(deviceProps.deviceName.data()));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
// VK_EXT_memory_budget extension is not supported, so we cannot determine used memory
|
|
58
|
+
warningLogCallback(
|
|
59
|
+
(
|
|
60
|
+
"Vulkan VK_EXT_memory_budget extension not supported for device \"" +
|
|
61
|
+
std::string(deviceProps.deviceName.data()) + "\", so VRAM info cannot be determained for it"
|
|
62
|
+
)
|
|
63
|
+
.c_str()
|
|
64
|
+
);
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
*total = totalMem;
|
|
70
|
+
*used = usedMem;
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
bool gpuInfoGetTotalVulkanDevicesInfo(size_t* total, size_t* used, gpuInfoVulkanWarningLogCallback_t warningLogCallback) {
|
|
75
|
+
return enumerateVulkanDevices(total, used, false, nullptr, warningLogCallback);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
bool gpuInfoGetVulkanDeviceNames(std::vector<std::string> * deviceNames, gpuInfoVulkanWarningLogCallback_t warningLogCallback) {
|
|
79
|
+
size_t vulkanDeviceTotal = 0;
|
|
80
|
+
size_t vulkanDeviceUsed = 0;
|
|
81
|
+
|
|
82
|
+
return enumerateVulkanDevices(&vulkanDeviceTotal, &vulkanDeviceUsed, true, deviceNames, warningLogCallback);
|
|
83
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <stddef.h>
|
|
4
|
+
#include <vector>
|
|
5
|
+
|
|
6
|
+
typedef void (*gpuInfoVulkanWarningLogCallback_t)(const char* message);
|
|
7
|
+
|
|
8
|
+
bool gpuInfoGetTotalVulkanDevicesInfo(size_t* total, size_t* used, gpuInfoVulkanWarningLogCallback_t warningLogCallback);
|
|
9
|
+
bool gpuInfoGetVulkanDeviceNames(std::vector<std::string> * deviceNames, gpuInfoVulkanWarningLogCallback_t warningLogCallback);
|
package/llama/grammars/README.md
CHANGED
|
@@ -51,7 +51,7 @@ single-line ::= [^\n]+ "\n"`
|
|
|
51
51
|
|
|
52
52
|
## Sequences and Alternatives
|
|
53
53
|
|
|
54
|
-
The order of symbols in a sequence
|
|
54
|
+
The order of symbols in a sequence matters. For example, in `"1. " move " " move "\n"`, the `"1. "` must come before the first `move`, etc.
|
|
55
55
|
|
|
56
56
|
Alternatives, denoted by `|`, give different sequences that are acceptable. For example, in `move ::= pawn | nonpawn | castle`, `move` can be a `pawn` move, a `nonpawn` move, or a `castle`.
|
|
57
57
|
|
|
@@ -59,9 +59,13 @@ Parentheses `()` can be used to group sequences, which allows for embedding alte
|
|
|
59
59
|
|
|
60
60
|
## Repetition and Optional Symbols
|
|
61
61
|
|
|
62
|
-
- `*` after a symbol or sequence means that it can be repeated zero or more times.
|
|
63
|
-
- `+` denotes that the symbol or sequence should appear one or more times.
|
|
64
|
-
- `?` makes the preceding symbol or sequence optional.
|
|
62
|
+
- `*` after a symbol or sequence means that it can be repeated zero or more times (equivalent to `{0,}`).
|
|
63
|
+
- `+` denotes that the symbol or sequence should appear one or more times (equivalent to `{1,}`).
|
|
64
|
+
- `?` makes the preceding symbol or sequence optional (equivalent to `{0,1}`).
|
|
65
|
+
- `{m}` repeats the precedent symbol or sequence exactly `m` times
|
|
66
|
+
- `{m,}` repeats the precedent symbol or sequence at least `m` times
|
|
67
|
+
- `{m,n}` repeats the precedent symbol or sequence at between `m` and `n` times (included)
|
|
68
|
+
- `{0,n}` repeats the precedent symbol or sequence at most `n` times (included)
|
|
65
69
|
|
|
66
70
|
## Comments and newlines
|
|
67
71
|
|
|
@@ -87,5 +91,54 @@ item ::= [^\n]+ "\n"
|
|
|
87
91
|
|
|
88
92
|
This guide provides a brief overview. Check out the GBNF files in this directory (`grammars/`) for examples of full grammars. You can try them out with:
|
|
89
93
|
```
|
|
90
|
-
./
|
|
94
|
+
./llama-cli -m <model> --grammar-file grammars/some-grammar.gbnf -p 'Some prompt'
|
|
91
95
|
```
|
|
96
|
+
|
|
97
|
+
`llama.cpp` can also convert JSON schemas to grammars either ahead of time or at each request, see below.
|
|
98
|
+
|
|
99
|
+
## Troubleshooting
|
|
100
|
+
|
|
101
|
+
Grammars currently have performance gotchas (see https://github.com/ggerganov/llama.cpp/issues/4218).
|
|
102
|
+
|
|
103
|
+
### Efficient optional repetitions
|
|
104
|
+
|
|
105
|
+
A common pattern is to allow repetitions of a pattern `x` up to N times.
|
|
106
|
+
|
|
107
|
+
While semantically correct, the syntax `x? x? x?.... x?` (with N repetitions) may result in extremely slow sampling. Instead, you can write `x{0,N}` (or `(x (x (x ... (x)?...)?)?)?` w/ N-deep nesting in earlier llama.cpp versions).
|
|
108
|
+
|
|
109
|
+
## Using GBNF grammars
|
|
110
|
+
|
|
111
|
+
You can use GBNF grammars:
|
|
112
|
+
|
|
113
|
+
- In [llama-server](../examples/server)'s completion endpoints, passed as the `grammar` body field
|
|
114
|
+
- In [llama-cli](../examples/main), passed as the `--grammar` & `--grammar-file` flags
|
|
115
|
+
- With [llama-gbnf-validator](../examples/gbnf-validator) tool, to test them against strings.
|
|
116
|
+
|
|
117
|
+
## JSON Schemas → GBNF
|
|
118
|
+
|
|
119
|
+
`llama.cpp` supports converting a subset of https://json-schema.org/ to GBNF grammars:
|
|
120
|
+
|
|
121
|
+
- In [llama-server](../examples/server):
|
|
122
|
+
- For any completion endpoints, passed as the `json_schema` body field
|
|
123
|
+
- For the `/chat/completions` endpoint, passed inside the `result_format` body field (e.g. `{"type", "json_object", "schema": {"items": {}}}`)
|
|
124
|
+
- In [llama-cli](../examples/main), passed as the `--json` / `-j` flag
|
|
125
|
+
- To convert to a grammar ahead of time:
|
|
126
|
+
- in CLI, with [examples/json_schema_to_grammar.py](../examples/json_schema_to_grammar.py)
|
|
127
|
+
- in JavaScript with [json-schema-to-grammar.mjs](../examples/server/public/json-schema-to-grammar.mjs) (this is used by the [server](../examples/server)'s Web UI)
|
|
128
|
+
|
|
129
|
+
Take a look at [tests](../../tests/test-json-schema-to-grammar.cpp) to see which features are likely supported (you'll also find usage examples in https://github.com/ggerganov/llama.cpp/pull/5978, https://github.com/ggerganov/llama.cpp/pull/6659 & https://github.com/ggerganov/llama.cpp/pull/6555).
|
|
130
|
+
|
|
131
|
+
Here is also a non-exhaustive list of **unsupported** features:
|
|
132
|
+
|
|
133
|
+
- `additionalProperties`: to be fixed in https://github.com/ggerganov/llama.cpp/pull/7840
|
|
134
|
+
- `minimum`, `exclusiveMinimum`, `maximum`, `exclusiveMaximum`
|
|
135
|
+
- `integer` constraints to be implemented in https://github.com/ggerganov/llama.cpp/pull/7797
|
|
136
|
+
- Remote `$ref`s in the C++ version (Python & JavaScript versions fetch https refs)
|
|
137
|
+
- Mixing `properties` w/ `anyOf` / `oneOf` in the same type (https://github.com/ggerganov/llama.cpp/issues/7703)
|
|
138
|
+
- `string` formats `uri`, `email`
|
|
139
|
+
- [`contains`](https://json-schema.org/draft/2020-12/json-schema-core#name-contains) / `minContains`
|
|
140
|
+
- `uniqueItems`
|
|
141
|
+
- `$anchor` (cf. [dereferencing](https://json-schema.org/draft/2020-12/json-schema-core#name-dereferencing))
|
|
142
|
+
- [`not`](https://json-schema.org/draft/2020-12/json-schema-core#name-not)
|
|
143
|
+
- [Conditionals](https://json-schema.org/draft/2020-12/json-schema-core#name-keywords-for-applying-subsche) `if` / `then` / `else` / `dependentSchemas`
|
|
144
|
+
- [`patternProperties`](https://json-schema.org/draft/2020-12/json-schema-core#name-patternproperties)
|
package/llama/grammars/json.gbnf
CHANGED
|
@@ -15,11 +15,11 @@ array ::=
|
|
|
15
15
|
|
|
16
16
|
string ::=
|
|
17
17
|
"\"" (
|
|
18
|
-
[^"
|
|
19
|
-
"\\" (["
|
|
18
|
+
[^"\\\x7F\x00-\x1F] |
|
|
19
|
+
"\\" (["\\bfnrt] | "u" [0-9a-fA-F]{4}) # escapes
|
|
20
20
|
)* "\"" ws
|
|
21
21
|
|
|
22
|
-
number ::= ("-"? ([0-9] | [1-9] [0-9]
|
|
22
|
+
number ::= ("-"? ([0-9] | [1-9] [0-9]{0,15})) ("." [0-9]+)? ([eE] [-+]? [0-9] [1-9]{0,15})? ws
|
|
23
23
|
|
|
24
24
|
# Optional space: by convention, applied in this grammar after literal chars when allowed
|
|
25
|
-
ws ::=
|
|
25
|
+
ws ::= | " " | "\n" [ \t]{0,20}
|
|
@@ -24,11 +24,11 @@ array ::=
|
|
|
24
24
|
|
|
25
25
|
string ::=
|
|
26
26
|
"\"" (
|
|
27
|
-
[^"
|
|
28
|
-
"\\" (["
|
|
27
|
+
[^"\\\x7F\x00-\x1F] |
|
|
28
|
+
"\\" (["\\bfnrt] | "u" [0-9a-fA-F]{4}) # escapes
|
|
29
29
|
)* "\"" ws
|
|
30
30
|
|
|
31
|
-
number ::= ("-"? ([0-9] | [1-9] [0-9]
|
|
31
|
+
number ::= ("-"? ([0-9] | [1-9] [0-9]{0,15})) ("." [0-9]+)? ([eE] [-+]? [1-9] [0-9]{0,15})? ws
|
|
32
32
|
|
|
33
33
|
# Optional space: by convention, applied in this grammar after literal chars when allowed
|
|
34
|
-
ws ::=
|
|
34
|
+
ws ::= | " " | "\n" [ \t]{0,20}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
set(CMAKE_SYSTEM_NAME Windows)
|
|
2
|
+
set(CMAKE_SYSTEM_PROCESSOR ARM64)
|
|
3
|
+
|
|
4
|
+
# Look for cl.exe in the Visual Studio installation directories
|
|
5
|
+
set(PROGRAMFILES "$ENV{ProgramFiles}")
|
|
6
|
+
set(PROGRAMFILES_X86 "$ENV{ProgramFiles\(x86\)}")
|
|
7
|
+
|
|
8
|
+
set(VS_INSTALL_PATHS
|
|
9
|
+
"${PROGRAMFILES_X86}/Microsoft Visual Studio"
|
|
10
|
+
"${PROGRAMFILES}/Microsoft Visual Studio"
|
|
11
|
+
"C:/Program Files (x86)/Microsoft Visual Studio"
|
|
12
|
+
"C:/Program Files/Microsoft Visual Studio"
|
|
13
|
+
)
|
|
14
|
+
foreach(PATH IN LISTS VS_INSTALL_PATHS)
|
|
15
|
+
if(CL_EXE_PATH)
|
|
16
|
+
break()
|
|
17
|
+
endif()
|
|
18
|
+
|
|
19
|
+
file(GLOB_RECURSE FOUND_CL_EXE "${PATH}/*/VC/Tools/MSVC/*/bin/Hostx64/arm64/cl.exe")
|
|
20
|
+
if(FOUND_CL_EXE)
|
|
21
|
+
list(GET FOUND_CL_EXE 0 CL_EXE_PATH)
|
|
22
|
+
break()
|
|
23
|
+
endif()
|
|
24
|
+
|
|
25
|
+
if(CL_EXE_PATH)
|
|
26
|
+
break()
|
|
27
|
+
endif()
|
|
28
|
+
|
|
29
|
+
file(GLOB_RECURSE FOUND_CL_EXE "${PATH}/**/*/VC/Tools/MSVC/*/bin/Hostx64/arm64/cl.exe")
|
|
30
|
+
if(FOUND_CL_EXE)
|
|
31
|
+
list(GET FOUND_CL_EXE 0 CL_EXE_PATH)
|
|
32
|
+
break()
|
|
33
|
+
endif()
|
|
34
|
+
endforeach()
|
|
35
|
+
|
|
36
|
+
if(NOT CL_EXE_PATH)
|
|
37
|
+
message(FATAL_ERROR "cl.exe not found for ARM architecture.")
|
|
38
|
+
else()
|
|
39
|
+
set(CMAKE_C_COMPILER "${CL_EXE_PATH}")
|
|
40
|
+
set(CMAKE_CXX_COMPILER "${CL_EXE_PATH}")
|
|
41
|
+
endif()
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-llama-cpp",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.30",
|
|
4
4
|
"description": "Run AI models locally on your machine with node.js bindings for llama.cpp. Force a JSON schema on the model output on the generation level",
|
|
5
|
-
"main": "dist/index.js",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"bin": {
|
|
9
|
-
"node-llama-cpp": "
|
|
9
|
+
"node-llama-cpp": "dist/cli/cli.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist/",
|
|
13
|
+
"templates/packed/",
|
|
13
14
|
"llama/",
|
|
14
|
-
"
|
|
15
|
+
"bins/",
|
|
15
16
|
"package.json",
|
|
16
17
|
"README.md",
|
|
17
18
|
"LICENSE"
|
|
@@ -40,31 +41,33 @@
|
|
|
40
41
|
"node": ">=18.0.0"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
|
-
"prepare": "[ \"$CI\" = true ] || [ -d '.husky/_' ] || husky
|
|
44
|
+
"prepare": "[ \"$CI\" = true ] || [ -d '.husky/_' ] || husky",
|
|
45
|
+
"postinstall": "node ./dist/cli/cli.js postinstall",
|
|
44
46
|
"prebuild": "rimraf ./dist ./tsconfig.tsbuildinfo",
|
|
45
|
-
"build": "tsc --build tsconfig.json --force",
|
|
47
|
+
"build": "tsc --build tsconfig.json --force && npm run build:packTemplates",
|
|
48
|
+
"build:packTemplates": "vite-node scripts/packTemplates.ts",
|
|
46
49
|
"addPostinstallScript": "npm pkg set scripts.postinstall=\"node ./dist/cli/cli.js postinstall\"",
|
|
47
50
|
"prewatch": "rimraf ./dist ./tsconfig.tsbuildinfo",
|
|
48
51
|
"watch": "tsc --build tsconfig.json --watch --force",
|
|
49
52
|
"cmake-js-llama": "cd llama && cmake-js",
|
|
50
|
-
"test": "npm run test:typescript && npm run lint:eslint && npm run test:
|
|
53
|
+
"test": "npm run test:typescript && npm run lint:eslint && npm run test:vitest",
|
|
54
|
+
"test:vitest": "vitest run ./test",
|
|
51
55
|
"test:standalone": "vitest run ./test/standalone",
|
|
52
56
|
"test:standalone:interactive": "vitest watch ./test/standalone",
|
|
53
57
|
"test:modelDependent": "vitest run ./test/modelDependent",
|
|
54
58
|
"test:modelDependent:interactive": "vitest watch ./test/modelDependent",
|
|
55
59
|
"test:typescript": "tsc --build tsconfig.json --dry --force",
|
|
56
60
|
"lint": "npm run lint:eslint",
|
|
57
|
-
"lint:eslint": "eslint --ext .js --ext .ts .",
|
|
61
|
+
"lint:eslint": "eslint --ext .js --ext .ts --report-unused-disable-directives .",
|
|
58
62
|
"format": "npm run lint:eslint -- --fix",
|
|
59
|
-
"dev:setup:downloadAllTestModels": "
|
|
60
|
-
"dev:setup": "npm run build && node ./dist/cli/cli.js download && npm run docs:generateTypedoc && npm run dev:setup:downloadAllTestModels",
|
|
61
|
-
"dev:build": "npm run build && node ./dist/cli/cli.js build",
|
|
62
|
-
"clean": "rm -rf ./node_modules ./dist ./tsconfig.tsbuildinfo ./test/.models",
|
|
63
|
-
"docs:generateTypedoc": "typedoc && rimraf ./docs/api/index.md ./docs/api/
|
|
63
|
+
"dev:setup:downloadAllTestModels": "vite-node test/utils/scripts/downloadAllTestModels.ts",
|
|
64
|
+
"dev:setup": "npm run build && node ./dist/cli/cli.js download --noUsageExample && npm run docs:generateTypedoc && npm run dev:setup:downloadAllTestModels",
|
|
65
|
+
"dev:build": "npm run build && node ./dist/cli/cli.js build --noUsageExample",
|
|
66
|
+
"clean": "rm -rf ./node_modules ./dist ./tsconfig.tsbuildinfo ./test/.models ./docs/api ./docs/api-overrides ./templates/packed",
|
|
67
|
+
"docs:generateTypedoc": "typedoc --entryPoints ./src/apiDocsIndex.ts && rimraf ./docs/api/index.md ./docs/api/globals.md ./docs/api/functions/LlamaText.md",
|
|
64
68
|
"docs:dev": "npm run docs:generateTypedoc && vitepress dev",
|
|
65
69
|
"docs:build": "npm run docs:generateTypedoc && vitepress build",
|
|
66
|
-
"docs:preview": "npm run docs:generateTypedoc && vitepress preview"
|
|
67
|
-
"postinstall": "node ./dist/cli/cli.js postinstall"
|
|
70
|
+
"docs:preview": "npm run docs:generateTypedoc && vitepress preview"
|
|
68
71
|
},
|
|
69
72
|
"repository": {
|
|
70
73
|
"type": "git",
|
|
@@ -83,10 +86,15 @@
|
|
|
83
86
|
"gguf",
|
|
84
87
|
"metal",
|
|
85
88
|
"cuda",
|
|
89
|
+
"vulkan",
|
|
86
90
|
"grammar",
|
|
87
91
|
"json-grammar",
|
|
88
92
|
"json-schema-grammar",
|
|
93
|
+
"functions",
|
|
94
|
+
"function-calling",
|
|
95
|
+
"embedding",
|
|
89
96
|
"temperature",
|
|
97
|
+
"minP",
|
|
90
98
|
"topK",
|
|
91
99
|
"topP",
|
|
92
100
|
"json-schema",
|
|
@@ -106,54 +114,71 @@
|
|
|
106
114
|
},
|
|
107
115
|
"homepage": "https://withcatai.github.io/node-llama-cpp/",
|
|
108
116
|
"devDependencies": {
|
|
109
|
-
"@commitlint/cli": "^
|
|
110
|
-
"@commitlint/config-conventional": "^
|
|
117
|
+
"@commitlint/cli": "^19.3.0",
|
|
118
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
111
119
|
"@semantic-release/exec": "^6.0.3",
|
|
112
|
-
"@
|
|
120
|
+
"@shikijs/vitepress-twoslash": "^1.6.3",
|
|
121
|
+
"@types/async-retry": "^1.4.8",
|
|
122
|
+
"@types/bytes": "^3.1.4",
|
|
113
123
|
"@types/cross-spawn": "^6.0.2",
|
|
114
|
-
"@types/fs-extra": "^11.0.
|
|
115
|
-
"@types/node": "^20.
|
|
116
|
-
"@types/
|
|
117
|
-
"@types/
|
|
124
|
+
"@types/fs-extra": "^11.0.4",
|
|
125
|
+
"@types/node": "^20.14.2",
|
|
126
|
+
"@types/proper-lockfile": "^4.1.4",
|
|
127
|
+
"@types/semver": "^7.5.8",
|
|
128
|
+
"@types/validate-npm-package-name": "^4.0.2",
|
|
129
|
+
"@types/which": "^3.0.4",
|
|
118
130
|
"@types/yargs": "^17.0.24",
|
|
119
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
120
|
-
"@typescript-eslint/parser": "^
|
|
121
|
-
"@vitest/coverage-v8": "^
|
|
131
|
+
"@typescript-eslint/eslint-plugin": "^7.12.0",
|
|
132
|
+
"@typescript-eslint/parser": "^7.12.0",
|
|
133
|
+
"@vitest/coverage-v8": "^1.6.0",
|
|
134
|
+
"@vitest/ui": "^1.6.0",
|
|
122
135
|
"eslint": "^8.46.0",
|
|
123
|
-
"eslint-plugin-import": "^2.
|
|
124
|
-
"eslint-plugin-jsdoc": "^46.
|
|
125
|
-
"eslint-plugin-n": "^
|
|
126
|
-
"husky": "^
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
"
|
|
131
|
-
"
|
|
132
|
-
"typedoc": "^
|
|
133
|
-
"typedoc-
|
|
134
|
-
"
|
|
135
|
-
"
|
|
136
|
-
"
|
|
137
|
-
"
|
|
138
|
-
"
|
|
139
|
-
"zx": "^7.2.3"
|
|
136
|
+
"eslint-plugin-import": "^2.29.1",
|
|
137
|
+
"eslint-plugin-jsdoc": "^46.10.1",
|
|
138
|
+
"eslint-plugin-n": "^17.8.1",
|
|
139
|
+
"husky": "^9.0.11",
|
|
140
|
+
"rimraf": "^5.0.7",
|
|
141
|
+
"semantic-release": "^23.1.1",
|
|
142
|
+
"tslib": "^2.6.3",
|
|
143
|
+
"typedoc": "^0.25.13",
|
|
144
|
+
"typedoc-plugin-markdown": "^4.0.3",
|
|
145
|
+
"typedoc-plugin-mdn-links": "^3.1.28",
|
|
146
|
+
"typedoc-vitepress-theme": "^1.0.0",
|
|
147
|
+
"typescript": "^5.4.5",
|
|
148
|
+
"vite-node": "^1.6.0",
|
|
149
|
+
"vitepress": "^1.2.3",
|
|
150
|
+
"vitest": "^1.6.0",
|
|
151
|
+
"zx": "^8.1.2"
|
|
140
152
|
},
|
|
141
153
|
"dependencies": {
|
|
154
|
+
"@huggingface/jinja": "^0.2.2",
|
|
155
|
+
"async-retry": "^1.3.3",
|
|
156
|
+
"bytes": "^3.1.2",
|
|
142
157
|
"chalk": "^5.3.0",
|
|
143
158
|
"chmodrp": "^1.0.2",
|
|
144
|
-
"
|
|
145
|
-
"cmake-js": "^7.2.1",
|
|
159
|
+
"cmake-js": "^7.3.0",
|
|
146
160
|
"cross-env": "^7.0.3",
|
|
147
161
|
"cross-spawn": "^7.0.3",
|
|
148
|
-
"env-var": "^7.
|
|
149
|
-
"
|
|
150
|
-
"
|
|
151
|
-
"
|
|
152
|
-
"
|
|
153
|
-
"
|
|
154
|
-
"
|
|
155
|
-
"
|
|
156
|
-
"
|
|
162
|
+
"env-var": "^7.5.0",
|
|
163
|
+
"filenamify": "^6.0.0",
|
|
164
|
+
"fs-extra": "^11.2.0",
|
|
165
|
+
"ignore": "^5.3.1",
|
|
166
|
+
"ipull": "^3.3.0",
|
|
167
|
+
"is-unicode-supported": "^2.0.0",
|
|
168
|
+
"lifecycle-utils": "^1.4.1",
|
|
169
|
+
"log-symbols": "^6.0.0",
|
|
170
|
+
"nanoid": "^5.0.7",
|
|
171
|
+
"node-addon-api": "^8.0.0",
|
|
172
|
+
"octokit": "^4.0.2",
|
|
173
|
+
"ora": "^8.0.1",
|
|
174
|
+
"pretty-ms": "^9.0.0",
|
|
175
|
+
"proper-lockfile": "^4.1.2",
|
|
176
|
+
"semver": "^7.6.2",
|
|
177
|
+
"simple-git": "^3.24.0",
|
|
178
|
+
"slice-ansi": "^7.1.0",
|
|
179
|
+
"stdout-update": "^4.0.1",
|
|
180
|
+
"strip-ansi": "^7.1.0",
|
|
181
|
+
"validate-npm-package-name": "^5.0.1",
|
|
157
182
|
"which": "^4.0.0",
|
|
158
183
|
"yargs": "^17.7.2"
|
|
159
184
|
},
|