@promptbook/core 0.71.0-0 → 0.72.0-1
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 +194 -129
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/cli.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +6 -2
- package/esm/typings/src/_packages/openai.index.d.ts +8 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.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/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -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 +12 -2
- package/esm/typings/src/llm-providers/openai/createOpenAiAssistantExecutionTools.d.ts +15 -0
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +9 -0
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +9 -0
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.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/KnowledgeSourceJson.d.ts +2 -9
- package/package.json +1 -1
- package/umd/index.umd.js +195 -128
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -11,7 +11,7 @@ import moment from 'moment';
|
|
|
11
11
|
/**
|
|
12
12
|
* The version of the Promptbook library
|
|
13
13
|
*/
|
|
14
|
-
var PROMPTBOOK_VERSION = '0.
|
|
14
|
+
var PROMPTBOOK_VERSION = '0.72.0-0';
|
|
15
15
|
// TODO:[main] !!!! List here all the versions and annotate + put into script
|
|
16
16
|
|
|
17
17
|
/*! *****************************************************************************
|
|
@@ -1634,127 +1634,6 @@ var TemplateTypes = [
|
|
|
1634
1634
|
// <- [🅱]
|
|
1635
1635
|
];
|
|
1636
1636
|
|
|
1637
|
-
/**
|
|
1638
|
-
* @@@
|
|
1639
|
-
*
|
|
1640
|
-
* @public exported from `@promptbook/utils`
|
|
1641
|
-
*/
|
|
1642
|
-
function deepClone(objectValue) {
|
|
1643
|
-
return JSON.parse(JSON.stringify(objectValue));
|
|
1644
|
-
/*
|
|
1645
|
-
TODO: [🧠] Is there a better implementation?
|
|
1646
|
-
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1647
|
-
> for (const propertyName of propertyNames) {
|
|
1648
|
-
> const value = (objectValue as really_any)[propertyName];
|
|
1649
|
-
> if (value && typeof value === 'object') {
|
|
1650
|
-
> deepClone(value);
|
|
1651
|
-
> }
|
|
1652
|
-
> }
|
|
1653
|
-
> return Object.assign({}, objectValue);
|
|
1654
|
-
*/
|
|
1655
|
-
}
|
|
1656
|
-
/**
|
|
1657
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1658
|
-
*/
|
|
1659
|
-
|
|
1660
|
-
/**
|
|
1661
|
-
* @@@
|
|
1662
|
-
*
|
|
1663
|
-
* @public exported from `@promptbook/core`
|
|
1664
|
-
*/
|
|
1665
|
-
var ZERO_USAGE = $deepFreeze({
|
|
1666
|
-
price: { value: 0 },
|
|
1667
|
-
input: {
|
|
1668
|
-
tokensCount: { value: 0 },
|
|
1669
|
-
charactersCount: { value: 0 },
|
|
1670
|
-
wordsCount: { value: 0 },
|
|
1671
|
-
sentencesCount: { value: 0 },
|
|
1672
|
-
linesCount: { value: 0 },
|
|
1673
|
-
paragraphsCount: { value: 0 },
|
|
1674
|
-
pagesCount: { value: 0 },
|
|
1675
|
-
},
|
|
1676
|
-
output: {
|
|
1677
|
-
tokensCount: { value: 0 },
|
|
1678
|
-
charactersCount: { value: 0 },
|
|
1679
|
-
wordsCount: { value: 0 },
|
|
1680
|
-
sentencesCount: { value: 0 },
|
|
1681
|
-
linesCount: { value: 0 },
|
|
1682
|
-
paragraphsCount: { value: 0 },
|
|
1683
|
-
pagesCount: { value: 0 },
|
|
1684
|
-
},
|
|
1685
|
-
});
|
|
1686
|
-
/**
|
|
1687
|
-
* Function `addUsage` will add multiple usages into one
|
|
1688
|
-
*
|
|
1689
|
-
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
1690
|
-
*
|
|
1691
|
-
* @public exported from `@promptbook/core`
|
|
1692
|
-
*/
|
|
1693
|
-
function addUsage() {
|
|
1694
|
-
var usageItems = [];
|
|
1695
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1696
|
-
usageItems[_i] = arguments[_i];
|
|
1697
|
-
}
|
|
1698
|
-
return usageItems.reduce(function (acc, item) {
|
|
1699
|
-
var e_1, _a, e_2, _b;
|
|
1700
|
-
var _c;
|
|
1701
|
-
acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
|
|
1702
|
-
try {
|
|
1703
|
-
for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1704
|
-
var key = _e.value;
|
|
1705
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1706
|
-
//@ts-ignore
|
|
1707
|
-
if (item.input[key]) {
|
|
1708
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1709
|
-
//@ts-ignore
|
|
1710
|
-
acc.input[key].value += item.input[key].value || 0;
|
|
1711
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1712
|
-
//@ts-ignore
|
|
1713
|
-
if (item.input[key].isUncertain) {
|
|
1714
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1715
|
-
//@ts-ignore
|
|
1716
|
-
acc.input[key].isUncertain = true;
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1722
|
-
finally {
|
|
1723
|
-
try {
|
|
1724
|
-
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
1725
|
-
}
|
|
1726
|
-
finally { if (e_1) throw e_1.error; }
|
|
1727
|
-
}
|
|
1728
|
-
try {
|
|
1729
|
-
for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
1730
|
-
var key = _g.value;
|
|
1731
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1732
|
-
//@ts-ignore
|
|
1733
|
-
if (item.output[key]) {
|
|
1734
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1735
|
-
//@ts-ignore
|
|
1736
|
-
acc.output[key].value += item.output[key].value || 0;
|
|
1737
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1738
|
-
//@ts-ignore
|
|
1739
|
-
if (item.output[key].isUncertain) {
|
|
1740
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1741
|
-
//@ts-ignore
|
|
1742
|
-
acc.output[key].isUncertain = true;
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
}
|
|
1746
|
-
}
|
|
1747
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1748
|
-
finally {
|
|
1749
|
-
try {
|
|
1750
|
-
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
1751
|
-
}
|
|
1752
|
-
finally { if (e_2) throw e_2.error; }
|
|
1753
|
-
}
|
|
1754
|
-
return acc;
|
|
1755
|
-
}, deepClone(ZERO_USAGE));
|
|
1756
|
-
}
|
|
1757
|
-
|
|
1758
1637
|
/**
|
|
1759
1638
|
* Async version of Array.forEach
|
|
1760
1639
|
*
|
|
@@ -1830,6 +1709,59 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1830
1709
|
});
|
|
1831
1710
|
}
|
|
1832
1711
|
|
|
1712
|
+
/**
|
|
1713
|
+
* Represents the usage with no resources consumed
|
|
1714
|
+
*
|
|
1715
|
+
* @public exported from `@promptbook/core`
|
|
1716
|
+
*/
|
|
1717
|
+
var ZERO_USAGE = $deepFreeze({
|
|
1718
|
+
price: { value: 0 },
|
|
1719
|
+
input: {
|
|
1720
|
+
tokensCount: { value: 0 },
|
|
1721
|
+
charactersCount: { value: 0 },
|
|
1722
|
+
wordsCount: { value: 0 },
|
|
1723
|
+
sentencesCount: { value: 0 },
|
|
1724
|
+
linesCount: { value: 0 },
|
|
1725
|
+
paragraphsCount: { value: 0 },
|
|
1726
|
+
pagesCount: { value: 0 },
|
|
1727
|
+
},
|
|
1728
|
+
output: {
|
|
1729
|
+
tokensCount: { value: 0 },
|
|
1730
|
+
charactersCount: { value: 0 },
|
|
1731
|
+
wordsCount: { value: 0 },
|
|
1732
|
+
sentencesCount: { value: 0 },
|
|
1733
|
+
linesCount: { value: 0 },
|
|
1734
|
+
paragraphsCount: { value: 0 },
|
|
1735
|
+
pagesCount: { value: 0 },
|
|
1736
|
+
},
|
|
1737
|
+
});
|
|
1738
|
+
/**
|
|
1739
|
+
* Represents the usage with unknown resources consumed
|
|
1740
|
+
*
|
|
1741
|
+
* @public exported from `@promptbook/core`
|
|
1742
|
+
*/
|
|
1743
|
+
var UNCERTAIN_USAGE = $deepFreeze({
|
|
1744
|
+
price: { value: 0, isUncertain: true },
|
|
1745
|
+
input: {
|
|
1746
|
+
tokensCount: { value: 0, isUncertain: true },
|
|
1747
|
+
charactersCount: { value: 0, isUncertain: true },
|
|
1748
|
+
wordsCount: { value: 0, isUncertain: true },
|
|
1749
|
+
sentencesCount: { value: 0, isUncertain: true },
|
|
1750
|
+
linesCount: { value: 0, isUncertain: true },
|
|
1751
|
+
paragraphsCount: { value: 0, isUncertain: true },
|
|
1752
|
+
pagesCount: { value: 0, isUncertain: true },
|
|
1753
|
+
},
|
|
1754
|
+
output: {
|
|
1755
|
+
tokensCount: { value: 0, isUncertain: true },
|
|
1756
|
+
charactersCount: { value: 0, isUncertain: true },
|
|
1757
|
+
wordsCount: { value: 0, isUncertain: true },
|
|
1758
|
+
sentencesCount: { value: 0, isUncertain: true },
|
|
1759
|
+
linesCount: { value: 0, isUncertain: true },
|
|
1760
|
+
paragraphsCount: { value: 0, isUncertain: true },
|
|
1761
|
+
pagesCount: { value: 0, isUncertain: true },
|
|
1762
|
+
},
|
|
1763
|
+
});
|
|
1764
|
+
|
|
1833
1765
|
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"}];
|
|
1834
1766
|
|
|
1835
1767
|
var defaultDiacriticsRemovalMap = [
|
|
@@ -2718,6 +2650,101 @@ function arrayableToArray(input) {
|
|
|
2718
2650
|
return [input];
|
|
2719
2651
|
}
|
|
2720
2652
|
|
|
2653
|
+
/**
|
|
2654
|
+
* @@@
|
|
2655
|
+
*
|
|
2656
|
+
* @public exported from `@promptbook/utils`
|
|
2657
|
+
*/
|
|
2658
|
+
function deepClone(objectValue) {
|
|
2659
|
+
return JSON.parse(JSON.stringify(objectValue));
|
|
2660
|
+
/*
|
|
2661
|
+
TODO: [🧠] Is there a better implementation?
|
|
2662
|
+
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
2663
|
+
> for (const propertyName of propertyNames) {
|
|
2664
|
+
> const value = (objectValue as really_any)[propertyName];
|
|
2665
|
+
> if (value && typeof value === 'object') {
|
|
2666
|
+
> deepClone(value);
|
|
2667
|
+
> }
|
|
2668
|
+
> }
|
|
2669
|
+
> return Object.assign({}, objectValue);
|
|
2670
|
+
*/
|
|
2671
|
+
}
|
|
2672
|
+
/**
|
|
2673
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
2674
|
+
*/
|
|
2675
|
+
|
|
2676
|
+
/**
|
|
2677
|
+
* Function `addUsage` will add multiple usages into one
|
|
2678
|
+
*
|
|
2679
|
+
* Note: If you provide 0 values, it returns ZERO_USAGE
|
|
2680
|
+
*
|
|
2681
|
+
* @public exported from `@promptbook/core`
|
|
2682
|
+
*/
|
|
2683
|
+
function addUsage() {
|
|
2684
|
+
var usageItems = [];
|
|
2685
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2686
|
+
usageItems[_i] = arguments[_i];
|
|
2687
|
+
}
|
|
2688
|
+
return usageItems.reduce(function (acc, item) {
|
|
2689
|
+
var e_1, _a, e_2, _b;
|
|
2690
|
+
var _c;
|
|
2691
|
+
acc.price.value += ((_c = item.price) === null || _c === void 0 ? void 0 : _c.value) || 0;
|
|
2692
|
+
try {
|
|
2693
|
+
for (var _d = __values(Object.keys(acc.input)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
2694
|
+
var key = _e.value;
|
|
2695
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2696
|
+
//@ts-ignore
|
|
2697
|
+
if (item.input[key]) {
|
|
2698
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2699
|
+
//@ts-ignore
|
|
2700
|
+
acc.input[key].value += item.input[key].value || 0;
|
|
2701
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2702
|
+
//@ts-ignore
|
|
2703
|
+
if (item.input[key].isUncertain) {
|
|
2704
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2705
|
+
//@ts-ignore
|
|
2706
|
+
acc.input[key].isUncertain = true;
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2712
|
+
finally {
|
|
2713
|
+
try {
|
|
2714
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
2715
|
+
}
|
|
2716
|
+
finally { if (e_1) throw e_1.error; }
|
|
2717
|
+
}
|
|
2718
|
+
try {
|
|
2719
|
+
for (var _f = __values(Object.keys(acc.output)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
2720
|
+
var key = _g.value;
|
|
2721
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2722
|
+
//@ts-ignore
|
|
2723
|
+
if (item.output[key]) {
|
|
2724
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2725
|
+
//@ts-ignore
|
|
2726
|
+
acc.output[key].value += item.output[key].value || 0;
|
|
2727
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2728
|
+
//@ts-ignore
|
|
2729
|
+
if (item.output[key].isUncertain) {
|
|
2730
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2731
|
+
//@ts-ignore
|
|
2732
|
+
acc.output[key].isUncertain = true;
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2738
|
+
finally {
|
|
2739
|
+
try {
|
|
2740
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
2741
|
+
}
|
|
2742
|
+
finally { if (e_2) throw e_2.error; }
|
|
2743
|
+
}
|
|
2744
|
+
return acc;
|
|
2745
|
+
}, deepClone(ZERO_USAGE));
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2721
2748
|
/**
|
|
2722
2749
|
* Parses the given script and returns the list of all used variables that are not defined in the script
|
|
2723
2750
|
*
|
|
@@ -4099,12 +4126,12 @@ function executeFormatCells(options) {
|
|
|
4099
4126
|
if (!(error instanceof PipelineExecutionError)) {
|
|
4100
4127
|
throw error;
|
|
4101
4128
|
}
|
|
4102
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n ".concat(error.message, "\n\n This is error in FOREACH command\n You have probbably passed wrong data to pipeline or wrong data was generated which are processed by FOREACH command\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
4129
|
+
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n ".concat(error.message, "\n\n This is error in FOREACH command\n You have probbably passed wrong data to pipeline or wrong data was generated which are processed by FOREACH command\n\n ").concat(block(pipelineIdentification), "\n Subparameter index: ").concat(index, "\n "); }));
|
|
4103
4130
|
}
|
|
4104
4131
|
allSubparameters = __assign(__assign({}, parameters), mappedParameters);
|
|
4105
4132
|
// Note: [👨👨👧] Now we can freeze `subparameters` because we are sure that all and only used parameters are defined and are not going to be changed
|
|
4106
4133
|
Object.freeze(allSubparameters);
|
|
4107
|
-
return [4 /*yield*/, executeAttempts(__assign(__assign({}, options), { priority: priority + index, parameters: allSubparameters, pipelineIdentification: pipelineIdentification }))];
|
|
4134
|
+
return [4 /*yield*/, executeAttempts(__assign(__assign({}, options), { priority: priority + index, parameters: allSubparameters, pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Subparameter index: ").concat(index, "\n "); }) }))];
|
|
4108
4135
|
case 1:
|
|
4109
4136
|
subresultString = _a.sent();
|
|
4110
4137
|
return [2 /*return*/, subresultString];
|
|
@@ -4614,7 +4641,7 @@ function executePipeline(options) {
|
|
|
4614
4641
|
},
|
|
4615
4642
|
settings: settings,
|
|
4616
4643
|
$executionReport: executionReport,
|
|
4617
|
-
pipelineIdentification: pipelineIdentification,
|
|
4644
|
+
pipelineIdentification: spaceTrim$1(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }),
|
|
4618
4645
|
})
|
|
4619
4646
|
.then(function (newParametersToPass) {
|
|
4620
4647
|
parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
|
|
@@ -4737,9 +4764,11 @@ function createPipelineExecutor(options) {
|
|
|
4737
4764
|
else if (isNotPreparedWarningSupressed !== true) {
|
|
4738
4765
|
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 "); }));
|
|
4739
4766
|
}
|
|
4767
|
+
var runCount = 0;
|
|
4740
4768
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
4741
4769
|
return __generator(this, function (_a) {
|
|
4742
|
-
|
|
4770
|
+
runCount++;
|
|
4771
|
+
return [2 /*return*/, /* not await */ executePipeline({
|
|
4743
4772
|
pipeline: pipeline,
|
|
4744
4773
|
preparedPipeline: preparedPipeline,
|
|
4745
4774
|
setPreparedPipeline: function (newPreparedPipeline) {
|
|
@@ -4748,7 +4777,7 @@ function createPipelineExecutor(options) {
|
|
|
4748
4777
|
inputParameters: inputParameters,
|
|
4749
4778
|
tools: tools,
|
|
4750
4779
|
onProgress: onProgress,
|
|
4751
|
-
pipelineIdentification: pipelineIdentification,
|
|
4780
|
+
pipelineIdentification: spaceTrim$1(function (block) { return "\n ".concat(block(pipelineIdentification), "\n ").concat(runCount === 1 ? '' : "Run #".concat(runCount), "\n "); }),
|
|
4752
4781
|
settings: {
|
|
4753
4782
|
maxExecutionAttempts: maxExecutionAttempts,
|
|
4754
4783
|
maxParallelCount: maxParallelCount,
|
|
@@ -4921,7 +4950,7 @@ function prepareKnowledgePieces(knowledgeSources, options) {
|
|
|
4921
4950
|
var partialPieces, pieces;
|
|
4922
4951
|
return __generator(this, function (_a) {
|
|
4923
4952
|
switch (_a.label) {
|
|
4924
|
-
case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.sourceContent, // <- TODO: [🐝]
|
|
4953
|
+
case 0: return [4 /*yield*/, prepareKnowledgeFromMarkdown(knowledgeSource.sourceContent, // <- TODO: [🐝][main] !!! Unhardcode markdown, detect which type it is - BE AWARE of big package size
|
|
4925
4954
|
options)];
|
|
4926
4955
|
case 1:
|
|
4927
4956
|
partialPieces = _a.sent();
|
|
@@ -8886,6 +8915,42 @@ var _OpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
|
8886
8915
|
return null;
|
|
8887
8916
|
},
|
|
8888
8917
|
});
|
|
8918
|
+
/**
|
|
8919
|
+
* @@@ registration1 of default configuration for Open AI
|
|
8920
|
+
*
|
|
8921
|
+
* Note: [🏐] Configurations registrations are done in @@@ BUT constructor @@@
|
|
8922
|
+
*
|
|
8923
|
+
* @public exported from `@promptbook/core`
|
|
8924
|
+
* @public exported from `@promptbook/cli`
|
|
8925
|
+
*/
|
|
8926
|
+
var _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register({
|
|
8927
|
+
title: 'Open AI Assistant',
|
|
8928
|
+
packageName: '@promptbook/openai',
|
|
8929
|
+
className: 'OpenAiAssistantExecutionTools',
|
|
8930
|
+
getBoilerplateConfiguration: function () {
|
|
8931
|
+
return {
|
|
8932
|
+
title: 'Open AI Assistant (boilerplate)',
|
|
8933
|
+
packageName: '@promptbook/openai',
|
|
8934
|
+
className: 'OpenAiAssistantExecutionTools',
|
|
8935
|
+
options: {
|
|
8936
|
+
apiKey: 'sk-',
|
|
8937
|
+
},
|
|
8938
|
+
};
|
|
8939
|
+
},
|
|
8940
|
+
createConfigurationFromEnv: function (env) {
|
|
8941
|
+
if (typeof env.OPENAI_API_KEY === 'string') {
|
|
8942
|
+
return {
|
|
8943
|
+
title: 'Open AI Assistant (from env)',
|
|
8944
|
+
packageName: '@promptbook/openai',
|
|
8945
|
+
className: 'OpenAiAssistantExecutionTools',
|
|
8946
|
+
options: {
|
|
8947
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
8948
|
+
},
|
|
8949
|
+
};
|
|
8950
|
+
}
|
|
8951
|
+
return null;
|
|
8952
|
+
},
|
|
8953
|
+
});
|
|
8889
8954
|
|
|
8890
8955
|
/**
|
|
8891
8956
|
* This class behaves like LocalStorage but separates keys by prefix
|
|
@@ -9237,5 +9302,5 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
9237
9302
|
* TODO: [🧠] Should be in generated file GENERATOR_WARNING
|
|
9238
9303
|
*/
|
|
9239
9304
|
|
|
9240
|
-
export { $llmToolsMetadataRegister, $llmToolsRegister, CLAIM, CallbackInterfaceTools, CollectionError, CsvFormatDefinition, DEFAULT_CSV_SETTINGS, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, ERRORS, EXECUTIONS_CACHE_DIRNAME, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, IS_VERBOSE, LimitReachedError, MANDATORY_CSV_SETTINGS, 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, TextFormatDefinition, 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 };
|
|
9305
|
+
export { $llmToolsMetadataRegister, $llmToolsRegister, CLAIM, CallbackInterfaceTools, CollectionError, CsvFormatDefinition, DEFAULT_CSV_SETTINGS, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, ERRORS, EXECUTIONS_CACHE_DIRNAME, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, IS_VERBOSE, LimitReachedError, MANDATORY_CSV_SETTINGS, 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, TextFormatDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _OpenAiAssistantMetadataRegistration, _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 };
|
|
9241
9306
|
//# sourceMappingURL=index.es.js.map
|