@promptbook/core 0.61.0-25 → 0.61.0-26
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 +104 -95
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/utils.index.d.ts +4 -4
- package/esm/typings/src/conversion/utils/{extractParametersFromPromptTemplate.d.ts → extractParameterNamesFromPromptTemplate.d.ts} +1 -1
- package/esm/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -1
- package/esm/typings/src/utils/{extractParameters.d.ts → extractParameterNames.d.ts} +2 -2
- package/package.json +1 -1
- package/umd/index.umd.js +104 -95
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/_packages/utils.index.d.ts +4 -4
- package/umd/typings/src/conversion/utils/{extractParametersFromPromptTemplate.d.ts → extractParameterNamesFromPromptTemplate.d.ts} +1 -1
- package/umd/typings/src/types/PipelineJson/PipelineJson.d.ts +1 -1
- package/umd/typings/src/utils/{extractParameters.d.ts → extractParameterNames.d.ts} +2 -2
- /package/esm/typings/src/conversion/utils/{extractParametersFromPromptTemplate.test.d.ts → extractParameterNamesFromPromptTemplate.test.d.ts} +0 -0
- /package/esm/typings/src/utils/{extractParameters.test.d.ts → extractParameterNames.test.d.ts} +0 -0
- /package/umd/typings/src/conversion/utils/{extractParametersFromPromptTemplate.test.d.ts → extractParameterNamesFromPromptTemplate.test.d.ts} +0 -0
- /package/umd/typings/src/utils/{extractParameters.test.d.ts → extractParameterNames.test.d.ts} +0 -0
package/esm/index.es.js
CHANGED
|
@@ -700,52 +700,63 @@ function isValidPipelineUrl(url) {
|
|
|
700
700
|
*/
|
|
701
701
|
function validatePipeline(pipeline) {
|
|
702
702
|
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
703
|
-
var e_1, _a, e_2, _b, e_3, _c
|
|
703
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
704
|
+
var pipelineIdentification = (function () {
|
|
705
|
+
// Note: This is a 😐 implementation of [🚞]
|
|
706
|
+
var _ = [];
|
|
707
|
+
if (pipeline.sourceFile !== undefined) {
|
|
708
|
+
_.push("File: ".concat(pipeline.sourceFile));
|
|
709
|
+
}
|
|
710
|
+
if (pipeline.pipelineUrl !== undefined) {
|
|
711
|
+
_.push("Url: ".concat(pipeline.pipelineUrl));
|
|
712
|
+
}
|
|
713
|
+
return _.join('\n');
|
|
714
|
+
})();
|
|
704
715
|
if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
705
716
|
// <- Note: [🚲]
|
|
706
|
-
throw new PipelineLogicError("Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\""));
|
|
717
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid promptbook URL \"".concat(pipeline.pipelineUrl, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
707
718
|
}
|
|
708
719
|
if (!isValidPromptbookVersion(pipeline.promptbookVersion)) {
|
|
709
720
|
// <- Note: [🚲]
|
|
710
|
-
throw new PipelineLogicError("Invalid
|
|
721
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Invalid Promptbook Version \"".concat(pipeline.promptbookVersion, "\"\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
711
722
|
}
|
|
712
723
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
713
724
|
if (!Array.isArray(pipeline.parameters)) {
|
|
714
725
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
715
|
-
throw new ParsingError(spaceTrim$1("\n
|
|
726
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Promptbook is valid JSON but with wrong structure\n\n `promptbook.parameters` expected to be an array, but got ".concat(typeof pipeline.parameters, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
716
727
|
}
|
|
717
728
|
// TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
|
|
718
729
|
if (!Array.isArray(pipeline.promptTemplates)) {
|
|
719
730
|
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
720
|
-
throw new ParsingError(spaceTrim$1("\n
|
|
731
|
+
throw new ParsingError(spaceTrim$1(function (block) { return "\n Promptbook is valid JSON but with wrong structure\n\n `promptbook.promptTemplates` expected to be an array, but got ".concat(typeof pipeline.promptTemplates, "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
721
732
|
}
|
|
722
733
|
var _loop_1 = function (parameter) {
|
|
723
734
|
if (parameter.isInput && parameter.isOutput) {
|
|
724
|
-
throw new PipelineLogicError("Parameter {".concat(parameter.name, "} can not be both input and output"));
|
|
735
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n\n Parameter {".concat(parameter.name, "} can not be both input and output\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
725
736
|
}
|
|
726
737
|
// Note: Testing that parameter is either intermediate or output BUT not created and unused
|
|
727
738
|
if (!parameter.isInput &&
|
|
728
739
|
!parameter.isOutput &&
|
|
729
740
|
!pipeline.promptTemplates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
|
|
730
|
-
throw new PipelineLogicError(spaceTrim$1("\n
|
|
741
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameter.name, "} is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
|
|
731
742
|
}
|
|
732
743
|
// Note: Testing that parameter is either input or result of some template
|
|
733
744
|
if (!parameter.isInput &&
|
|
734
745
|
!pipeline.promptTemplates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
|
|
735
|
-
throw new PipelineLogicError(spaceTrim$1("\n
|
|
746
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n - Remove declaration of {").concat(parameter.name, "}\n - Add prompt template that results in -> {").concat(parameter.name, "}\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
736
747
|
}
|
|
737
748
|
};
|
|
738
749
|
try {
|
|
739
750
|
// Note: Check each parameter individually
|
|
740
|
-
for (var
|
|
741
|
-
var parameter =
|
|
751
|
+
for (var _d = __values(pipeline.parameters), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
752
|
+
var parameter = _e.value;
|
|
742
753
|
_loop_1(parameter);
|
|
743
754
|
}
|
|
744
755
|
}
|
|
745
756
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
746
757
|
finally {
|
|
747
758
|
try {
|
|
748
|
-
if (
|
|
759
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
749
760
|
}
|
|
750
761
|
finally { if (e_1) throw e_1.error; }
|
|
751
762
|
}
|
|
@@ -757,70 +768,80 @@ function validatePipeline(pipeline) {
|
|
|
757
768
|
var name = _a.name;
|
|
758
769
|
return name;
|
|
759
770
|
}));
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
771
|
+
var _loop_2 = function (template) {
|
|
772
|
+
var e_4, _h, e_5, _j;
|
|
773
|
+
if (definedParameters.has(template.resultingParameterName)) {
|
|
774
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(template.resultingParameterName, "} is defined multiple times\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
775
|
+
}
|
|
776
|
+
if (RESERVED_PARAMETER_NAMES.includes(template.resultingParameterName)) {
|
|
777
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter name {".concat(template.resultingParameterName, "} is reserved, please use different name\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
778
|
+
}
|
|
779
|
+
definedParameters.add(template.resultingParameterName);
|
|
780
|
+
if (template.blockType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
|
|
781
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n\n You must specify MODEL VARIANT in the prompt template \"".concat(template.title, "\"\n\n For example:\n - MODEL VARIANT Chat\n - MODEL NAME `gpt-4-1106-preview`").concat(/* <- TODO: Dynamic listing of command examples */ '', "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
782
|
+
}
|
|
783
|
+
if (template.jokerParameterNames && template.jokerParameterNames.length > 0) {
|
|
784
|
+
if (!template.expectFormat &&
|
|
785
|
+
!template.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
786
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Joker parameters are used for {".concat(template.resultingParameterName, "} but no expectations are defined\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
766
787
|
}
|
|
767
|
-
|
|
768
|
-
|
|
788
|
+
var _loop_4 = function (joker) {
|
|
789
|
+
if (!template.dependentParameterNames.includes(joker)) {
|
|
790
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in `dependentParameterNames`\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
try {
|
|
794
|
+
for (var _k = (e_4 = void 0, __values(template.jokerParameterNames)), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
795
|
+
var joker = _l.value;
|
|
796
|
+
_loop_4(joker);
|
|
797
|
+
}
|
|
769
798
|
}
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
799
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
800
|
+
finally {
|
|
801
|
+
try {
|
|
802
|
+
if (_l && !_l.done && (_h = _k.return)) _h.call(_k);
|
|
803
|
+
}
|
|
804
|
+
finally { if (e_4) throw e_4.error; }
|
|
773
805
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
806
|
+
}
|
|
807
|
+
if (template.expectations) {
|
|
808
|
+
var _loop_5 = function (unit, min, max) {
|
|
809
|
+
if (min !== undefined && max !== undefined && min > max) {
|
|
810
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
778
811
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
var joker = _l.value;
|
|
782
|
-
if (!template.dependentParameterNames.includes(joker)) {
|
|
783
|
-
throw new PipelineLogicError("Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in dependentParameterNames"));
|
|
784
|
-
}
|
|
785
|
-
}
|
|
812
|
+
if (min !== undefined && min < 0) {
|
|
813
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Min expectation of ".concat(unit, " must be zero or positive\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
786
814
|
}
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
815
|
+
if (max !== undefined && max <= 0) {
|
|
816
|
+
throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n Max expectation of ".concat(unit, " must be positive\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
try {
|
|
820
|
+
for (var _m = (e_5 = void 0, __values(Object.entries(template.expectations))), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
821
|
+
var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
|
|
822
|
+
_loop_5(unit, min, max);
|
|
793
823
|
}
|
|
794
824
|
}
|
|
795
|
-
|
|
825
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
826
|
+
finally {
|
|
796
827
|
try {
|
|
797
|
-
|
|
798
|
-
var _p = __read(_o.value, 2), unit = _p[0], _q = _p[1], min = _q.min, max = _q.max;
|
|
799
|
-
if (min !== undefined && max !== undefined && min > max) {
|
|
800
|
-
throw new PipelineLogicError("Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")"));
|
|
801
|
-
}
|
|
802
|
-
if (min !== undefined && min < 0) {
|
|
803
|
-
throw new PipelineLogicError("Min expectation of ".concat(unit, " must be zero or positive"));
|
|
804
|
-
}
|
|
805
|
-
if (max !== undefined && max <= 0) {
|
|
806
|
-
throw new PipelineLogicError("Max expectation of ".concat(unit, " must be positive"));
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
811
|
-
finally {
|
|
812
|
-
try {
|
|
813
|
-
if (_o && !_o.done && (_d = _m.return)) _d.call(_m);
|
|
814
|
-
}
|
|
815
|
-
finally { if (e_4) throw e_4.error; }
|
|
828
|
+
if (_o && !_o.done && (_j = _m.return)) _j.call(_m);
|
|
816
829
|
}
|
|
830
|
+
finally { if (e_5) throw e_5.error; }
|
|
817
831
|
}
|
|
818
832
|
}
|
|
833
|
+
};
|
|
834
|
+
try {
|
|
835
|
+
// Note: Checking each template individually
|
|
836
|
+
for (var _f = __values(pipeline.promptTemplates), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
837
|
+
var template = _g.value;
|
|
838
|
+
_loop_2(template);
|
|
839
|
+
}
|
|
819
840
|
}
|
|
820
841
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
821
842
|
finally {
|
|
822
843
|
try {
|
|
823
|
-
if (
|
|
844
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
824
845
|
}
|
|
825
846
|
finally { if (e_2) throw e_2.error; }
|
|
826
847
|
}
|
|
@@ -841,20 +862,20 @@ function validatePipeline(pipeline) {
|
|
|
841
862
|
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), [reservedParameterName], false);
|
|
842
863
|
}
|
|
843
864
|
}
|
|
844
|
-
catch (
|
|
865
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
845
866
|
finally {
|
|
846
867
|
try {
|
|
847
|
-
if (RESERVED_PARAMETER_NAMES_1_1 && !RESERVED_PARAMETER_NAMES_1_1.done && (
|
|
868
|
+
if (RESERVED_PARAMETER_NAMES_1_1 && !RESERVED_PARAMETER_NAMES_1_1.done && (_c = RESERVED_PARAMETER_NAMES_1.return)) _c.call(RESERVED_PARAMETER_NAMES_1);
|
|
848
869
|
}
|
|
849
|
-
finally { if (
|
|
870
|
+
finally { if (e_3) throw e_3.error; }
|
|
850
871
|
}
|
|
851
872
|
var unresovedTemplates = __spreadArray([], __read(pipeline.promptTemplates), false);
|
|
852
873
|
// <- TODO: [🧠][🥜]
|
|
853
874
|
var loopLimit = LOOP_LIMIT;
|
|
854
|
-
var
|
|
875
|
+
var _loop_3 = function () {
|
|
855
876
|
if (loopLimit-- < 0) {
|
|
856
877
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
857
|
-
throw new UnexpectedError(
|
|
878
|
+
throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Loop limit reached during detection of circular dependencies in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
858
879
|
}
|
|
859
880
|
var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
|
|
860
881
|
return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
@@ -869,7 +890,7 @@ function validatePipeline(pipeline) {
|
|
|
869
890
|
.map(function (dependentParameterName) { return "{".concat(dependentParameterName, "}"); })
|
|
870
891
|
.join(' and '));
|
|
871
892
|
})
|
|
872
|
-
.join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n "); }));
|
|
893
|
+
.join('\n')), "\n\n Resolved:\n ").concat(block(resovedParameters.map(function (name) { return "- Parameter {".concat(name, "}"); }).join('\n')), "\n\n ").concat(block(pipelineIdentification), "\n "); }));
|
|
873
894
|
}
|
|
874
895
|
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTemplates.map(function (_a) {
|
|
875
896
|
var resultingParameterName = _a.resultingParameterName;
|
|
@@ -878,7 +899,7 @@ function validatePipeline(pipeline) {
|
|
|
878
899
|
unresovedTemplates = unresovedTemplates.filter(function (template) { return !currentlyResovedTemplates.includes(template); });
|
|
879
900
|
};
|
|
880
901
|
while (unresovedTemplates.length > 0) {
|
|
881
|
-
|
|
902
|
+
_loop_3();
|
|
882
903
|
}
|
|
883
904
|
return pipeline;
|
|
884
905
|
}
|
|
@@ -937,7 +958,7 @@ var ReferenceError$1 = /** @class */ (function (_super) {
|
|
|
937
958
|
* @param template the template with parameters in {curly} braces
|
|
938
959
|
* @returns the list of parameter names
|
|
939
960
|
*/
|
|
940
|
-
function
|
|
961
|
+
function extractParameterNames(template) {
|
|
941
962
|
var e_1, _a;
|
|
942
963
|
var matches = template.matchAll(/{\w+}/g);
|
|
943
964
|
var parameterNames = new Set();
|
|
@@ -970,7 +991,7 @@ function unpreparePipeline(pipeline) {
|
|
|
970
991
|
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
971
992
|
promptTemplates = promptTemplates.map(function (promptTemplate) {
|
|
972
993
|
var dependentParameterNames = promptTemplate.dependentParameterNames;
|
|
973
|
-
var parameterNames =
|
|
994
|
+
var parameterNames = extractParameterNames(promptTemplate.preparedContent || '');
|
|
974
995
|
dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
|
|
975
996
|
var promptTemplateUnprepared = __assign(__assign({}, promptTemplate), { dependentParameterNames: dependentParameterNames });
|
|
976
997
|
delete promptTemplateUnprepared.preparedContent;
|
|
@@ -1499,7 +1520,7 @@ function forEachAsync(array, options, callbackfunction) {
|
|
|
1499
1520
|
});
|
|
1500
1521
|
}
|
|
1501
1522
|
|
|
1502
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-
|
|
1523
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.61.0-25",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",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> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-25",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-25",parameters:[{name:"knowledgePieceContent",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> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-25",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-25",parameters:[{name:"knowledgePieceContent",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> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[{id:1,promptbookVersion:"0.61.0-25",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-25",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-25",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"}];
|
|
1503
1524
|
|
|
1504
1525
|
var defaultDiacriticsRemovalMap = [
|
|
1505
1526
|
{
|
|
@@ -1938,12 +1959,12 @@ function extractVariables(script) {
|
|
|
1938
1959
|
* @returns the set of parameter names
|
|
1939
1960
|
* @throws {ParsingError} if the script is invalid
|
|
1940
1961
|
*/
|
|
1941
|
-
function
|
|
1962
|
+
function extractParameterNamesFromPromptTemplate(promptTemplate) {
|
|
1942
1963
|
var e_1, _a, e_2, _b, e_3, _c;
|
|
1943
1964
|
var title = promptTemplate.title, description = promptTemplate.description, blockType = promptTemplate.blockType, content = promptTemplate.content, preparedContent = promptTemplate.preparedContent, jokerParameterNames = promptTemplate.jokerParameterNames;
|
|
1944
1965
|
var parameterNames = new Set();
|
|
1945
1966
|
try {
|
|
1946
|
-
for (var _d = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(
|
|
1967
|
+
for (var _d = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameterNames(title)), false), __read(extractParameterNames(description || '')), false), __read(extractParameterNames(content)), false), __read(extractParameterNames(preparedContent || '')), false)), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
1947
1968
|
var parameterName = _e.value;
|
|
1948
1969
|
parameterNames.add(parameterName);
|
|
1949
1970
|
}
|
|
@@ -2504,7 +2525,7 @@ function union() {
|
|
|
2504
2525
|
/**
|
|
2505
2526
|
* The version of the Promptbook library
|
|
2506
2527
|
*/
|
|
2507
|
-
var PROMPTBOOK_VERSION = '0.61.0-
|
|
2528
|
+
var PROMPTBOOK_VERSION = '0.61.0-25';
|
|
2508
2529
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
2509
2530
|
|
|
2510
2531
|
/**
|
|
@@ -2764,7 +2785,7 @@ function createPipelineExecutor(options) {
|
|
|
2764
2785
|
_u.sent();
|
|
2765
2786
|
_u.label = 2;
|
|
2766
2787
|
case 2:
|
|
2767
|
-
usedParameterNames =
|
|
2788
|
+
usedParameterNames = extractParameterNamesFromPromptTemplate(currentTemplate);
|
|
2768
2789
|
dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
|
|
2769
2790
|
if (union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)).size !== 0) {
|
|
2770
2791
|
throw new UnexpectedError(spaceTrim$1("\n Dependent parameters are not consistent used parameters:\n\n Dependent parameters:\n ".concat(Array.from(dependentParameterNames).join(', '), "\n\n Used parameters:\n ").concat(Array.from(usedParameterNames).join(', '), "\n\n ")));
|
|
@@ -3150,14 +3171,7 @@ function createPipelineExecutor(options) {
|
|
|
3150
3171
|
) {
|
|
3151
3172
|
// TODO: [🧠] Maybe put other blockTypes into report
|
|
3152
3173
|
executionReport.promptExecutions.push({
|
|
3153
|
-
prompt: {
|
|
3154
|
-
title: currentTemplate.title /* <- Note: If title in pipeline contains emojis, pass it innto report */,
|
|
3155
|
-
content: prompt.content,
|
|
3156
|
-
modelRequirements: prompt.modelRequirements,
|
|
3157
|
-
expectations: prompt.expectations,
|
|
3158
|
-
expectFormat: prompt.expectFormat,
|
|
3159
|
-
// <- Note: Do want to pass ONLY wanted information to the report
|
|
3160
|
-
},
|
|
3174
|
+
prompt: __assign(__assign({ '!!! All information': null }, prompt), { '!!! Wanted information': null, title: currentTemplate.title /* <- Note: If title in pipeline contains emojis, pass it innto report */, content: prompt.content, modelRequirements: prompt.modelRequirements, expectations: prompt.expectations, expectFormat: prompt.expectFormat }),
|
|
3161
3175
|
result: result || undefined,
|
|
3162
3176
|
error: expectError || undefined,
|
|
3163
3177
|
});
|
|
@@ -4620,11 +4634,8 @@ var promptbookVersionCommandParser = {
|
|
|
4620
4634
|
/**
|
|
4621
4635
|
* Name of the command
|
|
4622
4636
|
*/
|
|
4623
|
-
name: '
|
|
4624
|
-
|
|
4625
|
-
Note: [📇] No need to put here "PROMPTBOOK" alias here
|
|
4626
|
-
aliasNames: ['PROMPTBOOK_VERSION'],
|
|
4627
|
-
*/
|
|
4637
|
+
name: 'PROMPTBOOK_VERSION',
|
|
4638
|
+
aliasNames: ['PTBK_VERSION', 'PTBK_V', 'PTBKV'],
|
|
4628
4639
|
/**
|
|
4629
4640
|
* BOILERPLATE command can be used in:
|
|
4630
4641
|
*/
|
|
@@ -4640,7 +4651,7 @@ var promptbookVersionCommandParser = {
|
|
|
4640
4651
|
/**
|
|
4641
4652
|
* Example usages of the PROMPTBOOK_VERSION command
|
|
4642
4653
|
*/
|
|
4643
|
-
examples: ["PROMPTBOOK VERSION ".concat(PROMPTBOOK_VERSION), "
|
|
4654
|
+
examples: ["PROMPTBOOK VERSION ".concat(PROMPTBOOK_VERSION), "PTBKV ".concat(PROMPTBOOK_VERSION)],
|
|
4644
4655
|
/**
|
|
4645
4656
|
* Parses the PROMPTBOOK_VERSION command
|
|
4646
4657
|
*/
|
|
@@ -4674,8 +4685,9 @@ var urlCommandParser = {
|
|
|
4674
4685
|
* Name of the command
|
|
4675
4686
|
*/
|
|
4676
4687
|
name: 'URL',
|
|
4688
|
+
aliasNames: ['PIPELINE_URL'],
|
|
4677
4689
|
/*
|
|
4678
|
-
Note: [🛵] No need for alias name because it is already preprocessed
|
|
4690
|
+
Note: [🛵] No need for this alias name because it is already preprocessed
|
|
4679
4691
|
aliasNames: ['HTTPS'],
|
|
4680
4692
|
*/
|
|
4681
4693
|
/**
|
|
@@ -4694,6 +4706,7 @@ var urlCommandParser = {
|
|
|
4694
4706
|
* Example usages of the URL command
|
|
4695
4707
|
*/
|
|
4696
4708
|
examples: [
|
|
4709
|
+
'PIPELINE URL https://promptbook.studio/library/write-cv.ptbk.md',
|
|
4697
4710
|
'URL https://promptbook.studio/library/write-cv.ptbk.md',
|
|
4698
4711
|
'https://promptbook.studio/library/write-cv.ptbk.md',
|
|
4699
4712
|
],
|
|
@@ -4932,10 +4945,6 @@ function parseCommand(raw, usagePlace) {
|
|
|
4932
4945
|
.split(' ')
|
|
4933
4946
|
.map(function (part) { return part.trim(); })
|
|
4934
4947
|
.filter(function (item) { return item !== ''; })
|
|
4935
|
-
// Note: [📇]:
|
|
4936
|
-
.filter(function (item) { return !/^PTBK$/i.test(item); })
|
|
4937
|
-
.filter(function (item) { return !/^PIPELINE$/i.test(item); })
|
|
4938
|
-
.filter(function (item) { return !/^PROMPTBOOK$/i.test(item); })
|
|
4939
4948
|
.map(removeMarkdownFormatting)
|
|
4940
4949
|
.map(function (item) { return item.trim(); });
|
|
4941
4950
|
if (items.length === 0 || items[0] === '') {
|
|
@@ -5650,7 +5659,7 @@ function pipelineStringToJsonSync(pipelineString) {
|
|
|
5650
5659
|
if (templateModelRequirements.modelVariant === undefined) {
|
|
5651
5660
|
templateModelRequirements.modelVariant = 'CHAT';
|
|
5652
5661
|
}
|
|
5653
|
-
templateJson.dependentParameterNames = Array.from(
|
|
5662
|
+
templateJson.dependentParameterNames = Array.from(extractParameterNamesFromPromptTemplate(templateJson));
|
|
5654
5663
|
// TODO: [🍧][❔] Remove this condition - modelRequirements should be put here via BLOCK command not removed when PROMPT_TEMPLATE
|
|
5655
5664
|
if (templateJson.blockType !== 'PROMPT_TEMPLATE') {
|
|
5656
5665
|
delete templateJson.modelRequirements;
|
|
@@ -6358,7 +6367,7 @@ function executionReportJsonToString(executionReportJson, options) {
|
|
|
6358
6367
|
spaceTrim$1(function (block) { return "\n\n ### Prompt\n\n ```\n ".concat(block(escapeMarkdownBlock(promptExecution.prompt.content)), "\n ```\n\n "); });
|
|
6359
6368
|
}
|
|
6360
6369
|
if (promptExecution.result && promptExecution.result.content) {
|
|
6361
|
-
executionReportString += '\n\n\n\n' + '### Result';
|
|
6370
|
+
executionReportString += '\n\n\n\n' + '### Result' + '\n\n';
|
|
6362
6371
|
if (promptExecution.result === undefined) {
|
|
6363
6372
|
executionReportString += '*No result*';
|
|
6364
6373
|
}
|