@promptbook/core 0.61.0-17 → 0.61.0-19
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 +126 -119
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/collection/SimplePipelineCollection.d.ts +10 -10
- package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +7 -7
- package/package.json +1 -1
- package/umd/index.umd.js +126 -119
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/collection/SimplePipelineCollection.d.ts +10 -10
- package/umd/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +7 -7
package/esm/index.es.js
CHANGED
|
@@ -918,79 +918,100 @@ var ReferenceError$1 = /** @class */ (function (_super) {
|
|
|
918
918
|
}(Error));
|
|
919
919
|
|
|
920
920
|
/**
|
|
921
|
-
*
|
|
922
|
-
|
|
921
|
+
* Unprepare just strips the preparation data of the pipeline
|
|
922
|
+
*/
|
|
923
|
+
function unpreparePipeline(pipeline) {
|
|
924
|
+
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources;
|
|
925
|
+
personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
|
|
926
|
+
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
927
|
+
return __assign(__assign({}, pipeline), { knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] });
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* TODO: [🔼] !!! Export via `@promptbook/core`
|
|
931
|
+
* TODO: Write tests for `preparePipeline`
|
|
932
|
+
*/
|
|
933
|
+
|
|
934
|
+
/**
|
|
935
|
+
* Library of pipelines that groups together pipelines for an application.
|
|
936
|
+
* This implementation is a very thin wrapper around the Array / Map of pipelines.
|
|
923
937
|
*
|
|
924
938
|
* @private use `createCollectionFromJson` instead
|
|
925
|
-
* @see https://github.com/webgptorg/
|
|
939
|
+
* @see https://github.com/webgptorg/pipeline#pipeline-collection
|
|
926
940
|
*/
|
|
927
941
|
var SimplePipelineCollection = /** @class */ (function () {
|
|
928
942
|
/**
|
|
929
|
-
* Constructs a pipeline collection from
|
|
943
|
+
* Constructs a pipeline collection from pipelines
|
|
930
944
|
*
|
|
931
|
-
* @param
|
|
945
|
+
* @param pipelines @@@
|
|
932
946
|
*
|
|
933
947
|
* @private Use instead `createCollectionFromJson`
|
|
934
|
-
* Note: During the construction logic of all
|
|
948
|
+
* Note: During the construction logic of all pipelines are validated
|
|
935
949
|
* Note: It is not recommended to use this constructor directly, use `createCollectionFromJson` *(or other variant)* instead
|
|
936
950
|
*/
|
|
937
951
|
function SimplePipelineCollection() {
|
|
938
952
|
var e_1, _a;
|
|
939
|
-
var
|
|
953
|
+
var pipelines = [];
|
|
940
954
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
941
|
-
|
|
955
|
+
pipelines[_i] = arguments[_i];
|
|
942
956
|
}
|
|
943
957
|
this.collection = new Map();
|
|
944
958
|
try {
|
|
945
|
-
for (var
|
|
946
|
-
var
|
|
947
|
-
|
|
948
|
-
|
|
959
|
+
for (var pipelines_1 = __values(pipelines), pipelines_1_1 = pipelines_1.next(); !pipelines_1_1.done; pipelines_1_1 = pipelines_1.next()) {
|
|
960
|
+
var pipeline = pipelines_1_1.value;
|
|
961
|
+
// TODO: [👠] DRY
|
|
962
|
+
if (pipeline.pipelineUrl === undefined) {
|
|
963
|
+
throw new ReferenceError$1(spaceTrim$1("\n Pipeline with name \"".concat(pipeline.title, "\" does not have defined URL\n\n File:\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: Pipelines without URLs are called anonymous pipelines\n They can be used as standalone pipelines, but they cannot be referenced by other pipelines\n And also they cannot be used in the pipeline collection\n\n ")));
|
|
949
964
|
}
|
|
950
|
-
|
|
965
|
+
// Note: [🐨]
|
|
966
|
+
validatePipeline(pipeline);
|
|
967
|
+
// TODO: [🦄] DRY
|
|
951
968
|
// Note: [🦄]
|
|
952
|
-
if (
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
969
|
+
if (
|
|
970
|
+
// TODO: [🐽]
|
|
971
|
+
this.collection.has(pipeline.pipelineUrl) &&
|
|
972
|
+
pipelineJsonToString(unpreparePipeline(pipeline)) !==
|
|
973
|
+
pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
|
|
974
|
+
var existing = this.collection.get(pipeline.pipelineUrl);
|
|
975
|
+
throw new ReferenceError$1(spaceTrim$1("\n Pipeline with URL \"".concat(pipeline.pipelineUrl, "\" is already in the collection\n\n Conflicting files:\n ").concat(existing.sourceFile || 'Unknown', "\n ").concat(pipeline.sourceFile || 'Unknown', "\n\n Note: Pipelines with the same URL are not allowed\n Only exepction is when the pipelines are identical\n\n ")));
|
|
956
976
|
}
|
|
957
|
-
|
|
977
|
+
// Note: [🧠] Overwrite existing pipeline with the same URL
|
|
978
|
+
this.collection.set(pipeline.pipelineUrl, pipeline);
|
|
958
979
|
}
|
|
959
980
|
}
|
|
960
981
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
961
982
|
finally {
|
|
962
983
|
try {
|
|
963
|
-
if (
|
|
984
|
+
if (pipelines_1_1 && !pipelines_1_1.done && (_a = pipelines_1.return)) _a.call(pipelines_1);
|
|
964
985
|
}
|
|
965
986
|
finally { if (e_1) throw e_1.error; }
|
|
966
987
|
}
|
|
967
988
|
}
|
|
968
989
|
/**
|
|
969
|
-
* Gets all
|
|
990
|
+
* Gets all pipelines in the collection
|
|
970
991
|
*/
|
|
971
992
|
SimplePipelineCollection.prototype.listPipelines = function () {
|
|
972
993
|
return Array.from(this.collection.keys());
|
|
973
994
|
};
|
|
974
995
|
/**
|
|
975
|
-
* Gets
|
|
996
|
+
* Gets pipeline by its URL
|
|
976
997
|
*
|
|
977
998
|
* Note: This is not a direct fetching from the URL, but a lookup in the collection
|
|
978
999
|
*/
|
|
979
1000
|
SimplePipelineCollection.prototype.getPipelineByUrl = function (url) {
|
|
980
1001
|
var _this = this;
|
|
981
|
-
var
|
|
982
|
-
if (!
|
|
1002
|
+
var pipeline = this.collection.get(url);
|
|
1003
|
+
if (!pipeline) {
|
|
983
1004
|
if (this.listPipelines().length === 0) {
|
|
984
|
-
throw new NotFoundError(spaceTrim$1("\n
|
|
1005
|
+
throw new NotFoundError(spaceTrim$1("\n Pipeline with url \"".concat(url, "\" not found\n\n No pipelines available\n ")));
|
|
985
1006
|
}
|
|
986
|
-
throw new NotFoundError(spaceTrim$1(function (block) { return "\n
|
|
1007
|
+
throw new NotFoundError(spaceTrim$1(function (block) { return "\n Pipeline with url \"".concat(url, "\" not found\n\n Available pipelines:\n ").concat(block(_this.listPipelines()
|
|
987
1008
|
.map(function (pipelineUrl) { return "- ".concat(pipelineUrl); })
|
|
988
1009
|
.join('\n')), "\n\n "); }));
|
|
989
1010
|
}
|
|
990
|
-
return
|
|
1011
|
+
return pipeline;
|
|
991
1012
|
};
|
|
992
1013
|
/**
|
|
993
|
-
* Checks whether given prompt was defined in any
|
|
1014
|
+
* Checks whether given prompt was defined in any pipeline in the collection
|
|
994
1015
|
*/
|
|
995
1016
|
SimplePipelineCollection.prototype.isResponsibleForPrompt = function (prompt) {
|
|
996
1017
|
return true;
|
|
@@ -1424,7 +1445,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1424
1445
|
});
|
|
1425
1446
|
}
|
|
1426
1447
|
|
|
1427
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
1448
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-18",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",dependentParameterNames:["content"],resultingParameterName:"knowledge"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-18",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.61.0-18",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",dependentParameterNames:["content"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-18",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.61.0-18",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",expectations:{words:{min:1,max:8}},dependentParameterNames:["content"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-18",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.61.0-18",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}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},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### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `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### Option `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}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-18",modelUsage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
1428
1449
|
|
|
1429
1450
|
var defaultDiacriticsRemovalMap = [
|
|
1430
1451
|
{
|
|
@@ -1804,39 +1825,6 @@ function assertsExecutionSuccessful(executionResult) {
|
|
|
1804
1825
|
* TODO: [🧠] Can this return type be better typed than void
|
|
1805
1826
|
*/
|
|
1806
1827
|
|
|
1807
|
-
/**
|
|
1808
|
-
* Create difference set of two sets.
|
|
1809
|
-
*
|
|
1810
|
-
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
1811
|
-
*/
|
|
1812
|
-
function difference(a, b, isEqual) {
|
|
1813
|
-
var e_1, _a;
|
|
1814
|
-
if (isEqual === void 0) { isEqual = function (a, b) { return a === b; }; }
|
|
1815
|
-
var diff = new Set();
|
|
1816
|
-
var _loop_1 = function (itemA) {
|
|
1817
|
-
if (!Array.from(b).some(function (itemB) { return isEqual(itemA, itemB); })) {
|
|
1818
|
-
diff.add(itemA);
|
|
1819
|
-
}
|
|
1820
|
-
};
|
|
1821
|
-
try {
|
|
1822
|
-
for (var _b = __values(Array.from(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1823
|
-
var itemA = _c.value;
|
|
1824
|
-
_loop_1(itemA);
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1828
|
-
finally {
|
|
1829
|
-
try {
|
|
1830
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1831
|
-
}
|
|
1832
|
-
finally { if (e_1) throw e_1.error; }
|
|
1833
|
-
}
|
|
1834
|
-
return diff;
|
|
1835
|
-
}
|
|
1836
|
-
/**
|
|
1837
|
-
* TODO: [🧠][💯] Maybe also implement symmetricDifference
|
|
1838
|
-
*/
|
|
1839
|
-
|
|
1840
1828
|
/**
|
|
1841
1829
|
* Parses the template and returns the list of all parameter names
|
|
1842
1830
|
*
|
|
@@ -1970,46 +1958,6 @@ function extractParametersFromPromptTemplate(promptTemplate) {
|
|
|
1970
1958
|
* TODO: [🔣] If script require contentLanguage
|
|
1971
1959
|
*/
|
|
1972
1960
|
|
|
1973
|
-
/**
|
|
1974
|
-
* Creates a new set with all elements that are present in either set
|
|
1975
|
-
*
|
|
1976
|
-
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
1977
|
-
*/
|
|
1978
|
-
function union() {
|
|
1979
|
-
var e_1, _a, e_2, _b;
|
|
1980
|
-
var sets = [];
|
|
1981
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1982
|
-
sets[_i] = arguments[_i];
|
|
1983
|
-
}
|
|
1984
|
-
var union = new Set();
|
|
1985
|
-
try {
|
|
1986
|
-
for (var sets_1 = __values(sets), sets_1_1 = sets_1.next(); !sets_1_1.done; sets_1_1 = sets_1.next()) {
|
|
1987
|
-
var set = sets_1_1.value;
|
|
1988
|
-
try {
|
|
1989
|
-
for (var _c = (e_2 = void 0, __values(Array.from(set))), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
1990
|
-
var item = _d.value;
|
|
1991
|
-
union.add(item);
|
|
1992
|
-
}
|
|
1993
|
-
}
|
|
1994
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
1995
|
-
finally {
|
|
1996
|
-
try {
|
|
1997
|
-
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
1998
|
-
}
|
|
1999
|
-
finally { if (e_2) throw e_2.error; }
|
|
2000
|
-
}
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2004
|
-
finally {
|
|
2005
|
-
try {
|
|
2006
|
-
if (sets_1_1 && !sets_1_1.done && (_a = sets_1.return)) _a.call(sets_1);
|
|
2007
|
-
}
|
|
2008
|
-
finally { if (e_1) throw e_1.error; }
|
|
2009
|
-
}
|
|
2010
|
-
return union;
|
|
2011
|
-
}
|
|
2012
|
-
|
|
2013
1961
|
/**
|
|
2014
1962
|
* This error occurs when some expectation is not met in the execution of the pipeline
|
|
2015
1963
|
*
|
|
@@ -2176,7 +2124,7 @@ var MultipleLlmExecutionTools = /** @class */ (function () {
|
|
|
2176
2124
|
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n All execution tools failed:\n\n ".concat(block(errors.map(function (error) { return "- ".concat(error.name || 'Error', ": ").concat(error.message); }).join('\n')), "\n\n "); }));
|
|
2177
2125
|
}
|
|
2178
2126
|
else {
|
|
2179
|
-
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n
|
|
2127
|
+
throw new PipelineExecutionError(spaceTrim(function (block) { return "\n You have not provided any `LlmExecutionTools` that support model variant \"".concat(prompt.modelRequirements.modelVariant, "\n\n Available `LlmExecutionTools`:\n ").concat(block(_this.llmExecutionTools
|
|
2180
2128
|
.map(function (tools) { return "- ".concat(tools.title, " ").concat(tools.description || ''); })
|
|
2181
2129
|
.join('\n')), "\n\n "); }));
|
|
2182
2130
|
}
|
|
@@ -2255,7 +2203,7 @@ function joinLlmExecutionTools() {
|
|
|
2255
2203
|
llmExecutionTools[_i] = arguments[_i];
|
|
2256
2204
|
}
|
|
2257
2205
|
if (llmExecutionTools.length === 0) {
|
|
2258
|
-
var warningMessage = spaceTrim("\n You have provided
|
|
2206
|
+
var warningMessage = spaceTrim("\n You have not provided any `LlmExecutionTools`\n This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.\n\n Technically, it's not an error, but it's probably not what you want because it does not make sense to use Promptbook without language models.\n ");
|
|
2259
2207
|
// TODO: [🟥] Detect browser / node and make it colorfull
|
|
2260
2208
|
console.warn(warningMessage);
|
|
2261
2209
|
/*
|
|
@@ -2415,10 +2363,83 @@ function replaceParameters(template, parameters) {
|
|
|
2415
2363
|
return replacedTemplate;
|
|
2416
2364
|
}
|
|
2417
2365
|
|
|
2366
|
+
/**
|
|
2367
|
+
* Create difference set of two sets.
|
|
2368
|
+
*
|
|
2369
|
+
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
2370
|
+
*/
|
|
2371
|
+
function difference(a, b, isEqual) {
|
|
2372
|
+
var e_1, _a;
|
|
2373
|
+
if (isEqual === void 0) { isEqual = function (a, b) { return a === b; }; }
|
|
2374
|
+
var diff = new Set();
|
|
2375
|
+
var _loop_1 = function (itemA) {
|
|
2376
|
+
if (!Array.from(b).some(function (itemB) { return isEqual(itemA, itemB); })) {
|
|
2377
|
+
diff.add(itemA);
|
|
2378
|
+
}
|
|
2379
|
+
};
|
|
2380
|
+
try {
|
|
2381
|
+
for (var _b = __values(Array.from(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
2382
|
+
var itemA = _c.value;
|
|
2383
|
+
_loop_1(itemA);
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2387
|
+
finally {
|
|
2388
|
+
try {
|
|
2389
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
2390
|
+
}
|
|
2391
|
+
finally { if (e_1) throw e_1.error; }
|
|
2392
|
+
}
|
|
2393
|
+
return diff;
|
|
2394
|
+
}
|
|
2395
|
+
/**
|
|
2396
|
+
* TODO: [🧠][💯] Maybe also implement symmetricDifference
|
|
2397
|
+
*/
|
|
2398
|
+
|
|
2399
|
+
/**
|
|
2400
|
+
* Creates a new set with all elements that are present in either set
|
|
2401
|
+
*
|
|
2402
|
+
* @deprecated use new javascript set methods instead @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
|
2403
|
+
*/
|
|
2404
|
+
function union() {
|
|
2405
|
+
var e_1, _a, e_2, _b;
|
|
2406
|
+
var sets = [];
|
|
2407
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
2408
|
+
sets[_i] = arguments[_i];
|
|
2409
|
+
}
|
|
2410
|
+
var union = new Set();
|
|
2411
|
+
try {
|
|
2412
|
+
for (var sets_1 = __values(sets), sets_1_1 = sets_1.next(); !sets_1_1.done; sets_1_1 = sets_1.next()) {
|
|
2413
|
+
var set = sets_1_1.value;
|
|
2414
|
+
try {
|
|
2415
|
+
for (var _c = (e_2 = void 0, __values(Array.from(set))), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
2416
|
+
var item = _d.value;
|
|
2417
|
+
union.add(item);
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
2421
|
+
finally {
|
|
2422
|
+
try {
|
|
2423
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
2424
|
+
}
|
|
2425
|
+
finally { if (e_2) throw e_2.error; }
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2430
|
+
finally {
|
|
2431
|
+
try {
|
|
2432
|
+
if (sets_1_1 && !sets_1_1.done && (_a = sets_1.return)) _a.call(sets_1);
|
|
2433
|
+
}
|
|
2434
|
+
finally { if (e_1) throw e_1.error; }
|
|
2435
|
+
}
|
|
2436
|
+
return union;
|
|
2437
|
+
}
|
|
2438
|
+
|
|
2418
2439
|
/**
|
|
2419
2440
|
* The version of the Promptbook library
|
|
2420
2441
|
*/
|
|
2421
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
2442
|
+
var PROMPTBOOK_VERSION = '0.61.0-18';
|
|
2422
2443
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
2423
2444
|
|
|
2424
2445
|
/**
|
|
@@ -2569,7 +2590,7 @@ function createPipelineExecutor(options) {
|
|
|
2569
2590
|
pipeline = rawPipeline;
|
|
2570
2591
|
}
|
|
2571
2592
|
else {
|
|
2572
|
-
console.warn(spaceTrim$1("\n Pipeline is not prepared\n\n It will be prepared ad-hoc before the first execution\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n "));
|
|
2593
|
+
console.warn(spaceTrim$1("\n Pipeline ".concat(rawPipeline.pipelineUrl || rawPipeline.sourceFile || rawPipeline.title, " is not prepared\n\n It will be prepared ad-hoc before the first execution\n But it is recommended to prepare the pipeline during collection preparation\n\n @see more at https://ptbk.io/prepare-pipeline\n ")));
|
|
2573
2594
|
}
|
|
2574
2595
|
var pipelineExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
|
|
2575
2596
|
function getContextForTemplate(// <- TODO: [🧠][🥜]
|
|
@@ -5844,20 +5865,6 @@ var SimplePromptInterfaceTools = /** @class */ (function () {
|
|
|
5844
5865
|
* Note: [🔵] This code should never be published outside of `@promptbook/browser`
|
|
5845
5866
|
*/
|
|
5846
5867
|
|
|
5847
|
-
/**
|
|
5848
|
-
* Unprepare just strips the preparation data of the pipeline
|
|
5849
|
-
*/
|
|
5850
|
-
function unpreparePipeline(pipeline) {
|
|
5851
|
-
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources;
|
|
5852
|
-
personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
|
|
5853
|
-
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
5854
|
-
return __assign(__assign({}, pipeline), { knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] });
|
|
5855
|
-
}
|
|
5856
|
-
/**
|
|
5857
|
-
* TODO: [🔼] !!! Export via `@promptbook/core`
|
|
5858
|
-
* TODO: Write tests for `preparePipeline`
|
|
5859
|
-
*/
|
|
5860
|
-
|
|
5861
5868
|
/**
|
|
5862
5869
|
* Default options for generating an execution report string
|
|
5863
5870
|
*/
|