@promptbook/core 0.70.0-1 β 0.72.0-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 +21 -57
- package/esm/index.es.js +260 -277
- package/esm/index.es.js.map +1 -1
- package/esm/typings/promptbook-collection/index.d.ts +0 -3
- package/esm/typings/src/_packages/core.index.d.ts +4 -2
- package/esm/typings/src/_packages/openai.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
- package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
- package/esm/typings/src/commands/FOREACH/ForeachCommand.d.ts +1 -6
- package/esm/typings/src/commands/FOREACH/foreachCommandParser.d.ts +1 -2
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +1 -16
- package/esm/typings/src/config.d.ts +2 -2
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -1
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +5 -5
- package/esm/typings/src/execution/createPipelineExecutor.d.ts +1 -1
- package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +1 -1
- package/esm/typings/src/execution/utils/addUsage.d.ts +0 -56
- package/esm/typings/src/execution/utils/usage-constants.d.ts +127 -0
- package/esm/typings/src/knowledge/dialogs/callback/CallbackInterfaceTools.d.ts +1 -1
- package/esm/typings/src/knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -1
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -1
- package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/cache/CacheItem.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -2
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +2 -2
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +3 -2
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +37 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +14 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -2
- package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/personas/preparePersona.d.ts +1 -1
- package/esm/typings/src/prepare/isPipelinePrepared.d.ts +1 -1
- package/esm/typings/src/prepare/prepareTemplates.d.ts +1 -1
- package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/python/PythonExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/typescript/TypescriptExecutionTools.d.ts +1 -1
- package/esm/typings/src/storage/files-storage/FilesStorage.d.ts +1 -1
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -1
- package/esm/typings/src/types/typeAliases.d.ts +1 -1
- package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +1 -1
- package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +260 -276
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/personas/preparePersona.test.d.ts +0 -1
package/esm/index.es.js
CHANGED
|
@@ -10,8 +10,8 @@ import moment from 'moment';
|
|
|
10
10
|
/**
|
|
11
11
|
* The version of the Promptbook library
|
|
12
12
|
*/
|
|
13
|
-
var PROMPTBOOK_VERSION = '0.
|
|
14
|
-
// TODO: !!!! List here all the versions and annotate + put into script
|
|
13
|
+
var PROMPTBOOK_VERSION = '0.68.5';
|
|
14
|
+
// TODO:[main] !!!! List here all the versions and annotate + put into script
|
|
15
15
|
|
|
16
16
|
/*! *****************************************************************************
|
|
17
17
|
Copyright (c) Microsoft Corporation.
|
|
@@ -223,7 +223,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
223
223
|
commands.push("PIPELINE URL ".concat(pipelineUrl));
|
|
224
224
|
}
|
|
225
225
|
commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
|
|
226
|
-
// TODO: !!! This increase size of the bundle and is probbably not necessary
|
|
226
|
+
// TODO:[main] !!! This increase size of the bundle and is probbably not necessary
|
|
227
227
|
pipelineString = prettifyMarkdown(pipelineString);
|
|
228
228
|
try {
|
|
229
229
|
for (var _g = __values(parameters.filter(function (_a) {
|
|
@@ -371,12 +371,12 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
371
371
|
pipelineString += '```' + contentLanguage;
|
|
372
372
|
pipelineString += '\n';
|
|
373
373
|
pipelineString += spaceTrim(content);
|
|
374
|
-
// <- TODO: !!! Escape
|
|
374
|
+
// <- TODO:[main] !!! Escape
|
|
375
375
|
// <- TODO: [π§ ] Some clear strategy how to spaceTrim the blocks
|
|
376
376
|
pipelineString += '\n';
|
|
377
377
|
pipelineString += '```';
|
|
378
378
|
pipelineString += '\n\n';
|
|
379
|
-
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: !!! If the parameter here has description, add it and use templateParameterJsonToString
|
|
379
|
+
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO:[main] !!! If the parameter here has description, add it and use templateParameterJsonToString
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -596,7 +596,7 @@ function checkSerializableAsJson(name, value) {
|
|
|
596
596
|
}
|
|
597
597
|
/**
|
|
598
598
|
* TODO: [π§ ][π£] More elegant way to tracking than passing `name`
|
|
599
|
-
* TODO: [π§ ] !!! In-memory cache of same values to prevent multiple checks
|
|
599
|
+
* TODO: [π§ ][main] !!! In-memory cache of same values to prevent multiple checks
|
|
600
600
|
* Note: [π ] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
601
601
|
*/
|
|
602
602
|
|
|
@@ -667,14 +667,14 @@ var MAX_EXECUTION_ATTEMPTS = 3;
|
|
|
667
667
|
var MAX_FILENAME_LENGTH = 30;
|
|
668
668
|
/**
|
|
669
669
|
* @@@
|
|
670
|
-
* TODO: [π] !!! Use
|
|
670
|
+
* TODO: [π][main] !!! Use
|
|
671
671
|
*
|
|
672
672
|
* @public exported from `@promptbook/core`
|
|
673
673
|
*/
|
|
674
674
|
var MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH = 3;
|
|
675
675
|
/**
|
|
676
676
|
* @@@
|
|
677
|
-
* TODO: [π] !!! Use
|
|
677
|
+
* TODO: [π][main] !!! Use
|
|
678
678
|
*
|
|
679
679
|
* @public exported from `@promptbook/core`
|
|
680
680
|
*/
|
|
@@ -829,7 +829,7 @@ function isValidPromptbookVersion(version) {
|
|
|
829
829
|
if ( /* version === '1.0.0' || */version === '2.0.0' || version === '3.0.0') {
|
|
830
830
|
return false;
|
|
831
831
|
}
|
|
832
|
-
// <- TODO: !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
|
|
832
|
+
// <- TODO:[main] !!! Check isValidPromptbookVersion against PROMPTBOOK_VERSIONS
|
|
833
833
|
return true;
|
|
834
834
|
}
|
|
835
835
|
|
|
@@ -978,7 +978,7 @@ function validatePipeline(pipeline) {
|
|
|
978
978
|
// <- Note: [π²]
|
|
979
979
|
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
980
980
|
}
|
|
981
|
-
if (!isValidPromptbookVersion(pipeline.promptbookVersion)) {
|
|
981
|
+
if (pipeline.promptbookVersion !== undefined && !isValidPromptbookVersion(pipeline.promptbookVersion)) {
|
|
982
982
|
// <- Note: [π²]
|
|
983
983
|
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
984
984
|
}
|
|
@@ -1173,11 +1173,11 @@ function validatePipeline(pipeline) {
|
|
|
1173
1173
|
* > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
|
|
1174
1174
|
*/
|
|
1175
1175
|
/**
|
|
1176
|
-
* TODO: [π£] !!!! Validate that all samples match expectations
|
|
1177
|
-
* TODO: [π£][π] !!!! Validate that knowledge is valid (non-void)
|
|
1178
|
-
* TODO: [π£] !!!! Validate that persona can be used only with CHAT variant
|
|
1179
|
-
* TODO: [π£] !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
|
|
1180
|
-
* TODO: [π£] !!!! Validate that reserved parameter is not used as joker
|
|
1176
|
+
* TODO: [π£][main] !!!! Validate that all samples match expectations
|
|
1177
|
+
* TODO: [π£][π][main] !!!! Validate that knowledge is valid (non-void)
|
|
1178
|
+
* TODO: [π£][main] !!!! Validate that persona can be used only with CHAT variant
|
|
1179
|
+
* TODO: [π£][main] !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
|
|
1180
|
+
* TODO: [π£][main] !!!! Validate that reserved parameter is not used as joker
|
|
1181
1181
|
* TODO: [π§ ] Validation not only logic itself but imports around - files and websites and rerefenced pipelines exists
|
|
1182
1182
|
* TODO: [π ] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
1183
1183
|
*/
|
|
@@ -1491,7 +1491,7 @@ function createCollectionFromUrl(url, options) {
|
|
|
1491
1491
|
});
|
|
1492
1492
|
}
|
|
1493
1493
|
/**
|
|
1494
|
-
* TODO: !!!! [π§ ] Library precompilation and do not mix markdown and json promptbooks
|
|
1494
|
+
* TODO:[main] !!!! [π§ ] Library precompilation and do not mix markdown and json promptbooks
|
|
1495
1495
|
*/
|
|
1496
1496
|
|
|
1497
1497
|
/**
|
|
@@ -1592,127 +1592,6 @@ var TemplateTypes = [
|
|
|
1592
1592
|
// <- [π
±]
|
|
1593
1593
|
];
|
|
1594
1594
|
|
|
1595
|
-
/**
|
|
1596
|
-
* @@@
|
|
1597
|
-
*
|
|
1598
|
-
* @public exported from `@promptbook/utils`
|
|
1599
|
-
*/
|
|
1600
|
-
function deepClone(objectValue) {
|
|
1601
|
-
return JSON.parse(JSON.stringify(objectValue));
|
|
1602
|
-
/*
|
|
1603
|
-
TODO: [π§ ] Is there a better implementation?
|
|
1604
|
-
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1605
|
-
> for (const propertyName of propertyNames) {
|
|
1606
|
-
> const value = (objectValue as really_any)[propertyName];
|
|
1607
|
-
> if (value && typeof value === 'object') {
|
|
1608
|
-
> deepClone(value);
|
|
1609
|
-
> }
|
|
1610
|
-
> }
|
|
1611
|
-
> return Object.assign({}, objectValue);
|
|
1612
|
-
*/
|
|
1613
|
-
}
|
|
1614
|
-
/**
|
|
1615
|
-
* TODO: [π§ ] Is there a way how to meaningfully test this utility
|
|
1616
|
-
*/
|
|
1617
|
-
|
|
1618
|
-
/**
|
|
1619
|
-
* @@@
|
|
1620
|
-
*
|
|
1621
|
-
* @public exported from `@promptbook/core`
|
|
1622
|
-
*/
|
|
1623
|
-
var ZERO_USAGE = $deepFreeze({
|
|
1624
|
-
price: { value: 0 },
|
|
1625
|
-
input: {
|
|
1626
|
-
tokensCount: { value: 0 },
|
|
1627
|
-
charactersCount: { value: 0 },
|
|
1628
|
-
wordsCount: { value: 0 },
|
|
1629
|
-
sentencesCount: { value: 0 },
|
|
1630
|
-
linesCount: { value: 0 },
|
|
1631
|
-
paragraphsCount: { value: 0 },
|
|
1632
|
-
pagesCount: { value: 0 },
|
|
1633
|
-
},
|
|
1634
|
-
output: {
|
|
1635
|
-
tokensCount: { value: 0 },
|
|
1636
|
-
charactersCount: { value: 0 },
|
|
1637
|
-
wordsCount: { value: 0 },
|
|
1638
|
-
sentencesCount: { value: 0 },
|
|
1639
|
-
linesCount: { value: 0 },
|
|
1640
|
-
paragraphsCount: { value: 0 },
|
|
1641
|
-
pagesCount: { value: 0 },
|
|
1642
|
-
},
|
|
1643
|
-
});
|
|
1644
|
-
/**
|
|
1645
|
-
* Function `addUsage` will add multiple usages into one
|
|
1646
|
-
*
|
|
1647
|
-
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
1648
|
-
*
|
|
1649
|
-
* @public exported from `@promptbook/core`
|
|
1650
|
-
*/
|
|
1651
|
-
function addUsage() {
|
|
1652
|
-
var usageItems = [];
|
|
1653
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1654
|
-
usageItems[_i] = arguments[_i];
|
|
1655
|
-
}
|
|
1656
|
-
return usageItems.reduce(function (acc, item) {
|
|
1657
|
-
var e_1, _a, e_2, _b;
|
|
1658
|
-
var _c;
|
|
1659
|
-
acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
|
|
1660
|
-
try {
|
|
1661
|
-
for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1662
|
-
var key = _e.value;
|
|
1663
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1664
|
-
//@ts-ignore
|
|
1665
|
-
if (item.input[key]) {
|
|
1666
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1667
|
-
//@ts-ignore
|
|
1668
|
-
acc.input[key].value += item.input[key].value || 0;
|
|
1669
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1670
|
-
//@ts-ignore
|
|
1671
|
-
if (item.input[key].isUncertain) {
|
|
1672
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1673
|
-
//@ts-ignore
|
|
1674
|
-
acc.input[key].isUncertain = true;
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1680
|
-
finally {
|
|
1681
|
-
try {
|
|
1682
|
-
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
1683
|
-
}
|
|
1684
|
-
finally { if (e_1) throw e_1.error; }
|
|
1685
|
-
}
|
|
1686
|
-
try {
|
|
1687
|
-
for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1688
|
-
var key = _g.value;
|
|
1689
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1690
|
-
//@ts-ignore
|
|
1691
|
-
if (item.output[key]) {
|
|
1692
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1693
|
-
//@ts-ignore
|
|
1694
|
-
acc.output[key].value += item.output[key].value || 0;
|
|
1695
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1696
|
-
//@ts-ignore
|
|
1697
|
-
if (item.output[key].isUncertain) {
|
|
1698
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1699
|
-
//@ts-ignore
|
|
1700
|
-
acc.output[key].isUncertain = true;
|
|
1701
|
-
}
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1704
|
-
}
|
|
1705
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1706
|
-
finally {
|
|
1707
|
-
try {
|
|
1708
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
1709
|
-
}
|
|
1710
|
-
finally { if (e_2) throw e_2.error; }
|
|
1711
|
-
}
|
|
1712
|
-
return acc;
|
|
1713
|
-
}, deepClone(ZERO_USAGE));
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
1595
|
/**
|
|
1717
1596
|
* Async version of Array.forEach
|
|
1718
1597
|
*
|
|
@@ -1788,7 +1667,60 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1788
1667
|
});
|
|
1789
1668
|
}
|
|
1790
1669
|
|
|
1791
|
-
|
|
1670
|
+
/**
|
|
1671
|
+
* Represents the usage with no resources consumed
|
|
1672
|
+
*
|
|
1673
|
+
* @public exported from `@promptbook/core`
|
|
1674
|
+
*/
|
|
1675
|
+
var ZERO_USAGE = $deepFreeze({
|
|
1676
|
+
price: { value: 0 },
|
|
1677
|
+
input: {
|
|
1678
|
+
tokensCount: { value: 0 },
|
|
1679
|
+
charactersCount: { value: 0 },
|
|
1680
|
+
wordsCount: { value: 0 },
|
|
1681
|
+
sentencesCount: { value: 0 },
|
|
1682
|
+
linesCount: { value: 0 },
|
|
1683
|
+
paragraphsCount: { value: 0 },
|
|
1684
|
+
pagesCount: { value: 0 },
|
|
1685
|
+
},
|
|
1686
|
+
output: {
|
|
1687
|
+
tokensCount: { value: 0 },
|
|
1688
|
+
charactersCount: { value: 0 },
|
|
1689
|
+
wordsCount: { value: 0 },
|
|
1690
|
+
sentencesCount: { value: 0 },
|
|
1691
|
+
linesCount: { value: 0 },
|
|
1692
|
+
paragraphsCount: { value: 0 },
|
|
1693
|
+
pagesCount: { value: 0 },
|
|
1694
|
+
},
|
|
1695
|
+
});
|
|
1696
|
+
/**
|
|
1697
|
+
* Represents the usage with unknown resources consumed
|
|
1698
|
+
*
|
|
1699
|
+
* @public exported from `@promptbook/core`
|
|
1700
|
+
*/
|
|
1701
|
+
var UNCERTAIN_USAGE = $deepFreeze({
|
|
1702
|
+
price: { value: 0, isUncertain: true },
|
|
1703
|
+
input: {
|
|
1704
|
+
tokensCount: { value: 0, isUncertain: true },
|
|
1705
|
+
charactersCount: { value: 0, isUncertain: true },
|
|
1706
|
+
wordsCount: { value: 0, isUncertain: true },
|
|
1707
|
+
sentencesCount: { value: 0, isUncertain: true },
|
|
1708
|
+
linesCount: { value: 0, isUncertain: true },
|
|
1709
|
+
paragraphsCount: { value: 0, isUncertain: true },
|
|
1710
|
+
pagesCount: { value: 0, isUncertain: true },
|
|
1711
|
+
},
|
|
1712
|
+
output: {
|
|
1713
|
+
tokensCount: { value: 0, isUncertain: true },
|
|
1714
|
+
charactersCount: { value: 0, isUncertain: true },
|
|
1715
|
+
wordsCount: { value: 0, isUncertain: true },
|
|
1716
|
+
sentencesCount: { value: 0, isUncertain: true },
|
|
1717
|
+
linesCount: { value: 0, isUncertain: true },
|
|
1718
|
+
paragraphsCount: { value: 0, isUncertain: true },
|
|
1719
|
+
pagesCount: { value: 0, isUncertain: true },
|
|
1720
|
+
},
|
|
1721
|
+
});
|
|
1722
|
+
|
|
1723
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],templates:[{templateType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
1792
1724
|
|
|
1793
1725
|
var defaultDiacriticsRemovalMap = [
|
|
1794
1726
|
{
|
|
@@ -2896,7 +2828,7 @@ function isPipelinePrepared(pipeline) {
|
|
|
2896
2828
|
return true;
|
|
2897
2829
|
}
|
|
2898
2830
|
/**
|
|
2899
|
-
* TODO: [π] !!!!! If the pipeline was prepared with different version or different set of models, prepare it once again
|
|
2831
|
+
* TODO: [π][main] !!!!! If the pipeline was prepared with different version or different set of models, prepare it once again
|
|
2900
2832
|
* TODO: [π ] Maybe base this on `makeValidator`
|
|
2901
2833
|
* TODO: [π§] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2902
2834
|
* TODO: [π§Ώ] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
@@ -3116,6 +3048,101 @@ function union() {
|
|
|
3116
3048
|
return union;
|
|
3117
3049
|
}
|
|
3118
3050
|
|
|
3051
|
+
/**
|
|
3052
|
+
* @@@
|
|
3053
|
+
*
|
|
3054
|
+
* @public exported from `@promptbook/utils`
|
|
3055
|
+
*/
|
|
3056
|
+
function deepClone(objectValue) {
|
|
3057
|
+
return JSON.parse(JSON.stringify(objectValue));
|
|
3058
|
+
/*
|
|
3059
|
+
TODO: [π§ ] Is there a better implementation?
|
|
3060
|
+
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
3061
|
+
> for (const propertyName of propertyNames) {
|
|
3062
|
+
> const value = (objectValue as really_any)[propertyName];
|
|
3063
|
+
> if (value && typeof value === 'object') {
|
|
3064
|
+
> deepClone(value);
|
|
3065
|
+
> }
|
|
3066
|
+
> }
|
|
3067
|
+
> return Object.assign({}, objectValue);
|
|
3068
|
+
*/
|
|
3069
|
+
}
|
|
3070
|
+
/**
|
|
3071
|
+
* TODO: [π§ ] Is there a way how to meaningfully test this utility
|
|
3072
|
+
*/
|
|
3073
|
+
|
|
3074
|
+
/**
|
|
3075
|
+
* Function `addUsage` will add multiple usages into one
|
|
3076
|
+
*
|
|
3077
|
+
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
3078
|
+
*
|
|
3079
|
+
* @public exported from `@promptbook/core`
|
|
3080
|
+
*/
|
|
3081
|
+
function addUsage() {
|
|
3082
|
+
var usageItems = [];
|
|
3083
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3084
|
+
usageItems[_i] = arguments[_i];
|
|
3085
|
+
}
|
|
3086
|
+
return usageItems.reduce(function (acc, item) {
|
|
3087
|
+
var e_1, _a, e_2, _b;
|
|
3088
|
+
var _c;
|
|
3089
|
+
acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
|
|
3090
|
+
try {
|
|
3091
|
+
for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
3092
|
+
var key = _e.value;
|
|
3093
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3094
|
+
//@ts-ignore
|
|
3095
|
+
if (item.input[key]) {
|
|
3096
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3097
|
+
//@ts-ignore
|
|
3098
|
+
acc.input[key].value += item.input[key].value || 0;
|
|
3099
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3100
|
+
//@ts-ignore
|
|
3101
|
+
if (item.input[key].isUncertain) {
|
|
3102
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3103
|
+
//@ts-ignore
|
|
3104
|
+
acc.input[key].isUncertain = true;
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3110
|
+
finally {
|
|
3111
|
+
try {
|
|
3112
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
3113
|
+
}
|
|
3114
|
+
finally { if (e_1) throw e_1.error; }
|
|
3115
|
+
}
|
|
3116
|
+
try {
|
|
3117
|
+
for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
3118
|
+
var key = _g.value;
|
|
3119
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3120
|
+
//@ts-ignore
|
|
3121
|
+
if (item.output[key]) {
|
|
3122
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3123
|
+
//@ts-ignore
|
|
3124
|
+
acc.output[key].value += item.output[key].value || 0;
|
|
3125
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3126
|
+
//@ts-ignore
|
|
3127
|
+
if (item.output[key].isUncertain) {
|
|
3128
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3129
|
+
//@ts-ignore
|
|
3130
|
+
acc.output[key].isUncertain = true;
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3136
|
+
finally {
|
|
3137
|
+
try {
|
|
3138
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
3139
|
+
}
|
|
3140
|
+
finally { if (e_2) throw e_2.error; }
|
|
3141
|
+
}
|
|
3142
|
+
return acc;
|
|
3143
|
+
}, deepClone(ZERO_USAGE));
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3119
3146
|
/**
|
|
3120
3147
|
* Counts number of characters in the text
|
|
3121
3148
|
*
|
|
@@ -3297,7 +3324,7 @@ function createPipelineExecutor(options) {
|
|
|
3297
3324
|
console.warn(spaceTrim$1(function (block) { return "\n Pipeline is not prepared\n\n ".concat(block(pipelineIdentification), "\n\n It will be prepared ad-hoc before the first execution and **returned as `preparedPipeline` in `PipelineExecutorResult`**\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n "); }));
|
|
3298
3325
|
}
|
|
3299
3326
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
3300
|
-
// TODO: !!! Extract to separate functions and files - ALL FUNCTIONS BELOW
|
|
3327
|
+
// TODO:[main] !!! Extract to separate functions and files - ALL FUNCTIONS BELOW
|
|
3301
3328
|
function getContextForTemplate(template) {
|
|
3302
3329
|
return __awaiter(this, void 0, void 0, function () {
|
|
3303
3330
|
return __generator(this, function (_a) {
|
|
@@ -4116,7 +4143,7 @@ function createPipelineExecutor(options) {
|
|
|
4116
4143
|
return pipelineExecutor;
|
|
4117
4144
|
}
|
|
4118
4145
|
/**
|
|
4119
|
-
* TODO: !!! Identify not only pipeline BUT exact template ${block(pipelineIdentification)}
|
|
4146
|
+
* TODO:[main] !!! Identify not only pipeline BUT exact template ${block(pipelineIdentification)}
|
|
4120
4147
|
* TODO: Use isVerbose here (not only pass to `preparePipeline`)
|
|
4121
4148
|
* TODO: [π§ ][π³] Use here `countTotalUsage` and put preparation and prepared pipiline to report
|
|
4122
4149
|
* TODO: [πͺ] Use maxParallelCount here (not only pass to `preparePipeline`)
|
|
@@ -4179,7 +4206,7 @@ function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [π] (?mayb
|
|
|
4179
4206
|
outputParameters = result.outputParameters;
|
|
4180
4207
|
knowledgePiecesRaw = outputParameters.knowledgePieces;
|
|
4181
4208
|
knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
4182
|
-
// <- TODO: !!!!! Smarter split and filter out empty pieces
|
|
4209
|
+
// <- TODO:[main] !!!!! Smarter split and filter out empty pieces
|
|
4183
4210
|
if (isVerbose) {
|
|
4184
4211
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
4185
4212
|
}
|
|
@@ -4259,7 +4286,7 @@ function prepareKnowledgeFromMarkdown(knowledgeContent /* <- TODO: [π] (?mayb
|
|
|
4259
4286
|
});
|
|
4260
4287
|
}
|
|
4261
4288
|
/**
|
|
4262
|
-
* TODO: [π][πΌ] !!! Export via `@promptbook/markdown`
|
|
4289
|
+
* TODO: [π][πΌ][main] !!! Export via `@promptbook/markdown`
|
|
4263
4290
|
* TODO: [πͺ] Do it in parallel 11:11
|
|
4264
4291
|
* Note: No need to aggregate usage here, it is done by intercepting the llmTools
|
|
4265
4292
|
*/
|
|
@@ -4283,7 +4310,7 @@ function prepareKnowledgePieces(knowledgeSources, options) {
|
|
|
4283
4310
|
var partialPieces, pieces;
|
|
4284
4311
|
return __generator(this, function (_a) {
|
|
4285
4312
|
switch (_a.label) {
|
|
4286
|
-
case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.sourceContent, // <- TODO: [π] !!! Unhardcode markdown, detect which type it is - BE AWARE of big package size
|
|
4313
|
+
case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.sourceContent, // <- TODO: [π][main] !!! Unhardcode markdown, detect which type it is - BE AWARE of big package size
|
|
4287
4314
|
options)];
|
|
4288
4315
|
case 1:
|
|
4289
4316
|
partialPieces = _a.sent();
|
|
@@ -4475,7 +4502,7 @@ function preparePersona(personaDescription, options) {
|
|
|
4475
4502
|
});
|
|
4476
4503
|
}
|
|
4477
4504
|
/**
|
|
4478
|
-
* TODO: [π] !!!!! If the persona was prepared with different version or different set of models, prepare it once again
|
|
4505
|
+
* TODO: [π][main] !!!!! If the persona was prepared with different version or different set of models, prepare it once again
|
|
4479
4506
|
* TODO: [π’] !! Check validity of `modelName` in pipeline
|
|
4480
4507
|
* TODO: [π’] !! Check validity of `systemMessage` in pipeline
|
|
4481
4508
|
* TODO: [π’] !! Check validity of `temperature` in pipeline
|
|
@@ -4524,7 +4551,7 @@ function prepareTemplates(pipeline, options) {
|
|
|
4524
4551
|
case 0:
|
|
4525
4552
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
|
|
4526
4553
|
templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
4527
|
-
// TODO: !!!!! Apply samples to each template (if missing and is for the template defined)
|
|
4554
|
+
// TODO:[main] !!!!! Apply samples to each template (if missing and is for the template defined)
|
|
4528
4555
|
TODO_USE(parameters);
|
|
4529
4556
|
templatesPrepared = new Array(
|
|
4530
4557
|
// <- TODO: [π§±] Implement in a functional (not new Class) way
|
|
@@ -4556,7 +4583,7 @@ function prepareTemplates(pipeline, options) {
|
|
|
4556
4583
|
/**
|
|
4557
4584
|
* TODO: [π§ ] Add context to each template (if missing)
|
|
4558
4585
|
* TODO: [π§ ] What is better name `prepareTemplate` or `prepareTemplateAndParameters`
|
|
4559
|
-
* TODO: [β¨] !!! Prepare index the samples and maybe templates
|
|
4586
|
+
* TODO: [β¨][main] !!! Prepare index the samples and maybe templates
|
|
4560
4587
|
* TODO: Write tests for `preparePipeline`
|
|
4561
4588
|
* TODO: [π] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
4562
4589
|
* TODO: [π§] In future one preparation can take data from previous preparation and save tokens and time
|
|
@@ -4728,7 +4755,7 @@ var knowledgeCommandParser = {
|
|
|
4728
4755
|
if (sourceContent === '') {
|
|
4729
4756
|
throw new ParseError("Source is not defined");
|
|
4730
4757
|
}
|
|
4731
|
-
// TODO: !!!! Following checks should be applied every link in the `sourceContent`
|
|
4758
|
+
// TODO:[main] !!!! Following checks should be applied every link in the `sourceContent`
|
|
4732
4759
|
if (sourceContent.startsWith('http://')) {
|
|
4733
4760
|
throw new ParseError("Source is not secure");
|
|
4734
4761
|
}
|
|
@@ -4913,7 +4940,7 @@ var templateCommandParser = {
|
|
|
4913
4940
|
if (command.templateType === 'KNOWLEDGE') {
|
|
4914
4941
|
knowledgeCommandParser.$applyToPipelineJson({
|
|
4915
4942
|
type: 'KNOWLEDGE',
|
|
4916
|
-
sourceContent: $templateJson.content, // <- TODO: [π] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
|
|
4943
|
+
sourceContent: $templateJson.content, // <- TODO: [π][main] !!! Work with KNOWLEDGE which not referring to the source file or website, but its content itself
|
|
4917
4944
|
}, $pipelineJson);
|
|
4918
4945
|
$templateJson.isTemplate = false;
|
|
4919
4946
|
return;
|
|
@@ -5193,76 +5220,6 @@ var expectCommandParser = {
|
|
|
5193
5220
|
},
|
|
5194
5221
|
};
|
|
5195
5222
|
|
|
5196
|
-
/**
|
|
5197
|
-
* @@@
|
|
5198
|
-
*
|
|
5199
|
-
* @param text @@@
|
|
5200
|
-
* @returns @@@
|
|
5201
|
-
* @example 'HELLO_WORLD'
|
|
5202
|
-
* @example 'I_LOVE_PROMPTBOOK'
|
|
5203
|
-
* @public exported from `@promptbook/utils`
|
|
5204
|
-
*/
|
|
5205
|
-
function normalizeTo_SCREAMING_CASE(text) {
|
|
5206
|
-
var e_1, _a;
|
|
5207
|
-
var charType;
|
|
5208
|
-
var lastCharType = 'OTHER';
|
|
5209
|
-
var normalizedName = '';
|
|
5210
|
-
try {
|
|
5211
|
-
for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
|
|
5212
|
-
var char = text_1_1.value;
|
|
5213
|
-
var normalizedChar = void 0;
|
|
5214
|
-
if (/^[a-z]$/.test(char)) {
|
|
5215
|
-
charType = 'LOWERCASE';
|
|
5216
|
-
normalizedChar = char.toUpperCase();
|
|
5217
|
-
}
|
|
5218
|
-
else if (/^[A-Z]$/.test(char)) {
|
|
5219
|
-
charType = 'UPPERCASE';
|
|
5220
|
-
normalizedChar = char;
|
|
5221
|
-
}
|
|
5222
|
-
else if (/^[0-9]$/.test(char)) {
|
|
5223
|
-
charType = 'NUMBER';
|
|
5224
|
-
normalizedChar = char;
|
|
5225
|
-
}
|
|
5226
|
-
else if (/^\/$/.test(char)) {
|
|
5227
|
-
charType = 'SLASH';
|
|
5228
|
-
normalizedChar = char;
|
|
5229
|
-
}
|
|
5230
|
-
else {
|
|
5231
|
-
charType = 'OTHER';
|
|
5232
|
-
normalizedChar = '_';
|
|
5233
|
-
}
|
|
5234
|
-
if (charType !== lastCharType &&
|
|
5235
|
-
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
5236
|
-
!(lastCharType === 'NUMBER') &&
|
|
5237
|
-
!(charType === 'NUMBER')) {
|
|
5238
|
-
normalizedName += '_';
|
|
5239
|
-
}
|
|
5240
|
-
normalizedName += normalizedChar;
|
|
5241
|
-
lastCharType = charType;
|
|
5242
|
-
}
|
|
5243
|
-
}
|
|
5244
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
5245
|
-
finally {
|
|
5246
|
-
try {
|
|
5247
|
-
if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
|
|
5248
|
-
}
|
|
5249
|
-
finally { if (e_1) throw e_1.error; }
|
|
5250
|
-
}
|
|
5251
|
-
normalizedName = normalizedName.replace(/_+/g, '_');
|
|
5252
|
-
normalizedName = normalizedName.replace(/_?\/_?/g, '/');
|
|
5253
|
-
normalizedName = normalizedName.replace(/^_/, '');
|
|
5254
|
-
normalizedName = normalizedName.replace(/_$/, '');
|
|
5255
|
-
return normalizedName;
|
|
5256
|
-
}
|
|
5257
|
-
/**
|
|
5258
|
-
* TODO: Tests
|
|
5259
|
-
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
|
|
5260
|
-
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ΔΕ‘ΔΕΕΎΕΎΓ½Γ‘ΓΓΊΕ―' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
|
|
5261
|
-
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
|
|
5262
|
-
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
|
|
5263
|
-
* TODO: [πΊ] Use some intermediate util splitWords
|
|
5264
|
-
*/
|
|
5265
|
-
|
|
5266
5223
|
/**
|
|
5267
5224
|
* Parses the foreach command
|
|
5268
5225
|
*
|
|
@@ -5300,59 +5257,17 @@ var foreachCommandParser = {
|
|
|
5300
5257
|
'FOREACH List Line -> `{customer}`',
|
|
5301
5258
|
'FOR List Line -> `{customer}`',
|
|
5302
5259
|
'EACH List Line -> `{customer}`',
|
|
5303
|
-
// <- TODO: [π]
|
|
5260
|
+
// <- TODO: [π] More
|
|
5304
5261
|
],
|
|
5305
5262
|
/**
|
|
5306
5263
|
* Parses the FOREACH command
|
|
5307
5264
|
*/
|
|
5308
5265
|
parse: function (input) {
|
|
5309
|
-
var args = input.args
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
var assignSign = args[2];
|
|
5313
|
-
var parameter = args[3];
|
|
5314
|
-
if (![
|
|
5315
|
-
'LIST',
|
|
5316
|
-
'CSV',
|
|
5317
|
-
// <- TODO: [π’] Unhardcode formats
|
|
5318
|
-
].includes(formatName)) {
|
|
5319
|
-
console.info({ args: args, formatName: formatName });
|
|
5320
|
-
throw new Error("Unsupported format \"".concat(formatName, "\""));
|
|
5321
|
-
// <- TODO: [π’] List all supported format names
|
|
5322
|
-
}
|
|
5323
|
-
if (![
|
|
5324
|
-
'LINE',
|
|
5325
|
-
'ROW',
|
|
5326
|
-
'COLUMN',
|
|
5327
|
-
'CELL',
|
|
5328
|
-
// <- TODO: [π’] Unhardcode format cekks
|
|
5329
|
-
].includes(cellName)) {
|
|
5330
|
-
console.info({ args: args, cellName: cellName });
|
|
5331
|
-
throw new Error("Format ".concat(formatName, " does not support cell \"").concat(cellName, "\""));
|
|
5332
|
-
// <- TODO: [π’] List all supported cell names for the format
|
|
5333
|
-
}
|
|
5334
|
-
if (assignSign !== '->') {
|
|
5335
|
-
console.info({ args: args, assignSign: assignSign });
|
|
5336
|
-
throw new Error("FOREACH command must have '->' to assign the value to the parameter");
|
|
5337
|
-
}
|
|
5338
|
-
var parameterNames = extractParameterNames(parameter || rawArgs);
|
|
5339
|
-
if (parameterNames.size !== 1) {
|
|
5340
|
-
console.info({ args: args, parameter: parameter, rawArgs: rawArgs });
|
|
5341
|
-
throw new Error("FOREACH command contain exactly one parameter, but found ".concat(parameterNames.size));
|
|
5342
|
-
}
|
|
5343
|
-
var parameterName = parameterNames.values().next().value;
|
|
5344
|
-
if (typeof parameterName !== 'string'
|
|
5345
|
-
// <- TODO: !!!!!! Replace with propper parameter name validation
|
|
5346
|
-
) {
|
|
5347
|
-
console.info({ args: args, parameterName: parameterName });
|
|
5348
|
-
throw new Error("Invalid parameter name");
|
|
5349
|
-
// <- TODO: !!!!!! Better error (with rules and precise error) from validateParameterName
|
|
5350
|
-
}
|
|
5266
|
+
var args = input.args;
|
|
5267
|
+
keepUnused(args);
|
|
5268
|
+
// <- TODO: [π] Implement
|
|
5351
5269
|
return {
|
|
5352
5270
|
type: 'FOREACH',
|
|
5353
|
-
formatName: formatName,
|
|
5354
|
-
cellName: cellName,
|
|
5355
|
-
parameterName: parameterName,
|
|
5356
5271
|
};
|
|
5357
5272
|
},
|
|
5358
5273
|
/**
|
|
@@ -5362,7 +5277,7 @@ var foreachCommandParser = {
|
|
|
5362
5277
|
*/
|
|
5363
5278
|
$applyToTemplateJson: function (command, $templateJson, $pipelineJson) {
|
|
5364
5279
|
keepUnused(command, $templateJson, $pipelineJson);
|
|
5365
|
-
// <- TODO: [π]
|
|
5280
|
+
// <- TODO: [π] Implement
|
|
5366
5281
|
},
|
|
5367
5282
|
/**
|
|
5368
5283
|
* Converts the FOREACH command back to string
|
|
@@ -5372,7 +5287,7 @@ var foreachCommandParser = {
|
|
|
5372
5287
|
stringify: function (command) {
|
|
5373
5288
|
keepUnused(command);
|
|
5374
5289
|
return "";
|
|
5375
|
-
// <- TODO: [π]
|
|
5290
|
+
// <- TODO: [π] Implement
|
|
5376
5291
|
},
|
|
5377
5292
|
/**
|
|
5378
5293
|
* Reads the FOREACH command from the `TemplateJson`
|
|
@@ -5382,12 +5297,11 @@ var foreachCommandParser = {
|
|
|
5382
5297
|
takeFromTemplateJson: function ($templateJson) {
|
|
5383
5298
|
keepUnused($templateJson);
|
|
5384
5299
|
return [];
|
|
5385
|
-
// <- TODO: [π]
|
|
5300
|
+
// <- TODO: [π] Implement
|
|
5386
5301
|
},
|
|
5387
5302
|
};
|
|
5388
5303
|
/**
|
|
5389
|
-
* TODO:
|
|
5390
|
-
* TODO: [π] !!!!!! Make .ptbk.md file with examples of the FOREACH command and also with wrong parsing and logic
|
|
5304
|
+
* TODO: [π] Make .ptbk.md file with examples of the FOREACH command and also with wrong parsing and logic
|
|
5391
5305
|
*/
|
|
5392
5306
|
|
|
5393
5307
|
/**
|
|
@@ -5740,7 +5654,6 @@ var parameterCommandParser = {
|
|
|
5740
5654
|
isInput = false;
|
|
5741
5655
|
isOutput = false;
|
|
5742
5656
|
}
|
|
5743
|
-
// TODO: !!!!!! Add parameter name validation
|
|
5744
5657
|
return {
|
|
5745
5658
|
type: 'PARAMETER',
|
|
5746
5659
|
parameterName: parameterName,
|
|
@@ -6069,6 +5982,7 @@ var promptbookVersionCommandParser = {
|
|
|
6069
5982
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
6070
5983
|
*/
|
|
6071
5984
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
5985
|
+
// TODO: Warn if the version is overridden
|
|
6072
5986
|
$pipelineJson.promptbookVersion = command.promptbookVersion;
|
|
6073
5987
|
},
|
|
6074
5988
|
/**
|
|
@@ -6493,6 +6407,76 @@ function removeMarkdownFormatting(str) {
|
|
|
6493
6407
|
return str;
|
|
6494
6408
|
}
|
|
6495
6409
|
|
|
6410
|
+
/**
|
|
6411
|
+
* @@@
|
|
6412
|
+
*
|
|
6413
|
+
* @param text @@@
|
|
6414
|
+
* @returns @@@
|
|
6415
|
+
* @example 'HELLO_WORLD'
|
|
6416
|
+
* @example 'I_LOVE_PROMPTBOOK'
|
|
6417
|
+
* @public exported from `@promptbook/utils`
|
|
6418
|
+
*/
|
|
6419
|
+
function normalizeTo_SCREAMING_CASE(text) {
|
|
6420
|
+
var e_1, _a;
|
|
6421
|
+
var charType;
|
|
6422
|
+
var lastCharType = 'OTHER';
|
|
6423
|
+
var normalizedName = '';
|
|
6424
|
+
try {
|
|
6425
|
+
for (var text_1 = __values(text), text_1_1 = text_1.next(); !text_1_1.done; text_1_1 = text_1.next()) {
|
|
6426
|
+
var char = text_1_1.value;
|
|
6427
|
+
var normalizedChar = void 0;
|
|
6428
|
+
if (/^[a-z]$/.test(char)) {
|
|
6429
|
+
charType = 'LOWERCASE';
|
|
6430
|
+
normalizedChar = char.toUpperCase();
|
|
6431
|
+
}
|
|
6432
|
+
else if (/^[A-Z]$/.test(char)) {
|
|
6433
|
+
charType = 'UPPERCASE';
|
|
6434
|
+
normalizedChar = char;
|
|
6435
|
+
}
|
|
6436
|
+
else if (/^[0-9]$/.test(char)) {
|
|
6437
|
+
charType = 'NUMBER';
|
|
6438
|
+
normalizedChar = char;
|
|
6439
|
+
}
|
|
6440
|
+
else if (/^\/$/.test(char)) {
|
|
6441
|
+
charType = 'SLASH';
|
|
6442
|
+
normalizedChar = char;
|
|
6443
|
+
}
|
|
6444
|
+
else {
|
|
6445
|
+
charType = 'OTHER';
|
|
6446
|
+
normalizedChar = '_';
|
|
6447
|
+
}
|
|
6448
|
+
if (charType !== lastCharType &&
|
|
6449
|
+
!(lastCharType === 'UPPERCASE' && charType === 'LOWERCASE') &&
|
|
6450
|
+
!(lastCharType === 'NUMBER') &&
|
|
6451
|
+
!(charType === 'NUMBER')) {
|
|
6452
|
+
normalizedName += '_';
|
|
6453
|
+
}
|
|
6454
|
+
normalizedName += normalizedChar;
|
|
6455
|
+
lastCharType = charType;
|
|
6456
|
+
}
|
|
6457
|
+
}
|
|
6458
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
6459
|
+
finally {
|
|
6460
|
+
try {
|
|
6461
|
+
if (text_1_1 && !text_1_1.done && (_a = text_1.return)) _a.call(text_1);
|
|
6462
|
+
}
|
|
6463
|
+
finally { if (e_1) throw e_1.error; }
|
|
6464
|
+
}
|
|
6465
|
+
normalizedName = normalizedName.replace(/_+/g, '_');
|
|
6466
|
+
normalizedName = normalizedName.replace(/_?\/_?/g, '/');
|
|
6467
|
+
normalizedName = normalizedName.replace(/^_/, '');
|
|
6468
|
+
normalizedName = normalizedName.replace(/_$/, '');
|
|
6469
|
+
return normalizedName;
|
|
6470
|
+
}
|
|
6471
|
+
/**
|
|
6472
|
+
* TODO: Tests
|
|
6473
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'Moje tabule' })).toEqual('/VtG7sR9rRJqwNEdM2/Moje tabule');
|
|
6474
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: 'ΔΕ‘ΔΕΕΎΕΎΓ½Γ‘ΓΓΊΕ―' })).toEqual('/VtG7sR9rRJqwNEdM2/escrzyaieuu');
|
|
6475
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj');
|
|
6476
|
+
* > expect(encodeRoutePath({ uriId: 'VtG7sR9rRJqwNEdM2', name: ' ahoj_ahojAhoj ahoj ' })).toEqual('/VtG7sR9rRJqwNEdM2/ahoj-ahoj-ahoj-ahoj');
|
|
6477
|
+
* TODO: [πΊ] Use some intermediate util splitWords
|
|
6478
|
+
*/
|
|
6479
|
+
|
|
6496
6480
|
/**
|
|
6497
6481
|
* Parses one line of ul/ol to command
|
|
6498
6482
|
*
|
|
@@ -6505,7 +6489,6 @@ function parseCommand(raw, usagePlace) {
|
|
|
6505
6489
|
if (raw.includes('\n') || raw.includes('\r')) {
|
|
6506
6490
|
throw new ParseError('Command can not contain new line characters' /* <- TODO: [π] */);
|
|
6507
6491
|
}
|
|
6508
|
-
// TODO: Unit test all this processing and parsing
|
|
6509
6492
|
var normalized = raw.trim();
|
|
6510
6493
|
normalized = normalized.split('`').join('');
|
|
6511
6494
|
normalized = normalized.split('"').join('');
|
|
@@ -6561,7 +6544,7 @@ function parseCommand(raw, usagePlace) {
|
|
|
6561
6544
|
// Arg1 Arg2 Arg3 | FOO
|
|
6562
6545
|
{
|
|
6563
6546
|
var commandNameRaw = items.slice(-1).join('_');
|
|
6564
|
-
var args = items.slice(0, -1);
|
|
6547
|
+
var args = items.slice(0, -1);
|
|
6565
6548
|
var rawArgs = raw.substring(0, raw.length - commandNameRaw.length).trim();
|
|
6566
6549
|
var command = parseCommandVariant({ usagePlace: usagePlace, raw: raw, rawArgs: rawArgs, normalized: normalized, args: args, commandNameRaw: commandNameRaw });
|
|
6567
6550
|
if (command !== null) {
|
|
@@ -6889,7 +6872,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
6889
6872
|
var $pipelineJson = {
|
|
6890
6873
|
title: undefined /* <- Note: [π] Putting here placeholder to keep `title` on top at final JSON */,
|
|
6891
6874
|
pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
|
|
6892
|
-
promptbookVersion:
|
|
6875
|
+
promptbookVersion: undefined /* <- Note: By default no explicit version */,
|
|
6893
6876
|
description: undefined /* <- Note: [π] Putting here placeholder to keep `description` on top at final JSON */,
|
|
6894
6877
|
parameters: [],
|
|
6895
6878
|
templates: [],
|
|
@@ -7180,7 +7163,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
7180
7163
|
return $asDeeplyFrozenSerializableJson('pipelineJson', $pipelineJson);
|
|
7181
7164
|
}
|
|
7182
7165
|
/**
|
|
7183
|
-
* TODO: !!!! Warn if used only sync version
|
|
7166
|
+
* TODO:[main] !!!! Warn if used only sync version
|
|
7184
7167
|
* TODO: [π] Report here line/column of error
|
|
7185
7168
|
* TODO: Use spaceTrim more effectively
|
|
7186
7169
|
* TODO: [π§ ] Parameter flags - isInput, isOutput, isInternal
|
|
@@ -7455,7 +7438,7 @@ function isSerializableAsJson(value) {
|
|
|
7455
7438
|
}
|
|
7456
7439
|
}
|
|
7457
7440
|
/**
|
|
7458
|
-
* TODO: [π§ ] !!! In-memory cache of same values to prevent multiple checks
|
|
7441
|
+
* TODO: [π§ ][main] !!! In-memory cache of same values to prevent multiple checks
|
|
7459
7442
|
* TODO: [π§ ][πΊ] Can be done this on type-level?
|
|
7460
7443
|
*/
|
|
7461
7444
|
|
|
@@ -8475,5 +8458,5 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
8475
8458
|
* TODO: [π§ ] Should be in generated file GENERATOR_WARNING
|
|
8476
8459
|
*/
|
|
8477
8460
|
|
|
8478
|
-
export { $llmToolsMetadataRegister, $llmToolsRegister, CLAIM, CallbackInterfaceTools, CollectionError, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, ERRORS, EXECUTIONS_CACHE_DIRNAME, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, IS_VERBOSE, LimitReachedError, MAX_EXECUTION_ATTEMPTS, MAX_FILENAME_LENGTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, MAX_PARALLEL_COUNT, MODEL_VARIANTS, MemoryStorage, NotFoundError, NotYetImplementedError, PIPELINE_COLLECTION_BASE_FILENAME, PROMPTBOOK_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, TemplateTypes, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _OpenAiMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgeFromMarkdown, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
|
|
8461
|
+
export { $llmToolsMetadataRegister, $llmToolsRegister, CLAIM, CallbackInterfaceTools, CollectionError, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, ERRORS, EXECUTIONS_CACHE_DIRNAME, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, IS_VERBOSE, LimitReachedError, MAX_EXECUTION_ATTEMPTS, MAX_FILENAME_LENGTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, MAX_PARALLEL_COUNT, MODEL_VARIANTS, MemoryStorage, NotFoundError, NotYetImplementedError, PIPELINE_COLLECTION_BASE_FILENAME, PROMPTBOOK_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, TemplateTypes, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _OpenAiMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgeFromMarkdown, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
|
|
8479
8462
|
//# sourceMappingURL=index.es.js.map
|