@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,67 @@
|
|
|
1
|
+
import { GbnfTerminal } from "../GbnfTerminal.js";
|
|
2
|
+
import { reservedRuleNames } from "./gbnfConsts.js";
|
|
3
|
+
import { GbnfVerbatimText } from "./GbnfVerbatimText.js";
|
|
4
|
+
export class GbnfWhitespace extends GbnfTerminal {
|
|
5
|
+
scopeState;
|
|
6
|
+
newLine;
|
|
7
|
+
constructor(scopeState, { newLine = "before" } = {}) {
|
|
8
|
+
super();
|
|
9
|
+
this.scopeState = scopeState;
|
|
10
|
+
this.newLine = newLine;
|
|
11
|
+
}
|
|
12
|
+
getGrammar() {
|
|
13
|
+
return this._getGrammar();
|
|
14
|
+
}
|
|
15
|
+
getGrammarFromResolve() {
|
|
16
|
+
return this._getGrammar(false);
|
|
17
|
+
}
|
|
18
|
+
_getGrammar(wrap = true) {
|
|
19
|
+
if (this.scopeState.settings.allowNewLines && this.newLine !== false) {
|
|
20
|
+
const values = [
|
|
21
|
+
...(this.newLine === "before"
|
|
22
|
+
? ["[\\n]"]
|
|
23
|
+
: []),
|
|
24
|
+
...(this.scopeState.currentNestingScope === 0
|
|
25
|
+
? []
|
|
26
|
+
: [
|
|
27
|
+
or([
|
|
28
|
+
verbatimTextRepetition(" ", this.scopeState.currentNestingScope * this.scopeState.settings.scopePadSpaces),
|
|
29
|
+
verbatimTextRepetition("\t", this.scopeState.currentNestingScope)
|
|
30
|
+
])
|
|
31
|
+
]),
|
|
32
|
+
...(this.newLine === "after"
|
|
33
|
+
? ["[\\n]"]
|
|
34
|
+
: [])
|
|
35
|
+
];
|
|
36
|
+
return or([
|
|
37
|
+
values.join(" "),
|
|
38
|
+
"[ ]?"
|
|
39
|
+
], wrap);
|
|
40
|
+
}
|
|
41
|
+
return "[ ]?";
|
|
42
|
+
}
|
|
43
|
+
getRuleName() {
|
|
44
|
+
return reservedRuleNames.whitespace({
|
|
45
|
+
newLine: this.scopeState.settings.allowNewLines
|
|
46
|
+
? this.newLine
|
|
47
|
+
: false,
|
|
48
|
+
scopeSpaces: this.scopeState.settings.scopePadSpaces,
|
|
49
|
+
nestingScope: this.scopeState.currentNestingScope
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function or(definitions, wrap = true) {
|
|
54
|
+
if (!wrap)
|
|
55
|
+
return definitions.join(" | ");
|
|
56
|
+
return "(" + definitions.join(" | ") + ")";
|
|
57
|
+
}
|
|
58
|
+
function verbatimTextRepetition(text, count) {
|
|
59
|
+
const textRepetitionGrammar = new GbnfVerbatimText(text.repeat(count)).getGrammar();
|
|
60
|
+
if (count <= 1)
|
|
61
|
+
return textRepetitionGrammar;
|
|
62
|
+
const textRepetitionGrammarWithRepetition = new GbnfVerbatimText(text).getGrammar() + "{" + count + "}";
|
|
63
|
+
if (textRepetitionGrammarWithRepetition.length < textRepetitionGrammar.length)
|
|
64
|
+
return textRepetitionGrammarWithRepetition;
|
|
65
|
+
return textRepetitionGrammar;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=GbnfWhitespace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GbnfWhitespace.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/GbnfWhitespace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAGvD,MAAM,OAAO,cAAe,SAAQ,YAAY;IAC5B,UAAU,CAAqB;IAC/B,OAAO,CAA6B;IAEpD,YAAmB,UAA8B,EAAE,EAC/C,OAAO,GAAG,QAAQ,KAGlB,EAAE;QACF,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAEM,UAAU;QACb,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAC9B,CAAC;IAEkB,qBAAqB;QACpC,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IAEO,WAAW,CAAC,OAAgB,IAAI;QACpC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,aAAa,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;YACnE,MAAM,MAAM,GAAG;gBACX,GAAG,CACC,IAAI,CAAC,OAAO,KAAK,QAAQ;oBACrB,CAAC,CAAC,CAAC,OAAO,CAAC;oBACX,CAAC,CAAC,EAAE,CACX;gBACD,GAAG,CACC,IAAI,CAAC,UAAU,CAAC,mBAAmB,KAAK,CAAC;oBACrC,CAAC,CAAC,EAAE;oBACJ,CAAC,CAAC;wBACE,EAAE,CAAC;4BACC,sBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,mBAAmB,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc,CAAC;4BAC1G,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC;yBACpE,CAAC;qBACL,CACR;gBACD,GAAG,CACC,IAAI,CAAC,OAAO,KAAK,OAAO;oBACpB,CAAC,CAAC,CAAC,OAAO,CAAC;oBACX,CAAC,CAAC,EAAE,CACX;aACJ,CAAC;YAEF,OAAO,EAAE,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;gBAChB,MAAM;aACT,EAAE,IAAI,CAAC,CAAC;QACb,CAAC;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;IAEkB,WAAW;QAC1B,OAAO,iBAAiB,CAAC,UAAU,CAAC;YAChC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,aAAa;gBAC3C,CAAC,CAAC,IAAI,CAAC,OAAO;gBACd,CAAC,CAAC,KAAK;YACX,WAAW,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,cAAc;YACpD,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,mBAAmB;SACpD,CAAC,CAAC;IACP,CAAC;CACJ;AAED,SAAS,EAAE,CAAC,WAAqB,EAAE,OAAgB,IAAI;IACnD,IAAI,CAAC,IAAI;QACL,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAEnC,OAAO,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC;AAC/C,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAY,EAAE,KAAa;IACvD,MAAM,qBAAqB,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;IAEpF,IAAI,KAAK,IAAI,CAAC;QACV,OAAO,qBAAqB,CAAC;IAEjC,MAAM,mCAAmC,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,GAAG,GAAG,GAAG,KAAK,GAAG,GAAG,CAAC;IACxG,IAAI,mCAAmC,CAAC,MAAM,GAAG,qBAAqB,CAAC,MAAM;QACzE,OAAO,mCAAmC,CAAC;IAE/C,OAAO,qBAAqB,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const grammarNoValue = "\"\"";
|
|
2
|
+
export declare const reservedRuleNames: {
|
|
3
|
+
readonly null: "null-rule";
|
|
4
|
+
readonly boolean: "boolean-rule";
|
|
5
|
+
readonly number: {
|
|
6
|
+
readonly fractional: "fractional-number-rule";
|
|
7
|
+
readonly integer: "integer-number-rule";
|
|
8
|
+
};
|
|
9
|
+
readonly stringChar: "string-char-rule";
|
|
10
|
+
readonly string: ({ minLength, maxLength }: {
|
|
11
|
+
minLength: number;
|
|
12
|
+
maxLength?: number;
|
|
13
|
+
}) => string;
|
|
14
|
+
readonly formatString: (format: string) => string;
|
|
15
|
+
readonly whitespace: ({ newLine, nestingScope, scopeSpaces }: {
|
|
16
|
+
newLine?: "before" | "after" | false;
|
|
17
|
+
nestingScope: number;
|
|
18
|
+
scopeSpaces: number;
|
|
19
|
+
}) => string;
|
|
20
|
+
readonly commaWhitespace: ({ newLine, nestingScope, scopeSpaces }: {
|
|
21
|
+
newLine?: "before" | "after" | false;
|
|
22
|
+
nestingScope: number;
|
|
23
|
+
scopeSpaces: number;
|
|
24
|
+
}) => string;
|
|
25
|
+
readonly anyJson: ({ allowNewLines, nestingScope, scopeSpaces }: {
|
|
26
|
+
allowNewLines: boolean;
|
|
27
|
+
nestingScope: number;
|
|
28
|
+
scopeSpaces: number;
|
|
29
|
+
}) => string;
|
|
30
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export const grammarNoValue = '""';
|
|
2
|
+
export const reservedRuleNames = {
|
|
3
|
+
null: "null-rule",
|
|
4
|
+
boolean: "boolean-rule",
|
|
5
|
+
number: {
|
|
6
|
+
fractional: "fractional-number-rule",
|
|
7
|
+
integer: "integer-number-rule"
|
|
8
|
+
},
|
|
9
|
+
stringChar: "string-char-rule",
|
|
10
|
+
string({ minLength, maxLength }) {
|
|
11
|
+
if (minLength === 0 && maxLength == null)
|
|
12
|
+
return "string-rule";
|
|
13
|
+
else if (maxLength == null)
|
|
14
|
+
return [
|
|
15
|
+
"string-",
|
|
16
|
+
minLength,
|
|
17
|
+
"-rule"
|
|
18
|
+
].join("");
|
|
19
|
+
return [
|
|
20
|
+
"string-",
|
|
21
|
+
minLength,
|
|
22
|
+
"-",
|
|
23
|
+
maxLength,
|
|
24
|
+
"-rule"
|
|
25
|
+
].join("");
|
|
26
|
+
},
|
|
27
|
+
formatString(format) {
|
|
28
|
+
return "string-format-" + format + "-rule";
|
|
29
|
+
},
|
|
30
|
+
whitespace({ newLine, nestingScope, scopeSpaces }) {
|
|
31
|
+
if (!newLine)
|
|
32
|
+
return "whitespace-no-new-lines-rule";
|
|
33
|
+
return [
|
|
34
|
+
"whitespace-",
|
|
35
|
+
newLine === "before"
|
|
36
|
+
? "b"
|
|
37
|
+
: newLine === "after"
|
|
38
|
+
? "a"
|
|
39
|
+
: "n",
|
|
40
|
+
"-" + nestingScope,
|
|
41
|
+
"-" + scopeSpaces,
|
|
42
|
+
"-rule"
|
|
43
|
+
].join("");
|
|
44
|
+
},
|
|
45
|
+
commaWhitespace({ newLine, nestingScope, scopeSpaces }) {
|
|
46
|
+
if (!newLine)
|
|
47
|
+
return "comma-whitespace-no-new-lines-rule";
|
|
48
|
+
return [
|
|
49
|
+
"comma-whitespace-",
|
|
50
|
+
newLine === "before"
|
|
51
|
+
? "b"
|
|
52
|
+
: newLine === "after"
|
|
53
|
+
? "a"
|
|
54
|
+
: "n",
|
|
55
|
+
"-" + nestingScope,
|
|
56
|
+
"-" + scopeSpaces,
|
|
57
|
+
"-rule"
|
|
58
|
+
].join("");
|
|
59
|
+
},
|
|
60
|
+
anyJson({ allowNewLines, nestingScope, scopeSpaces }) {
|
|
61
|
+
return [
|
|
62
|
+
"any-json-",
|
|
63
|
+
!allowNewLines
|
|
64
|
+
? "s-"
|
|
65
|
+
: "",
|
|
66
|
+
nestingScope,
|
|
67
|
+
"-" + scopeSpaces,
|
|
68
|
+
"-rule"
|
|
69
|
+
].join("");
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=gbnfConsts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gbnfConsts.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/terminals/gbnfConsts.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC;AACnC,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC7B,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,cAAc;IACvB,MAAM,EAAE;QACJ,UAAU,EAAE,wBAAwB;QACpC,OAAO,EAAE,qBAAqB;KACjC;IACD,UAAU,EAAE,kBAAkB;IAC9B,MAAM,CAAC,EAAC,SAAS,EAAE,SAAS,EAA0C;QAClE,IAAI,SAAS,KAAK,CAAC,IAAI,SAAS,IAAI,IAAI;YACpC,OAAO,aAAa,CAAC;aACpB,IAAI,SAAS,IAAI,IAAI;YACtB,OAAO;gBACH,SAAS;gBACT,SAAS;gBACT,OAAO;aACV,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEf,OAAO;YACH,SAAS;YACT,SAAS;YACT,GAAG;YACH,SAAS;YACT,OAAO;SACV,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,CAAC;IACD,YAAY,CAAC,MAAc;QACvB,OAAO,gBAAgB,GAAG,MAAM,GAAG,OAAO,CAAC;IAC/C,CAAC;IACD,UAAU,CAAC,EAAC,OAAO,EAAE,YAAY,EAAE,WAAW,EAE7C;QACG,IAAI,CAAC,OAAO;YACR,OAAO,8BAA8B,CAAC;QAE1C,OAAO;YACH,aAAa;YACb,OAAO,KAAK,QAAQ;gBAChB,CAAC,CAAC,GAAG;gBACL,CAAC,CAAC,OAAO,KAAK,OAAO;oBACjB,CAAC,CAAC,GAAG;oBACL,CAAC,CAAC,GAAG;YACb,GAAG,GAAG,YAAY;YAClB,GAAG,GAAG,WAAW;YACjB,OAAO;SACV,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,CAAC;IACD,eAAe,CAAC,EAAC,OAAO,EAAE,YAAY,EAAE,WAAW,EAElD;QACG,IAAI,CAAC,OAAO;YACR,OAAO,oCAAoC,CAAC;QAEhD,OAAO;YACH,mBAAmB;YACnB,OAAO,KAAK,QAAQ;gBAChB,CAAC,CAAC,GAAG;gBACL,CAAC,CAAC,OAAO,KAAK,OAAO;oBACjB,CAAC,CAAC,GAAG;oBACL,CAAC,CAAC,GAAG;YACb,GAAG,GAAG,YAAY;YAClB,GAAG,GAAG,WAAW;YACjB,OAAO;SACV,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,CAAC;IACD,OAAO,CAAC,EAAC,aAAa,EAAE,YAAY,EAAE,WAAW,EAEhD;QACG,OAAO;YACH,WAAW;YACX,CAAC,aAAa;gBACV,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,EAAE;YACR,YAAY;YACZ,GAAG,GAAG,WAAW;YACjB,OAAO;SACV,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,CAAC;CACK,CAAC"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
export type GbnfJsonSchemaImmutableType = "string" | "number" | "integer" | "boolean" | "null";
|
|
2
|
+
export type GbnfJsonSchema<Defs extends GbnfJsonDefList<Defs> = Record<any, any>> = GbnfJsonBasicSchema | GbnfJsonConstSchema | GbnfJsonEnumSchema | GbnfJsonOneOfSchema<Defs> | GbnfJsonStringSchema | GbnfJsonObjectSchema<string, Defs> | GbnfJsonArraySchema<Defs> | (keyof Defs extends string ? keyof NoInfer<Defs> extends never ? never : GbnfJsonRefSchema<Defs> : never);
|
|
3
|
+
export type GbnfJsonDefList<Defs extends GbnfJsonDefList<NoInfer<Defs>> = {}> = {
|
|
4
|
+
readonly [key: string]: GbnfJsonSchema<NoInfer<Defs>>;
|
|
5
|
+
};
|
|
6
|
+
export type GbnfJsonBasicSchema = {
|
|
7
|
+
readonly type: GbnfJsonSchemaImmutableType | readonly GbnfJsonSchemaImmutableType[];
|
|
8
|
+
/**
|
|
9
|
+
* A description of what you expect the model to set this value to.
|
|
10
|
+
*
|
|
11
|
+
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
|
12
|
+
*/
|
|
13
|
+
readonly description?: string;
|
|
14
|
+
};
|
|
15
|
+
export type GbnfJsonConstSchema = {
|
|
16
|
+
readonly const: string | number | boolean | null;
|
|
17
|
+
/**
|
|
18
|
+
* A description of what you expect the model to set this value to.
|
|
19
|
+
*
|
|
20
|
+
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
|
21
|
+
*/
|
|
22
|
+
readonly description?: string;
|
|
23
|
+
};
|
|
24
|
+
export type GbnfJsonEnumSchema = {
|
|
25
|
+
readonly enum: readonly (string | number | boolean | null)[];
|
|
26
|
+
/**
|
|
27
|
+
* A description of what you expect the model to set this value to.
|
|
28
|
+
*
|
|
29
|
+
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
|
30
|
+
*/
|
|
31
|
+
readonly description?: string;
|
|
32
|
+
};
|
|
33
|
+
export type GbnfJsonOneOfSchema<Defs extends GbnfJsonDefList<NoInfer<Defs>> = {}> = {
|
|
34
|
+
readonly oneOf: readonly GbnfJsonSchema<NoInfer<Defs>>[];
|
|
35
|
+
/**
|
|
36
|
+
* A description of what you expect the model to set this value to.
|
|
37
|
+
*
|
|
38
|
+
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
|
39
|
+
*/
|
|
40
|
+
readonly description?: string;
|
|
41
|
+
readonly $defs?: Defs;
|
|
42
|
+
};
|
|
43
|
+
export type GbnfJsonStringSchema = GbnfJsonBasicStringSchema | GbnfJsonFormatStringSchema;
|
|
44
|
+
export type GbnfJsonBasicStringSchema = {
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
/**
|
|
47
|
+
* When using `minLength` and/or `maxLength`,
|
|
48
|
+
* ensure to inform the model as part of the prompt what your expectations are regarding the length of the string.
|
|
49
|
+
* Not doing this may lead to hallucinations.
|
|
50
|
+
*/
|
|
51
|
+
readonly minLength?: number;
|
|
52
|
+
/**
|
|
53
|
+
* When using `minLength` and/or `maxLength`,
|
|
54
|
+
* ensure to inform the model as part of the prompt what your expectations are regarding the length of the string.
|
|
55
|
+
* Not doing this may lead to hallucinations.
|
|
56
|
+
*/
|
|
57
|
+
readonly maxLength?: number;
|
|
58
|
+
/**
|
|
59
|
+
* A description of what you expect the model to set this value to.
|
|
60
|
+
*
|
|
61
|
+
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
|
62
|
+
*/
|
|
63
|
+
readonly description?: string;
|
|
64
|
+
};
|
|
65
|
+
export type GbnfJsonFormatStringSchema = {
|
|
66
|
+
readonly type: "string";
|
|
67
|
+
readonly format: "date-time" | "time" | "date";
|
|
68
|
+
/**
|
|
69
|
+
* A description of what you expect the model to set this value to.
|
|
70
|
+
*
|
|
71
|
+
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
|
72
|
+
*/
|
|
73
|
+
readonly description?: string;
|
|
74
|
+
};
|
|
75
|
+
export type GbnfJsonObjectSchema<Keys extends string = string, Defs extends GbnfJsonDefList<NoInfer<Defs>> = {}> = {
|
|
76
|
+
readonly type: "object";
|
|
77
|
+
readonly properties?: {
|
|
78
|
+
readonly [key in Keys]: GbnfJsonSchema<NoInfer<Defs>>;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Unlike the JSON Schema spec, `additionalProperties` defaults to `false` to avoid breaking existing code.
|
|
82
|
+
*/
|
|
83
|
+
readonly additionalProperties?: boolean | GbnfJsonSchema<NoInfer<Defs>>;
|
|
84
|
+
/**
|
|
85
|
+
* Make sure you define `additionalProperties` for this to have any effect.
|
|
86
|
+
*
|
|
87
|
+
* When using `minProperties` and/or `maxProperties`,
|
|
88
|
+
* ensure to inform the model as part of the prompt what your expectations are regarding the number of keys in the object.
|
|
89
|
+
* Not doing this may lead to hallucinations.
|
|
90
|
+
*/
|
|
91
|
+
readonly minProperties?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Make sure you define `additionalProperties` for this to have any effect.
|
|
94
|
+
*
|
|
95
|
+
* When using `minProperties` and/or `maxProperties`,
|
|
96
|
+
* ensure to inform the model as part of the prompt what your expectations are regarding the number of keys in the object.
|
|
97
|
+
* Not doing this may lead to hallucinations.
|
|
98
|
+
*/
|
|
99
|
+
readonly maxProperties?: number;
|
|
100
|
+
/**
|
|
101
|
+
* `required` is always set to all keys in `properties`, and setting it has no effect.
|
|
102
|
+
*
|
|
103
|
+
* This limitation is due to how the generation works, and may be fixed in the future.
|
|
104
|
+
*
|
|
105
|
+
* This key is part of the type to avoid breaking exiting code (though it was never actually used in the past),
|
|
106
|
+
* and will be removed in the future.
|
|
107
|
+
* @deprecated
|
|
108
|
+
*/
|
|
109
|
+
readonly required?: readonly Keys[];
|
|
110
|
+
/**
|
|
111
|
+
* A description of what you expect the model to set this value to.
|
|
112
|
+
*
|
|
113
|
+
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
|
114
|
+
*/
|
|
115
|
+
readonly description?: string;
|
|
116
|
+
readonly $defs?: Defs;
|
|
117
|
+
};
|
|
118
|
+
export type GbnfJsonArraySchema<Defs extends GbnfJsonDefList<NoInfer<Defs>> = {}> = {
|
|
119
|
+
readonly type: "array";
|
|
120
|
+
readonly items?: GbnfJsonSchema<NoInfer<Defs>>;
|
|
121
|
+
readonly prefixItems?: readonly GbnfJsonSchema<NoInfer<Defs>>[];
|
|
122
|
+
/**
|
|
123
|
+
* When using `minItems` and/or `maxItems`,
|
|
124
|
+
* ensure to inform the model as part of the prompt what your expectations are regarding the length of the array.
|
|
125
|
+
* Not doing this may lead to hallucinations.
|
|
126
|
+
*/
|
|
127
|
+
readonly minItems?: number;
|
|
128
|
+
/**
|
|
129
|
+
* When using `minItems` and/or `maxItems`,
|
|
130
|
+
* ensure to inform the model as part of the prompt what your expectations are regarding the length of the array.
|
|
131
|
+
* Not doing this may lead to hallucinations.
|
|
132
|
+
*/
|
|
133
|
+
readonly maxItems?: number;
|
|
134
|
+
/**
|
|
135
|
+
* A description of what you expect the model to set this value to.
|
|
136
|
+
*
|
|
137
|
+
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
|
138
|
+
*/
|
|
139
|
+
readonly description?: string;
|
|
140
|
+
readonly $defs?: Defs;
|
|
141
|
+
};
|
|
142
|
+
export type GbnfJsonRefSchema<Defs extends GbnfJsonDefList<NoInfer<Defs>> = {}> = {
|
|
143
|
+
readonly $ref: keyof NoInfer<Defs> extends never ? never : `#/$defs/${OnlyStringKeys<NoInfer<Defs>>}`;
|
|
144
|
+
/**
|
|
145
|
+
* A description of what you expect the model to set this value to.
|
|
146
|
+
*
|
|
147
|
+
* Only passed to the model when using function calling, and has no effect when using JSON Schema grammar directly.
|
|
148
|
+
*/
|
|
149
|
+
readonly description?: string;
|
|
150
|
+
readonly $defs?: Defs;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Converts a GBNF JSON schema to a TypeScript type
|
|
154
|
+
*/
|
|
155
|
+
export type GbnfJsonSchemaToType<T> = 0 extends 1 & T ? any : GbnfJsonSchemaToTSType<T>;
|
|
156
|
+
export type GbnfJsonSchemaToTSType<T, Defs extends GbnfJsonDefList<NoInfer<Defs>> = {}> = Readonly<GbnfJsonBasicSchema> extends T ? undefined : undefined extends T ? undefined : T extends GbnfJsonBasicStringSchema ? GbnfJsonBasicStringSchemaToType<T> : T extends GbnfJsonFormatStringSchema ? string : T extends GbnfJsonBasicSchema ? GbnfJsonBasicSchemaToType<T["type"]> : T extends GbnfJsonConstSchema ? T["const"] : T extends GbnfJsonEnumSchema ? T["enum"][number] : T extends GbnfJsonOneOfSchema<Record<any, any>> ? GbnfJsonSchemaToTSType<T["oneOf"][number], CombineDefs<NoInfer<Defs>, T["$defs"]>> : T extends GbnfJsonObjectSchema<string, Record<any, any>> ? GbnfJsonObjectSchemaToType<T, NoInfer<Defs>> : T extends GbnfJsonArraySchema<Record<any, any>> ? ArrayTypeToType<T, CombineDefs<NoInfer<Defs>, T["$defs"]>> : T extends GbnfJsonRefSchema<any> ? GbnfJsonRefSchemaToType<T, CombineDefs<NoInfer<Defs>, T["$defs"]>> : undefined;
|
|
157
|
+
type GbnfJsonBasicStringSchemaToType<T extends GbnfJsonBasicStringSchema> = T["maxLength"] extends 0 ? "" : string;
|
|
158
|
+
type GbnfJsonBasicSchemaToType<T extends GbnfJsonBasicSchema["type"]> = T extends GbnfJsonSchemaImmutableType ? ImmutableTypeToType<T> : T[number] extends GbnfJsonSchemaImmutableType ? ImmutableTypeToType<T[number]> : never;
|
|
159
|
+
type ImmutableTypeToType<T extends GbnfJsonSchemaImmutableType> = T extends "string" ? string : T extends "number" ? number : T extends "integer" ? number : T extends "boolean" ? boolean : T extends "null" ? null : never;
|
|
160
|
+
type ArrayTypeToType<T extends GbnfJsonArraySchema<Record<any, any>>, Defs extends GbnfJsonDefList<Defs> = {}, MinItems extends number = T["minItems"] extends number ? T["prefixItems"] extends readonly GbnfJsonSchema[] ? keyof T["prefixItems"] extends T["minItems"] ? T["prefixItems"]["length"] : T["minItems"] : T["minItems"] : T["prefixItems"] extends readonly GbnfJsonSchema[] ? T["prefixItems"]["length"] : 0> = T["prefixItems"] extends readonly GbnfJsonSchema[] ? (MinItems extends T["prefixItems"]["length"] ? (T["maxItems"] extends MinItems ? [
|
|
161
|
+
...GbnfJsonOrderedArrayTypes<T["prefixItems"], CombineDefs<Defs, T["$defs"]>>,
|
|
162
|
+
...IndexRangeWithSkip<MinItems, T["prefixItems"]["length"], T["items"] extends GbnfJsonSchema ? GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>> : GbnfJsonAnyValue>
|
|
163
|
+
] : [
|
|
164
|
+
...GbnfJsonOrderedArrayTypes<T["prefixItems"], CombineDefs<Defs, T["$defs"]>>,
|
|
165
|
+
...(T["items"] extends GbnfJsonSchema ? GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>> : GbnfJsonAnyValue)[]
|
|
166
|
+
]) : T["maxItems"] extends MinItems ? [
|
|
167
|
+
...GbnfJsonOrderedArrayTypes<T["prefixItems"], CombineDefs<Defs, T["$defs"]>>,
|
|
168
|
+
...(T["items"] extends GbnfJsonSchema ? IndexRangeWithSkip<T["maxItems"], T["prefixItems"]["length"], GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>>> : IndexRangeWithSkip<T["maxItems"], T["prefixItems"]["length"], GbnfJsonAnyValue>)
|
|
169
|
+
] : [
|
|
170
|
+
...GbnfJsonOrderedArrayTypes<T["prefixItems"], CombineDefs<Defs, T["$defs"]>>,
|
|
171
|
+
...IndexRangeWithSkip<MinItems, T["prefixItems"]["length"], T["items"] extends GbnfJsonSchema ? GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>> : GbnfJsonAnyValue>,
|
|
172
|
+
...(T["items"] extends GbnfJsonSchema ? GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>> : GbnfJsonAnyValue)[]
|
|
173
|
+
]) : T["items"] extends GbnfJsonSchema ? (MinItems extends 0 ? GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>>[] : T["maxItems"] extends MinItems ? IndexRange<T["maxItems"], GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>>> : [
|
|
174
|
+
...IndexRange<MinItems, GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>>>,
|
|
175
|
+
...GbnfJsonSchemaToTSType<T["items"], CombineDefs<Defs, T["$defs"]>>[]
|
|
176
|
+
]) : (MinItems extends 0 ? GbnfJsonAnyValue[] : T["maxItems"] extends MinItems ? IndexRange<T["maxItems"], GbnfJsonAnyValue> : [
|
|
177
|
+
...IndexRange<MinItems, GbnfJsonAnyValue>,
|
|
178
|
+
...GbnfJsonAnyValue[]
|
|
179
|
+
]);
|
|
180
|
+
type GbnfJsonObjectSchemaToType<T extends GbnfJsonObjectSchema<string, Record<any, any>>, Defs extends GbnfJsonDefList<Defs> = {}, Props extends Readonly<Record<string, GbnfJsonSchema>> | undefined = T["properties"], AdditionalProps extends true | false | GbnfJsonSchema | undefined = T["additionalProperties"], PropsMap = Props extends undefined ? {} : {
|
|
181
|
+
-readonly [P in keyof Props]: GbnfJsonSchemaToTSType<Props[P], CombineDefs<Defs, T["$defs"]>>;
|
|
182
|
+
}, Res = AdditionalProps extends undefined | false ? PropsMap : AdditionalProps extends true ? PropsMap & {
|
|
183
|
+
[key: string]: GbnfJsonAnyValue;
|
|
184
|
+
} : AdditionalProps extends GbnfJsonSchema ? PropsMap & {
|
|
185
|
+
[key: string]: GbnfJsonSchemaToTSType<AdditionalProps, CombineDefs<Defs, T["$defs"]>>;
|
|
186
|
+
} : PropsMap> = Res;
|
|
187
|
+
type GbnfJsonRefSchemaToType<T extends GbnfJsonRefSchema<Defs>, Defs extends GbnfJsonDefList<Defs> = {}> = T["$ref"] extends `#/$defs/${infer Key}` ? Key extends keyof Defs ? GbnfJsonSchemaToTSType<Defs[Key], Defs> : never : never;
|
|
188
|
+
type GbnfJsonAnyValue = string | number | boolean | null | GbnfJsonAnyValue[] | {
|
|
189
|
+
[key: string]: GbnfJsonAnyValue;
|
|
190
|
+
};
|
|
191
|
+
export declare function isGbnfJsonConstSchema(schema: GbnfJsonSchema): schema is GbnfJsonConstSchema;
|
|
192
|
+
export declare function isGbnfJsonEnumSchema(schema: GbnfJsonSchema): schema is GbnfJsonEnumSchema;
|
|
193
|
+
export declare function isGbnfJsonOneOfSchema(schema: GbnfJsonSchema): schema is GbnfJsonOneOfSchema;
|
|
194
|
+
export declare function isGbnfJsonBasicStringSchema(schema: GbnfJsonSchema): schema is GbnfJsonBasicStringSchema;
|
|
195
|
+
export declare function isGbnfJsonFormatStringSchema(schema: GbnfJsonSchema): schema is GbnfJsonFormatStringSchema;
|
|
196
|
+
export declare function isGbnfJsonObjectSchema(schema: GbnfJsonSchema): schema is GbnfJsonObjectSchema;
|
|
197
|
+
export declare function isGbnfJsonArraySchema(schema: GbnfJsonSchema): schema is GbnfJsonArraySchema;
|
|
198
|
+
export declare function isGbnfJsonRefSchema(schema: GbnfJsonSchema): schema is GbnfJsonRefSchema<Record<any, any>>;
|
|
199
|
+
export declare function isGbnfJsonBasicSchemaIncludesType<T extends GbnfJsonSchemaImmutableType>(schema: GbnfJsonBasicSchema, type: T): schema is GbnfJsonBasicSchema & {
|
|
200
|
+
type: T | (T | GbnfJsonSchemaImmutableType)[];
|
|
201
|
+
};
|
|
202
|
+
type OnlyStringKeys<T extends object> = {
|
|
203
|
+
[K in keyof T]: K extends string ? K : never;
|
|
204
|
+
}[keyof T];
|
|
205
|
+
type CombineDefs<Defs1 extends GbnfJsonDefList<Defs1>, Param2 extends Defs1 | Defs2 | undefined, Defs2 extends GbnfJsonDefList<Defs2> = {}> = undefined extends NoInfer<Param2> ? Defs1 : Defs1 & Param2;
|
|
206
|
+
type IndexRange<Length extends number, FillType = number, Res = _IndexRange<[], Length, FillType>> = Res;
|
|
207
|
+
type _IndexRange<Value extends FillType[], MaxLength extends number, FillType = number> = Value["length"] extends MaxLength ? Value : _IndexRange<[...Value, FillType], MaxLength, FillType>;
|
|
208
|
+
type IndexRangeWithSkip<Length extends number, SkipFirst extends number, FillType, Res = _IndexRangeWithSkip<[], IndexRange<SkipFirst>, Length, FillType>> = Res;
|
|
209
|
+
type _IndexRangeWithSkip<Value extends FillType[], ConditionValue extends number[], MaxLength extends number, FillType> = ConditionValue["length"] extends MaxLength ? Value : _IndexRangeWithSkip<[...Value, FillType], [...ConditionValue, ConditionValue["length"]], MaxLength, FillType>;
|
|
210
|
+
type GbnfJsonOrderedArrayTypes<T extends readonly GbnfJsonSchema[], Defs extends GbnfJsonDefList<Defs> = {}> = {
|
|
211
|
+
-readonly [P in keyof T]: GbnfJsonSchemaToTSType<T[P], Defs>;
|
|
212
|
+
};
|
|
213
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function isGbnfJsonConstSchema(schema) {
|
|
2
|
+
return schema.const !== undefined;
|
|
3
|
+
}
|
|
4
|
+
export function isGbnfJsonEnumSchema(schema) {
|
|
5
|
+
return schema.enum != null;
|
|
6
|
+
}
|
|
7
|
+
export function isGbnfJsonOneOfSchema(schema) {
|
|
8
|
+
return schema.oneOf != null;
|
|
9
|
+
}
|
|
10
|
+
export function isGbnfJsonBasicStringSchema(schema) {
|
|
11
|
+
return schema.type === "string" && schema.format == null;
|
|
12
|
+
}
|
|
13
|
+
export function isGbnfJsonFormatStringSchema(schema) {
|
|
14
|
+
return schema.type === "string" && schema.format != null;
|
|
15
|
+
}
|
|
16
|
+
export function isGbnfJsonObjectSchema(schema) {
|
|
17
|
+
return schema.type === "object";
|
|
18
|
+
}
|
|
19
|
+
export function isGbnfJsonArraySchema(schema) {
|
|
20
|
+
return schema.type === "array";
|
|
21
|
+
}
|
|
22
|
+
export function isGbnfJsonRefSchema(schema) {
|
|
23
|
+
return typeof schema.$ref === "string";
|
|
24
|
+
}
|
|
25
|
+
export function isGbnfJsonBasicSchemaIncludesType(schema, type) {
|
|
26
|
+
if (schema.type instanceof Array)
|
|
27
|
+
return schema.type.includes(type);
|
|
28
|
+
return schema.type === type;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/gbnfJson/types.ts"],"names":[],"mappings":"AAgXA,MAAM,UAAU,qBAAqB,CAAC,MAAsB;IACxD,OAAQ,MAA8B,CAAC,KAAK,KAAK,SAAS,CAAC;AAC/D,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAAsB;IACvD,OAAQ,MAA6B,CAAC,IAAI,IAAI,IAAI,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAsB;IACxD,OAAQ,MAA8B,CAAC,KAAK,IAAI,IAAI,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,MAAsB;IAC9D,OAAQ,MAAoC,CAAC,IAAI,KAAK,QAAQ,IAAK,MAAqC,CAAC,MAAM,IAAI,IAAI,CAAC;AAC5H,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,MAAsB;IAC/D,OAAQ,MAAqC,CAAC,IAAI,KAAK,QAAQ,IAAK,MAAqC,CAAC,MAAM,IAAI,IAAI,CAAC;AAC7H,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAsB;IACzD,OAAQ,MAA+B,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAsB;IACxD,OAAQ,MAA8B,CAAC,IAAI,KAAK,OAAO,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAsB;IACtD,OAAO,OAAQ,MAA4B,CAAC,IAAI,KAAK,QAAQ,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,iCAAiC,CAC7C,MAA2B,EAAE,IAAO;IAEpC,IAAI,MAAM,CAAC,IAAI,YAAY,KAAK;QAC5B,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEtC,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type GbnfJsonScopeSettings = {
|
|
2
|
+
readonly allowNewLines: boolean;
|
|
3
|
+
readonly scopePadSpaces: number;
|
|
4
|
+
};
|
|
5
|
+
export declare class GbnfJsonScopeState {
|
|
6
|
+
readonly settings: GbnfJsonScopeSettings;
|
|
7
|
+
readonly currentNestingScope: number;
|
|
8
|
+
constructor(settings?: GbnfJsonScopeSettings, currentNestingScope?: number);
|
|
9
|
+
getForNewScope(): GbnfJsonScopeState;
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class GbnfJsonScopeState {
|
|
2
|
+
settings;
|
|
3
|
+
currentNestingScope;
|
|
4
|
+
constructor(settings = {
|
|
5
|
+
allowNewLines: true,
|
|
6
|
+
scopePadSpaces: 4
|
|
7
|
+
}, currentNestingScope = 0) {
|
|
8
|
+
this.settings = settings;
|
|
9
|
+
this.currentNestingScope = currentNestingScope;
|
|
10
|
+
}
|
|
11
|
+
getForNewScope() {
|
|
12
|
+
return new GbnfJsonScopeState(this.settings, this.currentNestingScope + 1);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=GbnfJsonScopeState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GbnfJsonScopeState.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/utils/GbnfJsonScopeState.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,kBAAkB;IACX,QAAQ,CAAwB;IAChC,mBAAmB,CAAS;IAE5C,YAAmB,WAAkC;QACjD,aAAa,EAAE,IAAI;QACnB,cAAc,EAAE,CAAC;KACpB,EAAE,sBAA8B,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACnD,CAAC;IAEM,cAAc;QACjB,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC;IAC/E,CAAC;CACJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MultiKeyMap } from "lifecycle-utils";
|
|
2
|
+
import { GbnfJsonSchema } from "../types.js";
|
|
3
|
+
export declare class DefScopeDefs {
|
|
4
|
+
defScopeDefs: MultiKeyMap<[string, GbnfJsonSchema], Record<string, GbnfJsonSchema>>;
|
|
5
|
+
registerDefs(scopeDefs: Record<string, GbnfJsonSchema>): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function joinDefs(parent: Record<string, GbnfJsonSchema>, current?: Record<string, GbnfJsonSchema>): Record<string, GbnfJsonSchema>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MultiKeyMap } from "lifecycle-utils";
|
|
2
|
+
export class DefScopeDefs {
|
|
3
|
+
defScopeDefs = new MultiKeyMap();
|
|
4
|
+
registerDefs(scopeDefs) {
|
|
5
|
+
for (const [defName, def] of Object.entries(scopeDefs))
|
|
6
|
+
this.defScopeDefs.set([defName, def], scopeDefs);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export function joinDefs(parent, current) {
|
|
10
|
+
if (current == null || Object.keys(current).length === 0)
|
|
11
|
+
return parent;
|
|
12
|
+
return {
|
|
13
|
+
...parent,
|
|
14
|
+
...current
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=defsScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defsScope.js","sourceRoot":"","sources":["../../../../src/utils/gbnfJson/utils/defsScope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAG5C,MAAM,OAAO,YAAY;IACd,YAAY,GAA0E,IAAI,WAAW,EAAE,CAAC;IAExG,YAAY,CAAC,SAAyC;QACzD,KAAK,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;YAClD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,SAAS,CAAC,CAAC;IACzD,CAAC;CACJ;AAED,MAAM,UAAU,QAAQ,CACpB,MAAsC,EACtC,OAAwC;IAExC,IAAI,OAAO,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC;QACpD,OAAO,MAAM,CAAC;IAElB,OAAO;QACH,GAAG,MAAM;QACT,GAAG,OAAO;KACb,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GbnfTerminal } from "../GbnfTerminal.js";
|
|
2
|
+
import { GbnfGrammarGenerator } from "../GbnfGrammarGenerator.js";
|
|
3
|
+
import { GbnfJsonSchema } from "../types.js";
|
|
4
|
+
import { GbnfJsonScopeState } from "./GbnfJsonScopeState.js";
|
|
5
|
+
export declare function getGbnfJsonTerminalForGbnfJsonSchema(schema: GbnfJsonSchema, grammarGenerator: GbnfGrammarGenerator, scopeState?: GbnfJsonScopeState, defs?: Record<string, GbnfJsonSchema>): GbnfTerminal;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { GbnfOr } from "../terminals/GbnfOr.js";
|
|
2
|
+
import { GbnfObjectMap } from "../terminals/GbnfObjectMap.js";
|
|
3
|
+
import { GbnfStringValue } from "../terminals/GbnfStringValue.js";
|
|
4
|
+
import { GbnfArray } from "../terminals/GbnfArray.js";
|
|
5
|
+
import { GbnfString } from "../terminals/GbnfString.js";
|
|
6
|
+
import { GbnfNumber } from "../terminals/GbnfNumber.js";
|
|
7
|
+
import { GbnfBoolean } from "../terminals/GbnfBoolean.js";
|
|
8
|
+
import { GbnfNull } from "../terminals/GbnfNull.js";
|
|
9
|
+
import { isGbnfJsonArraySchema, isGbnfJsonBasicSchemaIncludesType, isGbnfJsonConstSchema, isGbnfJsonEnumSchema, isGbnfJsonObjectSchema, isGbnfJsonOneOfSchema, isGbnfJsonBasicStringSchema, isGbnfJsonFormatStringSchema, isGbnfJsonRefSchema } from "../types.js";
|
|
10
|
+
import { getConsoleLogPrefix } from "../../getConsoleLogPrefix.js";
|
|
11
|
+
import { GbnfAnyJson } from "../terminals/GbnfAnyJson.js";
|
|
12
|
+
import { GbnfFormatString } from "../terminals/GbnfFormatString.js";
|
|
13
|
+
import { GbnfRef } from "../terminals/GbnfRef.js";
|
|
14
|
+
import { getGbnfJsonTerminalForLiteral } from "./getGbnfJsonTerminalForLiteral.js";
|
|
15
|
+
import { GbnfJsonScopeState } from "./GbnfJsonScopeState.js";
|
|
16
|
+
import { joinDefs } from "./defsScope.js";
|
|
17
|
+
const maxNestingScope = 512;
|
|
18
|
+
export function getGbnfJsonTerminalForGbnfJsonSchema(schema, grammarGenerator, scopeState = new GbnfJsonScopeState(), defs = {}) {
|
|
19
|
+
if (scopeState.currentNestingScope >= maxNestingScope)
|
|
20
|
+
throw new Error("Maximum nesting scope exceeded. Ensure that your schema does not have circular references or excessive nesting.");
|
|
21
|
+
if (isGbnfJsonRefSchema(schema)) {
|
|
22
|
+
const currentDefs = joinDefs(defs, schema.$defs);
|
|
23
|
+
grammarGenerator.registerDefs(currentDefs);
|
|
24
|
+
const ref = schema?.$ref;
|
|
25
|
+
const referencePrefix = "#/$defs/";
|
|
26
|
+
if (ref == null || !ref.startsWith(referencePrefix)) {
|
|
27
|
+
console.warn(getConsoleLogPrefix(true, false), `Reference "${ref}" does not start with "${referencePrefix}". ` +
|
|
28
|
+
'Using an "any" type instead of a reference.');
|
|
29
|
+
return new GbnfAnyJson(scopeState);
|
|
30
|
+
}
|
|
31
|
+
const defName = ref.slice(referencePrefix.length);
|
|
32
|
+
const def = currentDefs[defName];
|
|
33
|
+
if (def == null) {
|
|
34
|
+
console.warn(getConsoleLogPrefix(true, false), `Reference "${ref}" does not point to an existing definition. ` +
|
|
35
|
+
'Using an "any" type instead of a reference.');
|
|
36
|
+
return new GbnfAnyJson(scopeState);
|
|
37
|
+
}
|
|
38
|
+
return new GbnfRef({
|
|
39
|
+
getValueTerminal() {
|
|
40
|
+
const scopeDefs = grammarGenerator.defScopeDefs.get([defName, def]);
|
|
41
|
+
return getGbnfJsonTerminalForGbnfJsonSchema(def, grammarGenerator, new GbnfJsonScopeState({
|
|
42
|
+
allowNewLines: false,
|
|
43
|
+
scopePadSpaces: scopeState.settings.scopePadSpaces
|
|
44
|
+
}, 0), scopeDefs ?? {});
|
|
45
|
+
},
|
|
46
|
+
def,
|
|
47
|
+
defName
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else if (isGbnfJsonOneOfSchema(schema)) {
|
|
51
|
+
const currentDefs = joinDefs(defs, schema.$defs);
|
|
52
|
+
grammarGenerator.registerDefs(currentDefs);
|
|
53
|
+
const values = schema.oneOf
|
|
54
|
+
.map((altSchema) => (getGbnfJsonTerminalForGbnfJsonSchema(altSchema, grammarGenerator, scopeState, currentDefs)));
|
|
55
|
+
return new GbnfOr(values);
|
|
56
|
+
}
|
|
57
|
+
else if (isGbnfJsonConstSchema(schema)) {
|
|
58
|
+
return getGbnfJsonTerminalForLiteral(schema.const);
|
|
59
|
+
}
|
|
60
|
+
else if (isGbnfJsonEnumSchema(schema)) {
|
|
61
|
+
return new GbnfOr(schema.enum.map((item) => getGbnfJsonTerminalForLiteral(item)));
|
|
62
|
+
}
|
|
63
|
+
else if (isGbnfJsonObjectSchema(schema)) {
|
|
64
|
+
const propertiesEntries = Object.entries(schema.properties ?? {});
|
|
65
|
+
const currentDefs = joinDefs(defs, schema.$defs);
|
|
66
|
+
grammarGenerator.registerDefs(currentDefs);
|
|
67
|
+
let maxProperties = schema.maxProperties;
|
|
68
|
+
if (schema.properties != null && maxProperties != null && maxProperties < propertiesEntries.length) {
|
|
69
|
+
console.warn(getConsoleLogPrefix(true, false), `maxProperties (${maxProperties}) must be greater than or equal to ` +
|
|
70
|
+
`properties object keys number (${propertiesEntries.length}). ` +
|
|
71
|
+
"Using properties object keys number as maxProperties.");
|
|
72
|
+
maxProperties = propertiesEntries.length;
|
|
73
|
+
}
|
|
74
|
+
return new GbnfObjectMap({
|
|
75
|
+
fields: propertiesEntries.map(([propName, propSchema]) => {
|
|
76
|
+
return {
|
|
77
|
+
required: true,
|
|
78
|
+
key: new GbnfStringValue(propName),
|
|
79
|
+
value: getGbnfJsonTerminalForGbnfJsonSchema(propSchema, grammarGenerator, scopeState.getForNewScope(), currentDefs)
|
|
80
|
+
};
|
|
81
|
+
}),
|
|
82
|
+
additionalProperties: (schema.additionalProperties == null || schema.additionalProperties === false)
|
|
83
|
+
? undefined
|
|
84
|
+
: schema.additionalProperties === true
|
|
85
|
+
? new GbnfAnyJson(scopeState.getForNewScope())
|
|
86
|
+
: getGbnfJsonTerminalForGbnfJsonSchema(schema.additionalProperties, grammarGenerator, scopeState.getForNewScope(), currentDefs),
|
|
87
|
+
minProperties: schema.minProperties,
|
|
88
|
+
maxProperties,
|
|
89
|
+
scopeState
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
else if (isGbnfJsonArraySchema(schema)) {
|
|
93
|
+
const currentDefs = joinDefs(defs, schema.$defs);
|
|
94
|
+
grammarGenerator.registerDefs(currentDefs);
|
|
95
|
+
let maxItems = schema.maxItems;
|
|
96
|
+
if (schema.prefixItems != null && maxItems != null && maxItems < schema.prefixItems.length) {
|
|
97
|
+
console.warn(getConsoleLogPrefix(true, false), `maxItems (${maxItems}) must be greater than or equal to prefixItems array length (${schema.prefixItems.length}). ` +
|
|
98
|
+
"Using prefixItems length as maxItems.");
|
|
99
|
+
maxItems = schema.prefixItems.length;
|
|
100
|
+
}
|
|
101
|
+
return new GbnfArray({
|
|
102
|
+
items: schema.items == null
|
|
103
|
+
? undefined
|
|
104
|
+
: getGbnfJsonTerminalForGbnfJsonSchema(schema.items, grammarGenerator, scopeState.getForNewScope(), currentDefs),
|
|
105
|
+
prefixItems: schema.prefixItems == null
|
|
106
|
+
? undefined
|
|
107
|
+
: schema.prefixItems.map((item) => (getGbnfJsonTerminalForGbnfJsonSchema(item, grammarGenerator, scopeState.getForNewScope(), currentDefs))),
|
|
108
|
+
minItems: schema.minItems,
|
|
109
|
+
maxItems,
|
|
110
|
+
scopeState
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
else if (isGbnfJsonBasicStringSchema(schema)) {
|
|
114
|
+
const minLength = Math.max(0, schema.minLength ?? 0);
|
|
115
|
+
let maxLength = schema.maxLength;
|
|
116
|
+
if (maxLength != null && maxLength < minLength) {
|
|
117
|
+
console.warn(getConsoleLogPrefix(true, false), `maxLength (${maxLength}) must be greater than or equal to minLength (${minLength}). ` +
|
|
118
|
+
"Using minLength as maxLength.");
|
|
119
|
+
maxLength = minLength;
|
|
120
|
+
}
|
|
121
|
+
return new GbnfString({
|
|
122
|
+
minLength,
|
|
123
|
+
maxLength
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
else if (isGbnfJsonFormatStringSchema(schema))
|
|
127
|
+
return new GbnfFormatString(schema.format);
|
|
128
|
+
const terminals = [];
|
|
129
|
+
if (isGbnfJsonBasicSchemaIncludesType(schema, "string"))
|
|
130
|
+
terminals.push(new GbnfString());
|
|
131
|
+
if (isGbnfJsonBasicSchemaIncludesType(schema, "number"))
|
|
132
|
+
terminals.push(new GbnfNumber({ allowFractional: true }));
|
|
133
|
+
if (isGbnfJsonBasicSchemaIncludesType(schema, "integer"))
|
|
134
|
+
terminals.push(new GbnfNumber({ allowFractional: false }));
|
|
135
|
+
if (isGbnfJsonBasicSchemaIncludesType(schema, "boolean"))
|
|
136
|
+
terminals.push(new GbnfBoolean());
|
|
137
|
+
if (isGbnfJsonBasicSchemaIncludesType(schema, "null"))
|
|
138
|
+
terminals.push(new GbnfNull());
|
|
139
|
+
if (terminals.length === 0)
|
|
140
|
+
terminals.push(new GbnfNull());
|
|
141
|
+
return new GbnfOr(terminals);
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=getGbnfJsonTerminalForGbnfJsonSchema.js.map
|