@promptbook/cli 0.52.0 → 0.54.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/esm/index.es.js +631 -661
- package/esm/index.es.js.map +1 -1
- package/esm/typings/_packages/core.index.d.ts +10 -0
- package/esm/typings/_packages/types.index.d.ts +0 -1
- 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/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 -2
- 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 -2
- package/esm/typings/execution/plugins/llm-execution-tools/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +2 -1
- 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 +4 -2
- 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 +4 -2
- 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 +1 -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/replaceParameters.d.ts +2 -2
- package/esm/typings/library/SimplePromptbookLibrary.d.ts +1 -1
- package/esm/typings/library/constructors/createPromptbookLibraryFromDirectory.d.ts +2 -2
- package/esm/typings/library/constructors/createPromptbookLibraryFromPromise.d.ts +2 -2
- package/esm/typings/library/constructors/createPromptbookLibraryFromSources.d.ts +2 -1
- package/esm/typings/library/constructors/createPromptbookLibraryFromUrl.d.ts +2 -2
- package/esm/typings/library/constructors/createPromptbookSublibrary.d.ts +1 -1
- package/esm/typings/types/Command.d.ts +5 -2
- package/esm/typings/types/Prompt.d.ts +4 -1
- 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/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 +631 -661
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/_packages/core.index.d.ts +10 -0
- package/umd/typings/_packages/types.index.d.ts +0 -1
- 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/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 -2
- 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 -2
- package/umd/typings/execution/plugins/llm-execution-tools/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +2 -1
- 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 +4 -2
- 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 +4 -2
- 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 +1 -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/replaceParameters.d.ts +2 -2
- package/umd/typings/library/SimplePromptbookLibrary.d.ts +1 -1
- package/umd/typings/library/constructors/createPromptbookLibraryFromDirectory.d.ts +2 -2
- package/umd/typings/library/constructors/createPromptbookLibraryFromPromise.d.ts +2 -2
- package/umd/typings/library/constructors/createPromptbookLibraryFromSources.d.ts +2 -1
- package/umd/typings/library/constructors/createPromptbookLibraryFromUrl.d.ts +2 -2
- package/umd/typings/library/constructors/createPromptbookSublibrary.d.ts +1 -1
- package/umd/typings/types/Command.d.ts +5 -2
- package/umd/typings/types/Prompt.d.ts +4 -1
- 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/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/umd/index.umd.js
CHANGED
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
/**
|
|
147
147
|
* The version of the Promptbook library
|
|
148
148
|
*/
|
|
149
|
-
var PROMPTBOOK_VERSION = '0.
|
|
149
|
+
var PROMPTBOOK_VERSION = '0.53.0';
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
152
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -590,88 +590,108 @@
|
|
|
590
590
|
* TODO: [🔣] If script require contentLanguage
|
|
591
591
|
*/
|
|
592
592
|
|
|
593
|
+
/* tslint:disable */
|
|
594
|
+
/*
|
|
595
|
+
TODO: Tests
|
|
596
|
+
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
|
|
597
|
+
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ěščřžžýáíúů' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
|
|
598
|
+
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
|
|
599
|
+
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
|
|
600
|
+
*/
|
|
601
|
+
function normalizeTo_SCREAMING_CASE(sentence) {
|
|
602
|
+
var e_1, _a;
|
|
603
|
+
var charType;
|
|
604
|
+
var lastCharType = 'OTHER';
|
|
605
|
+
var normalizedName = '';
|
|
606
|
+
try {
|
|
607
|
+
for (var sentence_1 = __values(sentence), sentence_1_1 = sentence_1.next(); !sentence_1_1.done; sentence_1_1 = sentence_1.next()) {
|
|
608
|
+
var char = sentence_1_1.value;
|
|
609
|
+
var normalizedChar = void 0;
|
|
610
|
+
if (/^[a-z]$/.test(char)) {
|
|
611
|
+
charType = 'LOWERCASE';
|
|
612
|
+
normalizedChar = char.toUpperCase();
|
|
613
|
+
}
|
|
614
|
+
else if (/^[A-Z]$/.test(char)) {
|
|
615
|
+
charType = 'UPPERCASE';
|
|
616
|
+
normalizedChar = char;
|
|
617
|
+
}
|
|
618
|
+
else if (/^[0-9]$/.test(char)) {
|
|
619
|
+
charType = 'NUMBER';
|
|
620
|
+
normalizedChar = char;
|
|
621
|
+
}
|
|
622
|
+
else if (/^\/$/.test(char)) {
|
|
623
|
+
charType = 'SLASH';
|
|
624
|
+
normalizedChar = char;
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
charType = 'OTHER';
|
|
628
|
+
normalizedChar = '_';
|
|
629
|
+
}
|
|
630
|
+
if (charType !== lastCharType &&
|
|
631
|
+
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
632
|
+
!(lastCharType === 'NUMBER') &&
|
|
633
|
+
!(charType === 'NUMBER')) {
|
|
634
|
+
normalizedName += '_';
|
|
635
|
+
}
|
|
636
|
+
normalizedName += normalizedChar;
|
|
637
|
+
lastCharType = charType;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
641
|
+
finally {
|
|
642
|
+
try {
|
|
643
|
+
if (sentence_1_1 && !sentence_1_1.done && (_a = sentence_1.return)) _a.call(sentence_1);
|
|
644
|
+
}
|
|
645
|
+
finally { if (e_1) throw e_1.error; }
|
|
646
|
+
}
|
|
647
|
+
normalizedName = normalizedName.replace(/_+/g, '_');
|
|
648
|
+
normalizedName = normalizedName.replace(/_?\/_?/g, '/');
|
|
649
|
+
normalizedName = normalizedName.replace(/^_/, '');
|
|
650
|
+
normalizedName = normalizedName.replace(/_$/, '');
|
|
651
|
+
return normalizedName;
|
|
652
|
+
}
|
|
593
653
|
/**
|
|
594
|
-
*
|
|
654
|
+
* TODO: [🌺] Use some intermediate util splitWords
|
|
655
|
+
*/
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Execution type describes the way how the block is executed
|
|
595
659
|
*
|
|
596
|
-
* @
|
|
597
|
-
* @returns text without emojis
|
|
660
|
+
* @see https://github.com/webgptorg/promptbook#execution-type
|
|
598
661
|
*/
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
}
|
|
662
|
+
var ExecutionTypes = [
|
|
663
|
+
'PROMPT_TEMPLATE',
|
|
664
|
+
'SIMPLE_TEMPLATE',
|
|
665
|
+
'SCRIPT',
|
|
666
|
+
'PROMPT_DIALOG',
|
|
667
|
+
// <- [🥻] Insert here when making new command
|
|
668
|
+
];
|
|
607
669
|
|
|
608
670
|
/**
|
|
609
|
-
*
|
|
671
|
+
* Units of text measurement
|
|
672
|
+
*/
|
|
673
|
+
var EXPECTATION_UNITS = ['CHARACTERS', 'WORDS', 'SENTENCES', 'LINES', 'PARAGRAPHS', 'PAGES'];
|
|
674
|
+
/**
|
|
675
|
+
* TODO: [💝] Unite object for expecting amount and format - remove expectFormat
|
|
676
|
+
* TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
|
|
677
|
+
* TODO: [👙][🧠] Just selecting gpt3 or gpt4 level of model
|
|
610
678
|
*/
|
|
611
|
-
function titleToName(value) {
|
|
612
|
-
value = removeEmojis(value);
|
|
613
|
-
value = normalizeToKebabCase(value);
|
|
614
|
-
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
615
|
-
return value;
|
|
616
|
-
}
|
|
617
679
|
|
|
618
680
|
/**
|
|
619
|
-
*
|
|
681
|
+
* Removes Markdown formatting tags from a string.
|
|
620
682
|
*
|
|
621
|
-
*
|
|
683
|
+
* @param {string} str - The string to remove Markdown tags from.
|
|
684
|
+
* @returns {string} The input string with all Markdown tags removed.
|
|
622
685
|
*/
|
|
623
|
-
function
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
return 'input';
|
|
632
|
-
}
|
|
633
|
-
var template = promptbookJson.promptTemplates.find(function (template) { return template.resultingParameterName === parameterName; });
|
|
634
|
-
if (!template) {
|
|
635
|
-
throw new Error("Could not find template for {".concat(parameterName, "}"));
|
|
636
|
-
}
|
|
637
|
-
return normalizeTo_camelCase('template-' + titleToName(template.title));
|
|
638
|
-
};
|
|
639
|
-
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
|
|
640
|
-
.flatMap(function (_a) {
|
|
641
|
-
var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
|
|
642
|
-
return __spreadArray([
|
|
643
|
-
"".concat(parameterNameToTemplateName(resultingParameterName), "(\"").concat(title, "\")")
|
|
644
|
-
], __read(dependentParameterNames.map(function (dependentParameterName) {
|
|
645
|
-
return "".concat(parameterNameToTemplateName(dependentParameterName), "--\"{").concat(dependentParameterName, "}\"-->").concat(parameterNameToTemplateName(resultingParameterName));
|
|
646
|
-
})), false);
|
|
647
|
-
})
|
|
648
|
-
.join('\n')), "\n\n ").concat(block(promptbookJson.parameters
|
|
649
|
-
.filter(function (_a) {
|
|
650
|
-
var isOutput = _a.isOutput;
|
|
651
|
-
return isOutput;
|
|
652
|
-
})
|
|
653
|
-
.map(function (_a) {
|
|
654
|
-
var name = _a.name;
|
|
655
|
-
return "".concat(parameterNameToTemplateName(name), "--\"{").concat(name, "}\"-->output");
|
|
656
|
-
})
|
|
657
|
-
.join('\n')), "\n output((Output)):::output\n\n ").concat(block(promptbookJson.promptTemplates
|
|
658
|
-
.map(function (promptTemplate) {
|
|
659
|
-
var link = linkPromptTemplate(promptTemplate);
|
|
660
|
-
if (link === null) {
|
|
661
|
-
return '';
|
|
662
|
-
}
|
|
663
|
-
var href = link.href, title = link.title;
|
|
664
|
-
var templateName = parameterNameToTemplateName(promptTemplate.resultingParameterName);
|
|
665
|
-
return "click ".concat(templateName, " href \"").concat(href, "\" \"").concat(title, "\";");
|
|
666
|
-
})
|
|
667
|
-
.filter(function (line) { return line !== ''; })
|
|
668
|
-
.join('\n')), "\n\n classDef input color: grey;\n classDef output color: grey;\n\n end;\n\n "); });
|
|
669
|
-
return promptbookMermaid;
|
|
686
|
+
function removeMarkdownFormatting(str) {
|
|
687
|
+
// Remove bold formatting
|
|
688
|
+
str = str.replace(/\*\*(.*?)\*\*/g, '$1');
|
|
689
|
+
// Remove italic formatting
|
|
690
|
+
str = str.replace(/\*(.*?)\*/g, '$1');
|
|
691
|
+
// Remove code formatting
|
|
692
|
+
str = str.replace(/`(.*?)`/g, '$1');
|
|
693
|
+
return str;
|
|
670
694
|
}
|
|
671
|
-
/**
|
|
672
|
-
* TODO: Maybe use some Mermaid library instead of string templating
|
|
673
|
-
* TODO: [🕌] When more than 2 functionalities, split into separate functions
|
|
674
|
-
*/
|
|
675
695
|
|
|
676
696
|
/**
|
|
677
697
|
* Function parseNumber will parse number from string
|
|
@@ -741,127 +761,343 @@
|
|
|
741
761
|
*/
|
|
742
762
|
|
|
743
763
|
/**
|
|
744
|
-
*
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
function PromptbookLogicError(message) {
|
|
749
|
-
var _this = _super.call(this, message) || this;
|
|
750
|
-
_this.name = 'PromptbookLogicError';
|
|
751
|
-
Object.setPrototypeOf(_this, PromptbookLogicError.prototype);
|
|
752
|
-
return _this;
|
|
753
|
-
}
|
|
754
|
-
return PromptbookLogicError;
|
|
755
|
-
})(Error));
|
|
756
|
-
|
|
757
|
-
/**
|
|
758
|
-
* This error occurs during the parameter replacement in the template
|
|
764
|
+
* Parses one line of ul/ol to command
|
|
765
|
+
*
|
|
766
|
+
* @returns parsed command object
|
|
767
|
+
* @throws {PromptbookSyntaxError} if the command is invalid
|
|
759
768
|
*
|
|
760
|
-
*
|
|
769
|
+
* @private within the promptbookStringToJson
|
|
761
770
|
*/
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
_this.name = 'TemplateError';
|
|
767
|
-
Object.setPrototypeOf(_this, TemplateError.prototype);
|
|
768
|
-
return _this;
|
|
771
|
+
function parseCommand(listItem) {
|
|
772
|
+
var e_1, _a;
|
|
773
|
+
if (listItem.includes('\n') || listItem.includes('\r')) {
|
|
774
|
+
throw new PromptbookSyntaxError('Command can not contain new line characters:');
|
|
769
775
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
776
|
+
var type = listItem.trim();
|
|
777
|
+
type = type.split('`').join('');
|
|
778
|
+
type = type.split('"').join('');
|
|
779
|
+
type = type.split("'").join('');
|
|
780
|
+
type = type.split('~').join('');
|
|
781
|
+
type = type.split('[').join('');
|
|
782
|
+
type = type.split(']').join('');
|
|
783
|
+
type = type.split('(').join('');
|
|
784
|
+
type = type.split(')').join('');
|
|
785
|
+
type = normalizeTo_SCREAMING_CASE(type);
|
|
786
|
+
type = type.split('DIALOGUE').join('DIALOG');
|
|
787
|
+
var listItemParts = listItem
|
|
788
|
+
.split(' ')
|
|
789
|
+
.map(function (part) { return part.trim(); })
|
|
790
|
+
.filter(function (item) { return item !== ''; })
|
|
791
|
+
.filter(function (item) { return !/^PTBK$/i.test(item); })
|
|
792
|
+
.filter(function (item) { return !/^PROMPTBOOK$/i.test(item); })
|
|
793
|
+
.map(removeMarkdownFormatting);
|
|
794
|
+
if (type.startsWith('URL') ||
|
|
795
|
+
type.startsWith('PTBK_URL') ||
|
|
796
|
+
type.startsWith('PTBKURL') ||
|
|
797
|
+
type.startsWith('PROMPTBOOK_URL') ||
|
|
798
|
+
type.startsWith('PROMPTBOOKURL') ||
|
|
799
|
+
type.startsWith('HTTPS')) {
|
|
800
|
+
if (!(listItemParts.length === 2 || (listItemParts.length === 1 && type.startsWith('HTTPS')))) {
|
|
801
|
+
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n ")));
|
|
802
|
+
}
|
|
803
|
+
var promptbookUrlString = listItemParts.pop();
|
|
804
|
+
var promptbookUrl = new URL(promptbookUrlString);
|
|
805
|
+
if (promptbookUrl.protocol !== 'https:') {
|
|
806
|
+
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n Protocol must be HTTPS\n ")));
|
|
807
|
+
}
|
|
808
|
+
if (promptbookUrl.hash !== '') {
|
|
809
|
+
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 ")));
|
|
810
|
+
}
|
|
811
|
+
return {
|
|
812
|
+
type: 'PROMPTBOOK_URL',
|
|
813
|
+
promptbookUrl: promptbookUrl,
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
else if (type.startsWith('PROMPTBOOK_VERSION') || type.startsWith('PTBK_VERSION')) {
|
|
817
|
+
if (listItemParts.length !== 2) {
|
|
818
|
+
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid PROMPTBOOK_VERSION command:\n\n - ".concat(listItem, "\n ")));
|
|
819
|
+
}
|
|
820
|
+
var promptbookVersion = listItemParts.pop();
|
|
821
|
+
// TODO: Validate version
|
|
822
|
+
return {
|
|
823
|
+
type: 'PROMPTBOOK_VERSION',
|
|
824
|
+
promptbookVersion: promptbookVersion,
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
else if (type.startsWith('EXECUTE') ||
|
|
828
|
+
type.startsWith('EXEC') ||
|
|
829
|
+
type.startsWith('PROMPT_DIALOG') ||
|
|
830
|
+
type.startsWith('SIMPLE_TEMPLATE')) {
|
|
831
|
+
var executionTypes = ExecutionTypes.filter(function (executionType) { return type.includes(executionType); });
|
|
832
|
+
if (executionTypes.length !== 1) {
|
|
833
|
+
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 "); }));
|
|
834
|
+
}
|
|
835
|
+
return {
|
|
836
|
+
type: 'EXECUTE',
|
|
837
|
+
executionType: executionTypes[0],
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
else if (type.startsWith('MODEL')) {
|
|
841
|
+
// TODO: Make this more elegant and dynamically
|
|
842
|
+
if (type.startsWith('MODEL_VARIANT')) {
|
|
843
|
+
if (type === 'MODEL_VARIANT_CHAT') {
|
|
844
|
+
return {
|
|
845
|
+
type: 'MODEL',
|
|
846
|
+
key: 'modelVariant',
|
|
847
|
+
value: 'CHAT',
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
else if (type === 'MODEL_VARIANT_COMPLETION') {
|
|
851
|
+
return {
|
|
852
|
+
type: 'MODEL',
|
|
853
|
+
key: 'modelVariant',
|
|
854
|
+
value: 'COMPLETION',
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
else {
|
|
858
|
+
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 "); }));
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
if (type.startsWith('MODEL_NAME')) {
|
|
862
|
+
return {
|
|
863
|
+
type: 'MODEL',
|
|
864
|
+
key: 'modelName',
|
|
865
|
+
value: listItemParts.pop(),
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
else {
|
|
869
|
+
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 "); }));
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
else if (type.startsWith('PARAM') ||
|
|
873
|
+
type.startsWith('INPUT_PARAM') ||
|
|
874
|
+
type.startsWith('OUTPUT_PARAM') ||
|
|
875
|
+
listItem.startsWith('{') ||
|
|
876
|
+
listItem.startsWith('> {') /* <- Note: This is a bit hack to parse return parameters defined at the end of each section */) {
|
|
877
|
+
var parametersMatch = listItem.match(/\{(?<parameterName>[a-z0-9_]+)\}[^\S\r\n]*(?<parameterDescription>.*)$/im);
|
|
878
|
+
if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
|
|
879
|
+
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
|
|
880
|
+
}
|
|
881
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
882
|
+
var _b = parametersMatch.groups, parameterName = _b.parameterName, parameterDescription = _b.parameterDescription;
|
|
883
|
+
if (parameterDescription && parameterDescription.match(/\{(?<parameterName>[a-z0-9_]+)\}/im)) {
|
|
884
|
+
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Parameter {".concat(parameterName, "} can not contain another parameter in description:\n\n - ").concat(listItem, "\n ")));
|
|
885
|
+
}
|
|
886
|
+
var isInput = type.startsWith('INPUT');
|
|
887
|
+
var isOutput = type.startsWith('OUTPUT');
|
|
888
|
+
if (listItem.startsWith('> {')) {
|
|
889
|
+
isInput = false;
|
|
890
|
+
isOutput = false;
|
|
891
|
+
}
|
|
892
|
+
return {
|
|
893
|
+
type: 'PARAMETER',
|
|
894
|
+
parameterName: parameterName,
|
|
895
|
+
parameterDescription: parameterDescription.trim() || null,
|
|
896
|
+
isInput: isInput,
|
|
897
|
+
isOutput: isOutput,
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
else if (type.startsWith('JOKER')) {
|
|
901
|
+
if (listItemParts.length !== 2) {
|
|
902
|
+
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid JOKER command:\n\n - ".concat(listItem, "\n ")));
|
|
903
|
+
}
|
|
904
|
+
var parametersMatch = (listItemParts.pop() || '').match(/^\{(?<parameterName>[a-z0-9_]+)\}$/im);
|
|
905
|
+
if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
|
|
906
|
+
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
|
|
907
|
+
}
|
|
908
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
909
|
+
var parameterName = parametersMatch.groups.parameterName;
|
|
910
|
+
return {
|
|
911
|
+
type: 'JOKER',
|
|
912
|
+
parameterName: parameterName,
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
else if (type.startsWith('POSTPROCESS') || type.startsWith('POST_PROCESS')) {
|
|
916
|
+
if (listItemParts.length !== 2) {
|
|
917
|
+
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid POSTPROCESSING command:\n\n - ".concat(listItem, "\n ")));
|
|
918
|
+
}
|
|
919
|
+
var functionName = listItemParts.pop();
|
|
920
|
+
return {
|
|
921
|
+
type: 'POSTPROCESS',
|
|
922
|
+
functionName: functionName,
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
else if (type.startsWith('EXPECT_JSON')) {
|
|
926
|
+
return {
|
|
927
|
+
type: 'EXPECT_FORMAT',
|
|
928
|
+
format: 'JSON',
|
|
929
|
+
};
|
|
930
|
+
// [🥤]
|
|
931
|
+
}
|
|
932
|
+
else if (type.startsWith('EXPECT')) {
|
|
933
|
+
try {
|
|
934
|
+
listItemParts.shift();
|
|
935
|
+
var sign = void 0;
|
|
936
|
+
var signRaw = listItemParts.shift();
|
|
937
|
+
if (/^exact/i.test(signRaw)) {
|
|
938
|
+
sign = 'EXACTLY';
|
|
939
|
+
}
|
|
940
|
+
else if (/^min/i.test(signRaw)) {
|
|
941
|
+
sign = 'MINIMUM';
|
|
942
|
+
}
|
|
943
|
+
else if (/^max/i.test(signRaw)) {
|
|
944
|
+
sign = 'MAXIMUM';
|
|
945
|
+
}
|
|
946
|
+
else {
|
|
947
|
+
throw new PromptbookSyntaxError("Invalid sign \"".concat(signRaw, "\", expected EXACTLY, MIN or MAX"));
|
|
948
|
+
}
|
|
949
|
+
var amountRaw = listItemParts.shift();
|
|
950
|
+
var amount = parseNumber(amountRaw);
|
|
951
|
+
if (amount < 0) {
|
|
952
|
+
throw new PromptbookSyntaxError('Amount must be positive number or zero');
|
|
953
|
+
}
|
|
954
|
+
if (amount !== Math.floor(amount)) {
|
|
955
|
+
throw new PromptbookSyntaxError('Amount must be whole number');
|
|
956
|
+
}
|
|
957
|
+
var unitRaw = listItemParts.shift();
|
|
958
|
+
var unit = undefined;
|
|
959
|
+
try {
|
|
960
|
+
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()) {
|
|
961
|
+
var existingUnit = EXPECTATION_UNITS_1_1.value;
|
|
962
|
+
var existingUnitText = existingUnit;
|
|
963
|
+
existingUnitText = existingUnitText.substring(0, existingUnitText.length - 1);
|
|
964
|
+
if (existingUnitText === 'CHARACTER') {
|
|
965
|
+
existingUnitText = 'CHAR';
|
|
966
|
+
}
|
|
967
|
+
if (new RegExp("^".concat(existingUnitText.toLowerCase())).test(unitRaw.toLowerCase()) ||
|
|
968
|
+
new RegExp("^".concat(unitRaw.toLowerCase())).test(existingUnitText.toLowerCase())) {
|
|
969
|
+
if (unit !== undefined) {
|
|
970
|
+
throw new PromptbookSyntaxError("Ambiguous unit \"".concat(unitRaw, "\""));
|
|
971
|
+
}
|
|
972
|
+
unit = existingUnit;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
977
|
+
finally {
|
|
978
|
+
try {
|
|
979
|
+
if (EXPECTATION_UNITS_1_1 && !EXPECTATION_UNITS_1_1.done && (_a = EXPECTATION_UNITS_1.return)) _a.call(EXPECTATION_UNITS_1);
|
|
980
|
+
}
|
|
981
|
+
finally { if (e_1) throw e_1.error; }
|
|
982
|
+
}
|
|
983
|
+
if (unit === undefined) {
|
|
984
|
+
throw new PromptbookSyntaxError("Invalid unit \"".concat(unitRaw, "\""));
|
|
985
|
+
}
|
|
986
|
+
return {
|
|
987
|
+
type: 'EXPECT_AMOUNT',
|
|
988
|
+
sign: sign,
|
|
989
|
+
unit: unit,
|
|
990
|
+
amount: amount,
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
catch (error) {
|
|
994
|
+
if (!(error instanceof Error)) {
|
|
995
|
+
throw error;
|
|
996
|
+
}
|
|
997
|
+
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid EXPECT command; ".concat(error.message, ":\n\n - ").concat(listItem, "\n ")));
|
|
998
|
+
}
|
|
999
|
+
/*
|
|
1000
|
+
} else if (type.startsWith('__________________')) {
|
|
1001
|
+
// <- [🥻] Insert here when making new command
|
|
1002
|
+
*/
|
|
1003
|
+
}
|
|
1004
|
+
else {
|
|
1005
|
+
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 ")));
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
var defaultDiacriticsRemovalMap = [
|
|
851
1010
|
{
|
|
852
|
-
base: '
|
|
853
|
-
letters: '\
|
|
1011
|
+
base: 'A',
|
|
1012
|
+
letters: '\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F',
|
|
854
1013
|
},
|
|
1014
|
+
{ base: 'AA', letters: '\uA732' },
|
|
1015
|
+
{ base: 'AE', letters: '\u00C6\u01FC\u01E2' },
|
|
1016
|
+
{ base: 'AO', letters: '\uA734' },
|
|
1017
|
+
{ base: 'AU', letters: '\uA736' },
|
|
1018
|
+
{ base: 'AV', letters: '\uA738\uA73A' },
|
|
1019
|
+
{ base: 'AY', letters: '\uA73C' },
|
|
855
1020
|
{
|
|
856
|
-
base: '
|
|
857
|
-
letters: '\
|
|
1021
|
+
base: 'B',
|
|
1022
|
+
letters: '\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181',
|
|
858
1023
|
},
|
|
859
|
-
{ base: 'TZ', letters: '\uA728' },
|
|
860
1024
|
{
|
|
861
|
-
base: '
|
|
862
|
-
letters: '\
|
|
1025
|
+
base: 'C',
|
|
1026
|
+
letters: '\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E',
|
|
863
1027
|
},
|
|
864
|
-
{
|
|
1028
|
+
{
|
|
1029
|
+
base: 'D',
|
|
1030
|
+
letters: '\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779\u00D0',
|
|
1031
|
+
},
|
|
1032
|
+
{ base: 'DZ', letters: '\u01F1\u01C4' },
|
|
1033
|
+
{ base: 'Dz', letters: '\u01F2\u01C5' },
|
|
1034
|
+
{
|
|
1035
|
+
base: 'E',
|
|
1036
|
+
letters: '\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E',
|
|
1037
|
+
},
|
|
1038
|
+
{ base: 'F', letters: '\u0046\u24BB\uFF26\u1E1E\u0191\uA77B' },
|
|
1039
|
+
{
|
|
1040
|
+
base: 'G',
|
|
1041
|
+
letters: '\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E',
|
|
1042
|
+
},
|
|
1043
|
+
{
|
|
1044
|
+
base: 'H',
|
|
1045
|
+
letters: '\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D',
|
|
1046
|
+
},
|
|
1047
|
+
{
|
|
1048
|
+
base: 'I',
|
|
1049
|
+
letters: '\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197',
|
|
1050
|
+
},
|
|
1051
|
+
{ base: 'J', letters: '\u004A\u24BF\uFF2A\u0134\u0248' },
|
|
1052
|
+
{
|
|
1053
|
+
base: 'K',
|
|
1054
|
+
letters: '\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2',
|
|
1055
|
+
},
|
|
1056
|
+
{
|
|
1057
|
+
base: 'L',
|
|
1058
|
+
letters: '\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780',
|
|
1059
|
+
},
|
|
1060
|
+
{ base: 'LJ', letters: '\u01C7' },
|
|
1061
|
+
{ base: 'Lj', letters: '\u01C8' },
|
|
1062
|
+
{ base: 'M', letters: '\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C' },
|
|
1063
|
+
{
|
|
1064
|
+
base: 'N',
|
|
1065
|
+
letters: '\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4',
|
|
1066
|
+
},
|
|
1067
|
+
{ base: 'NJ', letters: '\u01CA' },
|
|
1068
|
+
{ base: 'Nj', letters: '\u01CB' },
|
|
1069
|
+
{
|
|
1070
|
+
base: 'O',
|
|
1071
|
+
letters: '\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C',
|
|
1072
|
+
},
|
|
1073
|
+
{ base: 'OI', letters: '\u01A2' },
|
|
1074
|
+
{ base: 'OO', letters: '\uA74E' },
|
|
1075
|
+
{ base: 'OU', letters: '\u0222' },
|
|
1076
|
+
{ base: 'OE', letters: '\u008C\u0152' },
|
|
1077
|
+
{ base: 'oe', letters: '\u009C\u0153' },
|
|
1078
|
+
{
|
|
1079
|
+
base: 'P',
|
|
1080
|
+
letters: '\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754',
|
|
1081
|
+
},
|
|
1082
|
+
{ base: 'Q', letters: '\u0051\u24C6\uFF31\uA756\uA758\u024A' },
|
|
1083
|
+
{
|
|
1084
|
+
base: 'R',
|
|
1085
|
+
letters: '\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782',
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
base: 'S',
|
|
1089
|
+
letters: '\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784',
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
base: 'T',
|
|
1093
|
+
letters: '\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786',
|
|
1094
|
+
},
|
|
1095
|
+
{ base: 'TZ', letters: '\uA728' },
|
|
1096
|
+
{
|
|
1097
|
+
base: 'U',
|
|
1098
|
+
letters: '\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244',
|
|
1099
|
+
},
|
|
1100
|
+
{ base: 'V', letters: '\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245' },
|
|
865
1101
|
{ base: 'VY', letters: '\uA760' },
|
|
866
1102
|
{
|
|
867
1103
|
base: 'W',
|
|
@@ -993,492 +1229,113 @@
|
|
|
993
1229
|
var letters = defaultDiacriticsRemovalMap[i].letters;
|
|
994
1230
|
// tslint:disable-next-line: prefer-for-of
|
|
995
1231
|
for (var j = 0; j < letters.length; j++) {
|
|
996
|
-
DIACRITIC_VARIANTS_LETTERS[letters[j]] = defaultDiacriticsRemovalMap[i].base;
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
// <- TODO: [🍓] Put to maker function to save execution time if not needed
|
|
1000
|
-
/*
|
|
1001
|
-
@see https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript
|
|
1002
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
1003
|
-
you may not use this file except in compliance with the License.
|
|
1004
|
-
You may obtain a copy of the License at
|
|
1005
|
-
|
|
1006
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
1007
|
-
|
|
1008
|
-
Unless required by applicable law or agreed to in writing, software
|
|
1009
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
1010
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1011
|
-
See the License for the specific language governing permissions and
|
|
1012
|
-
limitations under the License.
|
|
1013
|
-
*/
|
|
1014
|
-
|
|
1015
|
-
/**
|
|
1016
|
-
*
|
|
1017
|
-
*/
|
|
1018
|
-
function removeDiacritics(input) {
|
|
1019
|
-
/*eslint no-control-regex: "off"*/
|
|
1020
|
-
return input.replace(/[^\u0000-\u007E]/g, function (a) {
|
|
1021
|
-
return DIACRITIC_VARIANTS_LETTERS[a] || a;
|
|
1022
|
-
});
|
|
1023
|
-
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
/* tslint:disable */
|
|
1042
|
-
/*
|
|
1043
|
-
TODO: Tests
|
|
1044
|
-
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
|
|
1045
|
-
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ěščřžžýáíúů' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
|
|
1046
|
-
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
|
|
1047
|
-
expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
|
|
1048
|
-
*/
|
|
1049
|
-
function normalizeTo_SCREAMING_CASE(sentence) {
|
|
1050
|
-
var e_1, _a;
|
|
1051
|
-
var charType;
|
|
1052
|
-
var lastCharType = 'OTHER';
|
|
1053
|
-
var normalizedName = '';
|
|
1054
|
-
try {
|
|
1055
|
-
for (var sentence_1 = __values(sentence), sentence_1_1 = sentence_1.next(); !sentence_1_1.done; sentence_1_1 = sentence_1.next()) {
|
|
1056
|
-
var char = sentence_1_1.value;
|
|
1057
|
-
var normalizedChar = void 0;
|
|
1058
|
-
if (/^[a-z]$/.test(char)) {
|
|
1059
|
-
charType = 'LOWERCASE';
|
|
1060
|
-
normalizedChar = char.toUpperCase();
|
|
1061
|
-
}
|
|
1062
|
-
else if (/^[A-Z]$/.test(char)) {
|
|
1063
|
-
charType = 'UPPERCASE';
|
|
1064
|
-
normalizedChar = char;
|
|
1065
|
-
}
|
|
1066
|
-
else if (/^[0-9]$/.test(char)) {
|
|
1067
|
-
charType = 'NUMBER';
|
|
1068
|
-
normalizedChar = char;
|
|
1069
|
-
}
|
|
1070
|
-
else if (/^\/$/.test(char)) {
|
|
1071
|
-
charType = 'SLASH';
|
|
1072
|
-
normalizedChar = char;
|
|
1073
|
-
}
|
|
1074
|
-
else {
|
|
1075
|
-
charType = 'OTHER';
|
|
1076
|
-
normalizedChar = '_';
|
|
1077
|
-
}
|
|
1078
|
-
if (charType !== lastCharType &&
|
|
1079
|
-
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
1080
|
-
!(lastCharType === 'NUMBER') &&
|
|
1081
|
-
!(charType === 'NUMBER')) {
|
|
1082
|
-
normalizedName += '_';
|
|
1083
|
-
}
|
|
1084
|
-
normalizedName += normalizedChar;
|
|
1085
|
-
lastCharType = charType;
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1089
|
-
finally {
|
|
1090
|
-
try {
|
|
1091
|
-
if (sentence_1_1 && !sentence_1_1.done && (_a = sentence_1.return)) _a.call(sentence_1);
|
|
1092
|
-
}
|
|
1093
|
-
finally { if (e_1) throw e_1.error; }
|
|
1094
|
-
}
|
|
1095
|
-
normalizedName = normalizedName.replace(/_+/g, '_');
|
|
1096
|
-
normalizedName = normalizedName.replace(/_?\/_?/g, '/');
|
|
1097
|
-
normalizedName = normalizedName.replace(/^_/, '');
|
|
1098
|
-
normalizedName = normalizedName.replace(/_$/, '');
|
|
1099
|
-
return normalizedName;
|
|
1100
|
-
}
|
|
1101
|
-
/**
|
|
1102
|
-
* TODO: [🌺] Use some intermediate util splitWords
|
|
1103
|
-
*/
|
|
1104
|
-
|
|
1105
|
-
/* tslint:disable */
|
|
1106
|
-
function normalizeToKebabCase(sentence) {
|
|
1107
|
-
var e_1, _a;
|
|
1108
|
-
sentence = removeDiacritics(sentence);
|
|
1109
|
-
var charType;
|
|
1110
|
-
var lastCharType = 'OTHER';
|
|
1111
|
-
var normalizedName = '';
|
|
1112
|
-
try {
|
|
1113
|
-
for (var sentence_1 = __values(sentence), sentence_1_1 = sentence_1.next(); !sentence_1_1.done; sentence_1_1 = sentence_1.next()) {
|
|
1114
|
-
var char = sentence_1_1.value;
|
|
1115
|
-
var normalizedChar = void 0;
|
|
1116
|
-
if (/^[a-z]$/.test(char)) {
|
|
1117
|
-
charType = 'LOWERCASE';
|
|
1118
|
-
normalizedChar = char;
|
|
1119
|
-
}
|
|
1120
|
-
else if (/^[A-Z]$/.test(char)) {
|
|
1121
|
-
charType = 'UPPERCASE';
|
|
1122
|
-
normalizedChar = char.toLowerCase();
|
|
1123
|
-
}
|
|
1124
|
-
else if (/^[0-9]$/.test(char)) {
|
|
1125
|
-
charType = 'NUMBER';
|
|
1126
|
-
normalizedChar = char;
|
|
1127
|
-
}
|
|
1128
|
-
else if (/^\/$/.test(char)) {
|
|
1129
|
-
charType = 'SLASH';
|
|
1130
|
-
normalizedChar = char;
|
|
1131
|
-
}
|
|
1132
|
-
else {
|
|
1133
|
-
charType = 'OTHER';
|
|
1134
|
-
normalizedChar = '-';
|
|
1135
|
-
}
|
|
1136
|
-
if (charType !== lastCharType &&
|
|
1137
|
-
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
1138
|
-
!(lastCharType === 'NUMBER') &&
|
|
1139
|
-
!(charType === 'NUMBER')) {
|
|
1140
|
-
normalizedName += '-';
|
|
1141
|
-
}
|
|
1142
|
-
normalizedName += normalizedChar;
|
|
1143
|
-
lastCharType = charType;
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1147
|
-
finally {
|
|
1148
|
-
try {
|
|
1149
|
-
if (sentence_1_1 && !sentence_1_1.done && (_a = sentence_1.return)) _a.call(sentence_1);
|
|
1150
|
-
}
|
|
1151
|
-
finally { if (e_1) throw e_1.error; }
|
|
1152
|
-
}
|
|
1153
|
-
normalizedName = normalizedName.split(/-+/g).join('-');
|
|
1154
|
-
normalizedName = normalizedName.split(/-?\/-?/g).join('/');
|
|
1155
|
-
normalizedName = normalizedName.replace(/^-/, '');
|
|
1156
|
-
normalizedName = normalizedName.replace(/-$/, '');
|
|
1157
|
-
return normalizedName;
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
/* tslint:disable */
|
|
1161
|
-
function normalizeTo_camelCase(sentence, __firstLetterCapital) {
|
|
1162
|
-
var e_1, _a;
|
|
1163
|
-
if (__firstLetterCapital === void 0) { __firstLetterCapital = false; }
|
|
1164
|
-
var charType;
|
|
1165
|
-
var lastCharType = null;
|
|
1166
|
-
var normalizedName = '';
|
|
1167
|
-
try {
|
|
1168
|
-
for (var sentence_1 = __values(sentence), sentence_1_1 = sentence_1.next(); !sentence_1_1.done; sentence_1_1 = sentence_1.next()) {
|
|
1169
|
-
var char = sentence_1_1.value;
|
|
1170
|
-
var normalizedChar = void 0;
|
|
1171
|
-
if (/^[a-z]$/.test(char)) {
|
|
1172
|
-
charType = 'LOWERCASE';
|
|
1173
|
-
normalizedChar = char;
|
|
1174
|
-
}
|
|
1175
|
-
else if (/^[A-Z]$/.test(char)) {
|
|
1176
|
-
charType = 'UPPERCASE';
|
|
1177
|
-
normalizedChar = char.toLowerCase();
|
|
1178
|
-
}
|
|
1179
|
-
else if (/^[0-9]$/.test(char)) {
|
|
1180
|
-
charType = 'NUMBER';
|
|
1181
|
-
normalizedChar = char;
|
|
1182
|
-
}
|
|
1183
|
-
else {
|
|
1184
|
-
charType = 'OTHER';
|
|
1185
|
-
normalizedChar = '';
|
|
1186
|
-
}
|
|
1187
|
-
if (!lastCharType) {
|
|
1188
|
-
if (__firstLetterCapital) {
|
|
1189
|
-
normalizedChar = normalizedChar.toUpperCase(); //TODO: DRY
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
else if (charType !== lastCharType &&
|
|
1193
|
-
!(charType === 'LOWERCASE' && lastCharType === 'UPPERCASE') &&
|
|
1194
|
-
!(lastCharType === 'NUMBER') &&
|
|
1195
|
-
!(charType === 'NUMBER')) {
|
|
1196
|
-
normalizedChar = normalizedChar.toUpperCase(); //TODO: [🌺] DRY
|
|
1197
|
-
}
|
|
1198
|
-
normalizedName += normalizedChar;
|
|
1199
|
-
lastCharType = charType;
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1203
|
-
finally {
|
|
1204
|
-
try {
|
|
1205
|
-
if (sentence_1_1 && !sentence_1_1.done && (_a = sentence_1.return)) _a.call(sentence_1);
|
|
1206
|
-
}
|
|
1207
|
-
finally { if (e_1) throw e_1.error; }
|
|
1208
|
-
}
|
|
1209
|
-
return normalizedName;
|
|
1210
|
-
}
|
|
1211
|
-
/**
|
|
1212
|
-
* TODO: [🌺] Use some intermediate util splitWords
|
|
1213
|
-
*/
|
|
1214
|
-
|
|
1215
|
-
/**
|
|
1216
|
-
* Execution type describes the way how the block is executed
|
|
1217
|
-
*
|
|
1218
|
-
* @see https://github.com/webgptorg/promptbook#execution-type
|
|
1219
|
-
*/
|
|
1220
|
-
var ExecutionTypes = [
|
|
1221
|
-
'PROMPT_TEMPLATE',
|
|
1222
|
-
'SIMPLE_TEMPLATE',
|
|
1223
|
-
'SCRIPT',
|
|
1224
|
-
'PROMPT_DIALOG',
|
|
1225
|
-
// <- [🥻] Insert here when making new command
|
|
1226
|
-
];
|
|
1227
|
-
|
|
1228
|
-
/**
|
|
1229
|
-
* Units of text measurement
|
|
1230
|
-
*/
|
|
1231
|
-
var EXPECTATION_UNITS = ['CHARACTERS', 'WORDS', 'SENTENCES', 'LINES', 'PARAGRAPHS', 'PAGES'];
|
|
1232
|
-
/**
|
|
1233
|
-
* TODO: [💝] Unite object for expecting amount and format - remove expectFormat
|
|
1234
|
-
* TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
|
|
1235
|
-
* TODO: [👙][🧠] Just selecting gpt3 or gpt4 level of model
|
|
1236
|
-
*/
|
|
1237
|
-
|
|
1238
|
-
/**
|
|
1239
|
-
* Parses one line of ul/ol to command
|
|
1240
|
-
*
|
|
1241
|
-
* @returns parsed command object
|
|
1242
|
-
* @throws {PromptbookSyntaxError} if the command is invalid
|
|
1243
|
-
*
|
|
1244
|
-
* @private within the promptbookStringToJson
|
|
1245
|
-
*/
|
|
1246
|
-
function parseCommand(listItem) {
|
|
1247
|
-
var e_1, _a;
|
|
1248
|
-
if (listItem.includes('\n') || listItem.includes('\r')) {
|
|
1249
|
-
throw new PromptbookSyntaxError('Command can not contain new line characters:');
|
|
1250
|
-
}
|
|
1251
|
-
var type = listItem.trim();
|
|
1252
|
-
type = type.split('`').join('');
|
|
1253
|
-
type = type.split('"').join('');
|
|
1254
|
-
type = type.split("'").join('');
|
|
1255
|
-
type = type.split('~').join('');
|
|
1256
|
-
type = type.split('[').join('');
|
|
1257
|
-
type = type.split(']').join('');
|
|
1258
|
-
type = type.split('(').join('');
|
|
1259
|
-
type = type.split(')').join('');
|
|
1260
|
-
type = normalizeTo_SCREAMING_CASE(type);
|
|
1261
|
-
type = type.split('DIALOGUE').join('DIALOG');
|
|
1262
|
-
var listItemParts = listItem
|
|
1263
|
-
.split(' ')
|
|
1264
|
-
.map(function (part) { return part.trim(); })
|
|
1265
|
-
.filter(function (item) { return item !== ''; })
|
|
1266
|
-
.filter(function (item) { return !/^PTBK$/i.test(item); })
|
|
1267
|
-
.filter(function (item) { return !/^PROMPTBOOK$/i.test(item); })
|
|
1268
|
-
.map(removeMarkdownFormatting);
|
|
1269
|
-
if (type.startsWith('URL') ||
|
|
1270
|
-
type.startsWith('PTBK_URL') ||
|
|
1271
|
-
type.startsWith('PTBKURL') ||
|
|
1272
|
-
type.startsWith('PROMPTBOOK_URL') ||
|
|
1273
|
-
type.startsWith('PROMPTBOOKURL') ||
|
|
1274
|
-
type.startsWith('HTTPS')) {
|
|
1275
|
-
if (!(listItemParts.length === 2 || (listItemParts.length === 1 && type.startsWith('HTTPS')))) {
|
|
1276
|
-
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n ")));
|
|
1277
|
-
}
|
|
1278
|
-
var promptbookUrlString = listItemParts.pop();
|
|
1279
|
-
var promptbookUrl = new URL(promptbookUrlString);
|
|
1280
|
-
if (promptbookUrl.protocol !== 'https:') {
|
|
1281
|
-
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n Protocol must be HTTPS\n ")));
|
|
1282
|
-
}
|
|
1283
|
-
if (promptbookUrl.hash !== '') {
|
|
1284
|
-
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 ")));
|
|
1285
|
-
}
|
|
1286
|
-
return {
|
|
1287
|
-
type: 'PROMPTBOOK_URL',
|
|
1288
|
-
promptbookUrl: promptbookUrl,
|
|
1289
|
-
};
|
|
1290
|
-
}
|
|
1291
|
-
else if (type.startsWith('PROMPTBOOK_VERSION') || type.startsWith('PTBK_VERSION')) {
|
|
1292
|
-
if (listItemParts.length !== 2) {
|
|
1293
|
-
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid PROMPTBOOK_VERSION command:\n\n - ".concat(listItem, "\n ")));
|
|
1294
|
-
}
|
|
1295
|
-
var promptbookVersion = listItemParts.pop();
|
|
1296
|
-
// TODO: Validate version
|
|
1297
|
-
return {
|
|
1298
|
-
type: 'PROMPTBOOK_VERSION',
|
|
1299
|
-
promptbookVersion: promptbookVersion,
|
|
1300
|
-
};
|
|
1301
|
-
}
|
|
1302
|
-
else if (type.startsWith('EXECUTE') ||
|
|
1303
|
-
type.startsWith('EXEC') ||
|
|
1304
|
-
type.startsWith('PROMPT_DIALOG') ||
|
|
1305
|
-
type.startsWith('SIMPLE_TEMPLATE')) {
|
|
1306
|
-
var executionTypes = ExecutionTypes.filter(function (executionType) { return type.includes(executionType); });
|
|
1307
|
-
if (executionTypes.length !== 1) {
|
|
1308
|
-
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 "); }));
|
|
1309
|
-
}
|
|
1310
|
-
return {
|
|
1311
|
-
type: 'EXECUTE',
|
|
1312
|
-
executionType: executionTypes[0],
|
|
1313
|
-
};
|
|
1314
|
-
}
|
|
1315
|
-
else if (type.startsWith('MODEL')) {
|
|
1316
|
-
// TODO: Make this more elegant and dynamically
|
|
1317
|
-
if (type.startsWith('MODEL_VARIANT')) {
|
|
1318
|
-
if (type === 'MODEL_VARIANT_CHAT') {
|
|
1319
|
-
return {
|
|
1320
|
-
type: 'MODEL',
|
|
1321
|
-
key: 'modelVariant',
|
|
1322
|
-
value: 'CHAT',
|
|
1323
|
-
};
|
|
1324
|
-
}
|
|
1325
|
-
else if (type === 'MODEL_VARIANT_COMPLETION') {
|
|
1326
|
-
return {
|
|
1327
|
-
type: 'MODEL',
|
|
1328
|
-
key: 'modelVariant',
|
|
1329
|
-
value: 'COMPLETION',
|
|
1330
|
-
};
|
|
1331
|
-
}
|
|
1332
|
-
else {
|
|
1333
|
-
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 "); }));
|
|
1334
|
-
}
|
|
1335
|
-
}
|
|
1336
|
-
if (type.startsWith('MODEL_NAME')) {
|
|
1337
|
-
return {
|
|
1338
|
-
type: 'MODEL',
|
|
1339
|
-
key: 'modelName',
|
|
1340
|
-
value: listItemParts.pop(),
|
|
1341
|
-
};
|
|
1342
|
-
}
|
|
1343
|
-
else {
|
|
1344
|
-
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 "); }));
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
else if (type.startsWith('PARAM') ||
|
|
1348
|
-
type.startsWith('INPUT_PARAM') ||
|
|
1349
|
-
type.startsWith('OUTPUT_PARAM') ||
|
|
1350
|
-
listItem.startsWith('{') ||
|
|
1351
|
-
listItem.startsWith('> {') /* <- Note: This is a bit hack to parse return parameters defined at the end of each section */) {
|
|
1352
|
-
var parametersMatch = listItem.match(/\{(?<parameterName>[a-z0-9_]+)\}[^\S\r\n]*(?<parameterDescription>.*)$/im);
|
|
1353
|
-
if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
|
|
1354
|
-
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
|
|
1355
|
-
}
|
|
1356
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1357
|
-
var _b = parametersMatch.groups, parameterName = _b.parameterName, parameterDescription = _b.parameterDescription;
|
|
1358
|
-
if (parameterDescription && parameterDescription.match(/\{(?<parameterName>[a-z0-9_]+)\}/im)) {
|
|
1359
|
-
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Parameter {".concat(parameterName, "} can not contain another parameter in description:\n\n - ").concat(listItem, "\n ")));
|
|
1360
|
-
}
|
|
1361
|
-
var isInput = type.startsWith('INPUT');
|
|
1362
|
-
var isOutput = type.startsWith('OUTPUT');
|
|
1363
|
-
if (listItem.startsWith('> {')) {
|
|
1364
|
-
isInput = false;
|
|
1365
|
-
isOutput = false;
|
|
1366
|
-
}
|
|
1367
|
-
return {
|
|
1368
|
-
type: 'PARAMETER',
|
|
1369
|
-
parameterName: parameterName,
|
|
1370
|
-
parameterDescription: parameterDescription.trim() || null,
|
|
1371
|
-
isInput: isInput,
|
|
1372
|
-
isOutput: isOutput,
|
|
1373
|
-
};
|
|
1374
|
-
}
|
|
1375
|
-
else if (type.startsWith('JOKER')) {
|
|
1376
|
-
if (listItemParts.length !== 2) {
|
|
1377
|
-
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid JOKER command:\n\n - ".concat(listItem, "\n ")));
|
|
1378
|
-
}
|
|
1379
|
-
var parametersMatch = (listItemParts.pop() || '').match(/^\{(?<parameterName>[a-z0-9_]+)\}$/im);
|
|
1380
|
-
if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
|
|
1381
|
-
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
|
|
1382
|
-
}
|
|
1383
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1384
|
-
var parameterName = parametersMatch.groups.parameterName;
|
|
1385
|
-
return {
|
|
1386
|
-
type: 'JOKER',
|
|
1387
|
-
parameterName: parameterName,
|
|
1388
|
-
};
|
|
1389
|
-
}
|
|
1390
|
-
else if (type.startsWith('POSTPROCESS') || type.startsWith('POST_PROCESS')) {
|
|
1391
|
-
if (listItemParts.length !== 2) {
|
|
1392
|
-
throw new PromptbookSyntaxError(spacetrim.spaceTrim("\n Invalid POSTPROCESSING command:\n\n - ".concat(listItem, "\n ")));
|
|
1393
|
-
}
|
|
1394
|
-
var functionName = listItemParts.pop();
|
|
1395
|
-
return {
|
|
1396
|
-
type: 'POSTPROCESS',
|
|
1397
|
-
functionName: functionName,
|
|
1398
|
-
};
|
|
1399
|
-
}
|
|
1400
|
-
else if (type.startsWith('EXPECT_JSON')) {
|
|
1401
|
-
return {
|
|
1402
|
-
type: 'EXPECT_FORMAT',
|
|
1403
|
-
format: 'JSON',
|
|
1404
|
-
};
|
|
1405
|
-
// [🥤]
|
|
1406
|
-
}
|
|
1407
|
-
else if (type.startsWith('EXPECT')) {
|
|
1408
|
-
try {
|
|
1409
|
-
listItemParts.shift();
|
|
1410
|
-
var sign = void 0;
|
|
1411
|
-
var signRaw = listItemParts.shift();
|
|
1412
|
-
if (/^exact/i.test(signRaw)) {
|
|
1413
|
-
sign = 'EXACTLY';
|
|
1414
|
-
}
|
|
1415
|
-
else if (/^min/i.test(signRaw)) {
|
|
1416
|
-
sign = 'MINIMUM';
|
|
1417
|
-
}
|
|
1418
|
-
else if (/^max/i.test(signRaw)) {
|
|
1419
|
-
sign = 'MAXIMUM';
|
|
1420
|
-
}
|
|
1421
|
-
else {
|
|
1422
|
-
throw new PromptbookSyntaxError("Invalid sign \"".concat(signRaw, "\", expected EXACTLY, MIN or MAX"));
|
|
1423
|
-
}
|
|
1424
|
-
var amountRaw = listItemParts.shift();
|
|
1425
|
-
var amount = parseNumber(amountRaw);
|
|
1426
|
-
if (amount < 0) {
|
|
1427
|
-
throw new PromptbookSyntaxError('Amount must be positive number or zero');
|
|
1232
|
+
DIACRITIC_VARIANTS_LETTERS[letters[j]] = defaultDiacriticsRemovalMap[i].base;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
// <- TODO: [🍓] Put to maker function to save execution time if not needed
|
|
1236
|
+
/*
|
|
1237
|
+
@see https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript
|
|
1238
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
1239
|
+
you may not use this file except in compliance with the License.
|
|
1240
|
+
You may obtain a copy of the License at
|
|
1241
|
+
|
|
1242
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
1243
|
+
|
|
1244
|
+
Unless required by applicable law or agreed to in writing, software
|
|
1245
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
1246
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1247
|
+
See the License for the specific language governing permissions and
|
|
1248
|
+
limitations under the License.
|
|
1249
|
+
*/
|
|
1250
|
+
|
|
1251
|
+
/**
|
|
1252
|
+
*
|
|
1253
|
+
*/
|
|
1254
|
+
function removeDiacritics(input) {
|
|
1255
|
+
/*eslint no-control-regex: "off"*/
|
|
1256
|
+
return input.replace(/[^\u0000-\u007E]/g, function (a) {
|
|
1257
|
+
return DIACRITIC_VARIANTS_LETTERS[a] || a;
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
/* tslint:disable */
|
|
1262
|
+
function normalizeToKebabCase(sentence) {
|
|
1263
|
+
var e_1, _a;
|
|
1264
|
+
sentence = removeDiacritics(sentence);
|
|
1265
|
+
var charType;
|
|
1266
|
+
var lastCharType = 'OTHER';
|
|
1267
|
+
var normalizedName = '';
|
|
1268
|
+
try {
|
|
1269
|
+
for (var sentence_1 = __values(sentence), sentence_1_1 = sentence_1.next(); !sentence_1_1.done; sentence_1_1 = sentence_1.next()) {
|
|
1270
|
+
var char = sentence_1_1.value;
|
|
1271
|
+
var normalizedChar = void 0;
|
|
1272
|
+
if (/^[a-z]$/.test(char)) {
|
|
1273
|
+
charType = 'LOWERCASE';
|
|
1274
|
+
normalizedChar = char;
|
|
1428
1275
|
}
|
|
1429
|
-
if (
|
|
1430
|
-
|
|
1276
|
+
else if (/^[A-Z]$/.test(char)) {
|
|
1277
|
+
charType = 'UPPERCASE';
|
|
1278
|
+
normalizedChar = char.toLowerCase();
|
|
1431
1279
|
}
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
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()) {
|
|
1436
|
-
var existingUnit = EXPECTATION_UNITS_1_1.value;
|
|
1437
|
-
var existingUnitText = existingUnit;
|
|
1438
|
-
existingUnitText = existingUnitText.substring(0, existingUnitText.length - 1);
|
|
1439
|
-
if (existingUnitText === 'CHARACTER') {
|
|
1440
|
-
existingUnitText = 'CHAR';
|
|
1441
|
-
}
|
|
1442
|
-
if (new RegExp("^".concat(existingUnitText.toLowerCase())).test(unitRaw.toLowerCase()) ||
|
|
1443
|
-
new RegExp("^".concat(unitRaw.toLowerCase())).test(existingUnitText.toLowerCase())) {
|
|
1444
|
-
if (unit !== undefined) {
|
|
1445
|
-
throw new PromptbookSyntaxError("Ambiguous unit \"".concat(unitRaw, "\""));
|
|
1446
|
-
}
|
|
1447
|
-
unit = existingUnit;
|
|
1448
|
-
}
|
|
1449
|
-
}
|
|
1280
|
+
else if (/^[0-9]$/.test(char)) {
|
|
1281
|
+
charType = 'NUMBER';
|
|
1282
|
+
normalizedChar = char;
|
|
1450
1283
|
}
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
if (EXPECTATION_UNITS_1_1 && !EXPECTATION_UNITS_1_1.done && (_a = EXPECTATION_UNITS_1.return)) _a.call(EXPECTATION_UNITS_1);
|
|
1455
|
-
}
|
|
1456
|
-
finally { if (e_1) throw e_1.error; }
|
|
1284
|
+
else if (/^\/$/.test(char)) {
|
|
1285
|
+
charType = 'SLASH';
|
|
1286
|
+
normalizedChar = char;
|
|
1457
1287
|
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1288
|
+
else {
|
|
1289
|
+
charType = 'OTHER';
|
|
1290
|
+
normalizedChar = '-';
|
|
1460
1291
|
}
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
};
|
|
1467
|
-
}
|
|
1468
|
-
catch (error) {
|
|
1469
|
-
if (!(error instanceof Error)) {
|
|
1470
|
-
throw error;
|
|
1292
|
+
if (charType !== lastCharType &&
|
|
1293
|
+
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
1294
|
+
!(lastCharType === 'NUMBER') &&
|
|
1295
|
+
!(charType === 'NUMBER')) {
|
|
1296
|
+
normalizedName += '-';
|
|
1471
1297
|
}
|
|
1472
|
-
|
|
1298
|
+
normalizedName += normalizedChar;
|
|
1299
|
+
lastCharType = charType;
|
|
1473
1300
|
}
|
|
1474
|
-
/*
|
|
1475
|
-
} else if (type.startsWith('__________________')) {
|
|
1476
|
-
// <- [🥻] Insert here when making new command
|
|
1477
|
-
*/
|
|
1478
1301
|
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1302
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1303
|
+
finally {
|
|
1304
|
+
try {
|
|
1305
|
+
if (sentence_1_1 && !sentence_1_1.done && (_a = sentence_1.return)) _a.call(sentence_1);
|
|
1306
|
+
}
|
|
1307
|
+
finally { if (e_1) throw e_1.error; }
|
|
1481
1308
|
}
|
|
1309
|
+
normalizedName = normalizedName.split(/-+/g).join('-');
|
|
1310
|
+
normalizedName = normalizedName.split(/-?\/-?/g).join('/');
|
|
1311
|
+
normalizedName = normalizedName.replace(/^-/, '');
|
|
1312
|
+
normalizedName = normalizedName.replace(/-$/, '');
|
|
1313
|
+
return normalizedName;
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
/**
|
|
1317
|
+
* Removes emojis from a string and fix whitespaces
|
|
1318
|
+
*
|
|
1319
|
+
* @param text with emojis
|
|
1320
|
+
* @returns text without emojis
|
|
1321
|
+
*/
|
|
1322
|
+
function removeEmojis(text) {
|
|
1323
|
+
// Replace emojis (and also ZWJ sequence) with hyphens
|
|
1324
|
+
text = text.replace(/(\p{Extended_Pictographic})\p{Modifier_Symbol}/gu, '$1');
|
|
1325
|
+
text = text.replace(/(\p{Extended_Pictographic})[\u{FE00}-\u{FE0F}]/gu, '$1');
|
|
1326
|
+
text = text.replace(/(\p{Extended_Pictographic})(\u{200D}\p{Extended_Pictographic})*/gu, '$1');
|
|
1327
|
+
text = text.replace(/\p{Extended_Pictographic}/gu, '');
|
|
1328
|
+
return text;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* Function normalizes title to name which can be used as identifier
|
|
1333
|
+
*/
|
|
1334
|
+
function titleToName(value) {
|
|
1335
|
+
value = removeEmojis(value);
|
|
1336
|
+
value = normalizeToKebabCase(value);
|
|
1337
|
+
// TODO: [🧠] Maybe warn or add some padding to short name which are not good identifiers
|
|
1338
|
+
return value;
|
|
1482
1339
|
}
|
|
1483
1340
|
|
|
1484
1341
|
/**
|
|
@@ -1786,6 +1643,119 @@
|
|
|
1786
1643
|
}
|
|
1787
1644
|
}
|
|
1788
1645
|
|
|
1646
|
+
/* tslint:disable */
|
|
1647
|
+
function normalizeTo_camelCase(sentence, __firstLetterCapital) {
|
|
1648
|
+
var e_1, _a;
|
|
1649
|
+
if (__firstLetterCapital === void 0) { __firstLetterCapital = false; }
|
|
1650
|
+
var charType;
|
|
1651
|
+
var lastCharType = null;
|
|
1652
|
+
var normalizedName = '';
|
|
1653
|
+
try {
|
|
1654
|
+
for (var sentence_1 = __values(sentence), sentence_1_1 = sentence_1.next(); !sentence_1_1.done; sentence_1_1 = sentence_1.next()) {
|
|
1655
|
+
var char = sentence_1_1.value;
|
|
1656
|
+
var normalizedChar = void 0;
|
|
1657
|
+
if (/^[a-z]$/.test(char)) {
|
|
1658
|
+
charType = 'LOWERCASE';
|
|
1659
|
+
normalizedChar = char;
|
|
1660
|
+
}
|
|
1661
|
+
else if (/^[A-Z]$/.test(char)) {
|
|
1662
|
+
charType = 'UPPERCASE';
|
|
1663
|
+
normalizedChar = char.toLowerCase();
|
|
1664
|
+
}
|
|
1665
|
+
else if (/^[0-9]$/.test(char)) {
|
|
1666
|
+
charType = 'NUMBER';
|
|
1667
|
+
normalizedChar = char;
|
|
1668
|
+
}
|
|
1669
|
+
else {
|
|
1670
|
+
charType = 'OTHER';
|
|
1671
|
+
normalizedChar = '';
|
|
1672
|
+
}
|
|
1673
|
+
if (!lastCharType) {
|
|
1674
|
+
if (__firstLetterCapital) {
|
|
1675
|
+
normalizedChar = normalizedChar.toUpperCase(); //TODO: DRY
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
else if (charType !== lastCharType &&
|
|
1679
|
+
!(charType === 'LOWERCASE' && lastCharType === 'UPPERCASE') &&
|
|
1680
|
+
!(lastCharType === 'NUMBER') &&
|
|
1681
|
+
!(charType === 'NUMBER')) {
|
|
1682
|
+
normalizedChar = normalizedChar.toUpperCase(); //TODO: [🌺] DRY
|
|
1683
|
+
}
|
|
1684
|
+
normalizedName += normalizedChar;
|
|
1685
|
+
lastCharType = charType;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1689
|
+
finally {
|
|
1690
|
+
try {
|
|
1691
|
+
if (sentence_1_1 && !sentence_1_1.done && (_a = sentence_1.return)) _a.call(sentence_1);
|
|
1692
|
+
}
|
|
1693
|
+
finally { if (e_1) throw e_1.error; }
|
|
1694
|
+
}
|
|
1695
|
+
return normalizedName;
|
|
1696
|
+
}
|
|
1697
|
+
/**
|
|
1698
|
+
* TODO: [🌺] Use some intermediate util splitWords
|
|
1699
|
+
*/
|
|
1700
|
+
|
|
1701
|
+
/**
|
|
1702
|
+
* Creates a Mermaid graph based on the promptbook
|
|
1703
|
+
*
|
|
1704
|
+
* Note: The result is not wrapped in a Markdown code block
|
|
1705
|
+
*/
|
|
1706
|
+
function renderPromptbookMermaid(promptbookJson, options) {
|
|
1707
|
+
var _a = (options || {}).linkPromptTemplate, linkPromptTemplate = _a === void 0 ? function () { return null; } : _a;
|
|
1708
|
+
var parameterNameToTemplateName = function (parameterName) {
|
|
1709
|
+
var parameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
|
|
1710
|
+
if (!parameter) {
|
|
1711
|
+
throw new UnexpectedError("Could not find {".concat(parameterName, "}"));
|
|
1712
|
+
}
|
|
1713
|
+
if (parameter.isInput) {
|
|
1714
|
+
return 'input';
|
|
1715
|
+
}
|
|
1716
|
+
var template = promptbookJson.promptTemplates.find(function (template) { return template.resultingParameterName === parameterName; });
|
|
1717
|
+
if (!template) {
|
|
1718
|
+
throw new Error("Could not find template for {".concat(parameterName, "}"));
|
|
1719
|
+
}
|
|
1720
|
+
return normalizeTo_camelCase('template-' + titleToName(template.title));
|
|
1721
|
+
};
|
|
1722
|
+
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
|
|
1723
|
+
.flatMap(function (_a) {
|
|
1724
|
+
var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
|
|
1725
|
+
return __spreadArray([
|
|
1726
|
+
"".concat(parameterNameToTemplateName(resultingParameterName), "(\"").concat(title, "\")")
|
|
1727
|
+
], __read(dependentParameterNames.map(function (dependentParameterName) {
|
|
1728
|
+
return "".concat(parameterNameToTemplateName(dependentParameterName), "--\"{").concat(dependentParameterName, "}\"-->").concat(parameterNameToTemplateName(resultingParameterName));
|
|
1729
|
+
})), false);
|
|
1730
|
+
})
|
|
1731
|
+
.join('\n')), "\n\n ").concat(block(promptbookJson.parameters
|
|
1732
|
+
.filter(function (_a) {
|
|
1733
|
+
var isOutput = _a.isOutput;
|
|
1734
|
+
return isOutput;
|
|
1735
|
+
})
|
|
1736
|
+
.map(function (_a) {
|
|
1737
|
+
var name = _a.name;
|
|
1738
|
+
return "".concat(parameterNameToTemplateName(name), "--\"{").concat(name, "}\"-->output");
|
|
1739
|
+
})
|
|
1740
|
+
.join('\n')), "\n output((Output)):::output\n\n ").concat(block(promptbookJson.promptTemplates
|
|
1741
|
+
.map(function (promptTemplate) {
|
|
1742
|
+
var link = linkPromptTemplate(promptTemplate);
|
|
1743
|
+
if (link === null) {
|
|
1744
|
+
return '';
|
|
1745
|
+
}
|
|
1746
|
+
var href = link.href, title = link.title;
|
|
1747
|
+
var templateName = parameterNameToTemplateName(promptTemplate.resultingParameterName);
|
|
1748
|
+
return "click ".concat(templateName, " href \"").concat(href, "\" \"").concat(title, "\";");
|
|
1749
|
+
})
|
|
1750
|
+
.filter(function (line) { return line !== ''; })
|
|
1751
|
+
.join('\n')), "\n\n classDef input color: grey;\n classDef output color: grey;\n\n end;\n\n "); });
|
|
1752
|
+
return promptbookMermaid;
|
|
1753
|
+
}
|
|
1754
|
+
/**
|
|
1755
|
+
* TODO: Maybe use some Mermaid library instead of string templating
|
|
1756
|
+
* TODO: [🕌] When more than 2 functionalities, split into separate functions
|
|
1757
|
+
*/
|
|
1758
|
+
|
|
1789
1759
|
/**
|
|
1790
1760
|
* Prettyfies Promptbook string and adds Mermaid graph
|
|
1791
1761
|
*/
|