@promptbook/core 0.52.0-9 → 0.53.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/README.md +1 -13
- package/esm/index.es.js +1094 -817
- package/esm/index.es.js.map +1 -1
- package/esm/typings/_packages/core.index.d.ts +4 -2
- package/esm/typings/_packages/utils.index.d.ts +2 -0
- package/esm/typings/conversion/prettify/prettifyPromptbookString.d.ts +1 -1
- package/esm/typings/conversion/prettify/renderPromptbookMermaid.d.ts +2 -1
- package/esm/typings/conversion/utils/extractParametersFromPromptTemplate.d.ts +3 -3
- package/esm/typings/conversion/utils/extractVariables.d.ts +2 -1
- package/esm/typings/conversion/validation/_importPromptbook.d.ts +2 -2
- package/esm/typings/errors/PromptbookLibraryError.d.ts +7 -0
- package/esm/typings/execution/ExecutionTools.d.ts +5 -3
- package/esm/typings/execution/LlmExecutionTools.d.ts +4 -2
- package/esm/typings/execution/PromptResult.d.ts +5 -1
- package/esm/typings/execution/ScriptExecutionTools.d.ts +2 -1
- package/esm/typings/execution/UserInterfaceTools.d.ts +2 -1
- package/esm/typings/execution/createPromptbookExecutor.d.ts +3 -3
- package/esm/typings/execution/plugins/llm-execution-tools/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -3
- package/esm/typings/execution/plugins/llm-execution-tools/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/execution/plugins/llm-execution-tools/azure-openai/AzureOpenAiExecutionTools.d.ts +4 -3
- package/esm/typings/execution/plugins/llm-execution-tools/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +2 -1
- package/esm/typings/execution/plugins/llm-execution-tools/langtail/LangtailExecutionTools.d.ts +0 -3
- package/esm/typings/execution/plugins/llm-execution-tools/mocked/MockedEchoLlmExecutionTools.d.ts +4 -2
- package/esm/typings/execution/plugins/llm-execution-tools/mocked/MockedFackedLlmExecutionTools.d.ts +4 -2
- package/esm/typings/execution/plugins/llm-execution-tools/mocked/fakeTextToExpectations.d.ts +1 -1
- package/esm/typings/execution/plugins/llm-execution-tools/multiple/MultipleLlmExecutionTools.d.ts +4 -2
- package/esm/typings/execution/plugins/llm-execution-tools/multiple/MultipleLlmExecutionToolsOptions.d.ts +2 -1
- package/esm/typings/execution/plugins/llm-execution-tools/openai/OpenAiExecutionTools.d.ts +5 -3
- package/esm/typings/execution/plugins/llm-execution-tools/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/execution/plugins/llm-execution-tools/openai/openai-models.d.ts +1 -1
- package/esm/typings/execution/plugins/llm-execution-tools/remote/RemoteLlmExecutionTools.d.ts +5 -3
- package/esm/typings/execution/plugins/llm-execution-tools/remote/RemoteLlmExecutionToolsOptions.d.ts +2 -1
- package/esm/typings/execution/plugins/llm-execution-tools/remote/interfaces/Promptbook_Server_Progress.d.ts +1 -1
- package/esm/typings/execution/plugins/llm-execution-tools/remote/interfaces/Promptbook_Server_Response.d.ts +1 -1
- package/esm/typings/execution/plugins/llm-execution-tools/remote/interfaces/RemoteServerOptions.d.ts +2 -1
- package/esm/typings/execution/plugins/llm-execution-tools/remote/startRemoteServer.d.ts +2 -1
- package/esm/typings/execution/plugins/script-execution-tools/python/PythonExecutionTools.d.ts +3 -2
- package/esm/typings/execution/plugins/script-execution-tools/typescript/TypescriptExecutionTools.d.ts +3 -2
- package/esm/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools.d.ts +3 -2
- package/esm/typings/execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -2
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +1 -1
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +1 -1
- package/esm/typings/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +2 -2
- package/esm/typings/execution/translation/automatic-translate/translateMessages.d.ts +2 -2
- package/esm/typings/execution/utils/forEachAsync.d.ts +18 -0
- package/esm/typings/execution/utils/replaceParameters.d.ts +2 -2
- package/esm/typings/library/SimplePromptbookLibrary.d.ts +1 -1
- package/esm/typings/library/constructors/createPromptbookLibraryFromDirectory.d.ts +30 -6
- package/esm/typings/library/constructors/createPromptbookLibraryFromDirectory.test.d.ts +1 -0
- package/esm/typings/library/constructors/createPromptbookLibraryFromPromise.d.ts +4 -4
- package/esm/typings/library/constructors/createPromptbookLibraryFromPromise.test.d.ts +1 -0
- package/esm/typings/library/constructors/createPromptbookLibraryFromSources.d.ts +2 -1
- package/esm/typings/library/constructors/createPromptbookLibraryFromSources.test.d.ts +1 -0
- package/esm/typings/library/constructors/createPromptbookLibraryFromUrl.d.ts +23 -6
- package/esm/typings/library/constructors/createPromptbookSublibrary.d.ts +1 -1
- package/esm/typings/library/constructors/justTestFsImport.d.ts +7 -0
- package/esm/typings/types/Command.d.ts +5 -2
- package/esm/typings/types/Prompt.d.ts +5 -2
- package/esm/typings/types/PromptbookJson/PromptTemplateJson.d.ts +8 -1
- package/esm/typings/types/PromptbookJson/PromptbookJson.d.ts +2 -1
- package/esm/typings/types/TaskProgress.d.ts +2 -1
- package/esm/typings/types/execution-report/ExecutionReportJson.d.ts +2 -1
- package/esm/typings/types/execution-report/countWorkingDuration.d.ts +1 -1
- package/esm/typings/types/typeAliases.d.ts +2 -2
- package/esm/typings/utils/emojis.d.ts +1 -1
- package/esm/typings/utils/expectation-counters/index.d.ts +2 -1
- package/esm/typings/utils/extractParameters.d.ts +2 -1
- package/esm/typings/utils/markdown/addAutoGeneratedSection.d.ts +2 -1
- package/esm/typings/utils/markdown/createMarkdownChart.d.ts +2 -2
- package/esm/typings/utils/markdown/createMarkdownTable.d.ts +2 -1
- package/esm/typings/utils/markdown/escapeMarkdownBlock.d.ts +1 -1
- package/esm/typings/utils/markdown/extractAllListItemsFromMarkdown.d.ts +2 -1
- package/esm/typings/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
- package/esm/typings/utils/markdown/removeContentComments.d.ts +2 -1
- package/esm/typings/utils/markdown/removeMarkdownFormatting.d.ts +1 -1
- package/esm/typings/utils/markdown-json/countMarkdownStructureDeepness.d.ts +1 -1
- package/esm/typings/utils/markdown-json/markdownToMarkdownStructure.d.ts +1 -1
- package/esm/typings/utils/normalization/isValidKeyword.d.ts +1 -1
- package/esm/typings/utils/normalization/parseKeywords.d.ts +1 -1
- package/esm/typings/utils/normalization/parseKeywordsFromString.d.ts +1 -1
- package/esm/typings/utils/normalization/searchKeywords.d.ts +1 -1
- package/esm/typings/utils/postprocessing/extractBlock.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +1098 -821
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/_packages/core.index.d.ts +4 -2
- package/umd/typings/_packages/utils.index.d.ts +2 -0
- package/umd/typings/conversion/prettify/prettifyPromptbookString.d.ts +1 -1
- package/umd/typings/conversion/prettify/renderPromptbookMermaid.d.ts +2 -1
- package/umd/typings/conversion/utils/extractParametersFromPromptTemplate.d.ts +3 -3
- package/umd/typings/conversion/utils/extractVariables.d.ts +2 -1
- package/umd/typings/conversion/validation/_importPromptbook.d.ts +2 -2
- package/umd/typings/errors/PromptbookLibraryError.d.ts +7 -0
- package/umd/typings/execution/ExecutionTools.d.ts +5 -3
- package/umd/typings/execution/LlmExecutionTools.d.ts +4 -2
- package/umd/typings/execution/PromptResult.d.ts +5 -1
- package/umd/typings/execution/ScriptExecutionTools.d.ts +2 -1
- package/umd/typings/execution/UserInterfaceTools.d.ts +2 -1
- package/umd/typings/execution/createPromptbookExecutor.d.ts +3 -3
- package/umd/typings/execution/plugins/llm-execution-tools/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +4 -3
- package/umd/typings/execution/plugins/llm-execution-tools/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/umd/typings/execution/plugins/llm-execution-tools/azure-openai/AzureOpenAiExecutionTools.d.ts +4 -3
- package/umd/typings/execution/plugins/llm-execution-tools/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +2 -1
- package/umd/typings/execution/plugins/llm-execution-tools/langtail/LangtailExecutionTools.d.ts +0 -3
- package/umd/typings/execution/plugins/llm-execution-tools/mocked/MockedEchoLlmExecutionTools.d.ts +4 -2
- package/umd/typings/execution/plugins/llm-execution-tools/mocked/MockedFackedLlmExecutionTools.d.ts +4 -2
- package/umd/typings/execution/plugins/llm-execution-tools/mocked/fakeTextToExpectations.d.ts +1 -1
- package/umd/typings/execution/plugins/llm-execution-tools/multiple/MultipleLlmExecutionTools.d.ts +4 -2
- package/umd/typings/execution/plugins/llm-execution-tools/multiple/MultipleLlmExecutionToolsOptions.d.ts +2 -1
- package/umd/typings/execution/plugins/llm-execution-tools/openai/OpenAiExecutionTools.d.ts +5 -3
- package/umd/typings/execution/plugins/llm-execution-tools/openai/OpenAiExecutionToolsOptions.d.ts +1 -1
- package/umd/typings/execution/plugins/llm-execution-tools/openai/openai-models.d.ts +1 -1
- package/umd/typings/execution/plugins/llm-execution-tools/remote/RemoteLlmExecutionTools.d.ts +5 -3
- package/umd/typings/execution/plugins/llm-execution-tools/remote/RemoteLlmExecutionToolsOptions.d.ts +2 -1
- package/umd/typings/execution/plugins/llm-execution-tools/remote/interfaces/Promptbook_Server_Progress.d.ts +1 -1
- package/umd/typings/execution/plugins/llm-execution-tools/remote/interfaces/Promptbook_Server_Response.d.ts +1 -1
- package/umd/typings/execution/plugins/llm-execution-tools/remote/interfaces/RemoteServerOptions.d.ts +2 -1
- package/umd/typings/execution/plugins/llm-execution-tools/remote/startRemoteServer.d.ts +2 -1
- package/umd/typings/execution/plugins/script-execution-tools/python/PythonExecutionTools.d.ts +3 -2
- package/umd/typings/execution/plugins/script-execution-tools/typescript/TypescriptExecutionTools.d.ts +3 -2
- package/umd/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools.d.ts +3 -2
- package/umd/typings/execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools.d.ts +3 -2
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/DebugAutomaticTranslator.d.ts +1 -1
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/FakeAutomaticTranslator.d.ts +1 -1
- package/umd/typings/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +2 -2
- package/umd/typings/execution/translation/automatic-translate/translateMessages.d.ts +2 -2
- package/umd/typings/execution/utils/forEachAsync.d.ts +18 -0
- package/umd/typings/execution/utils/replaceParameters.d.ts +2 -2
- package/umd/typings/library/SimplePromptbookLibrary.d.ts +1 -1
- package/umd/typings/library/constructors/createPromptbookLibraryFromDirectory.d.ts +30 -6
- package/umd/typings/library/constructors/createPromptbookLibraryFromDirectory.test.d.ts +1 -0
- package/umd/typings/library/constructors/createPromptbookLibraryFromPromise.d.ts +4 -4
- package/umd/typings/library/constructors/createPromptbookLibraryFromPromise.test.d.ts +1 -0
- package/umd/typings/library/constructors/createPromptbookLibraryFromSources.d.ts +2 -1
- package/umd/typings/library/constructors/createPromptbookLibraryFromSources.test.d.ts +1 -0
- package/umd/typings/library/constructors/createPromptbookLibraryFromUrl.d.ts +23 -6
- package/umd/typings/library/constructors/createPromptbookSublibrary.d.ts +1 -1
- package/umd/typings/library/constructors/justTestFsImport.d.ts +7 -0
- package/umd/typings/types/Command.d.ts +5 -2
- package/umd/typings/types/Prompt.d.ts +5 -2
- package/umd/typings/types/PromptbookJson/PromptTemplateJson.d.ts +8 -1
- package/umd/typings/types/PromptbookJson/PromptbookJson.d.ts +2 -1
- package/umd/typings/types/TaskProgress.d.ts +2 -1
- package/umd/typings/types/execution-report/ExecutionReportJson.d.ts +2 -1
- package/umd/typings/types/execution-report/countWorkingDuration.d.ts +1 -1
- package/umd/typings/types/typeAliases.d.ts +2 -2
- package/umd/typings/utils/emojis.d.ts +1 -1
- package/umd/typings/utils/expectation-counters/index.d.ts +2 -1
- package/umd/typings/utils/extractParameters.d.ts +2 -1
- package/umd/typings/utils/markdown/addAutoGeneratedSection.d.ts +2 -1
- package/umd/typings/utils/markdown/createMarkdownChart.d.ts +2 -2
- package/umd/typings/utils/markdown/createMarkdownTable.d.ts +2 -1
- package/umd/typings/utils/markdown/escapeMarkdownBlock.d.ts +1 -1
- package/umd/typings/utils/markdown/extractAllListItemsFromMarkdown.d.ts +2 -1
- package/umd/typings/utils/markdown/extractOneBlockFromMarkdown.d.ts +2 -2
- package/umd/typings/utils/markdown/removeContentComments.d.ts +2 -1
- package/umd/typings/utils/markdown/removeMarkdownFormatting.d.ts +1 -1
- package/umd/typings/utils/markdown-json/countMarkdownStructureDeepness.d.ts +1 -1
- package/umd/typings/utils/markdown-json/markdownToMarkdownStructure.d.ts +1 -1
- package/umd/typings/utils/normalization/isValidKeyword.d.ts +1 -1
- package/umd/typings/utils/normalization/parseKeywords.d.ts +1 -1
- package/umd/typings/utils/normalization/parseKeywordsFromString.d.ts +1 -1
- package/umd/typings/utils/normalization/searchKeywords.d.ts +1 -1
- package/umd/typings/utils/postprocessing/extractBlock.d.ts +1 -1
- package/esm/typings/wizzard/Wizzard.d.ts +0 -4
- package/esm/typings/wizzard/sample.d.ts +0 -6
- package/umd/typings/wizzard/Wizzard.d.ts +0 -4
- package/umd/typings/wizzard/sample.d.ts +0 -6
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('moment')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'moment'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.moment));
|
|
5
|
-
})(this, (function (exports, spaceTrim, prettier, parserHtml, moment) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('path'), require('moment')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'prettier', 'prettier/parser-html', 'path', 'moment'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-core"] = {}, global.spaceTrim, global.prettier, global.parserHtml, global.path, global.moment));
|
|
5
|
+
})(this, (function (exports, spaceTrim, prettier, parserHtml, path, moment) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -454,7 +454,7 @@
|
|
|
454
454
|
/**
|
|
455
455
|
* The version of the Promptbook library
|
|
456
456
|
*/
|
|
457
|
-
var PROMPTBOOK_VERSION = '0.52.0
|
|
457
|
+
var PROMPTBOOK_VERSION = '0.52.0';
|
|
458
458
|
|
|
459
459
|
/**
|
|
460
460
|
* Parses the template and returns the list of all parameter names
|
|
@@ -576,88 +576,108 @@
|
|
|
576
576
|
* TODO: [🔣] If script require contentLanguage
|
|
577
577
|
*/
|
|
578
578
|
|
|
579
|
+
/* tslint:disable */
|
|
580
|
+
/*
|
|
581
|
+
TODO: Tests
|
|
582
|
+
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
|
|
583
|
+
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ěščřžžýáíúů' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
|
|
584
|
+
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
|
|
585
|
+
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
|
|
586
|
+
*/
|
|
587
|
+
function normalizeTo_SCREAMING_CASE(sentence) {
|
|
588
|
+
var e_1, _a;
|
|
589
|
+
var charType;
|
|
590
|
+
var lastCharType = 'OTHER';
|
|
591
|
+
var normalizedName = '';
|
|
592
|
+
try {
|
|
593
|
+
for (var sentence_1 = __values(sentence), sentence_1_1 = sentence_1.next(); !sentence_1_1.done; sentence_1_1 = sentence_1.next()) {
|
|
594
|
+
var char = sentence_1_1.value;
|
|
595
|
+
var normalizedChar = void 0;
|
|
596
|
+
if (/^[a-z]$/.test(char)) {
|
|
597
|
+
charType = 'LOWERCASE';
|
|
598
|
+
normalizedChar = char.toUpperCase();
|
|
599
|
+
}
|
|
600
|
+
else if (/^[A-Z]$/.test(char)) {
|
|
601
|
+
charType = 'UPPERCASE';
|
|
602
|
+
normalizedChar = char;
|
|
603
|
+
}
|
|
604
|
+
else if (/^[0-9]$/.test(char)) {
|
|
605
|
+
charType = 'NUMBER';
|
|
606
|
+
normalizedChar = char;
|
|
607
|
+
}
|
|
608
|
+
else if (/^\/$/.test(char)) {
|
|
609
|
+
charType = 'SLASH';
|
|
610
|
+
normalizedChar = char;
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
charType = 'OTHER';
|
|
614
|
+
normalizedChar = '_';
|
|
615
|
+
}
|
|
616
|
+
if (charType !== lastCharType &&
|
|
617
|
+
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
618
|
+
!(lastCharType === 'NUMBER') &&
|
|
619
|
+
!(charType === 'NUMBER')) {
|
|
620
|
+
normalizedName += '_';
|
|
621
|
+
}
|
|
622
|
+
normalizedName += normalizedChar;
|
|
623
|
+
lastCharType = charType;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
627
|
+
finally {
|
|
628
|
+
try {
|
|
629
|
+
if (sentence_1_1 && !sentence_1_1.done && (_a = sentence_1.return)) _a.call(sentence_1);
|
|
630
|
+
}
|
|
631
|
+
finally { if (e_1) throw e_1.error; }
|
|
632
|
+
}
|
|
633
|
+
normalizedName = normalizedName.replace(/_+/g, '_');
|
|
634
|
+
normalizedName = normalizedName.replace(/_?\/_?/g, '/');
|
|
635
|
+
normalizedName = normalizedName.replace(/^_/, '');
|
|
636
|
+
normalizedName = normalizedName.replace(/_$/, '');
|
|
637
|
+
return normalizedName;
|
|
638
|
+
}
|
|
579
639
|
/**
|
|
580
|
-
*
|
|
640
|
+
* TODO: [🌺] Use some intermediate util splitWords
|
|
641
|
+
*/
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Execution type describes the way how the block is executed
|
|
581
645
|
*
|
|
582
|
-
* @
|
|
583
|
-
* @returns text without emojis
|
|
646
|
+
* @see https://github.com/webgptorg/promptbook#execution-type
|
|
584
647
|
*/
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
}
|
|
648
|
+
var ExecutionTypes = [
|
|
649
|
+
'PROMPT_TEMPLATE',
|
|
650
|
+
'SIMPLE_TEMPLATE',
|
|
651
|
+
'SCRIPT',
|
|
652
|
+
'PROMPT_DIALOG',
|
|
653
|
+
// <- [🥻] Insert here when making new command
|
|
654
|
+
];
|
|
593
655
|
|
|
594
656
|
/**
|
|
595
|
-
*
|
|
657
|
+
* Units of text measurement
|
|
658
|
+
*/
|
|
659
|
+
var EXPECTATION_UNITS = ['CHARACTERS', 'WORDS', 'SENTENCES', 'LINES', 'PARAGRAPHS', 'PAGES'];
|
|
660
|
+
/**
|
|
661
|
+
* TODO: [💝] Unite object for expecting amount and format - remove expectFormat
|
|
662
|
+
* TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
|
|
663
|
+
* TODO: [👙][🧠] Just selecting gpt3 or gpt4 level of model
|
|
596
664
|
*/
|
|
597
|
-
function titleToName(value) {
|
|
598
|
-
value = removeEmojis(value);
|
|
599
|
-
value = normalizeToKebabCase(value);
|
|
600
|
-
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
601
|
-
return value;
|
|
602
|
-
}
|
|
603
665
|
|
|
604
666
|
/**
|
|
605
|
-
*
|
|
667
|
+
* Removes Markdown formatting tags from a string.
|
|
606
668
|
*
|
|
607
|
-
*
|
|
669
|
+
* @param {string} str - The string to remove Markdown tags from.
|
|
670
|
+
* @returns {string} The input string with all Markdown tags removed.
|
|
608
671
|
*/
|
|
609
|
-
function
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
return 'input';
|
|
618
|
-
}
|
|
619
|
-
var template = promptbookJson.promptTemplates.find(function (template) { return template.resultingParameterName === parameterName; });
|
|
620
|
-
if (!template) {
|
|
621
|
-
throw new Error("Could not find template for {".concat(parameterName, "}"));
|
|
622
|
-
}
|
|
623
|
-
return normalizeTo_camelCase('template-' + titleToName(template.title));
|
|
624
|
-
};
|
|
625
|
-
var promptbookMermaid = spaceTrim.spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(promptbookJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(promptbookJson.promptTemplates
|
|
626
|
-
.flatMap(function (_a) {
|
|
627
|
-
var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
|
|
628
|
-
return __spreadArray([
|
|
629
|
-
"".concat(parameterNameToTemplateName(resultingParameterName), "(\"").concat(title, "\")")
|
|
630
|
-
], __read(dependentParameterNames.map(function (dependentParameterName) {
|
|
631
|
-
return "".concat(parameterNameToTemplateName(dependentParameterName), "--\"{").concat(dependentParameterName, "}\"-->").concat(parameterNameToTemplateName(resultingParameterName));
|
|
632
|
-
})), false);
|
|
633
|
-
})
|
|
634
|
-
.join('\n')), "\n\n ").concat(block(promptbookJson.parameters
|
|
635
|
-
.filter(function (_a) {
|
|
636
|
-
var isOutput = _a.isOutput;
|
|
637
|
-
return isOutput;
|
|
638
|
-
})
|
|
639
|
-
.map(function (_a) {
|
|
640
|
-
var name = _a.name;
|
|
641
|
-
return "".concat(parameterNameToTemplateName(name), "--\"{").concat(name, "}\"-->output");
|
|
642
|
-
})
|
|
643
|
-
.join('\n')), "\n output((Output)):::output\n\n ").concat(block(promptbookJson.promptTemplates
|
|
644
|
-
.map(function (promptTemplate) {
|
|
645
|
-
var link = linkPromptTemplate(promptTemplate);
|
|
646
|
-
if (link === null) {
|
|
647
|
-
return '';
|
|
648
|
-
}
|
|
649
|
-
var href = link.href, title = link.title;
|
|
650
|
-
var templateName = parameterNameToTemplateName(promptTemplate.resultingParameterName);
|
|
651
|
-
return "click ".concat(templateName, " href \"").concat(href, "\" \"").concat(title, "\";");
|
|
652
|
-
})
|
|
653
|
-
.filter(function (line) { return line !== ''; })
|
|
654
|
-
.join('\n')), "\n\n classDef input color: grey;\n classDef output color: grey;\n\n end;\n\n "); });
|
|
655
|
-
return promptbookMermaid;
|
|
672
|
+
function removeMarkdownFormatting(str) {
|
|
673
|
+
// Remove bold formatting
|
|
674
|
+
str = str.replace(/\*\*(.*?)\*\*/g, '$1');
|
|
675
|
+
// Remove italic formatting
|
|
676
|
+
str = str.replace(/\*(.*?)\*/g, '$1');
|
|
677
|
+
// Remove code formatting
|
|
678
|
+
str = str.replace(/`(.*?)`/g, '$1');
|
|
679
|
+
return str;
|
|
656
680
|
}
|
|
657
|
-
/**
|
|
658
|
-
* TODO: Maybe use some Mermaid library instead of string templating
|
|
659
|
-
* TODO: [🕌] When more than 2 functionalities, split into separate functions
|
|
660
|
-
*/
|
|
661
681
|
|
|
662
682
|
/**
|
|
663
683
|
* Function parseNumber will parse number from string
|
|
@@ -727,146 +747,249 @@
|
|
|
727
747
|
*/
|
|
728
748
|
|
|
729
749
|
/**
|
|
730
|
-
*
|
|
731
|
-
*/
|
|
732
|
-
var PromptbookLogicError = /** @class */ (function (_super) {
|
|
733
|
-
__extends(PromptbookLogicError, _super);
|
|
734
|
-
function PromptbookLogicError(message) {
|
|
735
|
-
var _this = _super.call(this, message) || this;
|
|
736
|
-
_this.name = 'PromptbookLogicError';
|
|
737
|
-
Object.setPrototypeOf(_this, PromptbookLogicError.prototype);
|
|
738
|
-
return _this;
|
|
739
|
-
}
|
|
740
|
-
return PromptbookLogicError;
|
|
741
|
-
}(Error));
|
|
742
|
-
|
|
743
|
-
/**
|
|
744
|
-
* This error occurs during the parameter replacement in the template
|
|
745
|
-
*
|
|
746
|
-
* Note: This is a kindof subtype of PromptbookExecutionError because it occurs during the execution of the pipeline
|
|
747
|
-
*/
|
|
748
|
-
var TemplateError = /** @class */ (function (_super) {
|
|
749
|
-
__extends(TemplateError, _super);
|
|
750
|
-
function TemplateError(message) {
|
|
751
|
-
var _this = _super.call(this, message) || this;
|
|
752
|
-
_this.name = 'TemplateError';
|
|
753
|
-
Object.setPrototypeOf(_this, TemplateError.prototype);
|
|
754
|
-
return _this;
|
|
755
|
-
}
|
|
756
|
-
return TemplateError;
|
|
757
|
-
}(Error));
|
|
758
|
-
|
|
759
|
-
/**
|
|
760
|
-
* Replaces parameters in template with values from parameters object
|
|
750
|
+
* Parses one line of ul/ol to command
|
|
761
751
|
*
|
|
762
|
-
* @
|
|
763
|
-
* @
|
|
764
|
-
* @returns the template with replaced parameters
|
|
765
|
-
* @throws {TemplateError} if parameter is not defined, not closed, or not opened
|
|
752
|
+
* @returns parsed command object
|
|
753
|
+
* @throws {PromptbookSyntaxError} if the command is invalid
|
|
766
754
|
*
|
|
767
|
-
* @private within the
|
|
755
|
+
* @private within the promptbookStringToJson
|
|
768
756
|
*/
|
|
769
|
-
function
|
|
770
|
-
var
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
757
|
+
function parseCommand(listItem) {
|
|
758
|
+
var e_1, _a;
|
|
759
|
+
if (listItem.includes('\n') || listItem.includes('\r')) {
|
|
760
|
+
throw new PromptbookSyntaxError('Command can not contain new line characters:');
|
|
761
|
+
}
|
|
762
|
+
var type = listItem.trim();
|
|
763
|
+
type = type.split('`').join('');
|
|
764
|
+
type = type.split('"').join('');
|
|
765
|
+
type = type.split("'").join('');
|
|
766
|
+
type = type.split('~').join('');
|
|
767
|
+
type = type.split('[').join('');
|
|
768
|
+
type = type.split(']').join('');
|
|
769
|
+
type = type.split('(').join('');
|
|
770
|
+
type = type.split(')').join('');
|
|
771
|
+
type = normalizeTo_SCREAMING_CASE(type);
|
|
772
|
+
type = type.split('DIALOGUE').join('DIALOG');
|
|
773
|
+
var listItemParts = listItem
|
|
774
|
+
.split(' ')
|
|
775
|
+
.map(function (part) { return part.trim(); })
|
|
776
|
+
.filter(function (item) { return item !== ''; })
|
|
777
|
+
.filter(function (item) { return !/^PTBK$/i.test(item); })
|
|
778
|
+
.filter(function (item) { return !/^PROMPTBOOK$/i.test(item); })
|
|
779
|
+
.map(removeMarkdownFormatting);
|
|
780
|
+
if (type.startsWith('URL') ||
|
|
781
|
+
type.startsWith('PTBK_URL') ||
|
|
782
|
+
type.startsWith('PTBKURL') ||
|
|
783
|
+
type.startsWith('PROMPTBOOK_URL') ||
|
|
784
|
+
type.startsWith('PROMPTBOOKURL') ||
|
|
785
|
+
type.startsWith('HTTPS')) {
|
|
786
|
+
if (!(listItemParts.length === 2 || (listItemParts.length === 1 && type.startsWith('HTTPS')))) {
|
|
787
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n ")));
|
|
781
788
|
}
|
|
782
|
-
|
|
783
|
-
|
|
789
|
+
var promptbookUrlString = listItemParts.pop();
|
|
790
|
+
var promptbookUrl = new URL(promptbookUrlString);
|
|
791
|
+
if (promptbookUrl.protocol !== 'https:') {
|
|
792
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n Protocol must be HTTPS\n ")));
|
|
784
793
|
}
|
|
785
|
-
if (
|
|
786
|
-
throw new
|
|
794
|
+
if (promptbookUrl.hash !== '') {
|
|
795
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n URL must not contain hash\n Hash is used for identification of the prompt template in the pipeline\n ")));
|
|
787
796
|
}
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
797
|
+
return {
|
|
798
|
+
type: 'PROMPTBOOK_URL',
|
|
799
|
+
promptbookUrl: promptbookUrl,
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
else if (type.startsWith('PROMPTBOOK_VERSION') || type.startsWith('PTBK_VERSION')) {
|
|
803
|
+
if (listItemParts.length !== 2) {
|
|
804
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_VERSION command:\n\n - ".concat(listItem, "\n ")));
|
|
791
805
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
806
|
+
var promptbookVersion = listItemParts.pop();
|
|
807
|
+
// TODO: Validate version
|
|
808
|
+
return {
|
|
809
|
+
type: 'PROMPTBOOK_VERSION',
|
|
810
|
+
promptbookVersion: promptbookVersion,
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
else if (type.startsWith('EXECUTE') ||
|
|
814
|
+
type.startsWith('EXEC') ||
|
|
815
|
+
type.startsWith('PROMPT_DIALOG') ||
|
|
816
|
+
type.startsWith('SIMPLE_TEMPLATE')) {
|
|
817
|
+
var executionTypes = ExecutionTypes.filter(function (executionType) { return type.includes(executionType); });
|
|
818
|
+
if (executionTypes.length !== 1) {
|
|
819
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type in command:\n\n - ".concat(listItem, "\n\n Supported execution types are:\n ").concat(block(ExecutionTypes.join(', ')), "\n "); }));
|
|
798
820
|
}
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
};
|
|
804
|
-
while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
|
|
805
|
-
.exec(replacedTemplate))) {
|
|
806
|
-
_loop_1();
|
|
821
|
+
return {
|
|
822
|
+
type: 'EXECUTE',
|
|
823
|
+
executionType: executionTypes[0],
|
|
824
|
+
};
|
|
807
825
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
826
|
+
else if (type.startsWith('MODEL')) {
|
|
827
|
+
// TODO: Make this more elegant and dynamically
|
|
828
|
+
if (type.startsWith('MODEL_VARIANT')) {
|
|
829
|
+
if (type === 'MODEL_VARIANT_CHAT') {
|
|
830
|
+
return {
|
|
831
|
+
type: 'MODEL',
|
|
832
|
+
key: 'modelVariant',
|
|
833
|
+
value: 'CHAT',
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
else if (type === 'MODEL_VARIANT_COMPLETION') {
|
|
837
|
+
return {
|
|
838
|
+
type: 'MODEL',
|
|
839
|
+
key: 'modelVariant',
|
|
840
|
+
value: 'COMPLETION',
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
else {
|
|
844
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Unknown model variant in command:\n\n - ".concat(listItem, "\n\n Supported variants are:\n ").concat(block(['CHAT', 'COMPLETION'].join(', ')), "\n "); }));
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
if (type.startsWith('MODEL_NAME')) {
|
|
848
|
+
return {
|
|
849
|
+
type: 'MODEL',
|
|
850
|
+
key: 'modelName',
|
|
851
|
+
value: listItemParts.pop(),
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Unknown model key in command:\n\n - ".concat(listItem, "\n\n Supported model keys are:\n ").concat(block(['variant', 'name'].join(', ')), "\n\n Example:\n\n - MODEL VARIANT Chat\n - MODEL NAME gpt-4\n "); }));
|
|
856
|
+
}
|
|
811
857
|
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
858
|
+
else if (type.startsWith('PARAM') ||
|
|
859
|
+
type.startsWith('INPUT_PARAM') ||
|
|
860
|
+
type.startsWith('OUTPUT_PARAM') ||
|
|
861
|
+
listItem.startsWith('{') ||
|
|
862
|
+
listItem.startsWith('> {') /* <- Note: This is a bit hack to parse return parameters defined at the end of each section */) {
|
|
863
|
+
var parametersMatch = listItem.match(/\{(?<parameterName>[a-z0-9_]+)\}[^\S\r\n]*(?<parameterDescription>.*)$/im);
|
|
864
|
+
if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
|
|
865
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
|
|
866
|
+
}
|
|
867
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
868
|
+
var _b = parametersMatch.groups, parameterName = _b.parameterName, parameterDescription = _b.parameterDescription;
|
|
869
|
+
if (parameterDescription && parameterDescription.match(/\{(?<parameterName>[a-z0-9_]+)\}/im)) {
|
|
870
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Parameter {".concat(parameterName, "} can not contain another parameter in description:\n\n - ").concat(listItem, "\n ")));
|
|
871
|
+
}
|
|
872
|
+
var isInput = type.startsWith('INPUT');
|
|
873
|
+
var isOutput = type.startsWith('OUTPUT');
|
|
874
|
+
if (listItem.startsWith('> {')) {
|
|
875
|
+
isInput = false;
|
|
876
|
+
isOutput = false;
|
|
877
|
+
}
|
|
878
|
+
return {
|
|
879
|
+
type: 'PARAMETER',
|
|
880
|
+
parameterName: parameterName,
|
|
881
|
+
parameterDescription: parameterDescription.trim() || null,
|
|
882
|
+
isInput: isInput,
|
|
883
|
+
isOutput: isOutput,
|
|
884
|
+
};
|
|
815
885
|
}
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
886
|
+
else if (type.startsWith('JOKER')) {
|
|
887
|
+
if (listItemParts.length !== 2) {
|
|
888
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid JOKER command:\n\n - ".concat(listItem, "\n ")));
|
|
889
|
+
}
|
|
890
|
+
var parametersMatch = (listItemParts.pop() || '').match(/^\{(?<parameterName>[a-z0-9_]+)\}$/im);
|
|
891
|
+
if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
|
|
892
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
|
|
893
|
+
}
|
|
894
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
895
|
+
var parameterName = parametersMatch.groups.parameterName;
|
|
896
|
+
return {
|
|
897
|
+
type: 'JOKER',
|
|
898
|
+
parameterName: parameterName,
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
else if (type.startsWith('POSTPROCESS') || type.startsWith('POST_PROCESS')) {
|
|
902
|
+
if (listItemParts.length !== 2) {
|
|
903
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid POSTPROCESSING command:\n\n - ".concat(listItem, "\n ")));
|
|
904
|
+
}
|
|
905
|
+
var functionName = listItemParts.pop();
|
|
906
|
+
return {
|
|
907
|
+
type: 'POSTPROCESS',
|
|
908
|
+
functionName: functionName,
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
else if (type.startsWith('EXPECT_JSON')) {
|
|
912
|
+
return {
|
|
913
|
+
type: 'EXPECT_FORMAT',
|
|
914
|
+
format: 'JSON',
|
|
915
|
+
};
|
|
916
|
+
// [🥤]
|
|
917
|
+
}
|
|
918
|
+
else if (type.startsWith('EXPECT')) {
|
|
919
|
+
try {
|
|
920
|
+
listItemParts.shift();
|
|
921
|
+
var sign = void 0;
|
|
922
|
+
var signRaw = listItemParts.shift();
|
|
923
|
+
if (/^exact/i.test(signRaw)) {
|
|
924
|
+
sign = 'EXACTLY';
|
|
925
|
+
}
|
|
926
|
+
else if (/^min/i.test(signRaw)) {
|
|
927
|
+
sign = 'MINIMUM';
|
|
928
|
+
}
|
|
929
|
+
else if (/^max/i.test(signRaw)) {
|
|
930
|
+
sign = 'MAXIMUM';
|
|
931
|
+
}
|
|
932
|
+
else {
|
|
933
|
+
throw new PromptbookSyntaxError("Invalid sign \"".concat(signRaw, "\", expected EXACTLY, MIN or MAX"));
|
|
934
|
+
}
|
|
935
|
+
var amountRaw = listItemParts.shift();
|
|
936
|
+
var amount = parseNumber(amountRaw);
|
|
937
|
+
if (amount < 0) {
|
|
938
|
+
throw new PromptbookSyntaxError('Amount must be positive number or zero');
|
|
939
|
+
}
|
|
940
|
+
if (amount !== Math.floor(amount)) {
|
|
941
|
+
throw new PromptbookSyntaxError('Amount must be whole number');
|
|
942
|
+
}
|
|
943
|
+
var unitRaw = listItemParts.shift();
|
|
944
|
+
var unit = undefined;
|
|
945
|
+
try {
|
|
946
|
+
for (var EXPECTATION_UNITS_1 = __values(EXPECTATION_UNITS), EXPECTATION_UNITS_1_1 = EXPECTATION_UNITS_1.next(); !EXPECTATION_UNITS_1_1.done; EXPECTATION_UNITS_1_1 = EXPECTATION_UNITS_1.next()) {
|
|
947
|
+
var existingUnit = EXPECTATION_UNITS_1_1.value;
|
|
948
|
+
var existingUnitText = existingUnit;
|
|
949
|
+
existingUnitText = existingUnitText.substring(0, existingUnitText.length - 1);
|
|
950
|
+
if (existingUnitText === 'CHARACTER') {
|
|
951
|
+
existingUnitText = 'CHAR';
|
|
952
|
+
}
|
|
953
|
+
if (new RegExp("^".concat(existingUnitText.toLowerCase())).test(unitRaw.toLowerCase()) ||
|
|
954
|
+
new RegExp("^".concat(unitRaw.toLowerCase())).test(existingUnitText.toLowerCase())) {
|
|
955
|
+
if (unit !== undefined) {
|
|
956
|
+
throw new PromptbookSyntaxError("Ambiguous unit \"".concat(unitRaw, "\""));
|
|
957
|
+
}
|
|
958
|
+
unit = existingUnit;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
963
|
+
finally {
|
|
964
|
+
try {
|
|
965
|
+
if (EXPECTATION_UNITS_1_1 && !EXPECTATION_UNITS_1_1.done && (_a = EXPECTATION_UNITS_1.return)) _a.call(EXPECTATION_UNITS_1);
|
|
966
|
+
}
|
|
967
|
+
finally { if (e_1) throw e_1.error; }
|
|
968
|
+
}
|
|
969
|
+
if (unit === undefined) {
|
|
970
|
+
throw new PromptbookSyntaxError("Invalid unit \"".concat(unitRaw, "\""));
|
|
971
|
+
}
|
|
972
|
+
return {
|
|
973
|
+
type: 'EXPECT_AMOUNT',
|
|
974
|
+
sign: sign,
|
|
975
|
+
unit: unit,
|
|
976
|
+
amount: amount,
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
catch (error) {
|
|
980
|
+
if (!(error instanceof Error)) {
|
|
981
|
+
throw error;
|
|
982
|
+
}
|
|
983
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid EXPECT command; ".concat(error.message, ":\n\n - ").concat(listItem, "\n ")));
|
|
984
|
+
}
|
|
985
|
+
/*
|
|
986
|
+
} else if (type.startsWith('__________________')) {
|
|
987
|
+
// <- [🥻] Insert here when making new command
|
|
988
|
+
*/
|
|
989
|
+
}
|
|
990
|
+
else {
|
|
991
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Unknown command:\n\n - ".concat(listItem, "\n\n Supported commands are:\n - PROMPTBOOK_URL <url>\n - PROMPTBOOK_VERSION <version>\n - EXECUTE PROMPT TEMPLATE\n - EXECUTE SIMPLE TEMPLATE\n - SIMPLE TEMPLATE\n - EXECUTE SCRIPT\n - EXECUTE PROMPT_DIALOG'\n - PROMPT_DIALOG'\n - MODEL NAME <name>\n - MODEL VARIANT <\"Chat\"|\"Completion\">\n - INPUT PARAM {<name>} <description>\n - OUTPUT PARAM {<name>} <description>\n - POSTPROCESS `{functionName}`\n - JOKER {<name>}\n - EXPECT JSON\n - EXPECT <\"Exactly\"|\"Min\"|\"Max\"> <number> <\"Chars\"|\"Words\"|\"Sentences\"|\"Paragraphs\"|\"Pages\">\n\n ")));
|
|
838
992
|
}
|
|
839
|
-
return text.split('\n').length;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
/**
|
|
843
|
-
* Counts number of pages in the text
|
|
844
|
-
*/
|
|
845
|
-
function countPages(text) {
|
|
846
|
-
var sentencesPerPage = 5; // Assuming each page has 5 sentences
|
|
847
|
-
var sentences = text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
|
|
848
|
-
var pageCount = Math.ceil(sentences.length / sentencesPerPage);
|
|
849
|
-
return pageCount;
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
/**
|
|
853
|
-
* Counts number of paragraphs in the text
|
|
854
|
-
*/
|
|
855
|
-
function countParagraphs(text) {
|
|
856
|
-
return text.split(/\n\s*\n/).filter(function (paragraph) { return paragraph.trim() !== ''; }).length;
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
/**
|
|
860
|
-
* Split text into sentences
|
|
861
|
-
*/
|
|
862
|
-
function splitIntoSentences(text) {
|
|
863
|
-
return text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
|
|
864
|
-
}
|
|
865
|
-
/**
|
|
866
|
-
* Counts number of sentences in the text
|
|
867
|
-
*/
|
|
868
|
-
function countSentences(text) {
|
|
869
|
-
return splitIntoSentences(text).length;
|
|
870
993
|
}
|
|
871
994
|
|
|
872
995
|
var defaultDiacriticsRemovalMap = [
|
|
@@ -1078,546 +1201,127 @@
|
|
|
1078
1201
|
},
|
|
1079
1202
|
];
|
|
1080
1203
|
/**
|
|
1081
|
-
* Map of letters from diacritic variant to diacritless variant
|
|
1082
|
-
* Contains lowercase and uppercase separatelly
|
|
1083
|
-
*
|
|
1084
|
-
* > "á" => "a"
|
|
1085
|
-
* > "ě" => "e"
|
|
1086
|
-
* > "Ă" => "A"
|
|
1087
|
-
* > ...
|
|
1088
|
-
*/
|
|
1089
|
-
var DIACRITIC_VARIANTS_LETTERS = {};
|
|
1090
|
-
// tslint:disable-next-line: prefer-for-of
|
|
1091
|
-
for (var i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
1092
|
-
var letters = defaultDiacriticsRemovalMap[i].letters;
|
|
1093
|
-
// tslint:disable-next-line: prefer-for-of
|
|
1094
|
-
for (var j = 0; j < letters.length; j++) {
|
|
1095
|
-
DIACRITIC_VARIANTS_LETTERS[letters[j]] = defaultDiacriticsRemovalMap[i].base;
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
// <- TODO: [🍓] Put to maker function to save execution time if not needed
|
|
1099
|
-
/*
|
|
1100
|
-
@see https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript
|
|
1101
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
1102
|
-
you may not use this file except in compliance with the License.
|
|
1103
|
-
You may obtain a copy of the License at
|
|
1104
|
-
|
|
1105
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
1106
|
-
|
|
1107
|
-
Unless required by applicable law or agreed to in writing, software
|
|
1108
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
1109
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1110
|
-
See the License for the specific language governing permissions and
|
|
1111
|
-
limitations under the License.
|
|
1112
|
-
*/
|
|
1113
|
-
|
|
1114
|
-
/**
|
|
1115
|
-
*
|
|
1116
|
-
*/
|
|
1117
|
-
function removeDiacritics(input) {
|
|
1118
|
-
/*eslint no-control-regex: "off"*/
|
|
1119
|
-
return input.replace(/[^\u0000-\u007E]/g, function (a) {
|
|
1120
|
-
return DIACRITIC_VARIANTS_LETTERS[a] || a;
|
|
1121
|
-
});
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
/**
|
|
1125
|
-
* Counts number of words in the text
|
|
1126
|
-
*/
|
|
1127
|
-
function countWords(text) {
|
|
1128
|
-
text = text.replace(/[\p{Extended_Pictographic}]/gu, 'a');
|
|
1129
|
-
text = removeDiacritics(text);
|
|
1130
|
-
return text.split(/[^a-zа-я0-9]+/i).filter(function (word) { return word.length > 0; }).length;
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
/**
|
|
1134
|
-
* Index of all counter functions
|
|
1135
|
-
*/
|
|
1136
|
-
var CountUtils = {
|
|
1137
|
-
CHARACTERS: countCharacters,
|
|
1138
|
-
WORDS: countWords,
|
|
1139
|
-
SENTENCES: countSentences,
|
|
1140
|
-
PARAGRAPHS: countParagraphs,
|
|
1141
|
-
LINES: countLines,
|
|
1142
|
-
PAGES: countPages,
|
|
1143
|
-
};
|
|
1144
|
-
|
|
1145
|
-
/**
|
|
1146
|
-
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
1147
|
-
*/
|
|
1148
|
-
function isValidJsonString(value) {
|
|
1149
|
-
try {
|
|
1150
|
-
JSON.parse(value);
|
|
1151
|
-
return true;
|
|
1152
|
-
}
|
|
1153
|
-
catch (error) {
|
|
1154
|
-
if (!(error instanceof Error)) {
|
|
1155
|
-
throw error;
|
|
1156
|
-
}
|
|
1157
|
-
if (error.message.includes('Unexpected token')) {
|
|
1158
|
-
return false;
|
|
1159
|
-
}
|
|
1160
|
-
return false;
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
/**
|
|
1165
|
-
* Removes Markdown formatting tags from a string.
|
|
1166
|
-
*
|
|
1167
|
-
* @param {string} str - The string to remove Markdown tags from.
|
|
1168
|
-
* @returns {string} The input string with all Markdown tags removed.
|
|
1169
|
-
*/
|
|
1170
|
-
function removeMarkdownFormatting(str) {
|
|
1171
|
-
// Remove bold formatting
|
|
1172
|
-
str = str.replace(/\*\*(.*?)\*\*/g, '$1');
|
|
1173
|
-
// Remove italic formatting
|
|
1174
|
-
str = str.replace(/\*(.*?)\*/g, '$1');
|
|
1175
|
-
// Remove code formatting
|
|
1176
|
-
str = str.replace(/`(.*?)`/g, '$1');
|
|
1177
|
-
return str;
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
/* tslint:disable */
|
|
1181
|
-
/*
|
|
1182
|
-
TODO: Tests
|
|
1183
|
-
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
|
|
1184
|
-
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ěščřžžýáíúů' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
|
|
1185
|
-
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
|
|
1186
|
-
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
|
|
1187
|
-
*/
|
|
1188
|
-
function normalizeTo_SCREAMING_CASE(sentence) {
|
|
1189
|
-
var e_1, _a;
|
|
1190
|
-
var charType;
|
|
1191
|
-
var lastCharType = 'OTHER';
|
|
1192
|
-
var normalizedName = '';
|
|
1193
|
-
try {
|
|
1194
|
-
for (var sentence_1 = __values(sentence), sentence_1_1 = sentence_1.next(); !sentence_1_1.done; sentence_1_1 = sentence_1.next()) {
|
|
1195
|
-
var char = sentence_1_1.value;
|
|
1196
|
-
var normalizedChar = void 0;
|
|
1197
|
-
if (/^[a-z]$/.test(char)) {
|
|
1198
|
-
charType = 'LOWERCASE';
|
|
1199
|
-
normalizedChar = char.toUpperCase();
|
|
1200
|
-
}
|
|
1201
|
-
else if (/^[A-Z]$/.test(char)) {
|
|
1202
|
-
charType = 'UPPERCASE';
|
|
1203
|
-
normalizedChar = char;
|
|
1204
|
-
}
|
|
1205
|
-
else if (/^[0-9]$/.test(char)) {
|
|
1206
|
-
charType = 'NUMBER';
|
|
1207
|
-
normalizedChar = char;
|
|
1208
|
-
}
|
|
1209
|
-
else if (/^\/$/.test(char)) {
|
|
1210
|
-
charType = 'SLASH';
|
|
1211
|
-
normalizedChar = char;
|
|
1212
|
-
}
|
|
1213
|
-
else {
|
|
1214
|
-
charType = 'OTHER';
|
|
1215
|
-
normalizedChar = '_';
|
|
1216
|
-
}
|
|
1217
|
-
if (charType !== lastCharType &&
|
|
1218
|
-
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
1219
|
-
!(lastCharType === 'NUMBER') &&
|
|
1220
|
-
!(charType === 'NUMBER')) {
|
|
1221
|
-
normalizedName += '_';
|
|
1222
|
-
}
|
|
1223
|
-
normalizedName += normalizedChar;
|
|
1224
|
-
lastCharType = charType;
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1228
|
-
finally {
|
|
1229
|
-
try {
|
|
1230
|
-
if (sentence_1_1 && !sentence_1_1.done && (_a = sentence_1.return)) _a.call(sentence_1);
|
|
1231
|
-
}
|
|
1232
|
-
finally { if (e_1) throw e_1.error; }
|
|
1233
|
-
}
|
|
1234
|
-
normalizedName = normalizedName.replace(/_+/g, '_');
|
|
1235
|
-
normalizedName = normalizedName.replace(/_?\/_?/g, '/');
|
|
1236
|
-
normalizedName = normalizedName.replace(/^_/, '');
|
|
1237
|
-
normalizedName = normalizedName.replace(/_$/, '');
|
|
1238
|
-
return normalizedName;
|
|
1239
|
-
}
|
|
1240
|
-
/**
|
|
1241
|
-
* TODO: [🌺] Use some intermediate util splitWords
|
|
1242
|
-
*/
|
|
1243
|
-
|
|
1244
|
-
/* tslint:disable */
|
|
1245
|
-
function normalizeToKebabCase(sentence) {
|
|
1246
|
-
var e_1, _a;
|
|
1247
|
-
sentence = removeDiacritics(sentence);
|
|
1248
|
-
var charType;
|
|
1249
|
-
var lastCharType = 'OTHER';
|
|
1250
|
-
var normalizedName = '';
|
|
1251
|
-
try {
|
|
1252
|
-
for (var sentence_1 = __values(sentence), sentence_1_1 = sentence_1.next(); !sentence_1_1.done; sentence_1_1 = sentence_1.next()) {
|
|
1253
|
-
var char = sentence_1_1.value;
|
|
1254
|
-
var normalizedChar = void 0;
|
|
1255
|
-
if (/^[a-z]$/.test(char)) {
|
|
1256
|
-
charType = 'LOWERCASE';
|
|
1257
|
-
normalizedChar = char;
|
|
1258
|
-
}
|
|
1259
|
-
else if (/^[A-Z]$/.test(char)) {
|
|
1260
|
-
charType = 'UPPERCASE';
|
|
1261
|
-
normalizedChar = char.toLowerCase();
|
|
1262
|
-
}
|
|
1263
|
-
else if (/^[0-9]$/.test(char)) {
|
|
1264
|
-
charType = 'NUMBER';
|
|
1265
|
-
normalizedChar = char;
|
|
1266
|
-
}
|
|
1267
|
-
else if (/^\/$/.test(char)) {
|
|
1268
|
-
charType = 'SLASH';
|
|
1269
|
-
normalizedChar = char;
|
|
1270
|
-
}
|
|
1271
|
-
else {
|
|
1272
|
-
charType = 'OTHER';
|
|
1273
|
-
normalizedChar = '-';
|
|
1274
|
-
}
|
|
1275
|
-
if (charType !== lastCharType &&
|
|
1276
|
-
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
1277
|
-
!(lastCharType === 'NUMBER') &&
|
|
1278
|
-
!(charType === 'NUMBER')) {
|
|
1279
|
-
normalizedName += '-';
|
|
1280
|
-
}
|
|
1281
|
-
normalizedName += normalizedChar;
|
|
1282
|
-
lastCharType = charType;
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1286
|
-
finally {
|
|
1287
|
-
try {
|
|
1288
|
-
if (sentence_1_1 && !sentence_1_1.done && (_a = sentence_1.return)) _a.call(sentence_1);
|
|
1289
|
-
}
|
|
1290
|
-
finally { if (e_1) throw e_1.error; }
|
|
1291
|
-
}
|
|
1292
|
-
normalizedName = normalizedName.split(/-+/g).join('-');
|
|
1293
|
-
normalizedName = normalizedName.split(/-?\/-?/g).join('/');
|
|
1294
|
-
normalizedName = normalizedName.replace(/^-/, '');
|
|
1295
|
-
normalizedName = normalizedName.replace(/-$/, '');
|
|
1296
|
-
return normalizedName;
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
/* tslint:disable */
|
|
1300
|
-
function normalizeTo_camelCase(sentence, __firstLetterCapital) {
|
|
1301
|
-
var e_1, _a;
|
|
1302
|
-
if (__firstLetterCapital === void 0) { __firstLetterCapital = false; }
|
|
1303
|
-
var charType;
|
|
1304
|
-
var lastCharType = null;
|
|
1305
|
-
var normalizedName = '';
|
|
1306
|
-
try {
|
|
1307
|
-
for (var sentence_1 = __values(sentence), sentence_1_1 = sentence_1.next(); !sentence_1_1.done; sentence_1_1 = sentence_1.next()) {
|
|
1308
|
-
var char = sentence_1_1.value;
|
|
1309
|
-
var normalizedChar = void 0;
|
|
1310
|
-
if (/^[a-z]$/.test(char)) {
|
|
1311
|
-
charType = 'LOWERCASE';
|
|
1312
|
-
normalizedChar = char;
|
|
1313
|
-
}
|
|
1314
|
-
else if (/^[A-Z]$/.test(char)) {
|
|
1315
|
-
charType = 'UPPERCASE';
|
|
1316
|
-
normalizedChar = char.toLowerCase();
|
|
1317
|
-
}
|
|
1318
|
-
else if (/^[0-9]$/.test(char)) {
|
|
1319
|
-
charType = 'NUMBER';
|
|
1320
|
-
normalizedChar = char;
|
|
1321
|
-
}
|
|
1322
|
-
else {
|
|
1323
|
-
charType = 'OTHER';
|
|
1324
|
-
normalizedChar = '';
|
|
1325
|
-
}
|
|
1326
|
-
if (!lastCharType) {
|
|
1327
|
-
if (__firstLetterCapital) {
|
|
1328
|
-
normalizedChar = normalizedChar.toUpperCase(); //TODO: DRY
|
|
1329
|
-
}
|
|
1330
|
-
}
|
|
1331
|
-
else if (charType !== lastCharType &&
|
|
1332
|
-
!(charType === 'LOWERCASE' && lastCharType === 'UPPERCASE') &&
|
|
1333
|
-
!(lastCharType === 'NUMBER') &&
|
|
1334
|
-
!(charType === 'NUMBER')) {
|
|
1335
|
-
normalizedChar = normalizedChar.toUpperCase(); //TODO: [🌺] DRY
|
|
1336
|
-
}
|
|
1337
|
-
normalizedName += normalizedChar;
|
|
1338
|
-
lastCharType = charType;
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1342
|
-
finally {
|
|
1343
|
-
try {
|
|
1344
|
-
if (sentence_1_1 && !sentence_1_1.done && (_a = sentence_1.return)) _a.call(sentence_1);
|
|
1345
|
-
}
|
|
1346
|
-
finally { if (e_1) throw e_1.error; }
|
|
1347
|
-
}
|
|
1348
|
-
return normalizedName;
|
|
1349
|
-
}
|
|
1350
|
-
/**
|
|
1351
|
-
* TODO: [🌺] Use some intermediate util splitWords
|
|
1352
|
-
*/
|
|
1353
|
-
|
|
1354
|
-
/**
|
|
1355
|
-
* Execution type describes the way how the block is executed
|
|
1356
|
-
*
|
|
1357
|
-
* @see https://github.com/webgptorg/promptbook#execution-type
|
|
1358
|
-
*/
|
|
1359
|
-
var ExecutionTypes = [
|
|
1360
|
-
'PROMPT_TEMPLATE',
|
|
1361
|
-
'SIMPLE_TEMPLATE',
|
|
1362
|
-
'SCRIPT',
|
|
1363
|
-
'PROMPT_DIALOG',
|
|
1364
|
-
// <- [🥻] Insert here when making new command
|
|
1365
|
-
];
|
|
1366
|
-
|
|
1367
|
-
/**
|
|
1368
|
-
* Units of text measurement
|
|
1369
|
-
*/
|
|
1370
|
-
var EXPECTATION_UNITS = ['CHARACTERS', 'WORDS', 'SENTENCES', 'LINES', 'PARAGRAPHS', 'PAGES'];
|
|
1371
|
-
/**
|
|
1372
|
-
* TODO: [💝] Unite object for expecting amount and format - remove expectFormat
|
|
1373
|
-
* TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
|
|
1374
|
-
* TODO: [👙][🧠] Just selecting gpt3 or gpt4 level of model
|
|
1375
|
-
*/
|
|
1376
|
-
|
|
1377
|
-
/**
|
|
1378
|
-
* Parses one line of ul/ol to command
|
|
1379
|
-
*
|
|
1380
|
-
* @returns parsed command object
|
|
1381
|
-
* @throws {PromptbookSyntaxError} if the command is invalid
|
|
1382
|
-
*
|
|
1383
|
-
* @private within the promptbookStringToJson
|
|
1384
|
-
*/
|
|
1385
|
-
function parseCommand(listItem) {
|
|
1386
|
-
var e_1, _a;
|
|
1387
|
-
if (listItem.includes('\n') || listItem.includes('\r')) {
|
|
1388
|
-
throw new PromptbookSyntaxError('Command can not contain new line characters:');
|
|
1389
|
-
}
|
|
1390
|
-
var type = listItem.trim();
|
|
1391
|
-
type = type.split('`').join('');
|
|
1392
|
-
type = type.split('"').join('');
|
|
1393
|
-
type = type.split("'").join('');
|
|
1394
|
-
type = type.split('~').join('');
|
|
1395
|
-
type = type.split('[').join('');
|
|
1396
|
-
type = type.split(']').join('');
|
|
1397
|
-
type = type.split('(').join('');
|
|
1398
|
-
type = type.split(')').join('');
|
|
1399
|
-
type = normalizeTo_SCREAMING_CASE(type);
|
|
1400
|
-
type = type.split('DIALOGUE').join('DIALOG');
|
|
1401
|
-
var listItemParts = listItem
|
|
1402
|
-
.split(' ')
|
|
1403
|
-
.map(function (part) { return part.trim(); })
|
|
1404
|
-
.filter(function (item) { return item !== ''; })
|
|
1405
|
-
.filter(function (item) { return !/^PTBK$/i.test(item); })
|
|
1406
|
-
.filter(function (item) { return !/^PROMPTBOOK$/i.test(item); })
|
|
1407
|
-
.map(removeMarkdownFormatting);
|
|
1408
|
-
if (type.startsWith('URL') ||
|
|
1409
|
-
type.startsWith('PTBK_URL') ||
|
|
1410
|
-
type.startsWith('PTBKURL') ||
|
|
1411
|
-
type.startsWith('PROMPTBOOK_URL') ||
|
|
1412
|
-
type.startsWith('PROMPTBOOKURL') ||
|
|
1413
|
-
type.startsWith('HTTPS')) {
|
|
1414
|
-
if (!(listItemParts.length === 2 || (listItemParts.length === 1 && type.startsWith('HTTPS')))) {
|
|
1415
|
-
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n ")));
|
|
1416
|
-
}
|
|
1417
|
-
var promptbookUrlString = listItemParts.pop();
|
|
1418
|
-
var promptbookUrl = new URL(promptbookUrlString);
|
|
1419
|
-
if (promptbookUrl.protocol !== 'https:') {
|
|
1420
|
-
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n Protocol must be HTTPS\n ")));
|
|
1421
|
-
}
|
|
1422
|
-
if (promptbookUrl.hash !== '') {
|
|
1423
|
-
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n URL must not contain hash\n Hash is used for identification of the prompt template in the pipeline\n ")));
|
|
1424
|
-
}
|
|
1425
|
-
return {
|
|
1426
|
-
type: 'PROMPTBOOK_URL',
|
|
1427
|
-
promptbookUrl: promptbookUrl,
|
|
1428
|
-
};
|
|
1429
|
-
}
|
|
1430
|
-
else if (type.startsWith('PROMPTBOOK_VERSION') || type.startsWith('PTBK_VERSION')) {
|
|
1431
|
-
if (listItemParts.length !== 2) {
|
|
1432
|
-
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid PROMPTBOOK_VERSION command:\n\n - ".concat(listItem, "\n ")));
|
|
1433
|
-
}
|
|
1434
|
-
var promptbookVersion = listItemParts.pop();
|
|
1435
|
-
// TODO: Validate version
|
|
1436
|
-
return {
|
|
1437
|
-
type: 'PROMPTBOOK_VERSION',
|
|
1438
|
-
promptbookVersion: promptbookVersion,
|
|
1439
|
-
};
|
|
1440
|
-
}
|
|
1441
|
-
else if (type.startsWith('EXECUTE') ||
|
|
1442
|
-
type.startsWith('EXEC') ||
|
|
1443
|
-
type.startsWith('PROMPT_DIALOG') ||
|
|
1444
|
-
type.startsWith('SIMPLE_TEMPLATE')) {
|
|
1445
|
-
var executionTypes = ExecutionTypes.filter(function (executionType) { return type.includes(executionType); });
|
|
1446
|
-
if (executionTypes.length !== 1) {
|
|
1447
|
-
throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Unknown execution type in command:\n\n - ".concat(listItem, "\n\n Supported execution types are:\n ").concat(block(ExecutionTypes.join(', ')), "\n "); }));
|
|
1448
|
-
}
|
|
1449
|
-
return {
|
|
1450
|
-
type: 'EXECUTE',
|
|
1451
|
-
executionType: executionTypes[0],
|
|
1452
|
-
};
|
|
1204
|
+
* Map of letters from diacritic variant to diacritless variant
|
|
1205
|
+
* Contains lowercase and uppercase separatelly
|
|
1206
|
+
*
|
|
1207
|
+
* > "á" => "a"
|
|
1208
|
+
* > "ě" => "e"
|
|
1209
|
+
* > "Ă" => "A"
|
|
1210
|
+
* > ...
|
|
1211
|
+
*/
|
|
1212
|
+
var DIACRITIC_VARIANTS_LETTERS = {};
|
|
1213
|
+
// tslint:disable-next-line: prefer-for-of
|
|
1214
|
+
for (var i = 0; i < defaultDiacriticsRemovalMap.length; i++) {
|
|
1215
|
+
var letters = defaultDiacriticsRemovalMap[i].letters;
|
|
1216
|
+
// tslint:disable-next-line: prefer-for-of
|
|
1217
|
+
for (var j = 0; j < letters.length; j++) {
|
|
1218
|
+
DIACRITIC_VARIANTS_LETTERS[letters[j]] = defaultDiacriticsRemovalMap[i].base;
|
|
1453
1219
|
}
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1220
|
+
}
|
|
1221
|
+
// <- TODO: [🍓] Put to maker function to save execution time if not needed
|
|
1222
|
+
/*
|
|
1223
|
+
@see https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript
|
|
1224
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
1225
|
+
you may not use this file except in compliance with the License.
|
|
1226
|
+
You may obtain a copy of the License at
|
|
1227
|
+
|
|
1228
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
1229
|
+
|
|
1230
|
+
Unless required by applicable law or agreed to in writing, software
|
|
1231
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
1232
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1233
|
+
See the License for the specific language governing permissions and
|
|
1234
|
+
limitations under the License.
|
|
1235
|
+
*/
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
*
|
|
1239
|
+
*/
|
|
1240
|
+
function removeDiacritics(input) {
|
|
1241
|
+
/*eslint no-control-regex: "off"*/
|
|
1242
|
+
return input.replace(/[^\u0000-\u007E]/g, function (a) {
|
|
1243
|
+
return DIACRITIC_VARIANTS_LETTERS[a] || a;
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
/* tslint:disable */
|
|
1248
|
+
function normalizeToKebabCase(sentence) {
|
|
1249
|
+
var e_1, _a;
|
|
1250
|
+
sentence = removeDiacritics(sentence);
|
|
1251
|
+
var charType;
|
|
1252
|
+
var lastCharType = 'OTHER';
|
|
1253
|
+
var normalizedName = '';
|
|
1254
|
+
try {
|
|
1255
|
+
for (var sentence_1 = __values(sentence), sentence_1_1 = sentence_1.next(); !sentence_1_1.done; sentence_1_1 = sentence_1.next()) {
|
|
1256
|
+
var char = sentence_1_1.value;
|
|
1257
|
+
var normalizedChar = void 0;
|
|
1258
|
+
if (/^[a-z]$/.test(char)) {
|
|
1259
|
+
charType = 'LOWERCASE';
|
|
1260
|
+
normalizedChar = char;
|
|
1473
1261
|
}
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
type: 'MODEL',
|
|
1478
|
-
key: 'modelName',
|
|
1479
|
-
value: listItemParts.pop(),
|
|
1480
|
-
};
|
|
1481
|
-
}
|
|
1482
|
-
else {
|
|
1483
|
-
throw new PromptbookSyntaxError(spaceTrim.spaceTrim(function (block) { return "\n Unknown model key in command:\n\n - ".concat(listItem, "\n\n Supported model keys are:\n ").concat(block(['variant', 'name'].join(', ')), "\n\n Example:\n\n - MODEL VARIANT Chat\n - MODEL NAME gpt-4\n "); }));
|
|
1484
|
-
}
|
|
1485
|
-
}
|
|
1486
|
-
else if (type.startsWith('PARAM') ||
|
|
1487
|
-
type.startsWith('INPUT_PARAM') ||
|
|
1488
|
-
type.startsWith('OUTPUT_PARAM') ||
|
|
1489
|
-
listItem.startsWith('{') ||
|
|
1490
|
-
listItem.startsWith('> {') /* <- Note: This is a bit hack to parse return parameters defined at the end of each section */) {
|
|
1491
|
-
var parametersMatch = listItem.match(/\{(?<parameterName>[a-z0-9_]+)\}[^\S\r\n]*(?<parameterDescription>.*)$/im);
|
|
1492
|
-
if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
|
|
1493
|
-
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
|
|
1494
|
-
}
|
|
1495
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1496
|
-
var _b = parametersMatch.groups, parameterName = _b.parameterName, parameterDescription = _b.parameterDescription;
|
|
1497
|
-
if (parameterDescription && parameterDescription.match(/\{(?<parameterName>[a-z0-9_]+)\}/im)) {
|
|
1498
|
-
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Parameter {".concat(parameterName, "} can not contain another parameter in description:\n\n - ").concat(listItem, "\n ")));
|
|
1499
|
-
}
|
|
1500
|
-
var isInput = type.startsWith('INPUT');
|
|
1501
|
-
var isOutput = type.startsWith('OUTPUT');
|
|
1502
|
-
if (listItem.startsWith('> {')) {
|
|
1503
|
-
isInput = false;
|
|
1504
|
-
isOutput = false;
|
|
1505
|
-
}
|
|
1506
|
-
return {
|
|
1507
|
-
type: 'PARAMETER',
|
|
1508
|
-
parameterName: parameterName,
|
|
1509
|
-
parameterDescription: parameterDescription.trim() || null,
|
|
1510
|
-
isInput: isInput,
|
|
1511
|
-
isOutput: isOutput,
|
|
1512
|
-
};
|
|
1513
|
-
}
|
|
1514
|
-
else if (type.startsWith('JOKER')) {
|
|
1515
|
-
if (listItemParts.length !== 2) {
|
|
1516
|
-
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid JOKER command:\n\n - ".concat(listItem, "\n ")));
|
|
1517
|
-
}
|
|
1518
|
-
var parametersMatch = (listItemParts.pop() || '').match(/^\{(?<parameterName>[a-z0-9_]+)\}$/im);
|
|
1519
|
-
if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
|
|
1520
|
-
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
|
|
1521
|
-
}
|
|
1522
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1523
|
-
var parameterName = parametersMatch.groups.parameterName;
|
|
1524
|
-
return {
|
|
1525
|
-
type: 'JOKER',
|
|
1526
|
-
parameterName: parameterName,
|
|
1527
|
-
};
|
|
1528
|
-
}
|
|
1529
|
-
else if (type.startsWith('POSTPROCESS') || type.startsWith('POST_PROCESS')) {
|
|
1530
|
-
if (listItemParts.length !== 2) {
|
|
1531
|
-
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Invalid POSTPROCESSING command:\n\n - ".concat(listItem, "\n ")));
|
|
1532
|
-
}
|
|
1533
|
-
var functionName = listItemParts.pop();
|
|
1534
|
-
return {
|
|
1535
|
-
type: 'POSTPROCESS',
|
|
1536
|
-
functionName: functionName,
|
|
1537
|
-
};
|
|
1538
|
-
}
|
|
1539
|
-
else if (type.startsWith('EXPECT_JSON')) {
|
|
1540
|
-
return {
|
|
1541
|
-
type: 'EXPECT_FORMAT',
|
|
1542
|
-
format: 'JSON',
|
|
1543
|
-
};
|
|
1544
|
-
// [🥤]
|
|
1545
|
-
}
|
|
1546
|
-
else if (type.startsWith('EXPECT')) {
|
|
1547
|
-
try {
|
|
1548
|
-
listItemParts.shift();
|
|
1549
|
-
var sign = void 0;
|
|
1550
|
-
var signRaw = listItemParts.shift();
|
|
1551
|
-
if (/^exact/i.test(signRaw)) {
|
|
1552
|
-
sign = 'EXACTLY';
|
|
1262
|
+
else if (/^[A-Z]$/.test(char)) {
|
|
1263
|
+
charType = 'UPPERCASE';
|
|
1264
|
+
normalizedChar = char.toLowerCase();
|
|
1553
1265
|
}
|
|
1554
|
-
else if (/^
|
|
1555
|
-
|
|
1266
|
+
else if (/^[0-9]$/.test(char)) {
|
|
1267
|
+
charType = 'NUMBER';
|
|
1268
|
+
normalizedChar = char;
|
|
1556
1269
|
}
|
|
1557
|
-
else if (
|
|
1558
|
-
|
|
1270
|
+
else if (/^\/$/.test(char)) {
|
|
1271
|
+
charType = 'SLASH';
|
|
1272
|
+
normalizedChar = char;
|
|
1559
1273
|
}
|
|
1560
1274
|
else {
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
var amountRaw = listItemParts.shift();
|
|
1564
|
-
var amount = parseNumber(amountRaw);
|
|
1565
|
-
if (amount < 0) {
|
|
1566
|
-
throw new PromptbookSyntaxError('Amount must be positive number or zero');
|
|
1567
|
-
}
|
|
1568
|
-
if (amount !== Math.floor(amount)) {
|
|
1569
|
-
throw new PromptbookSyntaxError('Amount must be whole number');
|
|
1570
|
-
}
|
|
1571
|
-
var unitRaw = listItemParts.shift();
|
|
1572
|
-
var unit = undefined;
|
|
1573
|
-
try {
|
|
1574
|
-
for (var EXPECTATION_UNITS_1 = __values(EXPECTATION_UNITS), EXPECTATION_UNITS_1_1 = EXPECTATION_UNITS_1.next(); !EXPECTATION_UNITS_1_1.done; EXPECTATION_UNITS_1_1 = EXPECTATION_UNITS_1.next()) {
|
|
1575
|
-
var existingUnit = EXPECTATION_UNITS_1_1.value;
|
|
1576
|
-
var existingUnitText = existingUnit;
|
|
1577
|
-
existingUnitText = existingUnitText.substring(0, existingUnitText.length - 1);
|
|
1578
|
-
if (existingUnitText === 'CHARACTER') {
|
|
1579
|
-
existingUnitText = 'CHAR';
|
|
1580
|
-
}
|
|
1581
|
-
if (new RegExp("^".concat(existingUnitText.toLowerCase())).test(unitRaw.toLowerCase()) ||
|
|
1582
|
-
new RegExp("^".concat(unitRaw.toLowerCase())).test(existingUnitText.toLowerCase())) {
|
|
1583
|
-
if (unit !== undefined) {
|
|
1584
|
-
throw new PromptbookSyntaxError("Ambiguous unit \"".concat(unitRaw, "\""));
|
|
1585
|
-
}
|
|
1586
|
-
unit = existingUnit;
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1591
|
-
finally {
|
|
1592
|
-
try {
|
|
1593
|
-
if (EXPECTATION_UNITS_1_1 && !EXPECTATION_UNITS_1_1.done && (_a = EXPECTATION_UNITS_1.return)) _a.call(EXPECTATION_UNITS_1);
|
|
1594
|
-
}
|
|
1595
|
-
finally { if (e_1) throw e_1.error; }
|
|
1596
|
-
}
|
|
1597
|
-
if (unit === undefined) {
|
|
1598
|
-
throw new PromptbookSyntaxError("Invalid unit \"".concat(unitRaw, "\""));
|
|
1275
|
+
charType = 'OTHER';
|
|
1276
|
+
normalizedChar = '-';
|
|
1599
1277
|
}
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
};
|
|
1606
|
-
}
|
|
1607
|
-
catch (error) {
|
|
1608
|
-
if (!(error instanceof Error)) {
|
|
1609
|
-
throw error;
|
|
1278
|
+
if (charType !== lastCharType &&
|
|
1279
|
+
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
1280
|
+
!(lastCharType === 'NUMBER') &&
|
|
1281
|
+
!(charType === 'NUMBER')) {
|
|
1282
|
+
normalizedName += '-';
|
|
1610
1283
|
}
|
|
1611
|
-
|
|
1284
|
+
normalizedName += normalizedChar;
|
|
1285
|
+
lastCharType = charType;
|
|
1612
1286
|
}
|
|
1613
|
-
/*
|
|
1614
|
-
} else if (type.startsWith('__________________')) {
|
|
1615
|
-
// <- [🥻] Insert here when making new command
|
|
1616
|
-
*/
|
|
1617
1287
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1288
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1289
|
+
finally {
|
|
1290
|
+
try {
|
|
1291
|
+
if (sentence_1_1 && !sentence_1_1.done && (_a = sentence_1.return)) _a.call(sentence_1);
|
|
1292
|
+
}
|
|
1293
|
+
finally { if (e_1) throw e_1.error; }
|
|
1620
1294
|
}
|
|
1295
|
+
normalizedName = normalizedName.split(/-+/g).join('-');
|
|
1296
|
+
normalizedName = normalizedName.split(/-?\/-?/g).join('/');
|
|
1297
|
+
normalizedName = normalizedName.replace(/^-/, '');
|
|
1298
|
+
normalizedName = normalizedName.replace(/-$/, '');
|
|
1299
|
+
return normalizedName;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
/**
|
|
1303
|
+
* Removes emojis from a string and fix whitespaces
|
|
1304
|
+
*
|
|
1305
|
+
* @param text with emojis
|
|
1306
|
+
* @returns text without emojis
|
|
1307
|
+
*/
|
|
1308
|
+
function removeEmojis(text) {
|
|
1309
|
+
// Replace emojis (and also ZWJ sequence) with hyphens
|
|
1310
|
+
text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
|
|
1311
|
+
text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
|
|
1312
|
+
text = text.replace(/(\p{Extended_Pictographic})(\u{200D}\p{Extended_Pictographic})*/gu, '$1');
|
|
1313
|
+
text = text.replace(/\p{Extended_Pictographic}/gu, '');
|
|
1314
|
+
return text;
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* Function normalizes title to name which can be used as identifier
|
|
1319
|
+
*/
|
|
1320
|
+
function titleToName(value) {
|
|
1321
|
+
value = removeEmojis(value);
|
|
1322
|
+
value = normalizeToKebabCase(value);
|
|
1323
|
+
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
1324
|
+
return value;
|
|
1621
1325
|
}
|
|
1622
1326
|
|
|
1623
1327
|
/**
|
|
@@ -1831,6 +1535,9 @@
|
|
|
1831
1535
|
postprocessing = undefined;
|
|
1832
1536
|
}
|
|
1833
1537
|
dependentParameterNames = union(dependentParameterNames, extractParametersFromPromptTemplate(__assign(__assign({}, section), { description: description_1, executionType: executionType, content: content })));
|
|
1538
|
+
if (templateModelRequirements.modelVariant === undefined) {
|
|
1539
|
+
templateModelRequirements.modelVariant = 'CHAT';
|
|
1540
|
+
}
|
|
1834
1541
|
promptbookJson.promptTemplates.push({
|
|
1835
1542
|
name: titleToName(section.title),
|
|
1836
1543
|
title: section.title,
|
|
@@ -1922,6 +1629,119 @@
|
|
|
1922
1629
|
}
|
|
1923
1630
|
}
|
|
1924
1631
|
|
|
1632
|
+
/* tslint:disable */
|
|
1633
|
+
function normalizeTo_camelCase(sentence, __firstLetterCapital) {
|
|
1634
|
+
var e_1, _a;
|
|
1635
|
+
if (__firstLetterCapital === void 0) { __firstLetterCapital = false; }
|
|
1636
|
+
var charType;
|
|
1637
|
+
var lastCharType = null;
|
|
1638
|
+
var normalizedName = '';
|
|
1639
|
+
try {
|
|
1640
|
+
for (var sentence_1 = __values(sentence), sentence_1_1 = sentence_1.next(); !sentence_1_1.done; sentence_1_1 = sentence_1.next()) {
|
|
1641
|
+
var char = sentence_1_1.value;
|
|
1642
|
+
var normalizedChar = void 0;
|
|
1643
|
+
if (/^[a-z]$/.test(char)) {
|
|
1644
|
+
charType = 'LOWERCASE';
|
|
1645
|
+
normalizedChar = char;
|
|
1646
|
+
}
|
|
1647
|
+
else if (/^[A-Z]$/.test(char)) {
|
|
1648
|
+
charType = 'UPPERCASE';
|
|
1649
|
+
normalizedChar = char.toLowerCase();
|
|
1650
|
+
}
|
|
1651
|
+
else if (/^[0-9]$/.test(char)) {
|
|
1652
|
+
charType = 'NUMBER';
|
|
1653
|
+
normalizedChar = char;
|
|
1654
|
+
}
|
|
1655
|
+
else {
|
|
1656
|
+
charType = 'OTHER';
|
|
1657
|
+
normalizedChar = '';
|
|
1658
|
+
}
|
|
1659
|
+
if (!lastCharType) {
|
|
1660
|
+
if (__firstLetterCapital) {
|
|
1661
|
+
normalizedChar = normalizedChar.toUpperCase(); //TODO: DRY
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
else if (charType !== lastCharType &&
|
|
1665
|
+
!(charType === 'LOWERCASE' && lastCharType === 'UPPERCASE') &&
|
|
1666
|
+
!(lastCharType === 'NUMBER') &&
|
|
1667
|
+
!(charType === 'NUMBER')) {
|
|
1668
|
+
normalizedChar = normalizedChar.toUpperCase(); //TODO: [🌺] DRY
|
|
1669
|
+
}
|
|
1670
|
+
normalizedName += normalizedChar;
|
|
1671
|
+
lastCharType = charType;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1675
|
+
finally {
|
|
1676
|
+
try {
|
|
1677
|
+
if (sentence_1_1 && !sentence_1_1.done && (_a = sentence_1.return)) _a.call(sentence_1);
|
|
1678
|
+
}
|
|
1679
|
+
finally { if (e_1) throw e_1.error; }
|
|
1680
|
+
}
|
|
1681
|
+
return normalizedName;
|
|
1682
|
+
}
|
|
1683
|
+
/**
|
|
1684
|
+
* TODO: [🌺] Use some intermediate util splitWords
|
|
1685
|
+
*/
|
|
1686
|
+
|
|
1687
|
+
/**
|
|
1688
|
+
* Creates a Mermaid graph based on the promptbook
|
|
1689
|
+
*
|
|
1690
|
+
* Note: The result is not wrapped in a Markdown code block
|
|
1691
|
+
*/
|
|
1692
|
+
function renderPromptbookMermaid(promptbookJson, options) {
|
|
1693
|
+
var _a = (options || {}).linkPromptTemplate, linkPromptTemplate = _a === void 0 ? function () { return null; } : _a;
|
|
1694
|
+
var parameterNameToTemplateName = function (parameterName) {
|
|
1695
|
+
var parameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
1696
|
+
if (!parameter) {
|
|
1697
|
+
throw new UnexpectedError("Could not find {".concat(parameterName, "}"));
|
|
1698
|
+
}
|
|
1699
|
+
if (parameter.isInput) {
|
|
1700
|
+
return 'input';
|
|
1701
|
+
}
|
|
1702
|
+
var template = promptbookJson.promptTemplates.find(function (template) { return template.resultingParameterName === parameterName; });
|
|
1703
|
+
if (!template) {
|
|
1704
|
+
throw new Error("Could not find template for {".concat(parameterName, "}"));
|
|
1705
|
+
}
|
|
1706
|
+
return normalizeTo_camelCase('template-' + titleToName(template.title));
|
|
1707
|
+
};
|
|
1708
|
+
var promptbookMermaid = spaceTrim.spaceTrim(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(promptbookJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(promptbookJson.promptTemplates
|
|
1709
|
+
.flatMap(function (_a) {
|
|
1710
|
+
var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
|
|
1711
|
+
return __spreadArray([
|
|
1712
|
+
"".concat(parameterNameToTemplateName(resultingParameterName), "(\"").concat(title, "\")")
|
|
1713
|
+
], __read(dependentParameterNames.map(function (dependentParameterName) {
|
|
1714
|
+
return "".concat(parameterNameToTemplateName(dependentParameterName), "--\"{").concat(dependentParameterName, "}\"-->").concat(parameterNameToTemplateName(resultingParameterName));
|
|
1715
|
+
})), false);
|
|
1716
|
+
})
|
|
1717
|
+
.join('\n')), "\n\n ").concat(block(promptbookJson.parameters
|
|
1718
|
+
.filter(function (_a) {
|
|
1719
|
+
var isOutput = _a.isOutput;
|
|
1720
|
+
return isOutput;
|
|
1721
|
+
})
|
|
1722
|
+
.map(function (_a) {
|
|
1723
|
+
var name = _a.name;
|
|
1724
|
+
return "".concat(parameterNameToTemplateName(name), "--\"{").concat(name, "}\"-->output");
|
|
1725
|
+
})
|
|
1726
|
+
.join('\n')), "\n output((Output)):::output\n\n ").concat(block(promptbookJson.promptTemplates
|
|
1727
|
+
.map(function (promptTemplate) {
|
|
1728
|
+
var link = linkPromptTemplate(promptTemplate);
|
|
1729
|
+
if (link === null) {
|
|
1730
|
+
return '';
|
|
1731
|
+
}
|
|
1732
|
+
var href = link.href, title = link.title;
|
|
1733
|
+
var templateName = parameterNameToTemplateName(promptTemplate.resultingParameterName);
|
|
1734
|
+
return "click ".concat(templateName, " href \"").concat(href, "\" \"").concat(title, "\";");
|
|
1735
|
+
})
|
|
1736
|
+
.filter(function (line) { return line !== ''; })
|
|
1737
|
+
.join('\n')), "\n\n classDef input color: grey;\n classDef output color: grey;\n\n end;\n\n "); });
|
|
1738
|
+
return promptbookMermaid;
|
|
1739
|
+
}
|
|
1740
|
+
/**
|
|
1741
|
+
* TODO: Maybe use some Mermaid library instead of string templating
|
|
1742
|
+
* TODO: [🕌] When more than 2 functionalities, split into separate functions
|
|
1743
|
+
*/
|
|
1744
|
+
|
|
1925
1745
|
/**
|
|
1926
1746
|
* Prettyfies Promptbook string and adds Mermaid graph
|
|
1927
1747
|
*/
|
|
@@ -2136,6 +1956,20 @@
|
|
|
2136
1956
|
* TODO: Escape all
|
|
2137
1957
|
*/
|
|
2138
1958
|
|
|
1959
|
+
/**
|
|
1960
|
+
* This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
|
|
1961
|
+
*/
|
|
1962
|
+
var PromptbookLogicError = /** @class */ (function (_super) {
|
|
1963
|
+
__extends(PromptbookLogicError, _super);
|
|
1964
|
+
function PromptbookLogicError(message) {
|
|
1965
|
+
var _this = _super.call(this, message) || this;
|
|
1966
|
+
_this.name = 'PromptbookLogicError';
|
|
1967
|
+
Object.setPrototypeOf(_this, PromptbookLogicError.prototype);
|
|
1968
|
+
return _this;
|
|
1969
|
+
}
|
|
1970
|
+
return PromptbookLogicError;
|
|
1971
|
+
}(Error));
|
|
1972
|
+
|
|
2139
1973
|
/**
|
|
2140
1974
|
* Tests if given string is valid URL.
|
|
2141
1975
|
*
|
|
@@ -2176,6 +2010,7 @@
|
|
|
2176
2010
|
* @throws {PromptbookLogicError} on logical error in the promptbook
|
|
2177
2011
|
*/
|
|
2178
2012
|
function validatePromptbookJson(promptbook) {
|
|
2013
|
+
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
2179
2014
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
2180
2015
|
if (promptbook.promptbookUrl !== undefined) {
|
|
2181
2016
|
if (!isValidUrl(promptbook.promptbookUrl)) {
|
|
@@ -2183,6 +2018,16 @@
|
|
|
2183
2018
|
throw new PromptbookLogicError("Invalid promptbook URL \"".concat(promptbook.promptbookUrl, "\""));
|
|
2184
2019
|
}
|
|
2185
2020
|
}
|
|
2021
|
+
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
2022
|
+
if (!Array.isArray(promptbook.parameters)) {
|
|
2023
|
+
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2024
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Promptbook is valid JSON but with wrong structure\n\n promptbook.parameters expected to be an array, but got ".concat(typeof promptbook.parameters, "\n ")));
|
|
2025
|
+
}
|
|
2026
|
+
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
2027
|
+
if (!Array.isArray(promptbook.promptTemplates)) {
|
|
2028
|
+
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2029
|
+
throw new PromptbookSyntaxError(spaceTrim.spaceTrim("\n Promptbook is valid JSON but with wrong structure\n\n promptbook.promptTemplates expected to be an array, but got ".concat(typeof promptbook.promptTemplates, "\n ")));
|
|
2030
|
+
}
|
|
2186
2031
|
var _loop_1 = function (parameter) {
|
|
2187
2032
|
if (parameter.isInput && parameter.isOutput) {
|
|
2188
2033
|
throw new PromptbookLogicError("Parameter {".concat(parameter.name, "} can not be both input and output"));
|
|
@@ -2229,9 +2074,8 @@
|
|
|
2229
2074
|
}
|
|
2230
2075
|
definedParameters.add(template.resultingParameterName);
|
|
2231
2076
|
if (template.executionType === 'PROMPT_TEMPLATE' &&
|
|
2232
|
-
(template.modelRequirements.modelVariant === undefined
|
|
2233
|
-
|
|
2234
|
-
throw new PromptbookLogicError(spaceTrim.spaceTrim("\n\n You must specify MODEL VARIANT and MODEL NAME in the prompt template \"".concat(template.title, "\"\n\n For example:\n - MODEL VARIANT Chat\n - MODEL NAME `gpt-4-1106-preview`\n\n ")));
|
|
2077
|
+
(template.modelRequirements.modelVariant === undefined)) {
|
|
2078
|
+
throw new PromptbookLogicError(spaceTrim.spaceTrim("\n\n You must specify MODEL VARIANT in the prompt template \"".concat(template.title, "\"\n\n For example:\n - MODEL VARIANT Chat\n - MODEL NAME `gpt-4-1106-preview`\n\n ")));
|
|
2235
2079
|
}
|
|
2236
2080
|
if (template.jokers && template.jokers.length > 0) {
|
|
2237
2081
|
if (!template.expectFormat &&
|
|
@@ -2339,60 +2183,153 @@
|
|
|
2339
2183
|
*/
|
|
2340
2184
|
|
|
2341
2185
|
/**
|
|
2342
|
-
* This error indicates errors during the execution of the promptbook
|
|
2186
|
+
* This error indicates errors during the execution of the promptbook
|
|
2187
|
+
*/
|
|
2188
|
+
var PromptbookExecutionError = /** @class */ (function (_super) {
|
|
2189
|
+
__extends(PromptbookExecutionError, _super);
|
|
2190
|
+
function PromptbookExecutionError(message) {
|
|
2191
|
+
var _this = _super.call(this, message) || this;
|
|
2192
|
+
_this.name = 'PromptbookExecutionError';
|
|
2193
|
+
Object.setPrototypeOf(_this, PromptbookExecutionError.prototype);
|
|
2194
|
+
return _this;
|
|
2195
|
+
}
|
|
2196
|
+
return PromptbookExecutionError;
|
|
2197
|
+
}(Error));
|
|
2198
|
+
|
|
2199
|
+
/**
|
|
2200
|
+
* Asserts that the execution of a promptnook is successful
|
|
2201
|
+
*
|
|
2202
|
+
* @param executionResult - The partial result of the promptnook execution
|
|
2203
|
+
* @throws {PromptbookExecutionError} If the execution is not successful or if multiple errors occurred
|
|
2204
|
+
*/
|
|
2205
|
+
function assertsExecutionSuccessful(executionResult) {
|
|
2206
|
+
var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
|
|
2207
|
+
if (isSuccessful === true) {
|
|
2208
|
+
return;
|
|
2209
|
+
}
|
|
2210
|
+
if (errors.length === 0) {
|
|
2211
|
+
throw new PromptbookExecutionError("Promptnook Execution failed because of unknown reason");
|
|
2212
|
+
}
|
|
2213
|
+
else if (errors.length === 1) {
|
|
2214
|
+
throw errors[0];
|
|
2215
|
+
}
|
|
2216
|
+
else {
|
|
2217
|
+
throw new PromptbookExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Multiple errors occurred during promptnook execution\n\n ".concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n')), "\n "); }));
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
/**
|
|
2221
|
+
* TODO: [🧠] Can this return type be better typed than void
|
|
2222
|
+
*/
|
|
2223
|
+
|
|
2224
|
+
/**
|
|
2225
|
+
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
2226
|
+
*
|
|
2227
|
+
* @private Always catched and rethrown as `PromptbookExecutionError`
|
|
2228
|
+
* Note: This is a kindof subtype of PromptbookExecutionError
|
|
2229
|
+
*/
|
|
2230
|
+
var ExpectError = /** @class */ (function (_super) {
|
|
2231
|
+
__extends(ExpectError, _super);
|
|
2232
|
+
function ExpectError(message) {
|
|
2233
|
+
var _this = _super.call(this, message) || this;
|
|
2234
|
+
_this.name = 'ExpectError';
|
|
2235
|
+
Object.setPrototypeOf(_this, ExpectError.prototype);
|
|
2236
|
+
return _this;
|
|
2237
|
+
}
|
|
2238
|
+
return ExpectError;
|
|
2239
|
+
}(Error));
|
|
2240
|
+
|
|
2241
|
+
/**
|
|
2242
|
+
* Function isValidJsonString will tell you if the string is valid JSON or not
|
|
2243
|
+
*/
|
|
2244
|
+
function isValidJsonString(value) {
|
|
2245
|
+
try {
|
|
2246
|
+
JSON.parse(value);
|
|
2247
|
+
return true;
|
|
2248
|
+
}
|
|
2249
|
+
catch (error) {
|
|
2250
|
+
if (!(error instanceof Error)) {
|
|
2251
|
+
throw error;
|
|
2252
|
+
}
|
|
2253
|
+
if (error.message.includes('Unexpected token')) {
|
|
2254
|
+
return false;
|
|
2255
|
+
}
|
|
2256
|
+
return false;
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
/**
|
|
2261
|
+
* Counts number of characters in the text
|
|
2262
|
+
*/
|
|
2263
|
+
function countCharacters(text) {
|
|
2264
|
+
// Remove null characters
|
|
2265
|
+
text = text.replace(/\0/g, '');
|
|
2266
|
+
// Replace emojis (and also ZWJ sequence) with hyphens
|
|
2267
|
+
text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
|
|
2268
|
+
text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
|
|
2269
|
+
text = text.replace(/\p{Extended_Pictographic}(\u{200D}\p{Extended_Pictographic})*/gu, '-');
|
|
2270
|
+
return text.length;
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
/**
|
|
2274
|
+
* Counts number of lines in the text
|
|
2275
|
+
*/
|
|
2276
|
+
function countLines(text) {
|
|
2277
|
+
if (text === '') {
|
|
2278
|
+
return 0;
|
|
2279
|
+
}
|
|
2280
|
+
return text.split('\n').length;
|
|
2281
|
+
}
|
|
2282
|
+
|
|
2283
|
+
/**
|
|
2284
|
+
* Counts number of pages in the text
|
|
2285
|
+
*/
|
|
2286
|
+
function countPages(text) {
|
|
2287
|
+
var sentencesPerPage = 5; // Assuming each page has 5 sentences
|
|
2288
|
+
var sentences = text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
|
|
2289
|
+
var pageCount = Math.ceil(sentences.length / sentencesPerPage);
|
|
2290
|
+
return pageCount;
|
|
2291
|
+
}
|
|
2292
|
+
|
|
2293
|
+
/**
|
|
2294
|
+
* Counts number of paragraphs in the text
|
|
2295
|
+
*/
|
|
2296
|
+
function countParagraphs(text) {
|
|
2297
|
+
return text.split(/\n\s*\n/).filter(function (paragraph) { return paragraph.trim() !== ''; }).length;
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
/**
|
|
2301
|
+
* Split text into sentences
|
|
2343
2302
|
*/
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
var _this = _super.call(this, message) || this;
|
|
2348
|
-
_this.name = 'PromptbookExecutionError';
|
|
2349
|
-
Object.setPrototypeOf(_this, PromptbookExecutionError.prototype);
|
|
2350
|
-
return _this;
|
|
2351
|
-
}
|
|
2352
|
-
return PromptbookExecutionError;
|
|
2353
|
-
}(Error));
|
|
2354
|
-
|
|
2303
|
+
function splitIntoSentences(text) {
|
|
2304
|
+
return text.split(/[.!?]+/).filter(function (sentence) { return sentence.trim() !== ''; });
|
|
2305
|
+
}
|
|
2355
2306
|
/**
|
|
2356
|
-
*
|
|
2357
|
-
*
|
|
2358
|
-
* @param executionResult - The partial result of the promptnook execution
|
|
2359
|
-
* @throws {PromptbookExecutionError} If the execution is not successful or if multiple errors occurred
|
|
2307
|
+
* Counts number of sentences in the text
|
|
2360
2308
|
*/
|
|
2361
|
-
function
|
|
2362
|
-
|
|
2363
|
-
if (isSuccessful === true) {
|
|
2364
|
-
return;
|
|
2365
|
-
}
|
|
2366
|
-
if (errors.length === 0) {
|
|
2367
|
-
throw new PromptbookExecutionError("Promptnook Execution failed because of unknown reason");
|
|
2368
|
-
}
|
|
2369
|
-
else if (errors.length === 1) {
|
|
2370
|
-
throw errors[0];
|
|
2371
|
-
}
|
|
2372
|
-
else {
|
|
2373
|
-
throw new PromptbookExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Multiple errors occurred during promptnook execution\n\n ".concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n')), "\n "); }));
|
|
2374
|
-
}
|
|
2309
|
+
function countSentences(text) {
|
|
2310
|
+
return splitIntoSentences(text).length;
|
|
2375
2311
|
}
|
|
2312
|
+
|
|
2376
2313
|
/**
|
|
2377
|
-
*
|
|
2314
|
+
* Counts number of words in the text
|
|
2378
2315
|
*/
|
|
2316
|
+
function countWords(text) {
|
|
2317
|
+
text = text.replace(/[\p{Extended_Pictographic}]/gu, 'a');
|
|
2318
|
+
text = removeDiacritics(text);
|
|
2319
|
+
return text.split(/[^a-zа-я0-9]+/i).filter(function (word) { return word.length > 0; }).length;
|
|
2320
|
+
}
|
|
2379
2321
|
|
|
2380
2322
|
/**
|
|
2381
|
-
*
|
|
2382
|
-
*
|
|
2383
|
-
* @private Always catched and rethrown as `PromptbookExecutionError`
|
|
2384
|
-
* Note: This is a kindof subtype of PromptbookExecutionError
|
|
2323
|
+
* Index of all counter functions
|
|
2385
2324
|
*/
|
|
2386
|
-
var
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
return ExpectError;
|
|
2395
|
-
}(Error));
|
|
2325
|
+
var CountUtils = {
|
|
2326
|
+
CHARACTERS: countCharacters,
|
|
2327
|
+
WORDS: countWords,
|
|
2328
|
+
SENTENCES: countSentences,
|
|
2329
|
+
PARAGRAPHS: countParagraphs,
|
|
2330
|
+
LINES: countLines,
|
|
2331
|
+
PAGES: countPages,
|
|
2332
|
+
};
|
|
2396
2333
|
|
|
2397
2334
|
/**
|
|
2398
2335
|
* Function checkExpectations will check if the expectations on given value are met
|
|
@@ -2451,6 +2388,82 @@
|
|
|
2451
2388
|
* TODO: [💝] Unite object for expecting amount and format
|
|
2452
2389
|
*/
|
|
2453
2390
|
|
|
2391
|
+
/**
|
|
2392
|
+
* This error occurs during the parameter replacement in the template
|
|
2393
|
+
*
|
|
2394
|
+
* Note: This is a kindof subtype of PromptbookExecutionError because it occurs during the execution of the pipeline
|
|
2395
|
+
*/
|
|
2396
|
+
var TemplateError = /** @class */ (function (_super) {
|
|
2397
|
+
__extends(TemplateError, _super);
|
|
2398
|
+
function TemplateError(message) {
|
|
2399
|
+
var _this = _super.call(this, message) || this;
|
|
2400
|
+
_this.name = 'TemplateError';
|
|
2401
|
+
Object.setPrototypeOf(_this, TemplateError.prototype);
|
|
2402
|
+
return _this;
|
|
2403
|
+
}
|
|
2404
|
+
return TemplateError;
|
|
2405
|
+
}(Error));
|
|
2406
|
+
|
|
2407
|
+
/**
|
|
2408
|
+
* Replaces parameters in template with values from parameters object
|
|
2409
|
+
*
|
|
2410
|
+
* @param template the template with parameters in {curly} braces
|
|
2411
|
+
* @param parameters the object with parameters
|
|
2412
|
+
* @returns the template with replaced parameters
|
|
2413
|
+
* @throws {TemplateError} if parameter is not defined, not closed, or not opened
|
|
2414
|
+
*
|
|
2415
|
+
* @private within the createPromptbookExecutor
|
|
2416
|
+
*/
|
|
2417
|
+
function replaceParameters(template, parameters) {
|
|
2418
|
+
var replacedTemplate = template;
|
|
2419
|
+
var match;
|
|
2420
|
+
var loopLimit = LOOP_LIMIT;
|
|
2421
|
+
var _loop_1 = function () {
|
|
2422
|
+
if (loopLimit-- < 0) {
|
|
2423
|
+
throw new UnexpectedError('Loop limit reached during parameters replacement in `replaceParameters`');
|
|
2424
|
+
}
|
|
2425
|
+
var precol = match.groups.precol;
|
|
2426
|
+
var parameterName = match.groups.parameterName;
|
|
2427
|
+
if (parameterName === '') {
|
|
2428
|
+
return "continue";
|
|
2429
|
+
}
|
|
2430
|
+
if (parameterName.indexOf('{') !== -1 || parameterName.indexOf('}') !== -1) {
|
|
2431
|
+
throw new TemplateError('Parameter is already opened or not closed');
|
|
2432
|
+
}
|
|
2433
|
+
if (parameters[parameterName] === undefined) {
|
|
2434
|
+
throw new TemplateError("Parameter {".concat(parameterName, "} is not defined"));
|
|
2435
|
+
}
|
|
2436
|
+
var parameterValue = parameters[parameterName];
|
|
2437
|
+
if (parameterValue === undefined) {
|
|
2438
|
+
throw new TemplateError("Parameter {".concat(parameterName, "} is not defined"));
|
|
2439
|
+
}
|
|
2440
|
+
parameterValue = parameterValue.toString();
|
|
2441
|
+
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
2442
|
+
parameterValue = parameterValue
|
|
2443
|
+
.split('\n')
|
|
2444
|
+
.map(function (line, index) { return (index === 0 ? line : "".concat(precol).concat(line)); })
|
|
2445
|
+
.join('\n');
|
|
2446
|
+
}
|
|
2447
|
+
replacedTemplate =
|
|
2448
|
+
replacedTemplate.substring(0, match.index + precol.length) +
|
|
2449
|
+
parameterValue +
|
|
2450
|
+
replacedTemplate.substring(match.index + precol.length + parameterName.length + 2);
|
|
2451
|
+
};
|
|
2452
|
+
while ((match = /^(?<precol>.*){(?<parameterName>\w+)}(.*)/m /* <- Not global */
|
|
2453
|
+
.exec(replacedTemplate))) {
|
|
2454
|
+
_loop_1();
|
|
2455
|
+
}
|
|
2456
|
+
// [💫] Check if there are parameters that are not closed properly
|
|
2457
|
+
if (/{\w+$/.test(replacedTemplate)) {
|
|
2458
|
+
throw new TemplateError('Parameter is not closed');
|
|
2459
|
+
}
|
|
2460
|
+
// [💫] Check if there are parameters that are not opened properly
|
|
2461
|
+
if (/^\w+}/.test(replacedTemplate)) {
|
|
2462
|
+
throw new TemplateError('Parameter is not opened');
|
|
2463
|
+
}
|
|
2464
|
+
return replacedTemplate;
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2454
2467
|
/**
|
|
2455
2468
|
* Creates executor function from promptbook and execution tools.
|
|
2456
2469
|
*
|
|
@@ -2532,7 +2545,7 @@
|
|
|
2532
2545
|
title: currentTemplate.title,
|
|
2533
2546
|
promptbookUrl: "".concat(promptbook.promptbookUrl
|
|
2534
2547
|
? promptbook.promptbookUrl
|
|
2535
|
-
: 'anonymous' /* <- [🧠]
|
|
2548
|
+
: 'anonymous' /* <- TODO: [🧠] How to deal with anonymous PROMPTBOOKs, do here some auto-url like SHA-256 based ad-hoc identifier? */, "#").concat(currentTemplate.name),
|
|
2536
2549
|
parameters: parametersToPass,
|
|
2537
2550
|
content: replaceParameters(currentTemplate.content, parametersToPass) /* <- [2] */,
|
|
2538
2551
|
modelRequirements: currentTemplate.modelRequirements,
|
|
@@ -3162,6 +3175,20 @@
|
|
|
3162
3175
|
return SimplePromptInterfaceTools;
|
|
3163
3176
|
}());
|
|
3164
3177
|
|
|
3178
|
+
/**
|
|
3179
|
+
* This error indicates that the promptbook library cannot be propperly loaded
|
|
3180
|
+
*/
|
|
3181
|
+
var PromptbookLibraryError = /** @class */ (function (_super) {
|
|
3182
|
+
__extends(PromptbookLibraryError, _super);
|
|
3183
|
+
function PromptbookLibraryError(message) {
|
|
3184
|
+
var _this = _super.call(this, message) || this;
|
|
3185
|
+
_this.name = 'PromptbookLibraryError';
|
|
3186
|
+
Object.setPrototypeOf(_this, PromptbookLibraryError.prototype);
|
|
3187
|
+
return _this;
|
|
3188
|
+
}
|
|
3189
|
+
return PromptbookLibraryError;
|
|
3190
|
+
}(Error));
|
|
3191
|
+
|
|
3165
3192
|
/**
|
|
3166
3193
|
* Detects if the code is running in a browser environment in main thread (Not in a web worker)
|
|
3167
3194
|
*/
|
|
@@ -3175,6 +3202,23 @@
|
|
|
3175
3202
|
*/
|
|
3176
3203
|
new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) {\n return true;\n } else {\n return false;\n }\n } catch (e) {\n return false;\n }\n");
|
|
3177
3204
|
|
|
3205
|
+
/**
|
|
3206
|
+
* Returns the same value that is passed as argument.
|
|
3207
|
+
* No side effects.
|
|
3208
|
+
*
|
|
3209
|
+
* Note: It can be usefull for leveling indentation
|
|
3210
|
+
*
|
|
3211
|
+
* @param value any values
|
|
3212
|
+
* @returns the same values
|
|
3213
|
+
*/
|
|
3214
|
+
function just(value) {
|
|
3215
|
+
if (value === undefined) {
|
|
3216
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3217
|
+
return undefined;
|
|
3218
|
+
}
|
|
3219
|
+
return value;
|
|
3220
|
+
}
|
|
3221
|
+
|
|
3178
3222
|
/**
|
|
3179
3223
|
* This error indicates that promptbook not found in the library
|
|
3180
3224
|
*/
|
|
@@ -3232,6 +3276,12 @@
|
|
|
3232
3276
|
throw new PromptbookReferenceError(spaceTrim.spaceTrim("\n Promptbook with name \"".concat(promptbook.title, "\" does not have defined URL\n\n Note: Promptbooks without URLs are called anonymous promptbooks\n They can be used as standalone promptbooks, but they cannot be referenced by other promptbooks\n And also they cannot be used in the promptbook library\n\n ")));
|
|
3233
3277
|
}
|
|
3234
3278
|
validatePromptbookJson(promptbook);
|
|
3279
|
+
// Note: [🦄]
|
|
3280
|
+
if (this.library.has(promptbook.promptbookUrl) &&
|
|
3281
|
+
promptbookJsonToString(promptbook) !==
|
|
3282
|
+
promptbookJsonToString(this.library.get(promptbook.promptbookUrl))) {
|
|
3283
|
+
throw new PromptbookReferenceError(spaceTrim.spaceTrim("\n Promptbook with URL \"".concat(promptbook.promptbookUrl, "\" is already in the library\n\n Note: Promptbooks with the same URL are not allowed\n Note: Automatically check whether the promptbooks are the same BUT they are DIFFERENT\n\n ")));
|
|
3284
|
+
}
|
|
3235
3285
|
this.library.set(promptbook.promptbookUrl, promptbook);
|
|
3236
3286
|
}
|
|
3237
3287
|
}
|
|
@@ -3258,6 +3308,9 @@
|
|
|
3258
3308
|
var _this = this;
|
|
3259
3309
|
var promptbook = this.library.get(url);
|
|
3260
3310
|
if (!promptbook) {
|
|
3311
|
+
if (this.listPromptbooks().length === 0) {
|
|
3312
|
+
throw new PromptbookNotFoundError(spaceTrim.spaceTrim("\n Promptbook with url \"".concat(url, "\" not found\n\n No promptbooks available\n ")));
|
|
3313
|
+
}
|
|
3261
3314
|
throw new PromptbookNotFoundError(spaceTrim.spaceTrim(function (block) { return "\n Promptbook with url \"".concat(url, "\" not found\n\n Available promptbooks:\n ").concat(block(_this.listPromptbooks()
|
|
3262
3315
|
.map(function (promptbookUrl) { return "- ".concat(promptbookUrl); })
|
|
3263
3316
|
.join('\n')), "\n\n "); }));
|
|
@@ -3330,11 +3383,11 @@
|
|
|
3330
3383
|
* Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
|
|
3331
3384
|
* when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
|
|
3332
3385
|
*
|
|
3386
|
+
* Note: Consider using `createPromptbookLibraryFromDirectory` or `createPromptbookLibraryFromUrl`
|
|
3333
3387
|
*
|
|
3334
3388
|
* @param promptbookSourcesPromiseOrFactory
|
|
3335
3389
|
* @returns PromptbookLibrary
|
|
3336
|
-
*
|
|
3337
|
-
* @deprecated Consider using `createPromptbookLibraryFromUrl` or `createPromptbookLibraryFromDirectory`
|
|
3390
|
+
* @private Just internal tool for other constructor functions
|
|
3338
3391
|
*/
|
|
3339
3392
|
function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
|
|
3340
3393
|
var library;
|
|
@@ -3407,37 +3460,252 @@
|
|
|
3407
3460
|
* Constructs Promptbook from given directory
|
|
3408
3461
|
*
|
|
3409
3462
|
* Note: Works only in Node.js environment because it reads the file system
|
|
3410
|
-
* Note: The function does NOT return promise it returns the library directly which dynamically loads promptbooks when needed
|
|
3411
|
-
* SO during the construction syntax and logic sources IS NOT validated
|
|
3412
3463
|
*
|
|
3413
3464
|
* @param path - path to the directory with promptbooks
|
|
3414
3465
|
* @param options - Misc options for the library
|
|
3415
3466
|
* @returns PromptbookLibrary
|
|
3416
3467
|
*/
|
|
3417
3468
|
function createPromptbookLibraryFromDirectory(path, options) {
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3469
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3470
|
+
var _a, _b, isRecursive, _c, isVerbose, _d, isLazyLoaded, _e, isCrashOnError, library;
|
|
3471
|
+
var _this = this;
|
|
3472
|
+
return __generator(this, function (_f) {
|
|
3473
|
+
switch (_f.label) {
|
|
3474
|
+
case 0:
|
|
3475
|
+
if (!isRunningInNode()) {
|
|
3476
|
+
throw new Error('Function `createPromptbookLibraryFromDirectory` can only be run in Node.js environment because it reads the file system.');
|
|
3477
|
+
}
|
|
3478
|
+
_a = options || {}, _b = _a.isRecursive, isRecursive = _b === void 0 ? true : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? false : _c, _d = _a.isLazyLoaded, isLazyLoaded = _d === void 0 ? false : _d, _e = _a.isCrashOnError, isCrashOnError = _e === void 0 ? true : _e;
|
|
3479
|
+
library = createPromptbookLibraryFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3480
|
+
var fsPromises, readFile, fileNames, promptbooks, _loop_1, fileNames_1, fileNames_1_1, fileName, e_1_1;
|
|
3481
|
+
var e_1, _a;
|
|
3482
|
+
return __generator(this, function (_b) {
|
|
3483
|
+
switch (_b.label) {
|
|
3484
|
+
case 0:
|
|
3485
|
+
if (isVerbose) {
|
|
3486
|
+
console.info("Creating promptbook library from path ".concat(path));
|
|
3487
|
+
}
|
|
3488
|
+
fsPromises = require(just('fs/promises') /* <- Note: [1] */);
|
|
3489
|
+
readFile = fsPromises.readFile;
|
|
3490
|
+
return [4 /*yield*/, listAllFiles(path, isRecursive)];
|
|
3491
|
+
case 1:
|
|
3492
|
+
fileNames = _b.sent();
|
|
3493
|
+
if (isVerbose) {
|
|
3494
|
+
console.info('createPromptbookLibraryFromDirectory', { path: path, isRecursive: isRecursive, fileNames: fileNames });
|
|
3495
|
+
}
|
|
3496
|
+
promptbooks = [];
|
|
3497
|
+
_loop_1 = function (fileName) {
|
|
3498
|
+
var promptbook, promptbookString, _c, _d, error_1, wrappedErrorMessage;
|
|
3499
|
+
return __generator(this, function (_e) {
|
|
3500
|
+
switch (_e.label) {
|
|
3501
|
+
case 0:
|
|
3502
|
+
_e.trys.push([0, 6, , 7]);
|
|
3503
|
+
promptbook = null;
|
|
3504
|
+
if (!fileName.endsWith('.ptbk.md')) return [3 /*break*/, 2];
|
|
3505
|
+
return [4 /*yield*/, readFile(fileName, 'utf8')];
|
|
3506
|
+
case 1:
|
|
3507
|
+
promptbookString = (_e.sent());
|
|
3508
|
+
promptbook = promptbookStringToJson(promptbookString);
|
|
3509
|
+
return [3 /*break*/, 5];
|
|
3510
|
+
case 2:
|
|
3511
|
+
if (!fileName.endsWith('.ptbk.json')) return [3 /*break*/, 4];
|
|
3512
|
+
if (isVerbose) {
|
|
3513
|
+
console.info("Loading ".concat(fileName));
|
|
3514
|
+
}
|
|
3515
|
+
_d = (_c = JSON).parse;
|
|
3516
|
+
return [4 /*yield*/, readFile(fileName, 'utf8')];
|
|
3517
|
+
case 3:
|
|
3518
|
+
// TODO: Handle non-valid JSON files
|
|
3519
|
+
promptbook = _d.apply(_c, [_e.sent()]);
|
|
3520
|
+
return [3 /*break*/, 5];
|
|
3521
|
+
case 4:
|
|
3522
|
+
if (isVerbose) {
|
|
3523
|
+
console.info("Skipping file ".concat(fileName));
|
|
3524
|
+
}
|
|
3525
|
+
_e.label = 5;
|
|
3526
|
+
case 5:
|
|
3527
|
+
// ---
|
|
3528
|
+
if (promptbook !== null) {
|
|
3529
|
+
if (!promptbook.promptbookUrl) {
|
|
3530
|
+
if (isVerbose) {
|
|
3531
|
+
console.info("Not loading ".concat(fileName, " - missing URL"));
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
else {
|
|
3535
|
+
if (isVerbose) {
|
|
3536
|
+
console.info("Loading ".concat(fileName));
|
|
3537
|
+
}
|
|
3538
|
+
if (!isCrashOnError) {
|
|
3539
|
+
// Note: Validate promptbook to check if it is logically correct to not crash on invalid promptbooks
|
|
3540
|
+
// But be handled in current try-catch block
|
|
3541
|
+
validatePromptbookJson(promptbook);
|
|
3542
|
+
}
|
|
3543
|
+
// Note: [🦄] Promptbook with same url uniqueness will be checked automatically in SimplePromptbookLibrary
|
|
3544
|
+
promptbooks.push(promptbook);
|
|
3545
|
+
}
|
|
3546
|
+
}
|
|
3547
|
+
return [3 /*break*/, 7];
|
|
3548
|
+
case 6:
|
|
3549
|
+
error_1 = _e.sent();
|
|
3550
|
+
if (!(error_1 instanceof Error)) {
|
|
3551
|
+
throw error_1;
|
|
3552
|
+
}
|
|
3553
|
+
wrappedErrorMessage = spaceTrim__default["default"](function (block) { return "\n Error during loading promptbook from file ".concat(fileName.split('\\').join('/'), ":\n\n ").concat(block(error_1.message), "\n\n "); });
|
|
3554
|
+
if (isCrashOnError) {
|
|
3555
|
+
throw new PromptbookLibraryError(wrappedErrorMessage);
|
|
3556
|
+
}
|
|
3557
|
+
console.error(wrappedErrorMessage);
|
|
3558
|
+
return [3 /*break*/, 7];
|
|
3559
|
+
case 7: return [2 /*return*/];
|
|
3560
|
+
}
|
|
3561
|
+
});
|
|
3562
|
+
};
|
|
3563
|
+
_b.label = 2;
|
|
3564
|
+
case 2:
|
|
3565
|
+
_b.trys.push([2, 7, 8, 9]);
|
|
3566
|
+
fileNames_1 = __values(fileNames), fileNames_1_1 = fileNames_1.next();
|
|
3567
|
+
_b.label = 3;
|
|
3568
|
+
case 3:
|
|
3569
|
+
if (!!fileNames_1_1.done) return [3 /*break*/, 6];
|
|
3570
|
+
fileName = fileNames_1_1.value;
|
|
3571
|
+
return [5 /*yield**/, _loop_1(fileName)];
|
|
3572
|
+
case 4:
|
|
3573
|
+
_b.sent();
|
|
3574
|
+
_b.label = 5;
|
|
3575
|
+
case 5:
|
|
3576
|
+
fileNames_1_1 = fileNames_1.next();
|
|
3577
|
+
return [3 /*break*/, 3];
|
|
3578
|
+
case 6: return [3 /*break*/, 9];
|
|
3579
|
+
case 7:
|
|
3580
|
+
e_1_1 = _b.sent();
|
|
3581
|
+
e_1 = { error: e_1_1 };
|
|
3582
|
+
return [3 /*break*/, 9];
|
|
3583
|
+
case 8:
|
|
3584
|
+
try {
|
|
3585
|
+
if (fileNames_1_1 && !fileNames_1_1.done && (_a = fileNames_1.return)) _a.call(fileNames_1);
|
|
3586
|
+
}
|
|
3587
|
+
finally { if (e_1) throw e_1.error; }
|
|
3588
|
+
return [7 /*endfinally*/];
|
|
3589
|
+
case 9: return [2 /*return*/, promptbooks];
|
|
3590
|
+
}
|
|
3591
|
+
});
|
|
3592
|
+
}); });
|
|
3593
|
+
if (!(isLazyLoaded === false)) return [3 /*break*/, 2];
|
|
3594
|
+
return [4 /*yield*/, library.listPromptbooks()];
|
|
3595
|
+
case 1:
|
|
3596
|
+
_f.sent();
|
|
3597
|
+
_f.label = 2;
|
|
3598
|
+
case 2: return [2 /*return*/, library];
|
|
3599
|
+
}
|
|
3600
|
+
});
|
|
3601
|
+
});
|
|
3602
|
+
}
|
|
3603
|
+
/**
|
|
3604
|
+
* Reads all files in the directory
|
|
3605
|
+
*
|
|
3606
|
+
* @param path
|
|
3607
|
+
* @param isRecursive
|
|
3608
|
+
* @returns List of all files in the directory
|
|
3609
|
+
* @private internal function for `createPromptbookLibraryFromDirectory`
|
|
3610
|
+
*/
|
|
3611
|
+
function listAllFiles(path$1, isRecursive) {
|
|
3612
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3613
|
+
var fsPromises, readdir, dirents, fileNames, _a, _b, dirent, subPath, _c, _d, _e, _f, e_2_1;
|
|
3614
|
+
var e_2, _g;
|
|
3615
|
+
return __generator(this, function (_h) {
|
|
3616
|
+
switch (_h.label) {
|
|
3617
|
+
case 0:
|
|
3618
|
+
fsPromises = require(just('fs/promises') /* <- Note: [1] */);
|
|
3619
|
+
readdir = fsPromises.readdir;
|
|
3620
|
+
return [4 /*yield*/, readdir(path$1, {
|
|
3621
|
+
withFileTypes: true /* Note: This is not working: recursive: isRecursive */,
|
|
3622
|
+
})];
|
|
3428
3623
|
case 1:
|
|
3429
|
-
|
|
3430
|
-
return
|
|
3624
|
+
dirents = _h.sent();
|
|
3625
|
+
fileNames = dirents.filter(function (dirent) { return dirent.isFile(); }).map(function (_a) {
|
|
3626
|
+
var name = _a.name;
|
|
3627
|
+
return path.join(path$1, name);
|
|
3628
|
+
});
|
|
3629
|
+
if (!isRecursive) return [3 /*break*/, 9];
|
|
3630
|
+
_h.label = 2;
|
|
3431
3631
|
case 2:
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3632
|
+
_h.trys.push([2, 7, 8, 9]);
|
|
3633
|
+
_a = __values(dirents.filter(function (dirent) { return dirent.isDirectory(); })), _b = _a.next();
|
|
3634
|
+
_h.label = 3;
|
|
3635
|
+
case 3:
|
|
3636
|
+
if (!!_b.done) return [3 /*break*/, 6];
|
|
3637
|
+
dirent = _b.value;
|
|
3638
|
+
subPath = path.join(path$1, dirent.name);
|
|
3639
|
+
_d = (_c = fileNames.push).apply;
|
|
3640
|
+
_e = [fileNames];
|
|
3641
|
+
_f = [[]];
|
|
3642
|
+
return [4 /*yield*/, listAllFiles(subPath, isRecursive)];
|
|
3643
|
+
case 4:
|
|
3644
|
+
_d.apply(_c, _e.concat([__spreadArray.apply(void 0, _f.concat([__read.apply(void 0, [(_h.sent())]), false]))]));
|
|
3645
|
+
_h.label = 5;
|
|
3646
|
+
case 5:
|
|
3647
|
+
_b = _a.next();
|
|
3648
|
+
return [3 /*break*/, 3];
|
|
3649
|
+
case 6: return [3 /*break*/, 9];
|
|
3650
|
+
case 7:
|
|
3651
|
+
e_2_1 = _h.sent();
|
|
3652
|
+
e_2 = { error: e_2_1 };
|
|
3653
|
+
return [3 /*break*/, 9];
|
|
3654
|
+
case 8:
|
|
3655
|
+
try {
|
|
3656
|
+
if (_b && !_b.done && (_g = _a.return)) _g.call(_a);
|
|
3657
|
+
}
|
|
3658
|
+
finally { if (e_2) throw e_2.error; }
|
|
3659
|
+
return [7 /*endfinally*/];
|
|
3660
|
+
case 9: return [2 /*return*/, fileNames];
|
|
3661
|
+
}
|
|
3662
|
+
});
|
|
3663
|
+
});
|
|
3664
|
+
}
|
|
3665
|
+
/***
|
|
3666
|
+
* TODO: [🧠] Maybe do not do hacks like [1] and just create package @promptbook/node
|
|
3667
|
+
* [🍓][🚯] maybe make `@promptbook/library` package
|
|
3668
|
+
* TODO: Fix the dynamic import issue in Webpack (! Not working !)
|
|
3669
|
+
* > ./node_modules/@promptbook/core/esm/index.es.js
|
|
3670
|
+
* > Critical dependency: the request of a dependency is an expression
|
|
3671
|
+
*
|
|
3672
|
+
* Note: [1] Using require(just('fs/promises')) to allow
|
|
3673
|
+
* the `@promptbook/core` work for both Node.js and browser environments
|
|
3674
|
+
*/
|
|
3675
|
+
|
|
3676
|
+
/**
|
|
3677
|
+
* Constructs Promptbook from remote Promptbase URL
|
|
3678
|
+
|
|
3679
|
+
* @returns PromptbookLibrary
|
|
3680
|
+
*/
|
|
3681
|
+
function createPromptbookLibraryFromUrl(url, options) {
|
|
3682
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3683
|
+
var _a, _b, isVerbose, _c, isLazyLoaded, library;
|
|
3684
|
+
var _this = this;
|
|
3685
|
+
return __generator(this, function (_d) {
|
|
3686
|
+
switch (_d.label) {
|
|
3687
|
+
case 0:
|
|
3688
|
+
_a = options || {}, _b = _a.isVerbose, isVerbose = _b === void 0 ? false : _b, _c = _a.isLazyLoaded, isLazyLoaded = _c === void 0 ? false : _c;
|
|
3689
|
+
library = createPromptbookLibraryFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
3690
|
+
return __generator(this, function (_a) {
|
|
3691
|
+
if (isVerbose) {
|
|
3692
|
+
console.info("Creating promptbook library from url ".concat(url.toString()));
|
|
3693
|
+
}
|
|
3694
|
+
throw new Error('Not implemented yet');
|
|
3695
|
+
});
|
|
3696
|
+
}); });
|
|
3697
|
+
if (!(isLazyLoaded === false)) return [3 /*break*/, 2];
|
|
3698
|
+
return [4 /*yield*/, library.listPromptbooks()];
|
|
3699
|
+
case 1:
|
|
3700
|
+
_d.sent();
|
|
3701
|
+
_d.label = 2;
|
|
3702
|
+
case 2: return [2 /*return*/, library];
|
|
3436
3703
|
}
|
|
3437
3704
|
});
|
|
3438
|
-
});
|
|
3705
|
+
});
|
|
3439
3706
|
}
|
|
3440
3707
|
/***
|
|
3708
|
+
* TODO: [⚖] Compatible with remote server
|
|
3441
3709
|
* TODO: [🍓][🚯] !!! Add to README and samples + maybe make `@promptbook/library` package
|
|
3442
3710
|
*/
|
|
3443
3711
|
|
|
@@ -3523,6 +3791,31 @@
|
|
|
3523
3791
|
* TODO: [🍓][🚯] !!! Add to README and samples + maybe make `@promptbook/library` package
|
|
3524
3792
|
*/
|
|
3525
3793
|
|
|
3794
|
+
/**
|
|
3795
|
+
* Just testing imports and compatibility
|
|
3796
|
+
*/
|
|
3797
|
+
function justTestFsImport() {
|
|
3798
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3799
|
+
var files;
|
|
3800
|
+
return __generator(this, function (_a) {
|
|
3801
|
+
switch (_a.label) {
|
|
3802
|
+
case 0:
|
|
3803
|
+
if (!isRunningInNode()) {
|
|
3804
|
+
throw new Error('Function `testFiles` can only be run in Node.js environment because it reads the file system.');
|
|
3805
|
+
}
|
|
3806
|
+
return [4 /*yield*/, require(just('glob-promise'))('/**/*')];
|
|
3807
|
+
case 1:
|
|
3808
|
+
files = _a.sent();
|
|
3809
|
+
console.info('testFiles', { files: files });
|
|
3810
|
+
return [2 /*return*/];
|
|
3811
|
+
}
|
|
3812
|
+
});
|
|
3813
|
+
});
|
|
3814
|
+
}
|
|
3815
|
+
/**
|
|
3816
|
+
* TODO: !!! Remove this file
|
|
3817
|
+
*/
|
|
3818
|
+
|
|
3526
3819
|
/**
|
|
3527
3820
|
* Format either small or big number
|
|
3528
3821
|
*
|
|
@@ -3543,23 +3836,6 @@
|
|
|
3543
3836
|
return value.toString();
|
|
3544
3837
|
}
|
|
3545
3838
|
|
|
3546
|
-
/**
|
|
3547
|
-
* Returns the same value that is passed as argument.
|
|
3548
|
-
* No side effects.
|
|
3549
|
-
*
|
|
3550
|
-
* Note: It can be usefull for leveling indentation
|
|
3551
|
-
*
|
|
3552
|
-
* @param value any values
|
|
3553
|
-
* @returns the same values
|
|
3554
|
-
*/
|
|
3555
|
-
function just(value) {
|
|
3556
|
-
if (value === undefined) {
|
|
3557
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3558
|
-
return undefined;
|
|
3559
|
-
}
|
|
3560
|
-
return value;
|
|
3561
|
-
}
|
|
3562
|
-
|
|
3563
3839
|
/**
|
|
3564
3840
|
* Create a markdown table from a 2D array of strings
|
|
3565
3841
|
*
|
|
@@ -3851,11 +4127,12 @@
|
|
|
3851
4127
|
exports.checkExpectations = checkExpectations;
|
|
3852
4128
|
exports.createPromptbookExecutor = createPromptbookExecutor;
|
|
3853
4129
|
exports.createPromptbookLibraryFromDirectory = createPromptbookLibraryFromDirectory;
|
|
3854
|
-
exports.createPromptbookLibraryFromPromise = createPromptbookLibraryFromPromise;
|
|
3855
4130
|
exports.createPromptbookLibraryFromSources = createPromptbookLibraryFromSources;
|
|
4131
|
+
exports.createPromptbookLibraryFromUrl = createPromptbookLibraryFromUrl;
|
|
3856
4132
|
exports.createPromptbookSublibrary = createPromptbookSublibrary;
|
|
3857
4133
|
exports.executionReportJsonToString = executionReportJsonToString;
|
|
3858
4134
|
exports.isPassingExpectations = isPassingExpectations;
|
|
4135
|
+
exports.justTestFsImport = justTestFsImport;
|
|
3859
4136
|
exports.prettifyPromptbookString = prettifyPromptbookString;
|
|
3860
4137
|
exports.promptbookJsonToString = promptbookJsonToString;
|
|
3861
4138
|
exports.promptbookStringToJson = promptbookStringToJson;
|