@realtimex/node-llama-cpp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +108 -0
- package/dist/ChatWrapper.d.ts +27 -0
- package/dist/ChatWrapper.js +233 -0
- package/dist/ChatWrapper.js.map +1 -0
- package/dist/apiDocsIndex.d.ts +1 -0
- package/dist/apiDocsIndex.js +7 -0
- package/dist/apiDocsIndex.js.map +1 -0
- package/dist/bindings/AddonTypes.d.ts +203 -0
- package/dist/bindings/AddonTypes.js +2 -0
- package/dist/bindings/AddonTypes.js.map +1 -0
- package/dist/bindings/Llama.d.ts +104 -0
- package/dist/bindings/Llama.js +570 -0
- package/dist/bindings/Llama.js.map +1 -0
- package/dist/bindings/consts.d.ts +2 -0
- package/dist/bindings/consts.js +13 -0
- package/dist/bindings/consts.js.map +1 -0
- package/dist/bindings/getLlama.d.ts +297 -0
- package/dist/bindings/getLlama.js +569 -0
- package/dist/bindings/getLlama.js.map +1 -0
- package/dist/bindings/types.d.ts +72 -0
- package/dist/bindings/types.js +105 -0
- package/dist/bindings/types.js.map +1 -0
- package/dist/bindings/utils/MemoryOrchestrator.d.ts +23 -0
- package/dist/bindings/utils/MemoryOrchestrator.js +50 -0
- package/dist/bindings/utils/MemoryOrchestrator.js.map +1 -0
- package/dist/bindings/utils/NoBinaryFoundError.d.ts +2 -0
- package/dist/bindings/utils/NoBinaryFoundError.js +7 -0
- package/dist/bindings/utils/NoBinaryFoundError.js.map +1 -0
- package/dist/bindings/utils/asyncEvery.d.ts +5 -0
- package/dist/bindings/utils/asyncEvery.js +15 -0
- package/dist/bindings/utils/asyncEvery.js.map +1 -0
- package/dist/bindings/utils/asyncSome.d.ts +5 -0
- package/dist/bindings/utils/asyncSome.js +29 -0
- package/dist/bindings/utils/asyncSome.js.map +1 -0
- package/dist/bindings/utils/binariesGithubRelease.d.ts +6 -0
- package/dist/bindings/utils/binariesGithubRelease.js +15 -0
- package/dist/bindings/utils/binariesGithubRelease.js.map +1 -0
- package/dist/bindings/utils/clearAllLocalBuilds.d.ts +1 -0
- package/dist/bindings/utils/clearAllLocalBuilds.js +47 -0
- package/dist/bindings/utils/clearAllLocalBuilds.js.map +1 -0
- package/dist/bindings/utils/cloneLlamaCppRepo.d.ts +11 -0
- package/dist/bindings/utils/cloneLlamaCppRepo.js +166 -0
- package/dist/bindings/utils/cloneLlamaCppRepo.js.map +1 -0
- package/dist/bindings/utils/compileLLamaCpp.d.ts +22 -0
- package/dist/bindings/utils/compileLLamaCpp.js +526 -0
- package/dist/bindings/utils/compileLLamaCpp.js.map +1 -0
- package/dist/bindings/utils/detectAvailableComputeLayers.d.ts +18 -0
- package/dist/bindings/utils/detectAvailableComputeLayers.js +311 -0
- package/dist/bindings/utils/detectAvailableComputeLayers.js.map +1 -0
- package/dist/bindings/utils/detectBuildTools.d.ts +14 -0
- package/dist/bindings/utils/detectBuildTools.js +149 -0
- package/dist/bindings/utils/detectBuildTools.js.map +1 -0
- package/dist/bindings/utils/detectGlibc.d.ts +4 -0
- package/dist/bindings/utils/detectGlibc.js +74 -0
- package/dist/bindings/utils/detectGlibc.js.map +1 -0
- package/dist/bindings/utils/disposeBeforeExit.d.ts +8 -0
- package/dist/bindings/utils/disposeBeforeExit.js +36 -0
- package/dist/bindings/utils/disposeBeforeExit.js.map +1 -0
- package/dist/bindings/utils/getBestComputeLayersAvailable.d.ts +9 -0
- package/dist/bindings/utils/getBestComputeLayersAvailable.js +29 -0
- package/dist/bindings/utils/getBestComputeLayersAvailable.js.map +1 -0
- package/dist/bindings/utils/getBuildFolderNameForBuildOptions.d.ts +6 -0
- package/dist/bindings/utils/getBuildFolderNameForBuildOptions.js +105 -0
- package/dist/bindings/utils/getBuildFolderNameForBuildOptions.js.map +1 -0
- package/dist/bindings/utils/getCanUsePrebuiltBinaries.d.ts +1 -0
- package/dist/bindings/utils/getCanUsePrebuiltBinaries.js +8 -0
- package/dist/bindings/utils/getCanUsePrebuiltBinaries.js.map +1 -0
- package/dist/bindings/utils/getExampleUsageCodeOfGetLlama.d.ts +2 -0
- package/dist/bindings/utils/getExampleUsageCodeOfGetLlama.js +21 -0
- package/dist/bindings/utils/getExampleUsageCodeOfGetLlama.js.map +1 -0
- package/dist/bindings/utils/getGpuTypesToUseForOption.d.ts +12 -0
- package/dist/bindings/utils/getGpuTypesToUseForOption.js +39 -0
- package/dist/bindings/utils/getGpuTypesToUseForOption.js.map +1 -0
- package/dist/bindings/utils/getLinuxDistroInfo.d.ts +9 -0
- package/dist/bindings/utils/getLinuxDistroInfo.js +46 -0
- package/dist/bindings/utils/getLinuxDistroInfo.js.map +1 -0
- package/dist/bindings/utils/getLlamaGpuTypes.d.ts +13 -0
- package/dist/bindings/utils/getLlamaGpuTypes.js +36 -0
- package/dist/bindings/utils/getLlamaGpuTypes.js.map +1 -0
- package/dist/bindings/utils/getLlamaWithoutBackend.d.ts +5 -0
- package/dist/bindings/utils/getLlamaWithoutBackend.js +40 -0
- package/dist/bindings/utils/getLlamaWithoutBackend.js.map +1 -0
- package/dist/bindings/utils/getPlatform.d.ts +2 -0
- package/dist/bindings/utils/getPlatform.js +15 -0
- package/dist/bindings/utils/getPlatform.js.map +1 -0
- package/dist/bindings/utils/getPlatformInfo.d.ts +5 -0
- package/dist/bindings/utils/getPlatformInfo.js +28 -0
- package/dist/bindings/utils/getPlatformInfo.js.map +1 -0
- package/dist/bindings/utils/hasBuildingFromSourceDependenciesInstalled.d.ts +3 -0
- package/dist/bindings/utils/hasBuildingFromSourceDependenciesInstalled.js +27 -0
- package/dist/bindings/utils/hasBuildingFromSourceDependenciesInstalled.js.map +1 -0
- package/dist/bindings/utils/hasFileInPath.d.ts +2 -0
- package/dist/bindings/utils/hasFileInPath.js +34 -0
- package/dist/bindings/utils/hasFileInPath.js.map +1 -0
- package/dist/bindings/utils/lastBuildInfo.d.ts +6 -0
- package/dist/bindings/utils/lastBuildInfo.js +17 -0
- package/dist/bindings/utils/lastBuildInfo.js.map +1 -0
- package/dist/bindings/utils/logBinaryUsageExampleToConsole.d.ts +2 -0
- package/dist/bindings/utils/logBinaryUsageExampleToConsole.js +22 -0
- package/dist/bindings/utils/logBinaryUsageExampleToConsole.js.map +1 -0
- package/dist/bindings/utils/logDistroInstallInstruction.d.ts +14 -0
- package/dist/bindings/utils/logDistroInstallInstruction.js +48 -0
- package/dist/bindings/utils/logDistroInstallInstruction.js.map +1 -0
- package/dist/bindings/utils/resolveActualBindingBinaryPath.d.ts +1 -0
- package/dist/bindings/utils/resolveActualBindingBinaryPath.js +18 -0
- package/dist/bindings/utils/resolveActualBindingBinaryPath.js.map +1 -0
- package/dist/bindings/utils/resolveCustomCmakeOptions.d.ts +1 -0
- package/dist/bindings/utils/resolveCustomCmakeOptions.js +43 -0
- package/dist/bindings/utils/resolveCustomCmakeOptions.js.map +1 -0
- package/dist/bindings/utils/testBindingBinary.d.ts +2 -0
- package/dist/bindings/utils/testBindingBinary.js +269 -0
- package/dist/bindings/utils/testBindingBinary.js.map +1 -0
- package/dist/bindings/utils/testCmakeBinary.d.ts +5 -0
- package/dist/bindings/utils/testCmakeBinary.js +32 -0
- package/dist/bindings/utils/testCmakeBinary.js.map +1 -0
- package/dist/chatWrappers/AlpacaChatWrapper.d.ts +17 -0
- package/dist/chatWrappers/AlpacaChatWrapper.js +33 -0
- package/dist/chatWrappers/AlpacaChatWrapper.js.map +1 -0
- package/dist/chatWrappers/ChatMLChatWrapper.d.ts +6 -0
- package/dist/chatWrappers/ChatMLChatWrapper.js +85 -0
- package/dist/chatWrappers/ChatMLChatWrapper.js.map +1 -0
- package/dist/chatWrappers/DeepSeekChatWrapper.d.ts +37 -0
- package/dist/chatWrappers/DeepSeekChatWrapper.js +294 -0
- package/dist/chatWrappers/DeepSeekChatWrapper.js.map +1 -0
- package/dist/chatWrappers/EmptyChatWrapper.d.ts +4 -0
- package/dist/chatWrappers/EmptyChatWrapper.js +5 -0
- package/dist/chatWrappers/EmptyChatWrapper.js.map +1 -0
- package/dist/chatWrappers/FalconChatWrapper.d.ts +19 -0
- package/dist/chatWrappers/FalconChatWrapper.js +126 -0
- package/dist/chatWrappers/FalconChatWrapper.js.map +1 -0
- package/dist/chatWrappers/FunctionaryChatWrapper.d.ts +17 -0
- package/dist/chatWrappers/FunctionaryChatWrapper.js +622 -0
- package/dist/chatWrappers/FunctionaryChatWrapper.js.map +1 -0
- package/dist/chatWrappers/GemmaChatWrapper.d.ts +7 -0
- package/dist/chatWrappers/GemmaChatWrapper.js +96 -0
- package/dist/chatWrappers/GemmaChatWrapper.js.map +1 -0
- package/dist/chatWrappers/GeneralChatWrapper.d.ts +19 -0
- package/dist/chatWrappers/GeneralChatWrapper.js +140 -0
- package/dist/chatWrappers/GeneralChatWrapper.js.map +1 -0
- package/dist/chatWrappers/HarmonyChatWrapper.d.ts +78 -0
- package/dist/chatWrappers/HarmonyChatWrapper.js +539 -0
- package/dist/chatWrappers/HarmonyChatWrapper.js.map +1 -0
- package/dist/chatWrappers/Llama2ChatWrapper.d.ts +12 -0
- package/dist/chatWrappers/Llama2ChatWrapper.js +95 -0
- package/dist/chatWrappers/Llama2ChatWrapper.js.map +1 -0
- package/dist/chatWrappers/Llama3ChatWrapper.d.ts +16 -0
- package/dist/chatWrappers/Llama3ChatWrapper.js +173 -0
- package/dist/chatWrappers/Llama3ChatWrapper.js.map +1 -0
- package/dist/chatWrappers/Llama3_1ChatWrapper.d.ts +32 -0
- package/dist/chatWrappers/Llama3_1ChatWrapper.js +290 -0
- package/dist/chatWrappers/Llama3_1ChatWrapper.js.map +1 -0
- package/dist/chatWrappers/Llama3_2LightweightChatWrapper.d.ts +35 -0
- package/dist/chatWrappers/Llama3_2LightweightChatWrapper.js +264 -0
- package/dist/chatWrappers/Llama3_2LightweightChatWrapper.js.map +1 -0
- package/dist/chatWrappers/MistralChatWrapper.d.ts +16 -0
- package/dist/chatWrappers/MistralChatWrapper.js +180 -0
- package/dist/chatWrappers/MistralChatWrapper.js.map +1 -0
- package/dist/chatWrappers/QwenChatWrapper.d.ts +36 -0
- package/dist/chatWrappers/QwenChatWrapper.js +344 -0
- package/dist/chatWrappers/QwenChatWrapper.js.map +1 -0
- package/dist/chatWrappers/SeedChatWrapper.d.ts +25 -0
- package/dist/chatWrappers/SeedChatWrapper.js +183 -0
- package/dist/chatWrappers/SeedChatWrapper.js.map +1 -0
- package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.d.ts +138 -0
- package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.js +665 -0
- package/dist/chatWrappers/generic/JinjaTemplateChatWrapper.js.map +1 -0
- package/dist/chatWrappers/generic/TemplateChatWrapper.d.ts +76 -0
- package/dist/chatWrappers/generic/TemplateChatWrapper.js +212 -0
- package/dist/chatWrappers/generic/TemplateChatWrapper.js.map +1 -0
- package/dist/chatWrappers/generic/utils/UniqueIdGenerator.d.ts +7 -0
- package/dist/chatWrappers/generic/utils/UniqueIdGenerator.js +30 -0
- package/dist/chatWrappers/generic/utils/UniqueIdGenerator.js.map +1 -0
- package/dist/chatWrappers/generic/utils/chatHistoryFunctionCallMessageTemplate.d.ts +24 -0
- package/dist/chatWrappers/generic/utils/chatHistoryFunctionCallMessageTemplate.js +45 -0
- package/dist/chatWrappers/generic/utils/chatHistoryFunctionCallMessageTemplate.js.map +1 -0
- package/dist/chatWrappers/generic/utils/extractFunctionCallSettingsFromJinjaTemplate.d.ts +25 -0
- package/dist/chatWrappers/generic/utils/extractFunctionCallSettingsFromJinjaTemplate.js +690 -0
- package/dist/chatWrappers/generic/utils/extractFunctionCallSettingsFromJinjaTemplate.js.map +1 -0
- package/dist/chatWrappers/generic/utils/extractSegmentSettingsFromTokenizerAndChatTemplate.d.ts +2 -0
- package/dist/chatWrappers/generic/utils/extractSegmentSettingsFromTokenizerAndChatTemplate.js +66 -0
- package/dist/chatWrappers/generic/utils/extractSegmentSettingsFromTokenizerAndChatTemplate.js.map +1 -0
- package/dist/chatWrappers/generic/utils/getFirstValidResult.d.ts +6 -0
- package/dist/chatWrappers/generic/utils/getFirstValidResult.js +19 -0
- package/dist/chatWrappers/generic/utils/getFirstValidResult.js.map +1 -0
- package/dist/chatWrappers/generic/utils/squashChatHistoryItems.d.ts +2 -0
- package/dist/chatWrappers/generic/utils/squashChatHistoryItems.js +35 -0
- package/dist/chatWrappers/generic/utils/squashChatHistoryItems.js.map +1 -0
- package/dist/chatWrappers/generic/utils/templateSegmentOptionsToChatWrapperSettings.d.ts +22 -0
- package/dist/chatWrappers/generic/utils/templateSegmentOptionsToChatWrapperSettings.js +28 -0
- package/dist/chatWrappers/generic/utils/templateSegmentOptionsToChatWrapperSettings.js.map +1 -0
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.d.ts +76 -0
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.js +177 -0
- package/dist/chatWrappers/utils/ChatModelFunctionsDocumentationGenerator.js.map +1 -0
- package/dist/chatWrappers/utils/chunkChatItems.d.ts +10 -0
- package/dist/chatWrappers/utils/chunkChatItems.js +44 -0
- package/dist/chatWrappers/utils/chunkChatItems.js.map +1 -0
- package/dist/chatWrappers/utils/getModelLinageNames.d.ts +2 -0
- package/dist/chatWrappers/utils/getModelLinageNames.js +18 -0
- package/dist/chatWrappers/utils/getModelLinageNames.js.map +1 -0
- package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.d.ts +4 -0
- package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.js +394 -0
- package/dist/chatWrappers/utils/isJinjaTemplateEquivalentToSpecializedChatWrapper.js.map +1 -0
- package/dist/chatWrappers/utils/isLlama3_2LightweightModel.d.ts +2 -0
- package/dist/chatWrappers/utils/isLlama3_2LightweightModel.js +9 -0
- package/dist/chatWrappers/utils/isLlama3_2LightweightModel.js.map +1 -0
- package/dist/chatWrappers/utils/jsonDumps.d.ts +7 -0
- package/dist/chatWrappers/utils/jsonDumps.js +18 -0
- package/dist/chatWrappers/utils/jsonDumps.js.map +1 -0
- package/dist/chatWrappers/utils/resolveChatWrapper.d.ts +148 -0
- package/dist/chatWrappers/utils/resolveChatWrapper.js +325 -0
- package/dist/chatWrappers/utils/resolveChatWrapper.js.map +1 -0
- package/dist/cli/cli.d.ts +2 -0
- package/dist/cli/cli.js +45 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/commands/ChatCommand.d.ts +59 -0
- package/dist/cli/commands/ChatCommand.js +856 -0
- package/dist/cli/commands/ChatCommand.js.map +1 -0
- package/dist/cli/commands/CompleteCommand.d.ts +47 -0
- package/dist/cli/commands/CompleteCommand.js +658 -0
- package/dist/cli/commands/CompleteCommand.js.map +1 -0
- package/dist/cli/commands/DebugCommand.d.ts +7 -0
- package/dist/cli/commands/DebugCommand.js +55 -0
- package/dist/cli/commands/DebugCommand.js.map +1 -0
- package/dist/cli/commands/InfillCommand.d.ts +49 -0
- package/dist/cli/commands/InfillCommand.js +693 -0
- package/dist/cli/commands/InfillCommand.js.map +1 -0
- package/dist/cli/commands/InitCommand.d.ts +12 -0
- package/dist/cli/commands/InitCommand.js +230 -0
- package/dist/cli/commands/InitCommand.js.map +1 -0
- package/dist/cli/commands/OnPostInstallCommand.d.ts +4 -0
- package/dist/cli/commands/OnPostInstallCommand.js +62 -0
- package/dist/cli/commands/OnPostInstallCommand.js.map +1 -0
- package/dist/cli/commands/PullCommand.d.ts +13 -0
- package/dist/cli/commands/PullCommand.js +158 -0
- package/dist/cli/commands/PullCommand.js.map +1 -0
- package/dist/cli/commands/inspect/InspectCommand.d.ts +4 -0
- package/dist/cli/commands/inspect/InspectCommand.js +21 -0
- package/dist/cli/commands/inspect/InspectCommand.js.map +1 -0
- package/dist/cli/commands/inspect/commands/InspectEstimateCommand.d.ts +17 -0
- package/dist/cli/commands/inspect/commands/InspectEstimateCommand.js +275 -0
- package/dist/cli/commands/inspect/commands/InspectEstimateCommand.js.map +1 -0
- package/dist/cli/commands/inspect/commands/InspectGgufCommand.d.ts +13 -0
- package/dist/cli/commands/inspect/commands/InspectGgufCommand.js +230 -0
- package/dist/cli/commands/inspect/commands/InspectGgufCommand.js.map +1 -0
- package/dist/cli/commands/inspect/commands/InspectGpuCommand.d.ts +4 -0
- package/dist/cli/commands/inspect/commands/InspectGpuCommand.js +296 -0
- package/dist/cli/commands/inspect/commands/InspectGpuCommand.js.map +1 -0
- package/dist/cli/commands/inspect/commands/InspectMeasureCommand.d.ts +26 -0
- package/dist/cli/commands/inspect/commands/InspectMeasureCommand.js +869 -0
- package/dist/cli/commands/inspect/commands/InspectMeasureCommand.js.map +1 -0
- package/dist/cli/commands/source/SourceCommand.d.ts +4 -0
- package/dist/cli/commands/source/SourceCommand.js +19 -0
- package/dist/cli/commands/source/SourceCommand.js.map +1 -0
- package/dist/cli/commands/source/commands/BuildCommand.d.ts +16 -0
- package/dist/cli/commands/source/commands/BuildCommand.js +148 -0
- package/dist/cli/commands/source/commands/BuildCommand.js.map +1 -0
- package/dist/cli/commands/source/commands/ClearCommand.d.ts +7 -0
- package/dist/cli/commands/source/commands/ClearCommand.js +54 -0
- package/dist/cli/commands/source/commands/ClearCommand.js.map +1 -0
- package/dist/cli/commands/source/commands/DownloadCommand.d.ts +16 -0
- package/dist/cli/commands/source/commands/DownloadCommand.js +219 -0
- package/dist/cli/commands/source/commands/DownloadCommand.js.map +1 -0
- package/dist/cli/projectTemplates.d.ts +7 -0
- package/dist/cli/projectTemplates.js +10 -0
- package/dist/cli/projectTemplates.js.map +1 -0
- package/dist/cli/recommendedModels.d.ts +2 -0
- package/dist/cli/recommendedModels.js +428 -0
- package/dist/cli/recommendedModels.js.map +1 -0
- package/dist/cli/startCreateCli.d.ts +2 -0
- package/dist/cli/startCreateCli.js +26 -0
- package/dist/cli/startCreateCli.js.map +1 -0
- package/dist/cli/utils/ConsoleInteraction.d.ts +22 -0
- package/dist/cli/utils/ConsoleInteraction.js +122 -0
- package/dist/cli/utils/ConsoleInteraction.js.map +1 -0
- package/dist/cli/utils/ConsoleTable.d.ts +24 -0
- package/dist/cli/utils/ConsoleTable.js +90 -0
- package/dist/cli/utils/ConsoleTable.js.map +1 -0
- package/dist/cli/utils/basicChooseFromListConsoleInteraction.d.ts +13 -0
- package/dist/cli/utils/basicChooseFromListConsoleInteraction.js +111 -0
- package/dist/cli/utils/basicChooseFromListConsoleInteraction.js.map +1 -0
- package/dist/cli/utils/consolePromptQuestion.d.ts +6 -0
- package/dist/cli/utils/consolePromptQuestion.js +81 -0
- package/dist/cli/utils/consolePromptQuestion.js.map +1 -0
- package/dist/cli/utils/getReadablePath.d.ts +1 -0
- package/dist/cli/utils/getReadablePath.js +14 -0
- package/dist/cli/utils/getReadablePath.js.map +1 -0
- package/dist/cli/utils/interactivelyAskForModel.d.ts +13 -0
- package/dist/cli/utils/interactivelyAskForModel.js +485 -0
- package/dist/cli/utils/interactivelyAskForModel.js.map +1 -0
- package/dist/cli/utils/isRunningUnderRosetta.d.ts +1 -0
- package/dist/cli/utils/isRunningUnderRosetta.js +20 -0
- package/dist/cli/utils/isRunningUnderRosetta.js.map +1 -0
- package/dist/cli/utils/logUsedGpuTypeOption.d.ts +2 -0
- package/dist/cli/utils/logUsedGpuTypeOption.js +9 -0
- package/dist/cli/utils/logUsedGpuTypeOption.js.map +1 -0
- package/dist/cli/utils/packageJsonConfig.d.ts +6 -0
- package/dist/cli/utils/packageJsonConfig.js +51 -0
- package/dist/cli/utils/packageJsonConfig.js.map +1 -0
- package/dist/cli/utils/packageManager.d.ts +1 -0
- package/dist/cli/utils/packageManager.js +15 -0
- package/dist/cli/utils/packageManager.js.map +1 -0
- package/dist/cli/utils/parseXtcArg.d.ts +5 -0
- package/dist/cli/utils/parseXtcArg.js +16 -0
- package/dist/cli/utils/parseXtcArg.js.map +1 -0
- package/dist/cli/utils/printCommonInfoLines.d.ts +12 -0
- package/dist/cli/utils/printCommonInfoLines.js +163 -0
- package/dist/cli/utils/printCommonInfoLines.js.map +1 -0
- package/dist/cli/utils/printInfoLine.d.ts +12 -0
- package/dist/cli/utils/printInfoLine.js +54 -0
- package/dist/cli/utils/printInfoLine.js.map +1 -0
- package/dist/cli/utils/printModelDestination.d.ts +2 -0
- package/dist/cli/utils/printModelDestination.js +11 -0
- package/dist/cli/utils/printModelDestination.js.map +1 -0
- package/dist/cli/utils/projectTemplates.d.ts +19 -0
- package/dist/cli/utils/projectTemplates.js +47 -0
- package/dist/cli/utils/projectTemplates.js.map +1 -0
- package/dist/cli/utils/renderModelCompatibilityPercentageWithColors.d.ts +6 -0
- package/dist/cli/utils/renderModelCompatibilityPercentageWithColors.js +14 -0
- package/dist/cli/utils/renderModelCompatibilityPercentageWithColors.js.map +1 -0
- package/dist/cli/utils/resolveCommandGgufPath.d.ts +19 -0
- package/dist/cli/utils/resolveCommandGgufPath.js +123 -0
- package/dist/cli/utils/resolveCommandGgufPath.js.map +1 -0
- package/dist/cli/utils/resolveHeaderFlag.d.ts +1 -0
- package/dist/cli/utils/resolveHeaderFlag.js +21 -0
- package/dist/cli/utils/resolveHeaderFlag.js.map +1 -0
- package/dist/cli/utils/resolveModelRecommendationFileOptions.d.ts +14 -0
- package/dist/cli/utils/resolveModelRecommendationFileOptions.js +12 -0
- package/dist/cli/utils/resolveModelRecommendationFileOptions.js.map +1 -0
- package/dist/cli/utils/resolveNpmrcConfig.d.ts +18 -0
- package/dist/cli/utils/resolveNpmrcConfig.js +129 -0
- package/dist/cli/utils/resolveNpmrcConfig.js.map +1 -0
- package/dist/cli/utils/splitAnsiToLines.d.ts +1 -0
- package/dist/cli/utils/splitAnsiToLines.js +32 -0
- package/dist/cli/utils/splitAnsiToLines.js.map +1 -0
- package/dist/cli/utils/toBytes.d.ts +1 -0
- package/dist/cli/utils/toBytes.js +5 -0
- package/dist/cli/utils/toBytes.js.map +1 -0
- package/dist/cli/utils/withCliCommandDescriptionDocsUrl.d.ts +2 -0
- package/dist/cli/utils/withCliCommandDescriptionDocsUrl.js +23 -0
- package/dist/cli/utils/withCliCommandDescriptionDocsUrl.js.map +1 -0
- package/dist/commands.d.ts +6 -0
- package/dist/commands.js +9 -0
- package/dist/commands.js.map +1 -0
- package/dist/config.d.ts +79 -0
- package/dist/config.js +127 -0
- package/dist/config.js.map +1 -0
- package/dist/consts.d.ts +4 -0
- package/dist/consts.js +11 -0
- package/dist/consts.js.map +1 -0
- package/dist/evaluator/LlamaChat/LlamaChat.d.ts +500 -0
- package/dist/evaluator/LlamaChat/LlamaChat.js +2696 -0
- package/dist/evaluator/LlamaChat/LlamaChat.js.map +1 -0
- package/dist/evaluator/LlamaChat/utils/FunctionCallNameGrammar.d.ts +11 -0
- package/dist/evaluator/LlamaChat/utils/FunctionCallNameGrammar.js +55 -0
- package/dist/evaluator/LlamaChat/utils/FunctionCallNameGrammar.js.map +1 -0
- package/dist/evaluator/LlamaChat/utils/FunctionCallParamsGrammar.d.ts +16 -0
- package/dist/evaluator/LlamaChat/utils/FunctionCallParamsGrammar.js +45 -0
- package/dist/evaluator/LlamaChat/utils/FunctionCallParamsGrammar.js.map +1 -0
- package/dist/evaluator/LlamaChat/utils/LlamaFunctionCallValidationError.d.ts +8 -0
- package/dist/evaluator/LlamaChat/utils/LlamaFunctionCallValidationError.js +12 -0
- package/dist/evaluator/LlamaChat/utils/LlamaFunctionCallValidationError.js.map +1 -0
- package/dist/evaluator/LlamaChat/utils/contextShiftStrategies/eraseFirstResponseAndKeepFirstSystemChatContextShiftStrategy.d.ts +16 -0
- package/dist/evaluator/LlamaChat/utils/contextShiftStrategies/eraseFirstResponseAndKeepFirstSystemChatContextShiftStrategy.js +260 -0
- package/dist/evaluator/LlamaChat/utils/contextShiftStrategies/eraseFirstResponseAndKeepFirstSystemChatContextShiftStrategy.js.map +1 -0
- package/dist/evaluator/LlamaChatSession/LlamaChatSession.d.ts +520 -0
- package/dist/evaluator/LlamaChatSession/LlamaChatSession.js +628 -0
- package/dist/evaluator/LlamaChatSession/LlamaChatSession.js.map +1 -0
- package/dist/evaluator/LlamaChatSession/utils/LlamaChatSessionPromptCompletionEngine.d.ts +45 -0
- package/dist/evaluator/LlamaChatSession/utils/LlamaChatSessionPromptCompletionEngine.js +191 -0
- package/dist/evaluator/LlamaChatSession/utils/LlamaChatSessionPromptCompletionEngine.js.map +1 -0
- package/dist/evaluator/LlamaChatSession/utils/defineChatSessionFunction.d.ts +15 -0
- package/dist/evaluator/LlamaChatSession/utils/defineChatSessionFunction.js +16 -0
- package/dist/evaluator/LlamaChatSession/utils/defineChatSessionFunction.js.map +1 -0
- package/dist/evaluator/LlamaCompletion.d.ts +219 -0
- package/dist/evaluator/LlamaCompletion.js +498 -0
- package/dist/evaluator/LlamaCompletion.js.map +1 -0
- package/dist/evaluator/LlamaContext/LlamaContext.d.ts +336 -0
- package/dist/evaluator/LlamaContext/LlamaContext.js +1919 -0
- package/dist/evaluator/LlamaContext/LlamaContext.js.map +1 -0
- package/dist/evaluator/LlamaContext/LlamaContextSequenceCheckpoints.d.ts +27 -0
- package/dist/evaluator/LlamaContext/LlamaContextSequenceCheckpoints.js +130 -0
- package/dist/evaluator/LlamaContext/LlamaContextSequenceCheckpoints.js.map +1 -0
- package/dist/evaluator/LlamaContext/LlamaSampler.d.ts +1 -0
- package/dist/evaluator/LlamaContext/LlamaSampler.js +39 -0
- package/dist/evaluator/LlamaContext/LlamaSampler.js.map +1 -0
- package/dist/evaluator/LlamaContext/TokenPredictor.d.ts +55 -0
- package/dist/evaluator/LlamaContext/TokenPredictor.js +20 -0
- package/dist/evaluator/LlamaContext/TokenPredictor.js.map +1 -0
- package/dist/evaluator/LlamaContext/tokenPredictors/DraftSequenceTokenPredictor.d.ts +56 -0
- package/dist/evaluator/LlamaContext/tokenPredictors/DraftSequenceTokenPredictor.js +266 -0
- package/dist/evaluator/LlamaContext/tokenPredictors/DraftSequenceTokenPredictor.js.map +1 -0
- package/dist/evaluator/LlamaContext/tokenPredictors/InputLookupTokenPredictor.d.ts +58 -0
- package/dist/evaluator/LlamaContext/tokenPredictors/InputLookupTokenPredictor.js +138 -0
- package/dist/evaluator/LlamaContext/tokenPredictors/InputLookupTokenPredictor.js.map +1 -0
- package/dist/evaluator/LlamaContext/types.d.ts +602 -0
- package/dist/evaluator/LlamaContext/types.js +2 -0
- package/dist/evaluator/LlamaContext/types.js.map +1 -0
- package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/firstInFirstOutStrategy.d.ts +5 -0
- package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/firstInFirstOutStrategy.js +16 -0
- package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/firstInFirstOutStrategy.js.map +1 -0
- package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/maximumParallelismStrategy.d.ts +5 -0
- package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/maximumParallelismStrategy.js +42 -0
- package/dist/evaluator/LlamaContext/utils/batchItemsPrioritizationStrategies/maximumParallelismStrategy.js.map +1 -0
- package/dist/evaluator/LlamaContext/utils/padSafeContextSize.d.ts +1 -0
- package/dist/evaluator/LlamaContext/utils/padSafeContextSize.js +18 -0
- package/dist/evaluator/LlamaContext/utils/padSafeContextSize.js.map +1 -0
- package/dist/evaluator/LlamaContext/utils/resolveBatchItemsPrioritizationStrategy.d.ts +2 -0
- package/dist/evaluator/LlamaContext/utils/resolveBatchItemsPrioritizationStrategy.js +13 -0
- package/dist/evaluator/LlamaContext/utils/resolveBatchItemsPrioritizationStrategy.js.map +1 -0
- package/dist/evaluator/LlamaEmbedding.d.ts +21 -0
- package/dist/evaluator/LlamaEmbedding.js +53 -0
- package/dist/evaluator/LlamaEmbedding.js.map +1 -0
- package/dist/evaluator/LlamaEmbeddingContext.d.ts +52 -0
- package/dist/evaluator/LlamaEmbeddingContext.js +86 -0
- package/dist/evaluator/LlamaEmbeddingContext.js.map +1 -0
- package/dist/evaluator/LlamaGrammar.d.ts +39 -0
- package/dist/evaluator/LlamaGrammar.js +72 -0
- package/dist/evaluator/LlamaGrammar.js.map +1 -0
- package/dist/evaluator/LlamaGrammarEvaluationState.d.ts +19 -0
- package/dist/evaluator/LlamaGrammarEvaluationState.js +29 -0
- package/dist/evaluator/LlamaGrammarEvaluationState.js.map +1 -0
- package/dist/evaluator/LlamaJsonSchemaGrammar.d.ts +17 -0
- package/dist/evaluator/LlamaJsonSchemaGrammar.js +35 -0
- package/dist/evaluator/LlamaJsonSchemaGrammar.js.map +1 -0
- package/dist/evaluator/LlamaModel/LlamaModel.d.ts +344 -0
- package/dist/evaluator/LlamaModel/LlamaModel.js +853 -0
- package/dist/evaluator/LlamaModel/LlamaModel.js.map +1 -0
- package/dist/evaluator/LlamaModel/utils/TokenAttributes.d.ts +29 -0
- package/dist/evaluator/LlamaModel/utils/TokenAttributes.js +65 -0
- package/dist/evaluator/LlamaModel/utils/TokenAttributes.js.map +1 -0
- package/dist/evaluator/LlamaRankingContext.d.ts +91 -0
- package/dist/evaluator/LlamaRankingContext.js +178 -0
- package/dist/evaluator/LlamaRankingContext.js.map +1 -0
- package/dist/evaluator/TokenBias.d.ts +37 -0
- package/dist/evaluator/TokenBias.js +68 -0
- package/dist/evaluator/TokenBias.js.map +1 -0
- package/dist/evaluator/TokenMeter.d.ts +45 -0
- package/dist/evaluator/TokenMeter.js +74 -0
- package/dist/evaluator/TokenMeter.js.map +1 -0
- package/dist/evaluator/utils/chunkDocument.d.ts +86 -0
- package/dist/evaluator/utils/chunkDocument.js +212 -0
- package/dist/evaluator/utils/chunkDocument.js.map +1 -0
- package/dist/gguf/consts.d.ts +4 -0
- package/dist/gguf/consts.js +12 -0
- package/dist/gguf/consts.js.map +1 -0
- package/dist/gguf/errors/InvalidGgufMagicError.d.ts +3 -0
- package/dist/gguf/errors/InvalidGgufMagicError.js +6 -0
- package/dist/gguf/errors/InvalidGgufMagicError.js.map +1 -0
- package/dist/gguf/errors/UnsupportedGgufValueTypeError.d.ts +4 -0
- package/dist/gguf/errors/UnsupportedGgufValueTypeError.js +9 -0
- package/dist/gguf/errors/UnsupportedGgufValueTypeError.js.map +1 -0
- package/dist/gguf/fileReaders/GgufFileReader.d.ts +36 -0
- package/dist/gguf/fileReaders/GgufFileReader.js +106 -0
- package/dist/gguf/fileReaders/GgufFileReader.js.map +1 -0
- package/dist/gguf/fileReaders/GgufFsFileReader.d.ts +16 -0
- package/dist/gguf/fileReaders/GgufFsFileReader.js +62 -0
- package/dist/gguf/fileReaders/GgufFsFileReader.js.map +1 -0
- package/dist/gguf/fileReaders/GgufNetworkFetchFileReader.d.ts +28 -0
- package/dist/gguf/fileReaders/GgufNetworkFetchFileReader.js +94 -0
- package/dist/gguf/fileReaders/GgufNetworkFetchFileReader.js.map +1 -0
- package/dist/gguf/insights/GgufInsights.d.ts +78 -0
- package/dist/gguf/insights/GgufInsights.js +854 -0
- package/dist/gguf/insights/GgufInsights.js.map +1 -0
- package/dist/gguf/insights/GgufInsightsConfigurationResolver.d.ts +203 -0
- package/dist/gguf/insights/GgufInsightsConfigurationResolver.js +284 -0
- package/dist/gguf/insights/GgufInsightsConfigurationResolver.js.map +1 -0
- package/dist/gguf/insights/GgufInsightsTokens.d.ts +5 -0
- package/dist/gguf/insights/GgufInsightsTokens.js +40 -0
- package/dist/gguf/insights/GgufInsightsTokens.js.map +1 -0
- package/dist/gguf/insights/utils/getRamUsageFromUnifiedVram.d.ts +5 -0
- package/dist/gguf/insights/utils/getRamUsageFromUnifiedVram.js +7 -0
- package/dist/gguf/insights/utils/getRamUsageFromUnifiedVram.js.map +1 -0
- package/dist/gguf/insights/utils/resolveContextContextSizeOption.d.ts +33 -0
- package/dist/gguf/insights/utils/resolveContextContextSizeOption.js +117 -0
- package/dist/gguf/insights/utils/resolveContextContextSizeOption.js.map +1 -0
- package/dist/gguf/insights/utils/resolveModelGpuLayersOption.d.ts +20 -0
- package/dist/gguf/insights/utils/resolveModelGpuLayersOption.js +251 -0
- package/dist/gguf/insights/utils/resolveModelGpuLayersOption.js.map +1 -0
- package/dist/gguf/insights/utils/scoreLevels.d.ts +5 -0
- package/dist/gguf/insights/utils/scoreLevels.js +16 -0
- package/dist/gguf/insights/utils/scoreLevels.js.map +1 -0
- package/dist/gguf/parser/GgufV2Parser.d.ts +20 -0
- package/dist/gguf/parser/GgufV2Parser.js +184 -0
- package/dist/gguf/parser/GgufV2Parser.js.map +1 -0
- package/dist/gguf/parser/GgufV3Parser.d.ts +3 -0
- package/dist/gguf/parser/GgufV3Parser.js +4 -0
- package/dist/gguf/parser/GgufV3Parser.js.map +1 -0
- package/dist/gguf/parser/parseGguf.d.ts +8 -0
- package/dist/gguf/parser/parseGguf.js +61 -0
- package/dist/gguf/parser/parseGguf.js.map +1 -0
- package/dist/gguf/readGgufFileInfo.d.ts +54 -0
- package/dist/gguf/readGgufFileInfo.js +82 -0
- package/dist/gguf/readGgufFileInfo.js.map +1 -0
- package/dist/gguf/types/GgufFileInfoTypes.d.ts +85 -0
- package/dist/gguf/types/GgufFileInfoTypes.js +18 -0
- package/dist/gguf/types/GgufFileInfoTypes.js.map +1 -0
- package/dist/gguf/types/GgufMetadataTypes.d.ts +480 -0
- package/dist/gguf/types/GgufMetadataTypes.js +194 -0
- package/dist/gguf/types/GgufMetadataTypes.js.map +1 -0
- package/dist/gguf/types/GgufTensorInfoTypes.d.ts +63 -0
- package/dist/gguf/types/GgufTensorInfoTypes.js +54 -0
- package/dist/gguf/types/GgufTensorInfoTypes.js.map +1 -0
- package/dist/gguf/utils/GgufReadOffset.d.ts +6 -0
- package/dist/gguf/utils/GgufReadOffset.js +18 -0
- package/dist/gguf/utils/GgufReadOffset.js.map +1 -0
- package/dist/gguf/utils/convertMetadataKeyValueRecordToNestedObject.d.ts +6 -0
- package/dist/gguf/utils/convertMetadataKeyValueRecordToNestedObject.js +76 -0
- package/dist/gguf/utils/convertMetadataKeyValueRecordToNestedObject.js.map +1 -0
- package/dist/gguf/utils/getGgufFileTypeName.d.ts +4 -0
- package/dist/gguf/utils/getGgufFileTypeName.js +13 -0
- package/dist/gguf/utils/getGgufFileTypeName.js.map +1 -0
- package/dist/gguf/utils/getGgufMetadataArchitectureData.d.ts +3 -0
- package/dist/gguf/utils/getGgufMetadataArchitectureData.js +4 -0
- package/dist/gguf/utils/getGgufMetadataArchitectureData.js.map +1 -0
- package/dist/gguf/utils/getGgufMetadataKeyValue.d.ts +1 -0
- package/dist/gguf/utils/getGgufMetadataKeyValue.js +27 -0
- package/dist/gguf/utils/getGgufMetadataKeyValue.js.map +1 -0
- package/dist/gguf/utils/ggufQuantNames.d.ts +2 -0
- package/dist/gguf/utils/ggufQuantNames.js +42 -0
- package/dist/gguf/utils/ggufQuantNames.js.map +1 -0
- package/dist/gguf/utils/normalizeGgufDownloadUrl.d.ts +2 -0
- package/dist/gguf/utils/normalizeGgufDownloadUrl.js +18 -0
- package/dist/gguf/utils/normalizeGgufDownloadUrl.js.map +1 -0
- package/dist/gguf/utils/resolveBinarySplitGgufPartUrls.d.ts +2 -0
- package/dist/gguf/utils/resolveBinarySplitGgufPartUrls.js +38 -0
- package/dist/gguf/utils/resolveBinarySplitGgufPartUrls.js.map +1 -0
- package/dist/gguf/utils/resolveSplitGgufParts.d.ts +7 -0
- package/dist/gguf/utils/resolveSplitGgufParts.js +64 -0
- package/dist/gguf/utils/resolveSplitGgufParts.js.map +1 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/dist/state.d.ts +6 -0
- package/dist/state.js +22 -0
- package/dist/state.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.d.ts +408 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/DisposeGuard.d.ts +13 -0
- package/dist/utils/DisposeGuard.js +120 -0
- package/dist/utils/DisposeGuard.js.map +1 -0
- package/dist/utils/InsufficientMemoryError.d.ts +3 -0
- package/dist/utils/InsufficientMemoryError.js +6 -0
- package/dist/utils/InsufficientMemoryError.js.map +1 -0
- package/dist/utils/LlamaText.d.ts +92 -0
- package/dist/utils/LlamaText.js +527 -0
- package/dist/utils/LlamaText.js.map +1 -0
- package/dist/utils/LruCache.d.ts +12 -0
- package/dist/utils/LruCache.js +44 -0
- package/dist/utils/LruCache.js.map +1 -0
- package/dist/utils/OpenAIFormat.d.ts +177 -0
- package/dist/utils/OpenAIFormat.js +488 -0
- package/dist/utils/OpenAIFormat.js.map +1 -0
- package/dist/utils/OverridesObject.d.ts +7 -0
- package/dist/utils/OverridesObject.js +2 -0
- package/dist/utils/OverridesObject.js.map +1 -0
- package/dist/utils/ReplHistory.d.ts +9 -0
- package/dist/utils/ReplHistory.js +72 -0
- package/dist/utils/ReplHistory.js.map +1 -0
- package/dist/utils/StopGenerationDetector.d.ts +47 -0
- package/dist/utils/StopGenerationDetector.js +291 -0
- package/dist/utils/StopGenerationDetector.js.map +1 -0
- package/dist/utils/ThreadsSplitter.d.ts +32 -0
- package/dist/utils/ThreadsSplitter.js +177 -0
- package/dist/utils/ThreadsSplitter.js.map +1 -0
- package/dist/utils/TokenStreamRegulator.d.ts +38 -0
- package/dist/utils/TokenStreamRegulator.js +200 -0
- package/dist/utils/TokenStreamRegulator.js.map +1 -0
- package/dist/utils/UnsupportedError.d.ts +2 -0
- package/dist/utils/UnsupportedError.js +7 -0
- package/dist/utils/UnsupportedError.js.map +1 -0
- package/dist/utils/appendUserMessageToChatHistory.d.ts +6 -0
- package/dist/utils/appendUserMessageToChatHistory.js +22 -0
- package/dist/utils/appendUserMessageToChatHistory.js.map +1 -0
- package/dist/utils/clearTempFolder.d.ts +1 -0
- package/dist/utils/clearTempFolder.js +16 -0
- package/dist/utils/clearTempFolder.js.map +1 -0
- package/dist/utils/cmake.d.ts +10 -0
- package/dist/utils/cmake.js +146 -0
- package/dist/utils/cmake.js.map +1 -0
- package/dist/utils/compareTokens.d.ts +2 -0
- package/dist/utils/compareTokens.js +4 -0
- package/dist/utils/compareTokens.js.map +1 -0
- package/dist/utils/createModelDownloader.d.ts +262 -0
- package/dist/utils/createModelDownloader.js +486 -0
- package/dist/utils/createModelDownloader.js.map +1 -0
- package/dist/utils/findBestOption.d.ts +4 -0
- package/dist/utils/findBestOption.js +15 -0
- package/dist/utils/findBestOption.js.map +1 -0
- package/dist/utils/findCharacterRemovalCountToFitChatHistoryInContext.d.ts +20 -0
- package/dist/utils/findCharacterRemovalCountToFitChatHistoryInContext.js +85 -0
- package/dist/utils/findCharacterRemovalCountToFitChatHistoryInContext.js.map +1 -0
- package/dist/utils/gbnfJson/GbnfGrammarGenerator.d.ts +19 -0
- package/dist/utils/gbnfJson/GbnfGrammarGenerator.js +60 -0
- package/dist/utils/gbnfJson/GbnfGrammarGenerator.js.map +1 -0
- package/dist/utils/gbnfJson/GbnfTerminal.d.ts +11 -0
- package/dist/utils/gbnfJson/GbnfTerminal.js +54 -0
- package/dist/utils/gbnfJson/GbnfTerminal.js.map +1 -0
- package/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.d.ts +5 -0
- package/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.js +11 -0
- package/dist/utils/gbnfJson/getGbnfGrammarForGbnfJsonSchema.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfAnyJson.d.ts +9 -0
- package/dist/utils/gbnfJson/terminals/GbnfAnyJson.js +53 -0
- package/dist/utils/gbnfJson/terminals/GbnfAnyJson.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfArray.d.ts +18 -0
- package/dist/utils/gbnfJson/terminals/GbnfArray.js +83 -0
- package/dist/utils/gbnfJson/terminals/GbnfArray.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfBoolean.d.ts +7 -0
- package/dist/utils/gbnfJson/terminals/GbnfBoolean.js +22 -0
- package/dist/utils/gbnfJson/terminals/GbnfBoolean.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfBooleanValue.d.ts +7 -0
- package/dist/utils/gbnfJson/terminals/GbnfBooleanValue.js +17 -0
- package/dist/utils/gbnfJson/terminals/GbnfBooleanValue.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.d.ts +11 -0
- package/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.js +28 -0
- package/dist/utils/gbnfJson/terminals/GbnfCommaWhitespace.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfFormatString.d.ts +11 -0
- package/dist/utils/gbnfJson/terminals/GbnfFormatString.js +90 -0
- package/dist/utils/gbnfJson/terminals/GbnfFormatString.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfGrammar.d.ts +9 -0
- package/dist/utils/gbnfJson/terminals/GbnfGrammar.js +23 -0
- package/dist/utils/gbnfJson/terminals/GbnfGrammar.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.d.ts +5 -0
- package/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.js +24 -0
- package/dist/utils/gbnfJson/terminals/GbnfInsideStringChar.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfNull.d.ts +5 -0
- package/dist/utils/gbnfJson/terminals/GbnfNull.js +11 -0
- package/dist/utils/gbnfJson/terminals/GbnfNull.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfNumber.d.ts +9 -0
- package/dist/utils/gbnfJson/terminals/GbnfNumber.js +22 -0
- package/dist/utils/gbnfJson/terminals/GbnfNumber.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfNumberValue.d.ts +9 -0
- package/dist/utils/gbnfJson/terminals/GbnfNumberValue.js +21 -0
- package/dist/utils/gbnfJson/terminals/GbnfNumberValue.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfObjectMap.d.ts +28 -0
- package/dist/utils/gbnfJson/terminals/GbnfObjectMap.js +88 -0
- package/dist/utils/gbnfJson/terminals/GbnfObjectMap.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfOr.d.ts +9 -0
- package/dist/utils/gbnfJson/terminals/GbnfOr.js +34 -0
- package/dist/utils/gbnfJson/terminals/GbnfOr.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfRef.d.ts +15 -0
- package/dist/utils/gbnfJson/terminals/GbnfRef.js +34 -0
- package/dist/utils/gbnfJson/terminals/GbnfRef.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfRepetition.d.ts +15 -0
- package/dist/utils/gbnfJson/terminals/GbnfRepetition.js +86 -0
- package/dist/utils/gbnfJson/terminals/GbnfRepetition.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfString.d.ts +12 -0
- package/dist/utils/gbnfJson/terminals/GbnfString.js +43 -0
- package/dist/utils/gbnfJson/terminals/GbnfString.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfStringValue.d.ts +8 -0
- package/dist/utils/gbnfJson/terminals/GbnfStringValue.js +26 -0
- package/dist/utils/gbnfJson/terminals/GbnfStringValue.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfVerbatimText.d.ts +6 -0
- package/dist/utils/gbnfJson/terminals/GbnfVerbatimText.js +21 -0
- package/dist/utils/gbnfJson/terminals/GbnfVerbatimText.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/GbnfWhitespace.d.ts +13 -0
- package/dist/utils/gbnfJson/terminals/GbnfWhitespace.js +67 -0
- package/dist/utils/gbnfJson/terminals/GbnfWhitespace.js.map +1 -0
- package/dist/utils/gbnfJson/terminals/gbnfConsts.d.ts +30 -0
- package/dist/utils/gbnfJson/terminals/gbnfConsts.js +72 -0
- package/dist/utils/gbnfJson/terminals/gbnfConsts.js.map +1 -0
- package/dist/utils/gbnfJson/types.d.ts +213 -0
- package/dist/utils/gbnfJson/types.js +30 -0
- package/dist/utils/gbnfJson/types.js.map +1 -0
- package/dist/utils/gbnfJson/utils/GbnfJsonScopeState.d.ts +10 -0
- package/dist/utils/gbnfJson/utils/GbnfJsonScopeState.js +15 -0
- package/dist/utils/gbnfJson/utils/GbnfJsonScopeState.js.map +1 -0
- package/dist/utils/gbnfJson/utils/defsScope.d.ts +7 -0
- package/dist/utils/gbnfJson/utils/defsScope.js +17 -0
- package/dist/utils/gbnfJson/utils/defsScope.js.map +1 -0
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.d.ts +5 -0
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js +143 -0
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForGbnfJsonSchema.js.map +1 -0
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.d.ts +5 -0
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.js +16 -0
- package/dist/utils/gbnfJson/utils/getGbnfJsonTerminalForLiteral.js.map +1 -0
- package/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.d.ts +8 -0
- package/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js +242 -0
- package/dist/utils/gbnfJson/utils/validateObjectAgainstGbnfSchema.js.map +1 -0
- package/dist/utils/getBuildDefaults.d.ts +5 -0
- package/dist/utils/getBuildDefaults.js +9 -0
- package/dist/utils/getBuildDefaults.js.map +1 -0
- package/dist/utils/getChatWrapperSegmentDefinition.d.ts +2 -0
- package/dist/utils/getChatWrapperSegmentDefinition.js +9 -0
- package/dist/utils/getChatWrapperSegmentDefinition.js.map +1 -0
- package/dist/utils/getConsoleLogPrefix.d.ts +1 -0
- package/dist/utils/getConsoleLogPrefix.js +10 -0
- package/dist/utils/getConsoleLogPrefix.js.map +1 -0
- package/dist/utils/getFirstWritableDir.d.ts +8 -0
- package/dist/utils/getFirstWritableDir.js +60 -0
- package/dist/utils/getFirstWritableDir.js.map +1 -0
- package/dist/utils/getGrammarsFolder.d.ts +2 -0
- package/dist/utils/getGrammarsFolder.js +19 -0
- package/dist/utils/getGrammarsFolder.js.map +1 -0
- package/dist/utils/getLlamaClasses.d.ts +9 -0
- package/dist/utils/getLlamaClasses.js +14 -0
- package/dist/utils/getLlamaClasses.js.map +1 -0
- package/dist/utils/getModuleVersion.d.ts +1 -0
- package/dist/utils/getModuleVersion.js +13 -0
- package/dist/utils/getModuleVersion.js.map +1 -0
- package/dist/utils/getQueuedTokensBeforeStopTrigger.d.ts +6 -0
- package/dist/utils/getQueuedTokensBeforeStopTrigger.js +22 -0
- package/dist/utils/getQueuedTokensBeforeStopTrigger.js.map +1 -0
- package/dist/utils/getReadableContextSize.d.ts +1 -0
- package/dist/utils/getReadableContextSize.js +7 -0
- package/dist/utils/getReadableContextSize.js.map +1 -0
- package/dist/utils/getTempDir.d.ts +10 -0
- package/dist/utils/getTempDir.js +121 -0
- package/dist/utils/getTempDir.js.map +1 -0
- package/dist/utils/getTypeScriptTypeStringForGbnfJsonSchema.d.ts +2 -0
- package/dist/utils/getTypeScriptTypeStringForGbnfJsonSchema.js +205 -0
- package/dist/utils/getTypeScriptTypeStringForGbnfJsonSchema.js.map +1 -0
- package/dist/utils/gitReleaseBundles.d.ts +2 -0
- package/dist/utils/gitReleaseBundles.js +132 -0
- package/dist/utils/gitReleaseBundles.js.map +1 -0
- package/dist/utils/hashString.d.ts +1 -0
- package/dist/utils/hashString.js +8 -0
- package/dist/utils/hashString.js.map +1 -0
- package/dist/utils/includesText.d.ts +1 -0
- package/dist/utils/includesText.js +12 -0
- package/dist/utils/includesText.js.map +1 -0
- package/dist/utils/isLockfileActive.d.ts +4 -0
- package/dist/utils/isLockfileActive.js +12 -0
- package/dist/utils/isLockfileActive.js.map +1 -0
- package/dist/utils/isToken.d.ts +2 -0
- package/dist/utils/isToken.js +4 -0
- package/dist/utils/isToken.js.map +1 -0
- package/dist/utils/isUrl.d.ts +1 -0
- package/dist/utils/isUrl.js +15 -0
- package/dist/utils/isUrl.js.map +1 -0
- package/dist/utils/mergeUnionTypes.d.ts +10 -0
- package/dist/utils/mergeUnionTypes.js +2 -0
- package/dist/utils/mergeUnionTypes.js.map +1 -0
- package/dist/utils/modelDownloadEndpoints.d.ts +13 -0
- package/dist/utils/modelDownloadEndpoints.js +27 -0
- package/dist/utils/modelDownloadEndpoints.js.map +1 -0
- package/dist/utils/modelFileAccessTokens.d.ts +5 -0
- package/dist/utils/modelFileAccessTokens.js +41 -0
- package/dist/utils/modelFileAccessTokens.js.map +1 -0
- package/dist/utils/optionsMatrix.d.ts +58 -0
- package/dist/utils/optionsMatrix.js +97 -0
- package/dist/utils/optionsMatrix.js.map +1 -0
- package/dist/utils/parseModelFileName.d.ts +15 -0
- package/dist/utils/parseModelFileName.js +132 -0
- package/dist/utils/parseModelFileName.js.map +1 -0
- package/dist/utils/parseModelUri.d.ts +40 -0
- package/dist/utils/parseModelUri.js +346 -0
- package/dist/utils/parseModelUri.js.map +1 -0
- package/dist/utils/parseTextTemplate.d.ts +66 -0
- package/dist/utils/parseTextTemplate.js +116 -0
- package/dist/utils/parseTextTemplate.js.map +1 -0
- package/dist/utils/prettyPrintObject.d.ts +10 -0
- package/dist/utils/prettyPrintObject.js +84 -0
- package/dist/utils/prettyPrintObject.js.map +1 -0
- package/dist/utils/pushAll.d.ts +6 -0
- package/dist/utils/pushAll.js +11 -0
- package/dist/utils/pushAll.js.map +1 -0
- package/dist/utils/removeNullFields.d.ts +2 -0
- package/dist/utils/removeNullFields.js +17 -0
- package/dist/utils/removeNullFields.js.map +1 -0
- package/dist/utils/resolveGithubRelease.d.ts +2 -0
- package/dist/utils/resolveGithubRelease.js +77 -0
- package/dist/utils/resolveGithubRelease.js.map +1 -0
- package/dist/utils/resolveLastTokens.d.ts +2 -0
- package/dist/utils/resolveLastTokens.js +12 -0
- package/dist/utils/resolveLastTokens.js.map +1 -0
- package/dist/utils/resolveModelDestination.d.ts +16 -0
- package/dist/utils/resolveModelDestination.js +54 -0
- package/dist/utils/resolveModelDestination.js.map +1 -0
- package/dist/utils/resolveModelFile.d.ts +142 -0
- package/dist/utils/resolveModelFile.js +201 -0
- package/dist/utils/resolveModelFile.js.map +1 -0
- package/dist/utils/runtime.d.ts +4 -0
- package/dist/utils/runtime.js +8 -0
- package/dist/utils/runtime.js.map +1 -0
- package/dist/utils/safeEventCallback.d.ts +6 -0
- package/dist/utils/safeEventCallback.js +29 -0
- package/dist/utils/safeEventCallback.js.map +1 -0
- package/dist/utils/signalSleep.d.ts +1 -0
- package/dist/utils/signalSleep.js +20 -0
- package/dist/utils/signalSleep.js.map +1 -0
- package/dist/utils/spawnCommand.d.ts +11 -0
- package/dist/utils/spawnCommand.js +89 -0
- package/dist/utils/spawnCommand.js.map +1 -0
- package/dist/utils/tokenizeInput.d.ts +3 -0
- package/dist/utils/tokenizeInput.js +14 -0
- package/dist/utils/tokenizeInput.js.map +1 -0
- package/dist/utils/tokenizerUtils.d.ts +12 -0
- package/dist/utils/tokenizerUtils.js +32 -0
- package/dist/utils/tokenizerUtils.js.map +1 -0
- package/dist/utils/transformPromisable.d.ts +54 -0
- package/dist/utils/transformPromisable.js +95 -0
- package/dist/utils/transformPromisable.js.map +1 -0
- package/dist/utils/truncateTextAndRoundToWords.d.ts +11 -0
- package/dist/utils/truncateTextAndRoundToWords.js +110 -0
- package/dist/utils/truncateTextAndRoundToWords.js.map +1 -0
- package/dist/utils/utilTypes.d.ts +18 -0
- package/dist/utils/utilTypes.js +2 -0
- package/dist/utils/utilTypes.js.map +1 -0
- package/dist/utils/waitForLockfileRelease.d.ts +5 -0
- package/dist/utils/waitForLockfileRelease.js +19 -0
- package/dist/utils/waitForLockfileRelease.js.map +1 -0
- package/dist/utils/withLockfile.d.ts +7 -0
- package/dist/utils/withLockfile.js +44 -0
- package/dist/utils/withLockfile.js.map +1 -0
- package/dist/utils/withOra.d.ts +7 -0
- package/dist/utils/withOra.js +37 -0
- package/dist/utils/withOra.js.map +1 -0
- package/dist/utils/withProgressLog.d.ts +22 -0
- package/dist/utils/withProgressLog.js +211 -0
- package/dist/utils/withProgressLog.js.map +1 -0
- package/dist/utils/withStatusLogs.d.ts +6 -0
- package/dist/utils/withStatusLogs.js +25 -0
- package/dist/utils/withStatusLogs.js.map +1 -0
- package/dist/utils/wrapAbortSignal.d.ts +1 -0
- package/dist/utils/wrapAbortSignal.js +14 -0
- package/dist/utils/wrapAbortSignal.js.map +1 -0
- package/llama/.clang-format +46 -0
- package/llama/CMakeLists.txt +141 -0
- package/llama/addon/AddonContext.cpp +1181 -0
- package/llama/addon/AddonContext.h +85 -0
- package/llama/addon/AddonGrammar.cpp +92 -0
- package/llama/addon/AddonGrammar.h +22 -0
- package/llama/addon/AddonGrammarEvaluationState.cpp +36 -0
- package/llama/addon/AddonGrammarEvaluationState.h +17 -0
- package/llama/addon/AddonModel.cpp +691 -0
- package/llama/addon/AddonModel.h +64 -0
- package/llama/addon/AddonModelData.cpp +25 -0
- package/llama/addon/AddonModelData.h +15 -0
- package/llama/addon/AddonModelLora.cpp +103 -0
- package/llama/addon/AddonModelLora.h +28 -0
- package/llama/addon/AddonSampler.cpp +669 -0
- package/llama/addon/AddonSampler.h +75 -0
- package/llama/addon/RingBuffer.h +109 -0
- package/llama/addon/addon.cpp +330 -0
- package/llama/addon/addonGlobals.cpp +22 -0
- package/llama/addon/addonGlobals.h +12 -0
- package/llama/addon/globals/addonLog.cpp +143 -0
- package/llama/addon/globals/addonLog.h +24 -0
- package/llama/addon/globals/addonProgress.cpp +15 -0
- package/llama/addon/globals/addonProgress.h +15 -0
- package/llama/addon/globals/getGpuInfo.cpp +146 -0
- package/llama/addon/globals/getGpuInfo.h +11 -0
- package/llama/addon/globals/getMemoryInfo.cpp +63 -0
- package/llama/addon/globals/getMemoryInfo.h +4 -0
- package/llama/addon/globals/getSwapInfo.cpp +69 -0
- package/llama/addon/globals/getSwapInfo.h +4 -0
- package/llama/binariesGithubRelease.json +3 -0
- package/llama/cmake/addVariantSuffix.cmake +21 -0
- package/llama/cmake/win32.ensureNinjaPath.cmake +68 -0
- package/llama/cmake/win32.ensureNodeLib.cmake +34 -0
- package/llama/cmake/win32.llvmApplyGnuModeAdaptations.cmake +12 -0
- package/llama/cmake/win32.llvmEnsureCmakeAr.cmake +37 -0
- package/llama/cmake/win32.llvmUseGnuModeCompilers.cmake +87 -0
- package/llama/cmake/win32.programFilesPaths.cmake +35 -0
- package/llama/gpuInfo/vulkan-gpu-info.cpp +207 -0
- package/llama/gpuInfo/vulkan-gpu-info.h +9 -0
- package/llama/package.json +5 -0
- package/llama/profiles/llvm.win32.host-arm64.target-arm64.cmake +14 -0
- package/llama/profiles/llvm.win32.host-x64.target-arm64.cmake +14 -0
- package/llama/profiles/llvm.win32.host-x64.target-x64.cmake +14 -0
- package/llama/toolchains/darwin.host-x64.target-arm64.cmake +8 -0
- package/llama/toolchains/linux.host-arm64.target-x64.cmake +5 -0
- package/llama/toolchains/linux.host-x64.target-arm64.cmake +5 -0
- package/llama/toolchains/linux.host-x64.target-arm71.cmake +5 -0
- package/llama/toolchains/llvm.win32.host-x64.target-x64.cmake +20 -0
- package/llama/toolchains/win32.host-arm64.target-arm64.cmake +21 -0
- package/llama/toolchains/win32.host-x64.target-arm64.cmake +21 -0
- package/llama/xpack/package.json +10 -0
- package/package.json +241 -0
- package/templates/README.md +6 -0
- package/templates/package.json +10 -0
- package/templates/packed/electron-typescript-react.json +1 -0
- package/templates/packed/node-typescript.json +1 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { ChatWrapper } from "../ChatWrapper.js";
|
|
2
|
+
import { SpecialToken, LlamaText, SpecialTokensText } from "../utils/LlamaText.js";
|
|
3
|
+
// source: https://github.com/openai/openai-python/blob/120d225b91a8453e15240a49fb1c6794d8119326/chatml.md
|
|
4
|
+
export class ChatMLChatWrapper extends ChatWrapper {
|
|
5
|
+
wrapperName = "ChatML";
|
|
6
|
+
generateContextState({ chatHistory, availableFunctions, documentFunctionParams }) {
|
|
7
|
+
const historyWithFunctions = this.addAvailableFunctionsSystemMessageToHistory(chatHistory, availableFunctions, {
|
|
8
|
+
documentParams: documentFunctionParams
|
|
9
|
+
});
|
|
10
|
+
const resultItems = [];
|
|
11
|
+
let systemTexts = [];
|
|
12
|
+
let userTexts = [];
|
|
13
|
+
let modelTexts = [];
|
|
14
|
+
let currentAggregateFocus = null;
|
|
15
|
+
function flush() {
|
|
16
|
+
if (systemTexts.length > 0 || userTexts.length > 0 || modelTexts.length > 0)
|
|
17
|
+
resultItems.push({
|
|
18
|
+
system: LlamaText.joinValues("\n\n", systemTexts),
|
|
19
|
+
user: LlamaText.joinValues("\n\n", userTexts),
|
|
20
|
+
model: LlamaText.joinValues("\n\n", modelTexts)
|
|
21
|
+
});
|
|
22
|
+
systemTexts = [];
|
|
23
|
+
userTexts = [];
|
|
24
|
+
modelTexts = [];
|
|
25
|
+
}
|
|
26
|
+
for (const item of historyWithFunctions) {
|
|
27
|
+
if (item.type === "system") {
|
|
28
|
+
if (currentAggregateFocus !== "system")
|
|
29
|
+
flush();
|
|
30
|
+
currentAggregateFocus = "system";
|
|
31
|
+
systemTexts.push(LlamaText.fromJSON(item.text));
|
|
32
|
+
}
|
|
33
|
+
else if (item.type === "user") {
|
|
34
|
+
flush();
|
|
35
|
+
currentAggregateFocus = null;
|
|
36
|
+
userTexts.push(LlamaText(item.text));
|
|
37
|
+
}
|
|
38
|
+
else if (item.type === "model") {
|
|
39
|
+
flush();
|
|
40
|
+
currentAggregateFocus = null;
|
|
41
|
+
modelTexts.push(this.generateModelResponseText(item.response));
|
|
42
|
+
}
|
|
43
|
+
else
|
|
44
|
+
void item;
|
|
45
|
+
}
|
|
46
|
+
flush();
|
|
47
|
+
const contextText = LlamaText(new SpecialToken("BOS"), resultItems.map(({ system, user, model }, index) => {
|
|
48
|
+
const isLastItem = index === resultItems.length - 1;
|
|
49
|
+
return LlamaText([
|
|
50
|
+
(system.values.length === 0)
|
|
51
|
+
? LlamaText([])
|
|
52
|
+
: LlamaText([
|
|
53
|
+
new SpecialTokensText("<|im_start|>system\n"),
|
|
54
|
+
system,
|
|
55
|
+
new SpecialTokensText("<|im_end|>\n")
|
|
56
|
+
]),
|
|
57
|
+
(user.values.length === 0)
|
|
58
|
+
? LlamaText([])
|
|
59
|
+
: LlamaText([
|
|
60
|
+
new SpecialTokensText("<|im_start|>user\n"),
|
|
61
|
+
user,
|
|
62
|
+
new SpecialTokensText("<|im_end|>\n")
|
|
63
|
+
]),
|
|
64
|
+
(model.values.length === 0 && !isLastItem)
|
|
65
|
+
? LlamaText([])
|
|
66
|
+
: LlamaText([
|
|
67
|
+
new SpecialTokensText("<|im_start|>assistant\n"),
|
|
68
|
+
model,
|
|
69
|
+
isLastItem
|
|
70
|
+
? LlamaText([])
|
|
71
|
+
: new SpecialTokensText("<|im_end|>\n")
|
|
72
|
+
])
|
|
73
|
+
]);
|
|
74
|
+
}));
|
|
75
|
+
return {
|
|
76
|
+
contextText,
|
|
77
|
+
stopGenerationTriggers: [
|
|
78
|
+
LlamaText(new SpecialToken("EOS")),
|
|
79
|
+
LlamaText(new SpecialTokensText("<|im_end|>")),
|
|
80
|
+
LlamaText("<|im_end|>")
|
|
81
|
+
]
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=ChatMLChatWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatMLChatWrapper.js","sourceRoot":"","sources":["../../src/chatWrappers/ChatMLChatWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAC,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AAEjF,0GAA0G;AAC1G,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAC9B,WAAW,GAAW,QAAQ,CAAC;IAE/B,oBAAoB,CAAC,EACjC,WAAW,EAAE,kBAAkB,EAAE,sBAAsB,EAClB;QACrC,MAAM,oBAAoB,GAAG,IAAI,CAAC,2CAA2C,CAAC,WAAW,EAAE,kBAAkB,EAAE;YAC3G,cAAc,EAAE,sBAAsB;SACzC,CAAC,CAAC;QAEH,MAAM,WAAW,GAIZ,EAAE,CAAC;QAER,IAAI,WAAW,GAAgB,EAAE,CAAC;QAClC,IAAI,SAAS,GAAgB,EAAE,CAAC;QAChC,IAAI,UAAU,GAAgB,EAAE,CAAC;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;YACX,sBAAsB,EAAE;gBACpB,SAAS,CAAC,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;gBAClC,SAAS,CAAC,IAAI,iBAAiB,CAAC,YAAY,CAAC,CAAC;gBAC9C,SAAS,CAAC,YAAY,CAAC;aAC1B;SACJ,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ChatWrapper } from "../ChatWrapper.js";
|
|
2
|
+
import { ChatModelFunctions, ChatWrapperGenerateContextStateOptions, ChatWrapperGeneratedContextState, ChatWrapperSettings } from "../types.js";
|
|
3
|
+
export declare class DeepSeekChatWrapper extends ChatWrapper {
|
|
4
|
+
readonly wrapperName: string;
|
|
5
|
+
readonly keepOnlyLastThought: boolean;
|
|
6
|
+
readonly functionCallingSyntax: "r1-workaround" | "simplified" | "original";
|
|
7
|
+
readonly parallelFunctionCalling: boolean;
|
|
8
|
+
readonly settings: ChatWrapperSettings;
|
|
9
|
+
constructor(options?: {
|
|
10
|
+
/**
|
|
11
|
+
* Whether to keep only the chain of thought from the last model response.
|
|
12
|
+
*
|
|
13
|
+
* Setting this to `false` will keep all the chain of thoughts from the model responses in the context state.
|
|
14
|
+
*
|
|
15
|
+
* Defaults to `true`.
|
|
16
|
+
*/
|
|
17
|
+
keepOnlyLastThought?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Use a different variation function calling syntax to improve syntax compliance.
|
|
20
|
+
*
|
|
21
|
+
* Defaults to `"r1-workaround"`.
|
|
22
|
+
*/
|
|
23
|
+
functionCallingSyntax?: "r1-workaround" | "simplified" | "original";
|
|
24
|
+
/**
|
|
25
|
+
* Support parallel function calling.
|
|
26
|
+
*
|
|
27
|
+
* May not work well with all distill model variations, as some distillation models make unnecessary additional calls in parallel.
|
|
28
|
+
*
|
|
29
|
+
* Defaults to `false`.
|
|
30
|
+
*/
|
|
31
|
+
parallelFunctionCalling?: boolean;
|
|
32
|
+
});
|
|
33
|
+
generateContextState({ chatHistory, availableFunctions, documentFunctionParams }: ChatWrapperGenerateContextStateOptions): ChatWrapperGeneratedContextState;
|
|
34
|
+
generateAvailableFunctionsSystemText(availableFunctions: ChatModelFunctions, { documentParams }: {
|
|
35
|
+
documentParams?: boolean;
|
|
36
|
+
}): import("../utils/LlamaText.js")._LlamaText;
|
|
37
|
+
}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { ChatWrapper } from "../ChatWrapper.js";
|
|
2
|
+
import { isChatModelResponseSegment } from "../types.js";
|
|
3
|
+
import { SpecialToken, LlamaText, SpecialTokensText } from "../utils/LlamaText.js";
|
|
4
|
+
import { ChatModelFunctionsDocumentationGenerator } from "./utils/ChatModelFunctionsDocumentationGenerator.js";
|
|
5
|
+
import { jsonDumps } from "./utils/jsonDumps.js";
|
|
6
|
+
export class DeepSeekChatWrapper extends ChatWrapper {
|
|
7
|
+
wrapperName = "DeepSeek";
|
|
8
|
+
keepOnlyLastThought;
|
|
9
|
+
functionCallingSyntax;
|
|
10
|
+
parallelFunctionCalling;
|
|
11
|
+
settings;
|
|
12
|
+
constructor(options = {}) {
|
|
13
|
+
super();
|
|
14
|
+
const { keepOnlyLastThought = true, functionCallingSyntax = "r1-workaround", parallelFunctionCalling = false } = options;
|
|
15
|
+
this.keepOnlyLastThought = keepOnlyLastThought;
|
|
16
|
+
this.functionCallingSyntax = functionCallingSyntax;
|
|
17
|
+
this.parallelFunctionCalling = parallelFunctionCalling;
|
|
18
|
+
const getFunctionsSettings = () => {
|
|
19
|
+
if (functionCallingSyntax === "original") {
|
|
20
|
+
if (parallelFunctionCalling)
|
|
21
|
+
return {
|
|
22
|
+
call: {
|
|
23
|
+
optionalPrefixSpace: true,
|
|
24
|
+
prefix: LlamaText(new SpecialTokensText("<|tool▁call▁begin|>function<|tool▁sep|>")),
|
|
25
|
+
paramsPrefix: LlamaText(new SpecialTokensText("\n```json\n")),
|
|
26
|
+
suffix: LlamaText([new SpecialTokensText("\n```<|tool▁call▁end|>")])
|
|
27
|
+
},
|
|
28
|
+
result: {
|
|
29
|
+
prefix: LlamaText(new SpecialTokensText("<|tool▁output▁begin|>")),
|
|
30
|
+
suffix: LlamaText(new SpecialTokensText("<|tool▁output▁end|>"))
|
|
31
|
+
},
|
|
32
|
+
parallelism: {
|
|
33
|
+
call: {
|
|
34
|
+
sectionPrefix: LlamaText(new SpecialTokensText("<|tool▁calls▁begin|>")),
|
|
35
|
+
betweenCalls: LlamaText(new SpecialTokensText("\n")),
|
|
36
|
+
sectionSuffix: LlamaText(new SpecialTokensText("<|tool▁calls▁end|><|end▁of▁sentence|>"))
|
|
37
|
+
},
|
|
38
|
+
result: {
|
|
39
|
+
sectionPrefix: LlamaText(new SpecialTokensText("<|tool▁outputs▁begin|>")),
|
|
40
|
+
betweenResults: LlamaText(new SpecialTokensText("\n")),
|
|
41
|
+
sectionSuffix: LlamaText(new SpecialTokensText("<|tool▁outputs▁end|><|Assistant|>"))
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
else
|
|
46
|
+
return {
|
|
47
|
+
call: {
|
|
48
|
+
optionalPrefixSpace: true,
|
|
49
|
+
prefix: LlamaText(new SpecialTokensText("<|tool▁calls▁begin|><|tool▁call▁begin|>function<|tool▁sep|>")),
|
|
50
|
+
paramsPrefix: LlamaText(new SpecialTokensText("\n```json\n")),
|
|
51
|
+
suffix: LlamaText([new SpecialTokensText("\n```<|tool▁call▁end|><|tool▁calls▁end|><|end▁of▁sentence|>")])
|
|
52
|
+
},
|
|
53
|
+
result: {
|
|
54
|
+
prefix: LlamaText(new SpecialTokensText("<|tool▁outputs▁begin|><|tool▁output▁begin|>")),
|
|
55
|
+
suffix: LlamaText(new SpecialTokensText("<|tool▁output▁end|><|tool▁outputs▁end|><|Assistant|>"))
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
else if (functionCallingSyntax === "simplified") {
|
|
60
|
+
if (parallelFunctionCalling)
|
|
61
|
+
return {
|
|
62
|
+
call: {
|
|
63
|
+
optionalPrefixSpace: true,
|
|
64
|
+
prefix: LlamaText(new SpecialTokensText("<|tool▁call▁begin|>")),
|
|
65
|
+
paramsPrefix: LlamaText(new SpecialTokensText("<|tool▁sep|>\n```json\n")),
|
|
66
|
+
suffix: LlamaText([new SpecialTokensText("\n```<|tool▁call▁end|>")])
|
|
67
|
+
},
|
|
68
|
+
result: {
|
|
69
|
+
prefix: LlamaText(new SpecialTokensText("<|tool▁output▁begin|>")),
|
|
70
|
+
suffix: LlamaText(new SpecialTokensText("<|tool▁output▁end|>"))
|
|
71
|
+
},
|
|
72
|
+
parallelism: {
|
|
73
|
+
call: {
|
|
74
|
+
sectionPrefix: LlamaText(new SpecialTokensText("<|tool▁calls▁begin|>")),
|
|
75
|
+
betweenCalls: LlamaText(new SpecialTokensText("\n")),
|
|
76
|
+
sectionSuffix: LlamaText(new SpecialTokensText("<|tool▁calls▁end|><|end▁of▁sentence|>"))
|
|
77
|
+
},
|
|
78
|
+
result: {
|
|
79
|
+
sectionPrefix: LlamaText(new SpecialTokensText("<|tool▁outputs▁begin|>")),
|
|
80
|
+
betweenResults: LlamaText(new SpecialTokensText("\n")),
|
|
81
|
+
sectionSuffix: LlamaText(new SpecialTokensText("<|tool▁outputs▁end|>"))
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
else
|
|
86
|
+
return {
|
|
87
|
+
call: {
|
|
88
|
+
optionalPrefixSpace: true,
|
|
89
|
+
prefix: LlamaText(new SpecialTokensText("<|tool▁call▁begin|>")),
|
|
90
|
+
paramsPrefix: LlamaText(new SpecialTokensText("<|tool▁sep|>\n```json\n")),
|
|
91
|
+
suffix: LlamaText([new SpecialTokensText("\n```<|tool▁call▁end|><|end▁of▁sentence|>")])
|
|
92
|
+
},
|
|
93
|
+
result: {
|
|
94
|
+
prefix: LlamaText(new SpecialTokensText("<|tool▁output▁begin|>")),
|
|
95
|
+
suffix: LlamaText(new SpecialTokensText("<|tool▁output▁end|>"))
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
void functionCallingSyntax;
|
|
100
|
+
if (parallelFunctionCalling)
|
|
101
|
+
throw new Error(`parallel function calling is not supported with "${"r1-workaround"}" syntax`);
|
|
102
|
+
return {
|
|
103
|
+
call: {
|
|
104
|
+
optionalPrefixSpace: true,
|
|
105
|
+
prefix: LlamaText(new SpecialTokensText("<function=")),
|
|
106
|
+
paramsPrefix: LlamaText(new SpecialTokensText(">")),
|
|
107
|
+
suffix: LlamaText(new SpecialTokensText("</function>"))
|
|
108
|
+
},
|
|
109
|
+
result: {
|
|
110
|
+
prefix: LlamaText(new SpecialTokensText("<|tool▁output▁begin|>")),
|
|
111
|
+
suffix: LlamaText(new SpecialTokensText("<|tool▁output▁end|>\n"))
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
this.settings = {
|
|
116
|
+
supportsSystemMessages: true,
|
|
117
|
+
functions: getFunctionsSettings(),
|
|
118
|
+
segments: {
|
|
119
|
+
reiterateStackAfterFunctionCalls: true,
|
|
120
|
+
thought: {
|
|
121
|
+
prefix: LlamaText(new SpecialTokensText("<think>")),
|
|
122
|
+
suffix: LlamaText(new SpecialTokensText("</think>")),
|
|
123
|
+
reopenAfterFunctionCalls: functionCallingSyntax === "simplified"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
generateContextState({ chatHistory, availableFunctions, documentFunctionParams }) {
|
|
129
|
+
const historyWithFunctions = this.addAvailableFunctionsSystemMessageToHistory(chatHistory, availableFunctions, {
|
|
130
|
+
documentParams: documentFunctionParams
|
|
131
|
+
});
|
|
132
|
+
const systemTexts = historyWithFunctions
|
|
133
|
+
.filter((item) => item.type === "system")
|
|
134
|
+
.map((item) => LlamaText.fromJSON(item.text));
|
|
135
|
+
const contextText = LlamaText(new SpecialToken("BOS"), LlamaText.joinValues("\n\n", systemTexts), historyWithFunctions.map((item, index) => {
|
|
136
|
+
const isLastItem = index === historyWithFunctions.length - 1;
|
|
137
|
+
// system messages are already prepended at the beginning
|
|
138
|
+
if (item.type === "system")
|
|
139
|
+
return LlamaText([]);
|
|
140
|
+
if (item.type === "user")
|
|
141
|
+
return LlamaText([
|
|
142
|
+
new SpecialTokensText("<|User|>"),
|
|
143
|
+
item.text
|
|
144
|
+
]);
|
|
145
|
+
else if (item.type === "model")
|
|
146
|
+
return LlamaText([
|
|
147
|
+
new SpecialTokensText("<|Assistant|>"),
|
|
148
|
+
this.generateModelResponseText((this.keepOnlyLastThought && !isLastItem)
|
|
149
|
+
? item.response.filter((response) => (!isChatModelResponseSegment(response) || response.segmentType !== "thought"))
|
|
150
|
+
: item.response),
|
|
151
|
+
isLastItem
|
|
152
|
+
? LlamaText([])
|
|
153
|
+
: new SpecialTokensText("<|end▁of▁sentence|>")
|
|
154
|
+
]);
|
|
155
|
+
void item;
|
|
156
|
+
return LlamaText([]);
|
|
157
|
+
}));
|
|
158
|
+
return {
|
|
159
|
+
contextText,
|
|
160
|
+
stopGenerationTriggers: [
|
|
161
|
+
LlamaText(new SpecialToken("EOS")),
|
|
162
|
+
LlamaText(new SpecialToken("EOT")),
|
|
163
|
+
LlamaText(new SpecialTokensText("<|end▁of▁sentence|>")),
|
|
164
|
+
LlamaText(new SpecialTokensText("<|User|>"))
|
|
165
|
+
]
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
generateAvailableFunctionsSystemText(availableFunctions, { documentParams = true }) {
|
|
169
|
+
const functionsDocumentationGenerator = new ChatModelFunctionsDocumentationGenerator(availableFunctions);
|
|
170
|
+
if (!functionsDocumentationGenerator.hasAnyFunctions)
|
|
171
|
+
return LlamaText([]);
|
|
172
|
+
if (this.functionCallingSyntax === "r1-workaround") {
|
|
173
|
+
return LlamaText.joinValues("\n", [
|
|
174
|
+
"The assistant calls the provided functions as needed to retrieve information instead of relying on existing knowledge.",
|
|
175
|
+
"To fulfill a request, the assistant calls relevant functions in advance when needed before responding to the request, and does not tell the user prior to calling a function.",
|
|
176
|
+
"If the result of function calls from previous turns might be stale, the assistant will call the functions again if needed.",
|
|
177
|
+
// "The assistant NEVER relies on existing knowledge when there's a function that can be used instead.",
|
|
178
|
+
"Provided functions:",
|
|
179
|
+
functionsDocumentationGenerator.getLlama3_2LightweightFunctionSignatures({ documentParams }),
|
|
180
|
+
"",
|
|
181
|
+
"Calling any of the provided functions can be done like this:",
|
|
182
|
+
LlamaText.joinValues("", [
|
|
183
|
+
this.settings.functions.call.prefix,
|
|
184
|
+
"getSomeInfo",
|
|
185
|
+
this.settings.functions.call.paramsPrefix,
|
|
186
|
+
jsonDumps({ someKey: "someValue" }),
|
|
187
|
+
this.settings.functions.call.suffix
|
|
188
|
+
]),
|
|
189
|
+
"",
|
|
190
|
+
LlamaText(["Note that the verbatim ", this.settings.functions.call.prefix, " prefix is mandatory."]),
|
|
191
|
+
"",
|
|
192
|
+
"The assistant never assumes the results of function calls, and instead uses the raw results directly for processing.",
|
|
193
|
+
"The assistant does not inform the user about using functions and does not explain anything before calling a function.",
|
|
194
|
+
"After calling a function, the raw result appears afterwards and is not part of the conversation.",
|
|
195
|
+
"To make information be part of the conversation, the assistant paraphrases and repeats the information without the function syntax.",
|
|
196
|
+
"The assistant never repeats itself unless necessary."
|
|
197
|
+
]);
|
|
198
|
+
}
|
|
199
|
+
return LlamaText.joinValues("\n", [
|
|
200
|
+
"You have access to the following functions:",
|
|
201
|
+
functionsDocumentationGenerator.getLlama3_2LightweightFunctionSignatures({ documentParams }),
|
|
202
|
+
"",
|
|
203
|
+
this.parallelFunctionCalling
|
|
204
|
+
? LlamaText.joinValues("\n", [
|
|
205
|
+
"If you choose to call a function, use the following format:",
|
|
206
|
+
LlamaText([
|
|
207
|
+
this.settings.functions.parallelism.call.sectionPrefix,
|
|
208
|
+
this.settings.functions.call.prefix,
|
|
209
|
+
"funcName",
|
|
210
|
+
this.settings.functions.call.paramsPrefix,
|
|
211
|
+
"parameters",
|
|
212
|
+
this.settings.functions.call.suffix,
|
|
213
|
+
this.settings.functions.parallelism.call.sectionSuffix
|
|
214
|
+
]),
|
|
215
|
+
"where",
|
|
216
|
+
"",
|
|
217
|
+
"funcName => the function name to call",
|
|
218
|
+
"parameters => a JSON dict with the function arguments",
|
|
219
|
+
// "",
|
|
220
|
+
// "Note that the following syntax is mandatory to precede the function name:",
|
|
221
|
+
// LlamaText([
|
|
222
|
+
// this.settings.functions.parallelism!.call.sectionPrefix,
|
|
223
|
+
// this.settings.functions.call.prefix
|
|
224
|
+
// ]),
|
|
225
|
+
"",
|
|
226
|
+
"You can call multiple functions in parallel using the following format:",
|
|
227
|
+
LlamaText([
|
|
228
|
+
this.settings.functions.parallelism.call.sectionPrefix,
|
|
229
|
+
this.settings.functions.call.prefix,
|
|
230
|
+
"funcName1",
|
|
231
|
+
this.settings.functions.call.paramsPrefix,
|
|
232
|
+
"parameters1",
|
|
233
|
+
this.settings.functions.call.suffix,
|
|
234
|
+
this.settings.functions.parallelism.call.betweenCalls ?? "",
|
|
235
|
+
this.settings.functions.call.prefix,
|
|
236
|
+
"funcName2",
|
|
237
|
+
this.settings.functions.call.paramsPrefix,
|
|
238
|
+
"parameters2",
|
|
239
|
+
this.settings.functions.call.suffix,
|
|
240
|
+
this.settings.functions.parallelism.call.sectionSuffix
|
|
241
|
+
])
|
|
242
|
+
])
|
|
243
|
+
: LlamaText.joinValues("\n", [
|
|
244
|
+
"If you choose to call a function, use the following format:",
|
|
245
|
+
LlamaText.joinValues("", [
|
|
246
|
+
this.settings.functions.call.prefix,
|
|
247
|
+
"funcName",
|
|
248
|
+
this.settings.functions.call.paramsPrefix,
|
|
249
|
+
"parameters",
|
|
250
|
+
this.settings.functions.call.suffix
|
|
251
|
+
]),
|
|
252
|
+
"where",
|
|
253
|
+
"",
|
|
254
|
+
"funcName => the function name to call",
|
|
255
|
+
"parameters => a JSON dict with the function arguments"
|
|
256
|
+
]),
|
|
257
|
+
"",
|
|
258
|
+
"Reminder:",
|
|
259
|
+
"- Function calls MUST follow the specified format verbatim",
|
|
260
|
+
this.parallelFunctionCalling
|
|
261
|
+
? LlamaText.joinValues("\n", [
|
|
262
|
+
"- You can call a single or multiple functions at a time, their responses will appear afterwards in the order they were called",
|
|
263
|
+
"- After calling functions, the results will appear afterwards and are visible only to you"
|
|
264
|
+
])
|
|
265
|
+
: LlamaText.joinValues("\n", [
|
|
266
|
+
"- Only call one function at a time",
|
|
267
|
+
"- After calling a function, the result will appear afterwards and is visible only to you"
|
|
268
|
+
]),
|
|
269
|
+
"- Do not inform the user about using functions and do not explain anything before calling a function",
|
|
270
|
+
"- After calling a function, the raw result appears afterwards and is not part of the conversation.",
|
|
271
|
+
"- To make information be part of the conversation, paraphrase and repeat the information without the function syntax.",
|
|
272
|
+
"- To make information visible to the user, you MUST include it in your response",
|
|
273
|
+
"- Call functions when needed and avoid redundant calls",
|
|
274
|
+
"- NEVER speak about functions, just use them",
|
|
275
|
+
"- NEVER tell the user about the functions you are using",
|
|
276
|
+
"- NEVER repeat yourself unless necessary",
|
|
277
|
+
LlamaText([
|
|
278
|
+
"- After calling a function, use ", new SpecialTokensText("</think>"), " to finish thinking and respond to the user"
|
|
279
|
+
])
|
|
280
|
+
]);
|
|
281
|
+
}
|
|
282
|
+
/** @internal */
|
|
283
|
+
static _getOptionConfigurationsToTestIfCanSupersedeJinjaTemplate() {
|
|
284
|
+
return [
|
|
285
|
+
[undefined, {}, { functionCallMessageTemplate: "noJinja" }],
|
|
286
|
+
[undefined, { keepOnlyLastThought: true }, { functionCallMessageTemplate: "noJinja" }],
|
|
287
|
+
[undefined, { functionCallingSyntax: "simplified" }, { functionCallMessageTemplate: "noJinja" }],
|
|
288
|
+
[undefined, { functionCallingSyntax: "simplified", keepOnlyLastThought: true }, { functionCallMessageTemplate: "noJinja" }],
|
|
289
|
+
[undefined, { functionCallingSyntax: "original" }, { functionCallMessageTemplate: "noJinja" }],
|
|
290
|
+
[undefined, { functionCallingSyntax: "original", keepOnlyLastThought: true }, { functionCallMessageTemplate: "noJinja" }]
|
|
291
|
+
];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
//# sourceMappingURL=DeepSeekChatWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeepSeekChatWrapper.js","sourceRoot":"","sources":["../../src/chatWrappers/DeepSeekChatWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAqC,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAEH,0BAA0B,EAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACjF,OAAO,EAAC,wCAAwC,EAAC,MAAM,qDAAqD,CAAC;AAC7G,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAG/C,MAAM,OAAO,mBAAoB,SAAQ,WAAW;IAChC,WAAW,GAAW,UAAU,CAAC;IAEjC,mBAAmB,CAAU;IAC7B,qBAAqB,CAA8C;IACnE,uBAAuB,CAAU;IAExB,QAAQ,CAAsB;IAEvD,YAAmB,UAyBf,EAAE;QACF,KAAK,EAAE,CAAC;QAER,MAAM,EACF,mBAAmB,GAAG,IAAI,EAC1B,qBAAqB,GAAG,eAAe,EACvC,uBAAuB,GAAG,KAAK,EAClC,GAAG,OAAO,CAAC;QAEZ,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAC/C,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;QAEvD,MAAM,oBAAoB,GAAG,GAAqC,EAAE;YAChE,IAAI,qBAAqB,KAAK,UAAU,EAAE,CAAC;gBACvC,IAAI,uBAAuB;oBACvB,OAAO;wBACH,IAAI,EAAE;4BACF,mBAAmB,EAAE,IAAI;4BACzB,MAAM,EAAE,SAAS,CAAC,IAAI,iBAAiB,CAAC,yCAAyC,CAAC,CAAC;4BACnF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AAC;SACxH,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmptyChatWrapper.js","sourceRoot":"","sources":["../../src/chatWrappers/EmptyChatWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAE9C,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAC7B,WAAW,GAAW,OAAO,CAAC;CACjD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ChatWrapper } from "../ChatWrapper.js";
|
|
2
|
+
import { ChatWrapperGenerateContextStateOptions, ChatWrapperGeneratedContextState } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* This chat wrapper is not safe against chat syntax injection attacks
|
|
5
|
+
* ([learn more](https://node-llama-cpp.withcat.ai/guide/llama-text#input-safety-in-node-llama-cpp)).
|
|
6
|
+
*/
|
|
7
|
+
export declare class FalconChatWrapper extends ChatWrapper {
|
|
8
|
+
readonly wrapperName: string;
|
|
9
|
+
constructor({ userMessageTitle, modelResponseTitle, middleSystemMessageTitle, allowSpecialTokensInTitles }?: {
|
|
10
|
+
userMessageTitle?: string;
|
|
11
|
+
modelResponseTitle?: string;
|
|
12
|
+
middleSystemMessageTitle?: string;
|
|
13
|
+
allowSpecialTokensInTitles?: boolean;
|
|
14
|
+
});
|
|
15
|
+
get userMessageTitle(): string;
|
|
16
|
+
get modelResponseTitle(): string;
|
|
17
|
+
get middleSystemMessageTitle(): string;
|
|
18
|
+
generateContextState({ chatHistory, availableFunctions, documentFunctionParams }: ChatWrapperGenerateContextStateOptions): ChatWrapperGeneratedContextState;
|
|
19
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { ChatWrapper } from "../ChatWrapper.js";
|
|
2
|
+
import { LlamaText, SpecialToken, SpecialTokensText } from "../utils/LlamaText.js";
|
|
3
|
+
/**
|
|
4
|
+
* This chat wrapper is not safe against chat syntax injection attacks
|
|
5
|
+
* ([learn more](https://node-llama-cpp.withcat.ai/guide/llama-text#input-safety-in-node-llama-cpp)).
|
|
6
|
+
*/
|
|
7
|
+
export class FalconChatWrapper extends ChatWrapper {
|
|
8
|
+
wrapperName = "Falcon";
|
|
9
|
+
/** @internal */ _userMessageTitle;
|
|
10
|
+
/** @internal */ _modelResponseTitle;
|
|
11
|
+
/** @internal */ _middleSystemMessageTitle;
|
|
12
|
+
/** @internal */ _allowSpecialTokensInTitles;
|
|
13
|
+
constructor({ userMessageTitle = "User", modelResponseTitle = "Assistant", middleSystemMessageTitle = "System", allowSpecialTokensInTitles = false } = {}) {
|
|
14
|
+
super();
|
|
15
|
+
this._userMessageTitle = userMessageTitle;
|
|
16
|
+
this._modelResponseTitle = modelResponseTitle;
|
|
17
|
+
this._middleSystemMessageTitle = middleSystemMessageTitle;
|
|
18
|
+
this._allowSpecialTokensInTitles = allowSpecialTokensInTitles;
|
|
19
|
+
}
|
|
20
|
+
get userMessageTitle() {
|
|
21
|
+
return this._userMessageTitle;
|
|
22
|
+
}
|
|
23
|
+
get modelResponseTitle() {
|
|
24
|
+
return this._modelResponseTitle;
|
|
25
|
+
}
|
|
26
|
+
get middleSystemMessageTitle() {
|
|
27
|
+
return this._middleSystemMessageTitle;
|
|
28
|
+
}
|
|
29
|
+
generateContextState({ chatHistory, availableFunctions, documentFunctionParams }) {
|
|
30
|
+
const historyWithFunctions = this.addAvailableFunctionsSystemMessageToHistory(chatHistory, availableFunctions, {
|
|
31
|
+
documentParams: documentFunctionParams
|
|
32
|
+
});
|
|
33
|
+
const resultItems = [];
|
|
34
|
+
let systemTexts = [];
|
|
35
|
+
let userTexts = [];
|
|
36
|
+
let modelTexts = [];
|
|
37
|
+
let currentAggregateFocus = null;
|
|
38
|
+
function flush() {
|
|
39
|
+
if (systemTexts.length > 0 || userTexts.length > 0 || modelTexts.length > 0)
|
|
40
|
+
resultItems.push({
|
|
41
|
+
system: LlamaText.joinValues("\n\n", systemTexts),
|
|
42
|
+
user: LlamaText.joinValues("\n\n", userTexts),
|
|
43
|
+
model: LlamaText.joinValues("\n\n", modelTexts)
|
|
44
|
+
});
|
|
45
|
+
systemTexts = [];
|
|
46
|
+
userTexts = [];
|
|
47
|
+
modelTexts = [];
|
|
48
|
+
}
|
|
49
|
+
for (const item of historyWithFunctions) {
|
|
50
|
+
if (item.type === "system") {
|
|
51
|
+
if (currentAggregateFocus !== "system")
|
|
52
|
+
flush();
|
|
53
|
+
currentAggregateFocus = "system";
|
|
54
|
+
systemTexts.push(LlamaText.fromJSON(item.text));
|
|
55
|
+
}
|
|
56
|
+
else if (item.type === "user") {
|
|
57
|
+
flush();
|
|
58
|
+
currentAggregateFocus = null;
|
|
59
|
+
userTexts.push(LlamaText(item.text));
|
|
60
|
+
}
|
|
61
|
+
else if (item.type === "model") {
|
|
62
|
+
flush();
|
|
63
|
+
currentAggregateFocus = null;
|
|
64
|
+
modelTexts.push(this.generateModelResponseText(item.response));
|
|
65
|
+
}
|
|
66
|
+
else
|
|
67
|
+
void item;
|
|
68
|
+
}
|
|
69
|
+
flush();
|
|
70
|
+
const contextText = LlamaText(new SpecialToken("BOS"), resultItems.map(({ system, user, model }, index) => {
|
|
71
|
+
const isFirstItem = index === 0;
|
|
72
|
+
const isLastItem = index === resultItems.length - 1;
|
|
73
|
+
return LlamaText([
|
|
74
|
+
(system.values.length === 0)
|
|
75
|
+
? LlamaText([])
|
|
76
|
+
: LlamaText([
|
|
77
|
+
isFirstItem
|
|
78
|
+
? LlamaText([])
|
|
79
|
+
: SpecialTokensText.wrapIf(this._allowSpecialTokensInTitles, `${this._middleSystemMessageTitle}: `),
|
|
80
|
+
system,
|
|
81
|
+
SpecialTokensText.wrapIf(this._allowSpecialTokensInTitles, "\n\n")
|
|
82
|
+
]),
|
|
83
|
+
(user.values.length === 0)
|
|
84
|
+
? LlamaText([])
|
|
85
|
+
: LlamaText([
|
|
86
|
+
SpecialTokensText.wrapIf(this._allowSpecialTokensInTitles, `${this._userMessageTitle}: `),
|
|
87
|
+
user,
|
|
88
|
+
SpecialTokensText.wrapIf(this._allowSpecialTokensInTitles, "\n\n")
|
|
89
|
+
]),
|
|
90
|
+
(model.values.length === 0 && !isLastItem)
|
|
91
|
+
? LlamaText([])
|
|
92
|
+
: LlamaText([
|
|
93
|
+
SpecialTokensText.wrapIf(this._allowSpecialTokensInTitles, `${this._modelResponseTitle}: `),
|
|
94
|
+
model,
|
|
95
|
+
isLastItem
|
|
96
|
+
? LlamaText([])
|
|
97
|
+
: SpecialTokensText.wrapIf(this._allowSpecialTokensInTitles, "\n\n")
|
|
98
|
+
])
|
|
99
|
+
]);
|
|
100
|
+
}));
|
|
101
|
+
return {
|
|
102
|
+
contextText,
|
|
103
|
+
stopGenerationTriggers: [
|
|
104
|
+
LlamaText(new SpecialToken("EOS")),
|
|
105
|
+
LlamaText(`\n${this._userMessageTitle}:`),
|
|
106
|
+
LlamaText(`\n${this._modelResponseTitle}:`),
|
|
107
|
+
LlamaText(`\n${this._middleSystemMessageTitle}:`),
|
|
108
|
+
...(!this._allowSpecialTokensInTitles
|
|
109
|
+
? []
|
|
110
|
+
: [
|
|
111
|
+
LlamaText(new SpecialTokensText(`\n${this._userMessageTitle}:`)),
|
|
112
|
+
LlamaText(new SpecialTokensText(`\n${this._modelResponseTitle}:`)),
|
|
113
|
+
LlamaText(new SpecialTokensText(`\n${this._middleSystemMessageTitle}:`))
|
|
114
|
+
])
|
|
115
|
+
]
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/** @internal */
|
|
119
|
+
static _getOptionConfigurationsToTestIfCanSupersedeJinjaTemplate() {
|
|
120
|
+
return [
|
|
121
|
+
{},
|
|
122
|
+
{ allowSpecialTokensInTitles: true }
|
|
123
|
+
];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=FalconChatWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FalconChatWrapper.js","sourceRoot":"","sources":["../../src/chatW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0,0 +1,17 @@
|
|
|
1
|
+
import { ChatWrapper } from "../ChatWrapper.js";
|
|
2
|
+
import { ChatHistoryItem, ChatModelFunctions, ChatWrapperGenerateContextStateOptions, ChatWrapperGeneratedContextState, ChatWrapperSettings } from "../types.js";
|
|
3
|
+
export declare class FunctionaryChatWrapper extends ChatWrapper {
|
|
4
|
+
readonly wrapperName: string;
|
|
5
|
+
readonly variation: "v3" | "v2" | "v2.llama3";
|
|
6
|
+
readonly settings: ChatWrapperSettings;
|
|
7
|
+
constructor({ variation }?: {
|
|
8
|
+
variation?: "v3" | "v2" | "v2.llama3";
|
|
9
|
+
});
|
|
10
|
+
generateContextState({ chatHistory, availableFunctions, documentFunctionParams }: ChatWrapperGenerateContextStateOptions): ChatWrapperGeneratedContextState;
|
|
11
|
+
generateAvailableFunctionsSystemText(availableFunctions: ChatModelFunctions, { documentParams }: {
|
|
12
|
+
documentParams?: boolean;
|
|
13
|
+
}): import("../utils/LlamaText.js")._LlamaText;
|
|
14
|
+
addAvailableFunctionsSystemMessageToHistory(history: readonly ChatHistoryItem[], availableFunctions?: ChatModelFunctions, { documentParams }?: {
|
|
15
|
+
documentParams?: boolean;
|
|
16
|
+
}): readonly ChatHistoryItem[];
|
|
17
|
+
}
|