@promptbook/cli 0.78.4 → 0.80.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 +4 -0
- package/esm/index.es.js +1332 -751
- package/esm/index.es.js.map +1 -1
- package/esm/typings/books/index.d.ts +6 -6
- package/esm/typings/src/_packages/core.index.d.ts +4 -2
- package/esm/typings/src/_packages/types.index.d.ts +10 -0
- package/esm/typings/src/_packages/utils.index.d.ts +4 -0
- package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +32 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +5 -2
- package/esm/typings/src/config.d.ts +0 -25
- package/esm/typings/src/constants.d.ts +35 -0
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -0
- package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -0
- package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +6 -1
- package/esm/typings/src/formfactors/index.d.ts +12 -2
- package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +6 -1
- package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +20 -0
- package/esm/typings/src/high-level-abstractions/implicit-formfactor/ImplicitFormfactorHla.d.ts +10 -0
- package/esm/typings/src/high-level-abstractions/index.d.ts +44 -0
- package/esm/typings/src/high-level-abstractions/quick-chatbot/QuickChatbotHla.d.ts +10 -0
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
- package/esm/typings/src/prepare/prepareTasks.d.ts +1 -0
- package/esm/typings/src/types/typeAliases.d.ts +1 -1
- package/esm/typings/src/utils/normalization/orderJson.d.ts +21 -0
- package/esm/typings/src/utils/normalization/orderJson.test.d.ts +4 -0
- package/esm/typings/src/utils/organization/keepTypeImported.d.ts +9 -0
- package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +1 -1
- package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +20 -2
- package/esm/typings/src/utils/serialization/deepClone.test.d.ts +1 -0
- package/esm/typings/src/utils/serialization/exportJson.d.ts +29 -0
- package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +2 -1
- package/package.json +2 -1
- package/umd/index.umd.js +1332 -751
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/utils/serialization/$asDeeplyFrozenSerializableJson.d.ts +0 -17
package/umd/index.umd.js
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
*
|
|
50
50
|
* @see https://github.com/webgptorg/promptbook
|
|
51
51
|
*/
|
|
52
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
52
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.79.0';
|
|
53
53
|
/**
|
|
54
54
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
55
55
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -320,41 +320,6 @@
|
|
|
320
320
|
* @public exported from `@promptbook/core`
|
|
321
321
|
*/
|
|
322
322
|
var DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME = "index";
|
|
323
|
-
/**
|
|
324
|
-
* Nonce which is used for replacing things in strings
|
|
325
|
-
*
|
|
326
|
-
* @private within the repository
|
|
327
|
-
*/
|
|
328
|
-
var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
|
|
329
|
-
/**
|
|
330
|
-
* The names of the parameters that are reserved for special purposes
|
|
331
|
-
*
|
|
332
|
-
* @public exported from `@promptbook/core`
|
|
333
|
-
*/
|
|
334
|
-
var RESERVED_PARAMETER_NAMES =
|
|
335
|
-
/* !!!!!! $asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', _____ as const); */ [
|
|
336
|
-
'content',
|
|
337
|
-
'context',
|
|
338
|
-
'knowledge',
|
|
339
|
-
'examples',
|
|
340
|
-
'modelName',
|
|
341
|
-
'currentDate',
|
|
342
|
-
// <- TODO: list here all command names
|
|
343
|
-
// <- TODO: Add more like 'date', 'modelName',...
|
|
344
|
-
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
345
|
-
];
|
|
346
|
-
/**
|
|
347
|
-
* @@@
|
|
348
|
-
*
|
|
349
|
-
* @private within the repository
|
|
350
|
-
*/
|
|
351
|
-
var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
352
|
-
/**
|
|
353
|
-
* @@@
|
|
354
|
-
*
|
|
355
|
-
* @private within the repository
|
|
356
|
-
*/
|
|
357
|
-
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
358
323
|
/**
|
|
359
324
|
* The thresholds for the relative time in the `moment` NPM package.
|
|
360
325
|
*
|
|
@@ -410,7 +375,6 @@
|
|
|
410
375
|
// Note: In normal situations, we check the pipeline logic:
|
|
411
376
|
true);
|
|
412
377
|
/**
|
|
413
|
-
* TODO: Extract `constants.ts` from `config.ts`
|
|
414
378
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
415
379
|
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value
|
|
416
380
|
*/
|
|
@@ -536,6 +500,56 @@
|
|
|
536
500
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
537
501
|
*/
|
|
538
502
|
|
|
503
|
+
/**
|
|
504
|
+
* Orders JSON object by keys
|
|
505
|
+
*
|
|
506
|
+
* @returns The same type of object as the input re-ordered
|
|
507
|
+
* @public exported from `@promptbook/utils`
|
|
508
|
+
*/
|
|
509
|
+
function orderJson(options) {
|
|
510
|
+
var value = options.value, order = options.order;
|
|
511
|
+
var orderedValue = __assign(__assign({}, (order === undefined ? {} : Object.fromEntries(order.map(function (key) { return [key, undefined]; })))), value);
|
|
512
|
+
return orderedValue;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* Freezes the given object and all its nested objects recursively
|
|
517
|
+
*
|
|
518
|
+
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
|
|
519
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
520
|
+
*
|
|
521
|
+
* @returns The same object as the input, but deeply frozen
|
|
522
|
+
* @public exported from `@promptbook/utils`
|
|
523
|
+
*/
|
|
524
|
+
function $deepFreeze(objectValue) {
|
|
525
|
+
var e_1, _a;
|
|
526
|
+
if (Array.isArray(objectValue)) {
|
|
527
|
+
return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
|
|
528
|
+
}
|
|
529
|
+
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
530
|
+
try {
|
|
531
|
+
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
532
|
+
var propertyName = propertyNames_1_1.value;
|
|
533
|
+
var value = objectValue[propertyName];
|
|
534
|
+
if (value && typeof value === 'object') {
|
|
535
|
+
$deepFreeze(value);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
540
|
+
finally {
|
|
541
|
+
try {
|
|
542
|
+
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
543
|
+
}
|
|
544
|
+
finally { if (e_1) throw e_1.error; }
|
|
545
|
+
}
|
|
546
|
+
Object.freeze(objectValue);
|
|
547
|
+
return objectValue;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
551
|
+
*/
|
|
552
|
+
|
|
539
553
|
/**
|
|
540
554
|
* Make error report URL for the given error
|
|
541
555
|
*
|
|
@@ -590,8 +604,9 @@
|
|
|
590
604
|
* @throws UnexpectedError if the value is not serializable as JSON
|
|
591
605
|
* @public exported from `@promptbook/utils`
|
|
592
606
|
*/
|
|
593
|
-
function checkSerializableAsJson(
|
|
607
|
+
function checkSerializableAsJson(options) {
|
|
594
608
|
var e_1, _a;
|
|
609
|
+
var value = options.value, name = options.name, message = options.message;
|
|
595
610
|
if (value === undefined) {
|
|
596
611
|
throw new UnexpectedError("".concat(name, " is undefined"));
|
|
597
612
|
}
|
|
@@ -615,12 +630,12 @@
|
|
|
615
630
|
}
|
|
616
631
|
else if (typeof value === 'object' && Array.isArray(value)) {
|
|
617
632
|
for (var i = 0; i < value.length; i++) {
|
|
618
|
-
checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
|
|
633
|
+
checkSerializableAsJson({ name: "".concat(name, "[").concat(i, "]"), value: value[i], message: message });
|
|
619
634
|
}
|
|
620
635
|
}
|
|
621
636
|
else if (typeof value === 'object') {
|
|
622
637
|
if (value instanceof Date) {
|
|
623
|
-
throw new UnexpectedError(spaceTrim__default["default"]("\n
|
|
638
|
+
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is Date\n\n Use `string_date_iso8601` instead\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
|
|
624
639
|
}
|
|
625
640
|
else if (value instanceof Map) {
|
|
626
641
|
throw new UnexpectedError("".concat(name, " is Map"));
|
|
@@ -632,7 +647,7 @@
|
|
|
632
647
|
throw new UnexpectedError("".concat(name, " is RegExp"));
|
|
633
648
|
}
|
|
634
649
|
else if (value instanceof Error) {
|
|
635
|
-
throw new UnexpectedError(spaceTrim__default["default"]("\n
|
|
650
|
+
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is unserialized Error\n\n Use function `serializeError`\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n\n "); }));
|
|
636
651
|
}
|
|
637
652
|
else {
|
|
638
653
|
try {
|
|
@@ -642,7 +657,7 @@
|
|
|
642
657
|
// Note: undefined in object is serializable - it is just omited
|
|
643
658
|
continue;
|
|
644
659
|
}
|
|
645
|
-
checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
|
|
660
|
+
checkSerializableAsJson({ name: "".concat(name, ".").concat(subName), value: subValue, message: message });
|
|
646
661
|
}
|
|
647
662
|
}
|
|
648
663
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -659,7 +674,7 @@
|
|
|
659
674
|
if (!(error instanceof Error)) {
|
|
660
675
|
throw error;
|
|
661
676
|
}
|
|
662
|
-
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
|
|
677
|
+
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.toString()), "\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
|
|
663
678
|
}
|
|
664
679
|
/*
|
|
665
680
|
TODO: [0] Is there some more elegant way to check circular references?
|
|
@@ -684,15 +699,134 @@
|
|
|
684
699
|
}
|
|
685
700
|
}
|
|
686
701
|
else {
|
|
687
|
-
throw new UnexpectedError("".concat(name, " is unknown"));
|
|
702
|
+
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is unknown type\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
|
|
688
703
|
}
|
|
689
704
|
}
|
|
690
705
|
/**
|
|
691
|
-
* TODO:
|
|
706
|
+
* TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
|
|
692
707
|
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
693
708
|
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
694
709
|
*/
|
|
695
710
|
|
|
711
|
+
/**
|
|
712
|
+
* @@@
|
|
713
|
+
*
|
|
714
|
+
* @public exported from `@promptbook/utils`
|
|
715
|
+
*/
|
|
716
|
+
function deepClone(objectValue) {
|
|
717
|
+
return JSON.parse(JSON.stringify(objectValue));
|
|
718
|
+
/*
|
|
719
|
+
!!!!!!!!
|
|
720
|
+
TODO: [🧠] Is there a better implementation?
|
|
721
|
+
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
722
|
+
> for (const propertyName of propertyNames) {
|
|
723
|
+
> const value = (objectValue as really_any)[propertyName];
|
|
724
|
+
> if (value && typeof value === 'object') {
|
|
725
|
+
> deepClone(value);
|
|
726
|
+
> }
|
|
727
|
+
> }
|
|
728
|
+
> return Object.assign({}, objectValue);
|
|
729
|
+
*/
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
733
|
+
*/
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Utility to export a JSON object from a function
|
|
737
|
+
*
|
|
738
|
+
* 1) Checks if the value is serializable as JSON
|
|
739
|
+
* 2) Makes a deep clone of the object
|
|
740
|
+
* 2) Orders the object properties
|
|
741
|
+
* 2) Deeply freezes the cloned object
|
|
742
|
+
*
|
|
743
|
+
* Note: This function does not mutates the given object
|
|
744
|
+
*
|
|
745
|
+
* @returns The same type of object as the input but read-only and re-ordered
|
|
746
|
+
* @public exported from `@promptbook/utils`
|
|
747
|
+
*/
|
|
748
|
+
function exportJson(options) {
|
|
749
|
+
var name = options.name, value = options.value, order = options.order, message = options.message;
|
|
750
|
+
checkSerializableAsJson({ name: name, value: value, message: message });
|
|
751
|
+
var orderedValue =
|
|
752
|
+
// TODO: Fix error "Type instantiation is excessively deep and possibly infinite."
|
|
753
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
754
|
+
// @ts-ignore
|
|
755
|
+
order === undefined
|
|
756
|
+
? deepClone(value)
|
|
757
|
+
: orderJson({
|
|
758
|
+
value: value,
|
|
759
|
+
// <- Note: checkSerializableAsJson asserts that the value is serializable as JSON
|
|
760
|
+
order: order,
|
|
761
|
+
});
|
|
762
|
+
$deepFreeze(orderedValue);
|
|
763
|
+
return orderedValue;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
767
|
+
*/
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Order of keys in the pipeline JSON
|
|
771
|
+
*
|
|
772
|
+
* @public exported from `@promptbook/core`
|
|
773
|
+
*/
|
|
774
|
+
var ORDER_OF_PIPELINE_JSON = [
|
|
775
|
+
'title',
|
|
776
|
+
'pipelineUrl',
|
|
777
|
+
'bookVersion',
|
|
778
|
+
'description',
|
|
779
|
+
'formfactorName',
|
|
780
|
+
'parameters',
|
|
781
|
+
'tasks',
|
|
782
|
+
'personas',
|
|
783
|
+
'preparations',
|
|
784
|
+
'knowledgeSources',
|
|
785
|
+
'knowledgePieces',
|
|
786
|
+
];
|
|
787
|
+
/**
|
|
788
|
+
* Nonce which is used for replacing things in strings
|
|
789
|
+
*
|
|
790
|
+
* @private within the repository
|
|
791
|
+
*/
|
|
792
|
+
var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
|
|
793
|
+
/**
|
|
794
|
+
* @@@
|
|
795
|
+
*
|
|
796
|
+
* @private within the repository
|
|
797
|
+
*/
|
|
798
|
+
var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
|
|
799
|
+
/**
|
|
800
|
+
* @@@
|
|
801
|
+
*
|
|
802
|
+
* @private within the repository
|
|
803
|
+
*/
|
|
804
|
+
var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
|
|
805
|
+
/**
|
|
806
|
+
* The names of the parameters that are reserved for special purposes
|
|
807
|
+
*
|
|
808
|
+
* @public exported from `@promptbook/core`
|
|
809
|
+
*/
|
|
810
|
+
var RESERVED_PARAMETER_NAMES = exportJson({
|
|
811
|
+
name: 'RESERVED_PARAMETER_NAMES',
|
|
812
|
+
message: "The names of the parameters that are reserved for special purposes",
|
|
813
|
+
value: [
|
|
814
|
+
'content',
|
|
815
|
+
'context',
|
|
816
|
+
'knowledge',
|
|
817
|
+
'examples',
|
|
818
|
+
'modelName',
|
|
819
|
+
'currentDate',
|
|
820
|
+
// <- TODO: list here all command names
|
|
821
|
+
// <- TODO: Add more like 'date', 'modelName',...
|
|
822
|
+
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
823
|
+
],
|
|
824
|
+
});
|
|
825
|
+
/**
|
|
826
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
827
|
+
*/
|
|
828
|
+
|
|
829
|
+
// <- TODO: !!!!!!! Auto convert to type `import { ... } from 'type-fest';`
|
|
696
830
|
/**
|
|
697
831
|
* Tests if the value is [🚉] serializable as JSON
|
|
698
832
|
*
|
|
@@ -714,7 +848,7 @@
|
|
|
714
848
|
*/
|
|
715
849
|
function isSerializableAsJson(value) {
|
|
716
850
|
try {
|
|
717
|
-
checkSerializableAsJson(
|
|
851
|
+
checkSerializableAsJson({ value: value });
|
|
718
852
|
return true;
|
|
719
853
|
}
|
|
720
854
|
catch (error) {
|
|
@@ -1512,63 +1646,6 @@
|
|
|
1512
1646
|
* @@@ write how to combine multiple interceptors
|
|
1513
1647
|
*/
|
|
1514
1648
|
|
|
1515
|
-
/**
|
|
1516
|
-
* @@@
|
|
1517
|
-
*
|
|
1518
|
-
* @public exported from `@promptbook/utils`
|
|
1519
|
-
*/
|
|
1520
|
-
function deepClone(objectValue) {
|
|
1521
|
-
return JSON.parse(JSON.stringify(objectValue));
|
|
1522
|
-
/*
|
|
1523
|
-
TODO: [🧠] Is there a better implementation?
|
|
1524
|
-
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1525
|
-
> for (const propertyName of propertyNames) {
|
|
1526
|
-
> const value = (objectValue as really_any)[propertyName];
|
|
1527
|
-
> if (value && typeof value === 'object') {
|
|
1528
|
-
> deepClone(value);
|
|
1529
|
-
> }
|
|
1530
|
-
> }
|
|
1531
|
-
> return Object.assign({}, objectValue);
|
|
1532
|
-
*/
|
|
1533
|
-
}
|
|
1534
|
-
/**
|
|
1535
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1536
|
-
*/
|
|
1537
|
-
|
|
1538
|
-
/**
|
|
1539
|
-
* @@@
|
|
1540
|
-
*
|
|
1541
|
-
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
|
|
1542
|
-
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
1543
|
-
*
|
|
1544
|
-
* @returns The same object as the input, but deeply frozen
|
|
1545
|
-
* @public exported from `@promptbook/utils`
|
|
1546
|
-
*/
|
|
1547
|
-
function $deepFreeze(objectValue) {
|
|
1548
|
-
var e_1, _a;
|
|
1549
|
-
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1550
|
-
try {
|
|
1551
|
-
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
1552
|
-
var propertyName = propertyNames_1_1.value;
|
|
1553
|
-
var value = objectValue[propertyName];
|
|
1554
|
-
if (value && typeof value === 'object') {
|
|
1555
|
-
$deepFreeze(value);
|
|
1556
|
-
}
|
|
1557
|
-
}
|
|
1558
|
-
}
|
|
1559
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1560
|
-
finally {
|
|
1561
|
-
try {
|
|
1562
|
-
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
1563
|
-
}
|
|
1564
|
-
finally { if (e_1) throw e_1.error; }
|
|
1565
|
-
}
|
|
1566
|
-
return Object.freeze(objectValue);
|
|
1567
|
-
}
|
|
1568
|
-
/**
|
|
1569
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1570
|
-
*/
|
|
1571
|
-
|
|
1572
1649
|
/**
|
|
1573
1650
|
* Represents the usage with no resources consumed
|
|
1574
1651
|
*
|
|
@@ -2633,6 +2710,7 @@
|
|
|
2633
2710
|
/**
|
|
2634
2711
|
* Converts promptbook in JSON format to string format
|
|
2635
2712
|
*
|
|
2713
|
+
* @deprecated TODO: [🥍][🧠] Backup original files in `PipelineJson` same as in Promptbook.studio
|
|
2636
2714
|
* @param pipelineJson Promptbook in JSON format (.book.json)
|
|
2637
2715
|
* @returns Promptbook in string format (.book.md)
|
|
2638
2716
|
* @public exported from `@promptbook/core`
|
|
@@ -2928,7 +3006,7 @@
|
|
|
2928
3006
|
});
|
|
2929
3007
|
}
|
|
2930
3008
|
|
|
2931
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",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"]}],
|
|
3009
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",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"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",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"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",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"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",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}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\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"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-persona.book.md"}];
|
|
2932
3010
|
|
|
2933
3011
|
/**
|
|
2934
3012
|
* This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
|
|
@@ -3173,6 +3251,21 @@
|
|
|
3173
3251
|
}
|
|
3174
3252
|
};
|
|
3175
3253
|
try {
|
|
3254
|
+
/*
|
|
3255
|
+
TODO: [🧠][🅾] Should be empty pipeline valid or not
|
|
3256
|
+
// Note: Check that pipeline has some tasks
|
|
3257
|
+
if (pipeline.tasks.length === 0) {
|
|
3258
|
+
throw new PipelineLogicError(
|
|
3259
|
+
spaceTrim(
|
|
3260
|
+
(block) => `
|
|
3261
|
+
Pipeline must have at least one task
|
|
3262
|
+
|
|
3263
|
+
${block(pipelineIdentification)}
|
|
3264
|
+
`,
|
|
3265
|
+
),
|
|
3266
|
+
);
|
|
3267
|
+
}
|
|
3268
|
+
*/
|
|
3176
3269
|
// Note: Check each parameter individually
|
|
3177
3270
|
for (var _d = __values(pipeline.parameters), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
3178
3271
|
var parameter = _e.value;
|
|
@@ -3333,6 +3426,9 @@
|
|
|
3333
3426
|
while (unresovedTasks.length > 0) {
|
|
3334
3427
|
_loop_3();
|
|
3335
3428
|
}
|
|
3429
|
+
// Note: Check that formfactor is corresponding to the pipeline interface
|
|
3430
|
+
// TODO: !!!!!! Implement this
|
|
3431
|
+
// pipeline.formfactorName
|
|
3336
3432
|
}
|
|
3337
3433
|
/**
|
|
3338
3434
|
* TODO: !! [🧞♀️] Do not allow joker + foreach
|
|
@@ -3416,26 +3512,6 @@
|
|
|
3416
3512
|
return parameterNames;
|
|
3417
3513
|
}
|
|
3418
3514
|
|
|
3419
|
-
/**
|
|
3420
|
-
* @@@
|
|
3421
|
-
* @@@
|
|
3422
|
-
*
|
|
3423
|
-
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
3424
|
-
*
|
|
3425
|
-
* @param name - Name of the object for debugging purposes
|
|
3426
|
-
* @param objectValue - Object to be deeply frozen
|
|
3427
|
-
* @returns The same object as the input, but deeply frozen
|
|
3428
|
-
* @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
|
|
3429
|
-
*/
|
|
3430
|
-
function $asDeeplyFrozenSerializableJson(name, objectValue) {
|
|
3431
|
-
checkSerializableAsJson(name, objectValue);
|
|
3432
|
-
return $deepFreeze(objectValue);
|
|
3433
|
-
}
|
|
3434
|
-
/**
|
|
3435
|
-
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
3436
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
3437
|
-
*/
|
|
3438
|
-
|
|
3439
3515
|
/**
|
|
3440
3516
|
* Unprepare just strips the preparation data of the pipeline
|
|
3441
3517
|
*
|
|
@@ -3453,7 +3529,12 @@
|
|
|
3453
3529
|
delete taskUnprepared.preparedContent;
|
|
3454
3530
|
return taskUnprepared;
|
|
3455
3531
|
});
|
|
3456
|
-
return
|
|
3532
|
+
return exportJson({
|
|
3533
|
+
name: 'pipelineJson',
|
|
3534
|
+
message: "Result of `unpreparePipeline`",
|
|
3535
|
+
order: ORDER_OF_PIPELINE_JSON,
|
|
3536
|
+
value: __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }),
|
|
3537
|
+
});
|
|
3457
3538
|
}
|
|
3458
3539
|
/**
|
|
3459
3540
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
@@ -5521,16 +5602,21 @@
|
|
|
5521
5602
|
// Note: Wait a short time to prevent race conditions
|
|
5522
5603
|
_g.sent();
|
|
5523
5604
|
_g.label = 6;
|
|
5524
|
-
case 6: return [2 /*return*/,
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5605
|
+
case 6: return [2 /*return*/, exportJson({
|
|
5606
|
+
name: "executionReport",
|
|
5607
|
+
message: "Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"),
|
|
5608
|
+
order: [],
|
|
5609
|
+
value: {
|
|
5610
|
+
isSuccessful: false,
|
|
5611
|
+
errors: __spreadArray([
|
|
5612
|
+
new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
|
|
5613
|
+
], __read(errors), false).map(serializeError),
|
|
5614
|
+
warnings: [],
|
|
5615
|
+
executionReport: executionReport,
|
|
5616
|
+
outputParameters: {},
|
|
5617
|
+
usage: ZERO_USAGE,
|
|
5618
|
+
preparedPipeline: preparedPipeline,
|
|
5619
|
+
},
|
|
5534
5620
|
})];
|
|
5535
5621
|
case 7:
|
|
5536
5622
|
_b = _a.next();
|
|
@@ -5569,16 +5655,21 @@
|
|
|
5569
5655
|
// Note: Wait a short time to prevent race conditions
|
|
5570
5656
|
_h.sent();
|
|
5571
5657
|
_h.label = 3;
|
|
5572
|
-
case 3: return [2 /*return*/, { value:
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5658
|
+
case 3: return [2 /*return*/, { value: exportJson({
|
|
5659
|
+
name: 'pipelineExecutorResult',
|
|
5660
|
+
message: spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }),
|
|
5661
|
+
order: [],
|
|
5662
|
+
value: {
|
|
5663
|
+
isSuccessful: false,
|
|
5664
|
+
errors: __spreadArray([
|
|
5665
|
+
new PipelineExecutionError(spaceTrim.spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
|
|
5666
|
+
], __read(errors), false).map(serializeError),
|
|
5667
|
+
warnings: warnings.map(serializeError),
|
|
5668
|
+
executionReport: executionReport,
|
|
5669
|
+
outputParameters: {},
|
|
5670
|
+
usage: ZERO_USAGE,
|
|
5671
|
+
preparedPipeline: preparedPipeline,
|
|
5672
|
+
},
|
|
5582
5673
|
}) }];
|
|
5583
5674
|
case 4: return [2 /*return*/];
|
|
5584
5675
|
}
|
|
@@ -5732,14 +5823,19 @@
|
|
|
5732
5823
|
// Note: Wait a short time to prevent race conditions
|
|
5733
5824
|
_g.sent();
|
|
5734
5825
|
_g.label = 27;
|
|
5735
|
-
case 27: return [2 /*return*/,
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5826
|
+
case 27: return [2 /*return*/, exportJson({
|
|
5827
|
+
name: 'pipelineExecutorResult',
|
|
5828
|
+
message: "Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult",
|
|
5829
|
+
order: [],
|
|
5830
|
+
value: {
|
|
5831
|
+
isSuccessful: false,
|
|
5832
|
+
errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
|
|
5833
|
+
warnings: warnings.map(serializeError),
|
|
5834
|
+
usage: usage_1,
|
|
5835
|
+
executionReport: executionReport,
|
|
5836
|
+
outputParameters: outputParameters_1,
|
|
5837
|
+
preparedPipeline: preparedPipeline,
|
|
5838
|
+
},
|
|
5743
5839
|
})];
|
|
5744
5840
|
case 28:
|
|
5745
5841
|
usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
|
|
@@ -5760,14 +5856,19 @@
|
|
|
5760
5856
|
// Note: Wait a short time to prevent race conditions
|
|
5761
5857
|
_g.sent();
|
|
5762
5858
|
_g.label = 30;
|
|
5763
|
-
case 30: return [2 /*return*/,
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5859
|
+
case 30: return [2 /*return*/, exportJson({
|
|
5860
|
+
name: 'pipelineExecutorResult',
|
|
5861
|
+
message: "Successful PipelineExecutorResult",
|
|
5862
|
+
order: [],
|
|
5863
|
+
value: {
|
|
5864
|
+
isSuccessful: true,
|
|
5865
|
+
errors: errors.map(serializeError),
|
|
5866
|
+
warnings: warnings.map(serializeError),
|
|
5867
|
+
usage: usage,
|
|
5868
|
+
executionReport: executionReport,
|
|
5869
|
+
outputParameters: outputParameters,
|
|
5870
|
+
preparedPipeline: preparedPipeline,
|
|
5871
|
+
},
|
|
5771
5872
|
})];
|
|
5772
5873
|
}
|
|
5773
5874
|
});
|
|
@@ -6369,36 +6470,6 @@
|
|
|
6369
6470
|
* [ ] One piece can have multiple sources
|
|
6370
6471
|
*/
|
|
6371
6472
|
|
|
6372
|
-
/**
|
|
6373
|
-
* @@@
|
|
6374
|
-
*
|
|
6375
|
-
* Note: It is usefull @@@
|
|
6376
|
-
*
|
|
6377
|
-
* @param pipeline
|
|
6378
|
-
* @public exported from `@promptbook/utils`
|
|
6379
|
-
*/
|
|
6380
|
-
function clonePipeline(pipeline) {
|
|
6381
|
-
// Note: Not using spread operator (...) because @@@
|
|
6382
|
-
var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, formfactorName = pipeline.formfactorName, parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
|
|
6383
|
-
return {
|
|
6384
|
-
pipelineUrl: pipelineUrl,
|
|
6385
|
-
sourceFile: sourceFile,
|
|
6386
|
-
title: title,
|
|
6387
|
-
bookVersion: bookVersion,
|
|
6388
|
-
description: description,
|
|
6389
|
-
formfactorName: formfactorName,
|
|
6390
|
-
parameters: parameters,
|
|
6391
|
-
tasks: tasks,
|
|
6392
|
-
knowledgeSources: knowledgeSources,
|
|
6393
|
-
knowledgePieces: knowledgePieces,
|
|
6394
|
-
personas: personas,
|
|
6395
|
-
preparations: preparations,
|
|
6396
|
-
};
|
|
6397
|
-
}
|
|
6398
|
-
/**
|
|
6399
|
-
* TODO: [🍙] Make some standard order of json properties
|
|
6400
|
-
*/
|
|
6401
|
-
|
|
6402
6473
|
/**
|
|
6403
6474
|
* @@@
|
|
6404
6475
|
*
|
|
@@ -6439,6 +6510,7 @@
|
|
|
6439
6510
|
});
|
|
6440
6511
|
}
|
|
6441
6512
|
/**
|
|
6513
|
+
* TODO: [😂] Adding knowledge should be convert to async high-level abstractions, simmilar thing with expectations to sync high-level abstractions
|
|
6442
6514
|
* TODO: [🧠] Add context to each task (if missing)
|
|
6443
6515
|
* TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
|
|
6444
6516
|
* TODO: [♨][main] !!! Prepare index the examples and maybe tasks
|
|
@@ -6527,11 +6599,19 @@
|
|
|
6527
6599
|
case 3:
|
|
6528
6600
|
tasksPrepared = (_c.sent()).tasksPrepared;
|
|
6529
6601
|
// ----- /Tasks preparation -----
|
|
6602
|
+
// TODO: [😂] Use here all `AsyncHighLevelAbstraction`
|
|
6530
6603
|
// Note: Count total usage
|
|
6531
6604
|
currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
|
|
6532
|
-
return [2 /*return*/,
|
|
6533
|
-
|
|
6534
|
-
|
|
6605
|
+
return [2 /*return*/, exportJson({
|
|
6606
|
+
name: 'pipelineJson',
|
|
6607
|
+
message: "Result of `preparePipeline`",
|
|
6608
|
+
order: ORDER_OF_PIPELINE_JSON,
|
|
6609
|
+
value: __assign(__assign({}, pipeline), {
|
|
6610
|
+
// <- TODO: Probbably deeply clone the pipeline because `$exportJson` freezes the subobjects
|
|
6611
|
+
knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, tasks: __spreadArray([], __read(tasksPrepared), false),
|
|
6612
|
+
// <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
|
|
6613
|
+
personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }),
|
|
6614
|
+
})];
|
|
6535
6615
|
}
|
|
6536
6616
|
});
|
|
6537
6617
|
});
|
|
@@ -6795,7 +6875,8 @@
|
|
|
6795
6875
|
expectResultingParameterName();
|
|
6796
6876
|
var parameter = $pipelineJson.parameters.find(function (param) { return param.name === $taskJson.resultingParameterName; });
|
|
6797
6877
|
if (parameter === undefined) {
|
|
6798
|
-
|
|
6878
|
+
// TODO: !!!!!! Change to logic error for higher level abstractions to work
|
|
6879
|
+
throw new ParseError("Parameter `{".concat($taskJson.resultingParameterName, "}` is not defined so can not define example value of it"));
|
|
6799
6880
|
}
|
|
6800
6881
|
parameter.exampleValues = parameter.exampleValues || [];
|
|
6801
6882
|
parameter.exampleValues.push($taskJson.content);
|
|
@@ -7688,7 +7769,13 @@
|
|
|
7688
7769
|
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
|
|
7689
7770
|
pipelineInterface: {
|
|
7690
7771
|
inputParameters: [
|
|
7691
|
-
|
|
7772
|
+
/* @@@ */
|
|
7773
|
+
{
|
|
7774
|
+
name: 'nonce',
|
|
7775
|
+
description: 'Just to prevent GENERATOR to be set as implicit formfactor',
|
|
7776
|
+
isInput: true,
|
|
7777
|
+
isOutput: false,
|
|
7778
|
+
},
|
|
7692
7779
|
],
|
|
7693
7780
|
outputParameters: [
|
|
7694
7781
|
/* @@@ */
|
|
@@ -7734,7 +7821,13 @@
|
|
|
7734
7821
|
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177",
|
|
7735
7822
|
pipelineInterface: {
|
|
7736
7823
|
inputParameters: [
|
|
7737
|
-
|
|
7824
|
+
/* @@@ */
|
|
7825
|
+
{
|
|
7826
|
+
name: 'nonce',
|
|
7827
|
+
description: 'Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor',
|
|
7828
|
+
isInput: true,
|
|
7829
|
+
isOutput: false,
|
|
7830
|
+
},
|
|
7738
7831
|
],
|
|
7739
7832
|
outputParameters: [
|
|
7740
7833
|
/* @@@ */
|
|
@@ -7883,6 +7976,9 @@
|
|
|
7883
7976
|
* Note: `$` is used to indicate that this function mutates given `pipelineJson`
|
|
7884
7977
|
*/
|
|
7885
7978
|
$applyToPipelineJson: function (command, $pipelineJson) {
|
|
7979
|
+
if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
|
|
7980
|
+
throw new ParseError(spaceTrim__default["default"]("\n Redefinition of `FORMFACTOR` in the pipeline head\n\n You have used:\n 1) FORMFACTOR `".concat($pipelineJson.formfactorName, "`\n 2) FORMFACTOR `").concat(command.formfactorName, "`\n ")));
|
|
7981
|
+
}
|
|
7886
7982
|
$pipelineJson.formfactorName = command.formfactorName;
|
|
7887
7983
|
},
|
|
7888
7984
|
/**
|
|
@@ -8070,7 +8166,7 @@
|
|
|
8070
8166
|
// <- TODO: [🚎][💩] Some better way how to get warnings from pipeline parsing / logic
|
|
8071
8167
|
}
|
|
8072
8168
|
else {
|
|
8073
|
-
throw new ParseError(spaceTrim__default["default"]("\n Redefinition of MODEL
|
|
8169
|
+
throw new ParseError(spaceTrim__default["default"]("\n Redefinition of `MODEL ".concat(command.key, "` in the pipeline head\n\n You have used:\n 1) `MODEL ").concat(command.key, " ").concat($pipelineJson.defaultModelRequirements[command.key], "`\n 2) `MODEL ").concat(command.key, " ").concat(command.value, "`\n ")));
|
|
8074
8170
|
}
|
|
8075
8171
|
}
|
|
8076
8172
|
$pipelineJson.defaultModelRequirements[command.key] = command.value;
|
|
@@ -8889,9 +8985,298 @@
|
|
|
8889
8985
|
}
|
|
8890
8986
|
|
|
8891
8987
|
/**
|
|
8892
|
-
*
|
|
8988
|
+
* @@@
|
|
8893
8989
|
*
|
|
8894
|
-
* @
|
|
8990
|
+
* @deprecated https://github.com/webgptorg/promptbook/pull/186
|
|
8991
|
+
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
8992
|
+
*
|
|
8993
|
+
* @public exported from `@promptbook/core`
|
|
8994
|
+
*/
|
|
8995
|
+
function getPipelineInterface(pipeline) {
|
|
8996
|
+
var e_1, _a, e_2, _b;
|
|
8997
|
+
var pipelineInterface = {
|
|
8998
|
+
inputParameters: [],
|
|
8999
|
+
outputParameters: [],
|
|
9000
|
+
};
|
|
9001
|
+
try {
|
|
9002
|
+
for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
9003
|
+
var parameter = _d.value;
|
|
9004
|
+
var isInput = parameter.isInput, isOutput = parameter.isOutput;
|
|
9005
|
+
if (isInput) {
|
|
9006
|
+
pipelineInterface.inputParameters.push(deepClone(parameter));
|
|
9007
|
+
}
|
|
9008
|
+
if (isOutput) {
|
|
9009
|
+
pipelineInterface.outputParameters.push(deepClone(parameter));
|
|
9010
|
+
}
|
|
9011
|
+
}
|
|
9012
|
+
}
|
|
9013
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
9014
|
+
finally {
|
|
9015
|
+
try {
|
|
9016
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
9017
|
+
}
|
|
9018
|
+
finally { if (e_1) throw e_1.error; }
|
|
9019
|
+
}
|
|
9020
|
+
try {
|
|
9021
|
+
for (var _e = __values(['inputParameters', 'outputParameters']), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
9022
|
+
var key = _f.value;
|
|
9023
|
+
pipelineInterface[key].sort(function (_a, _b) {
|
|
9024
|
+
var name1 = _a.name;
|
|
9025
|
+
var name2 = _b.name;
|
|
9026
|
+
return name1.localeCompare(name2);
|
|
9027
|
+
});
|
|
9028
|
+
}
|
|
9029
|
+
}
|
|
9030
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
9031
|
+
finally {
|
|
9032
|
+
try {
|
|
9033
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
9034
|
+
}
|
|
9035
|
+
finally { if (e_2) throw e_2.error; }
|
|
9036
|
+
}
|
|
9037
|
+
return exportJson({
|
|
9038
|
+
name: "pipelineInterface",
|
|
9039
|
+
message: "Result of `getPipelineInterface`",
|
|
9040
|
+
order: ['inputParameters', 'outputParameters'],
|
|
9041
|
+
value: pipelineInterface,
|
|
9042
|
+
});
|
|
9043
|
+
}
|
|
9044
|
+
|
|
9045
|
+
/**
|
|
9046
|
+
* @@@
|
|
9047
|
+
*
|
|
9048
|
+
* @deprecated https://github.com/webgptorg/promptbook/pull/186
|
|
9049
|
+
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
9050
|
+
*
|
|
9051
|
+
* @public exported from `@promptbook/core`
|
|
9052
|
+
*/
|
|
9053
|
+
function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
|
|
9054
|
+
var e_1, _a, e_2, _b;
|
|
9055
|
+
try {
|
|
9056
|
+
for (var _c = __values(['inputParameters', 'outputParameters']), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
9057
|
+
var whichParameters = _d.value;
|
|
9058
|
+
var parameters1 = pipelineInterface1[whichParameters]; // <- Note: `isPipelineInterfacesEqual` is just temporary solution, no need to fix this
|
|
9059
|
+
var parameters2 = pipelineInterface2[whichParameters];
|
|
9060
|
+
if (parameters1.length !== parameters2.length) {
|
|
9061
|
+
return false;
|
|
9062
|
+
}
|
|
9063
|
+
var _loop_1 = function (parameter) {
|
|
9064
|
+
var matchingParameter = parameters2.find(function (_a) {
|
|
9065
|
+
var name = _a.name;
|
|
9066
|
+
return name === parameter.name;
|
|
9067
|
+
});
|
|
9068
|
+
if (!matchingParameter) {
|
|
9069
|
+
return { value: false };
|
|
9070
|
+
}
|
|
9071
|
+
// Note: Do not compare description, it is not relevant for compatibility
|
|
9072
|
+
if (matchingParameter.isInput !== parameter.isInput) {
|
|
9073
|
+
return { value: false };
|
|
9074
|
+
}
|
|
9075
|
+
if (matchingParameter.isOutput !== parameter.isOutput) {
|
|
9076
|
+
return { value: false };
|
|
9077
|
+
}
|
|
9078
|
+
};
|
|
9079
|
+
try {
|
|
9080
|
+
for (var parameters1_1 = (e_2 = void 0, __values(parameters1)), parameters1_1_1 = parameters1_1.next(); !parameters1_1_1.done; parameters1_1_1 = parameters1_1.next()) {
|
|
9081
|
+
var parameter = parameters1_1_1.value;
|
|
9082
|
+
var state_1 = _loop_1(parameter);
|
|
9083
|
+
if (typeof state_1 === "object")
|
|
9084
|
+
return state_1.value;
|
|
9085
|
+
}
|
|
9086
|
+
}
|
|
9087
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
9088
|
+
finally {
|
|
9089
|
+
try {
|
|
9090
|
+
if (parameters1_1_1 && !parameters1_1_1.done && (_b = parameters1_1.return)) _b.call(parameters1_1);
|
|
9091
|
+
}
|
|
9092
|
+
finally { if (e_2) throw e_2.error; }
|
|
9093
|
+
}
|
|
9094
|
+
}
|
|
9095
|
+
}
|
|
9096
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
9097
|
+
finally {
|
|
9098
|
+
try {
|
|
9099
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
9100
|
+
}
|
|
9101
|
+
finally { if (e_1) throw e_1.error; }
|
|
9102
|
+
}
|
|
9103
|
+
return true;
|
|
9104
|
+
}
|
|
9105
|
+
|
|
9106
|
+
/**
|
|
9107
|
+
* @@@
|
|
9108
|
+
*
|
|
9109
|
+
* @deprecated https://github.com/webgptorg/promptbook/pull/186
|
|
9110
|
+
* @see https://github.com/webgptorg/promptbook/discussions/171
|
|
9111
|
+
*
|
|
9112
|
+
* @public exported from `@promptbook/core`
|
|
9113
|
+
*/
|
|
9114
|
+
function isPipelineImplementingInterface(options) {
|
|
9115
|
+
var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
|
|
9116
|
+
return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
|
|
9117
|
+
}
|
|
9118
|
+
|
|
9119
|
+
/**
|
|
9120
|
+
* Set formfactor based on the pipeline interface e
|
|
9121
|
+
*
|
|
9122
|
+
* @private
|
|
9123
|
+
*/
|
|
9124
|
+
var ImplicitFormfactorHla = {
|
|
9125
|
+
type: 'SYNC',
|
|
9126
|
+
$applyToPipelineJson: function ($pipelineJson) {
|
|
9127
|
+
var e_1, _a;
|
|
9128
|
+
if ($pipelineJson.formfactorName !== undefined) {
|
|
9129
|
+
// Note: When formfactor is already set, do nothing
|
|
9130
|
+
return;
|
|
9131
|
+
}
|
|
9132
|
+
try {
|
|
9133
|
+
for (var _b = __values(FORMFACTOR_DEFINITIONS.filter(function (_a) {
|
|
9134
|
+
var name = _a.name;
|
|
9135
|
+
return name !== 'GENERIC';
|
|
9136
|
+
})), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
9137
|
+
var formfactorDefinition = _c.value;
|
|
9138
|
+
// <- Note: [♓️][💩] This is the order of the formfactors, make some explicit priority
|
|
9139
|
+
var name_1 = formfactorDefinition.name, pipelineInterface = formfactorDefinition.pipelineInterface;
|
|
9140
|
+
var isCompatible = isPipelineImplementingInterface({
|
|
9141
|
+
pipeline: __assign({ formfactorName: name_1 }, $pipelineJson),
|
|
9142
|
+
pipelineInterface: pipelineInterface,
|
|
9143
|
+
});
|
|
9144
|
+
/*/
|
|
9145
|
+
console.log({
|
|
9146
|
+
subject: `${$pipelineJson.title} implements ${name}`,
|
|
9147
|
+
pipelineTitle: $pipelineJson.title,
|
|
9148
|
+
formfactorName: name,
|
|
9149
|
+
isCompatible,
|
|
9150
|
+
formfactorInterface: pipelineInterface,
|
|
9151
|
+
pipelineInterface: getPipelineInterface($pipelineJson as PipelineJson),
|
|
9152
|
+
});
|
|
9153
|
+
/**/
|
|
9154
|
+
if (isCompatible) {
|
|
9155
|
+
$pipelineJson.formfactorName = name_1;
|
|
9156
|
+
return;
|
|
9157
|
+
}
|
|
9158
|
+
}
|
|
9159
|
+
}
|
|
9160
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
9161
|
+
finally {
|
|
9162
|
+
try {
|
|
9163
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
9164
|
+
}
|
|
9165
|
+
finally { if (e_1) throw e_1.error; }
|
|
9166
|
+
}
|
|
9167
|
+
},
|
|
9168
|
+
};
|
|
9169
|
+
|
|
9170
|
+
/**
|
|
9171
|
+
* Allow to define chatbot with no need to write full interface
|
|
9172
|
+
*
|
|
9173
|
+
* @private
|
|
9174
|
+
*/
|
|
9175
|
+
var QuickChatbotHla = {
|
|
9176
|
+
type: 'SYNC',
|
|
9177
|
+
$applyToPipelineJson: function ($pipelineJson) {
|
|
9178
|
+
if ($pipelineJson.tasks.length !== 0) {
|
|
9179
|
+
// Note: When there are already tasks, do nothing
|
|
9180
|
+
return;
|
|
9181
|
+
}
|
|
9182
|
+
if ($pipelineJson.parameters.length !== 0) {
|
|
9183
|
+
// Note: When there are already parameters, do nothing
|
|
9184
|
+
return;
|
|
9185
|
+
}
|
|
9186
|
+
if ($pipelineJson.personas.length === 0) {
|
|
9187
|
+
// Note: When no personas defined, do nothing
|
|
9188
|
+
return;
|
|
9189
|
+
}
|
|
9190
|
+
var personaName = $pipelineJson.personas[0].name;
|
|
9191
|
+
$pipelineJson.formfactorName = 'CHATBOT';
|
|
9192
|
+
$pipelineJson.parameters.push({
|
|
9193
|
+
name: 'previousTitle',
|
|
9194
|
+
description: 'Previous title of the conversation',
|
|
9195
|
+
isInput: true,
|
|
9196
|
+
isOutput: false,
|
|
9197
|
+
}, {
|
|
9198
|
+
name: 'previousConversationSummary',
|
|
9199
|
+
description: 'Previous conversation summary',
|
|
9200
|
+
isInput: true,
|
|
9201
|
+
isOutput: false,
|
|
9202
|
+
}, {
|
|
9203
|
+
name: 'userMessage',
|
|
9204
|
+
description: 'User message',
|
|
9205
|
+
isInput: true,
|
|
9206
|
+
isOutput: false,
|
|
9207
|
+
}, {
|
|
9208
|
+
name: 'title',
|
|
9209
|
+
description: 'Title of the conversation',
|
|
9210
|
+
isInput: false,
|
|
9211
|
+
isOutput: true,
|
|
9212
|
+
}, {
|
|
9213
|
+
name: 'conversationSummary',
|
|
9214
|
+
description: 'Summary of the conversation',
|
|
9215
|
+
isInput: false,
|
|
9216
|
+
isOutput: true,
|
|
9217
|
+
}, {
|
|
9218
|
+
name: 'chatbotResponse',
|
|
9219
|
+
description: 'Chatbot response',
|
|
9220
|
+
isInput: false,
|
|
9221
|
+
isOutput: true,
|
|
9222
|
+
exampleValues: ['Hello, I am a Pavol`s virtual avatar. How can I help you?'],
|
|
9223
|
+
});
|
|
9224
|
+
// TODO: !!!!!! spaceTrim
|
|
9225
|
+
$pipelineJson.tasks.push({
|
|
9226
|
+
taskType: 'PROMPT_TASK',
|
|
9227
|
+
name: 'create-an-answer',
|
|
9228
|
+
title: 'Create an answer',
|
|
9229
|
+
content: 'Write a response to the user message:\n\n**Question from user**\n\n> {userMessage}\n\n**Previous conversation**\n\n> {previousConversationSummary}',
|
|
9230
|
+
resultingParameterName: 'chatbotResponse',
|
|
9231
|
+
personaName: personaName,
|
|
9232
|
+
dependentParameterNames: ['userMessage', 'previousConversationSummary' /* !!!!!!, 'knowledge'*/],
|
|
9233
|
+
// !!!!!! preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
|
|
9234
|
+
}, {
|
|
9235
|
+
taskType: 'PROMPT_TASK',
|
|
9236
|
+
name: 'summarize-the-conversation',
|
|
9237
|
+
title: 'Summarize the conversation',
|
|
9238
|
+
content: 'Summarize the conversation in a few words:\n\n## Rules\n\n- Summarise the text of the conversation in a few words\n- Convert the text to its basic idea\n- Imagine you are writing the headline or subject line of an email\n- Respond with a few words of summary only\n\n## Conversation\n\n**User:**\n\n> {userMessage}\n\n**You:**\n\n> {chatbotResponse}',
|
|
9239
|
+
resultingParameterName: 'conversationSummary',
|
|
9240
|
+
personaName: personaName,
|
|
9241
|
+
expectations: {
|
|
9242
|
+
words: {
|
|
9243
|
+
min: 1,
|
|
9244
|
+
max: 10,
|
|
9245
|
+
},
|
|
9246
|
+
},
|
|
9247
|
+
dependentParameterNames: ['userMessage', 'chatbotResponse' /* !!!!!!, 'knowledge'*/],
|
|
9248
|
+
// !!!!!! preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
|
|
9249
|
+
}, {
|
|
9250
|
+
taskType: 'SIMPLE_TASK',
|
|
9251
|
+
name: 'title',
|
|
9252
|
+
title: 'Title',
|
|
9253
|
+
content: '{conversationSummary}',
|
|
9254
|
+
resultingParameterName: 'title',
|
|
9255
|
+
dependentParameterNames: ['conversationSummary' /* !!!!!!, 'knowledge'*/],
|
|
9256
|
+
// !!!!!! preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
|
|
9257
|
+
});
|
|
9258
|
+
},
|
|
9259
|
+
};
|
|
9260
|
+
|
|
9261
|
+
/**
|
|
9262
|
+
* All high-level abstractions
|
|
9263
|
+
*
|
|
9264
|
+
* @private internal index of `pipelineStringToJsonSync` (= used for sync) and `preparePipeline` (= used for async)
|
|
9265
|
+
*/
|
|
9266
|
+
var HIGH_LEVEL_ABSTRACTIONS = [
|
|
9267
|
+
ImplicitFormfactorHla,
|
|
9268
|
+
QuickChatbotHla,
|
|
9269
|
+
// <- Note: [♓️][💩] This is the order of the application of high-level abstractions application on pipeline JSON
|
|
9270
|
+
];
|
|
9271
|
+
/**
|
|
9272
|
+
* TODO: Test that all sync high-level abstractions are before async high-level abstractions
|
|
9273
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
9274
|
+
*/
|
|
9275
|
+
|
|
9276
|
+
/**
|
|
9277
|
+
* Supported script languages
|
|
9278
|
+
*
|
|
9279
|
+
* @private internal base for `ScriptLanguage`
|
|
8895
9280
|
*/
|
|
8896
9281
|
var SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
|
|
8897
9282
|
// <- TODO: [🏥] DRY
|
|
@@ -9139,20 +9524,15 @@
|
|
|
9139
9524
|
* @public exported from `@promptbook/core`
|
|
9140
9525
|
*/
|
|
9141
9526
|
function pipelineStringToJsonSync(pipelineString) {
|
|
9142
|
-
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
|
|
9527
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
|
|
9143
9528
|
var $pipelineJson = {
|
|
9144
|
-
title:
|
|
9145
|
-
pipelineUrl: undefined /* <- Note: Putting here placeholder to keep `pipelineUrl` on top at final JSON */,
|
|
9146
|
-
bookVersion: undefined /* <- Note: By default no explicit version */,
|
|
9147
|
-
description: undefined /* <- Note: [🍙] Putting here placeholder to keep `description` on top at final JSON */,
|
|
9148
|
-
formfactorName: 'GENERIC',
|
|
9529
|
+
title: DEFAULT_TITLE,
|
|
9149
9530
|
parameters: [],
|
|
9150
9531
|
tasks: [],
|
|
9151
9532
|
knowledgeSources: [],
|
|
9152
9533
|
knowledgePieces: [],
|
|
9153
9534
|
personas: [],
|
|
9154
9535
|
preparations: [],
|
|
9155
|
-
// <- TODO: [🍙] Some standard order of properties
|
|
9156
9536
|
};
|
|
9157
9537
|
function getPipelineIdentification() {
|
|
9158
9538
|
// Note: This is a 😐 implementation of [🚞]
|
|
@@ -9168,7 +9548,7 @@
|
|
|
9168
9548
|
// =============================================================
|
|
9169
9549
|
// Note: 1️⃣ Parsing of the markdown into object
|
|
9170
9550
|
if (pipelineString.startsWith('#!')) {
|
|
9171
|
-
var
|
|
9551
|
+
var _g = __read(pipelineString.split('\n')), shebangLine_1 = _g[0], restLines = _g.slice(1);
|
|
9172
9552
|
if (!(shebangLine_1 || '').includes('ptbk')) {
|
|
9173
9553
|
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n It seems that you try to parse a book file which has non-standard shebang line for book files:\n Shebang line must contain 'ptbk'\n\n You have:\n ".concat(block(shebangLine_1 || '(empty line)'), "\n\n It should look like this:\n #!/usr/bin/env ptbk\n\n ").concat(block(getPipelineIdentification()), "\n "); }));
|
|
9174
9554
|
}
|
|
@@ -9178,7 +9558,7 @@
|
|
|
9178
9558
|
pipelineString = flattenMarkdown(pipelineString) /* <- Note: [🥞] */;
|
|
9179
9559
|
pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
|
|
9180
9560
|
pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
|
|
9181
|
-
var
|
|
9561
|
+
var _h = __read(splitMarkdownIntoSections(pipelineString).map(parseMarkdownSection)), pipelineHead = _h[0], pipelineSections = _h.slice(1); /* <- Note: [🥞] */
|
|
9182
9562
|
if (pipelineHead === undefined) {
|
|
9183
9563
|
throw new UnexpectedError(spaceTrim.spaceTrim(function (block) { return "\n Pipeline head is not defined\n\n ".concat(block(getPipelineIdentification()), "\n\n This should never happen, because the pipeline already flattened\n "); }));
|
|
9184
9564
|
}
|
|
@@ -9243,7 +9623,7 @@
|
|
|
9243
9623
|
}
|
|
9244
9624
|
try {
|
|
9245
9625
|
commandParser.$applyToPipelineJson(command, $pipelineJson);
|
|
9246
|
-
// <- Note: [🦦] Its strange that this assertion must be here, [🦦][4] should do this assertion
|
|
9626
|
+
// <- Note: [🦦] Its strange that this assertion must be here, [🦦][4] should do this assertion implicitly
|
|
9247
9627
|
}
|
|
9248
9628
|
catch (error) {
|
|
9249
9629
|
if (!(error instanceof ParseError)) {
|
|
@@ -9300,10 +9680,10 @@
|
|
|
9300
9680
|
return nameWithSuffix;
|
|
9301
9681
|
};
|
|
9302
9682
|
var _loop_2 = function (section) {
|
|
9303
|
-
var
|
|
9683
|
+
var e_7, _q, e_8, _r;
|
|
9304
9684
|
// TODO: Parse section's description (the content out of the codeblock and lists)
|
|
9305
9685
|
var listItems_2 = extractAllListItemsFromMarkdown(section.content);
|
|
9306
|
-
var
|
|
9686
|
+
var _s = extractOneBlockFromMarkdown(section.content), language = _s.language, content = _s.content;
|
|
9307
9687
|
// TODO: [🎾][1] DRY description
|
|
9308
9688
|
var description_1 = section.content;
|
|
9309
9689
|
// Note: Remove codeblocks - TODO: [🎾]
|
|
@@ -9351,7 +9731,7 @@
|
|
|
9351
9731
|
}
|
|
9352
9732
|
try {
|
|
9353
9733
|
commandParser.$applyToTaskJson(
|
|
9354
|
-
// <- Note: [🦦] Its strange that this assertion must be here, [🦦][4] should do this assertion
|
|
9734
|
+
// <- Note: [🦦] Its strange that this assertion must be here, [🦦][4] should do this assertion implicitly
|
|
9355
9735
|
command, $taskJson, $pipelineJson);
|
|
9356
9736
|
}
|
|
9357
9737
|
catch (error) {
|
|
@@ -9367,17 +9747,17 @@
|
|
|
9367
9747
|
};
|
|
9368
9748
|
try {
|
|
9369
9749
|
// TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
|
|
9370
|
-
for (var commands_1 = (
|
|
9371
|
-
var
|
|
9750
|
+
for (var commands_1 = (e_7 = void 0, __values(commands)), commands_1_1 = commands_1.next(); !commands_1_1.done; commands_1_1 = commands_1.next()) {
|
|
9751
|
+
var _t = commands_1_1.value, listItem = _t.listItem, command = _t.command;
|
|
9372
9752
|
_loop_4(listItem, command);
|
|
9373
9753
|
}
|
|
9374
9754
|
}
|
|
9375
|
-
catch (
|
|
9755
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
9376
9756
|
finally {
|
|
9377
9757
|
try {
|
|
9378
|
-
if (commands_1_1 && !commands_1_1.done && (
|
|
9758
|
+
if (commands_1_1 && !commands_1_1.done && (_q = commands_1.return)) _q.call(commands_1);
|
|
9379
9759
|
}
|
|
9380
|
-
finally { if (
|
|
9760
|
+
finally { if (e_7) throw e_7.error; }
|
|
9381
9761
|
}
|
|
9382
9762
|
// TODO: [🍧] Should be done in SECTION command
|
|
9383
9763
|
if ($taskJson.taskType === 'SCRIPT_TASK') {
|
|
@@ -9391,8 +9771,8 @@
|
|
|
9391
9771
|
}
|
|
9392
9772
|
$taskJson.dependentParameterNames = Array.from(extractParameterNamesFromTask($taskJson));
|
|
9393
9773
|
try {
|
|
9394
|
-
for (var
|
|
9395
|
-
var parameterName =
|
|
9774
|
+
for (var _u = (e_8 = void 0, __values($taskJson.dependentParameterNames)), _v = _u.next(); !_v.done; _v = _u.next()) {
|
|
9775
|
+
var parameterName = _v.value;
|
|
9396
9776
|
// TODO: [🧠] This definition should be made first in the task
|
|
9397
9777
|
defineParam({
|
|
9398
9778
|
parameterName: parameterName,
|
|
@@ -9403,12 +9783,12 @@
|
|
|
9403
9783
|
});
|
|
9404
9784
|
}
|
|
9405
9785
|
}
|
|
9406
|
-
catch (
|
|
9786
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
9407
9787
|
finally {
|
|
9408
9788
|
try {
|
|
9409
|
-
if (
|
|
9789
|
+
if (_v && !_v.done && (_r = _u.return)) _r.call(_u);
|
|
9410
9790
|
}
|
|
9411
|
-
finally { if (
|
|
9791
|
+
finally { if (e_8) throw e_8.error; }
|
|
9412
9792
|
}
|
|
9413
9793
|
/*
|
|
9414
9794
|
// TODO: [🍧] This should be checked in `MODEL` command + better error message
|
|
@@ -9457,18 +9837,22 @@
|
|
|
9457
9837
|
var isThisParameterResulting = $pipelineJson.tasks.some(function (task) { return task.resultingParameterName === parameter.name; });
|
|
9458
9838
|
if (!isThisParameterResulting) {
|
|
9459
9839
|
parameter.isInput = true;
|
|
9840
|
+
// <- TODO: [💔] Why this is making typescript error in vscode but not in cli
|
|
9841
|
+
// > Type 'true' is not assignable to type 'false'.ts(2322)
|
|
9842
|
+
// > (property) isInput: false
|
|
9843
|
+
// > The parameter is input of the pipeline The parameter is NOT input of the pipeline
|
|
9460
9844
|
}
|
|
9461
9845
|
};
|
|
9462
9846
|
try {
|
|
9463
|
-
for (var
|
|
9464
|
-
var parameter =
|
|
9847
|
+
for (var _j = __values($pipelineJson.parameters), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
9848
|
+
var parameter = _k.value;
|
|
9465
9849
|
_loop_3(parameter);
|
|
9466
9850
|
}
|
|
9467
9851
|
}
|
|
9468
9852
|
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
9469
9853
|
finally {
|
|
9470
9854
|
try {
|
|
9471
|
-
if (
|
|
9855
|
+
if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
|
|
9472
9856
|
}
|
|
9473
9857
|
finally { if (e_4) throw e_4.error; }
|
|
9474
9858
|
}
|
|
@@ -9477,17 +9861,18 @@
|
|
|
9477
9861
|
// Note: 7️⃣ Mark all non-INPUT parameters as OUTPUT if any OUTPUT is not set
|
|
9478
9862
|
if ($pipelineJson.parameters.every(function (parameter) { return !parameter.isOutput; })) {
|
|
9479
9863
|
try {
|
|
9480
|
-
for (var
|
|
9481
|
-
var parameter =
|
|
9864
|
+
for (var _l = __values($pipelineJson.parameters), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
9865
|
+
var parameter = _m.value;
|
|
9482
9866
|
if (!parameter.isInput) {
|
|
9483
9867
|
parameter.isOutput = true;
|
|
9868
|
+
// <- TODO: [💔]
|
|
9484
9869
|
}
|
|
9485
9870
|
}
|
|
9486
9871
|
}
|
|
9487
9872
|
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
9488
9873
|
finally {
|
|
9489
9874
|
try {
|
|
9490
|
-
if (
|
|
9875
|
+
if (_m && !_m.done && (_e = _l.return)) _e.call(_l);
|
|
9491
9876
|
}
|
|
9492
9877
|
finally { if (e_5) throw e_5.error; }
|
|
9493
9878
|
}
|
|
@@ -9495,7 +9880,7 @@
|
|
|
9495
9880
|
// =============================================================
|
|
9496
9881
|
// Note: 8️⃣ Cleanup of undefined values
|
|
9497
9882
|
$pipelineJson.tasks.forEach(function (tasks) {
|
|
9498
|
-
var
|
|
9883
|
+
var e_9, _a;
|
|
9499
9884
|
try {
|
|
9500
9885
|
for (var _b = __values(Object.entries(tasks)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
9501
9886
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -9504,16 +9889,16 @@
|
|
|
9504
9889
|
}
|
|
9505
9890
|
}
|
|
9506
9891
|
}
|
|
9507
|
-
catch (
|
|
9892
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
9508
9893
|
finally {
|
|
9509
9894
|
try {
|
|
9510
9895
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
9511
9896
|
}
|
|
9512
|
-
finally { if (
|
|
9897
|
+
finally { if (e_9) throw e_9.error; }
|
|
9513
9898
|
}
|
|
9514
9899
|
});
|
|
9515
9900
|
$pipelineJson.parameters.forEach(function (parameter) {
|
|
9516
|
-
var
|
|
9901
|
+
var e_10, _a;
|
|
9517
9902
|
try {
|
|
9518
9903
|
for (var _b = __values(Object.entries(parameter)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
9519
9904
|
var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
|
|
@@ -9522,19 +9907,49 @@
|
|
|
9522
9907
|
}
|
|
9523
9908
|
}
|
|
9524
9909
|
}
|
|
9525
|
-
catch (
|
|
9910
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
9526
9911
|
finally {
|
|
9527
9912
|
try {
|
|
9528
9913
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
9529
9914
|
}
|
|
9530
|
-
finally { if (
|
|
9915
|
+
finally { if (e_10) throw e_10.error; }
|
|
9531
9916
|
}
|
|
9532
9917
|
});
|
|
9918
|
+
try {
|
|
9919
|
+
// =============================================================
|
|
9920
|
+
// Note: 9️⃣ Apply sync high-level abstractions
|
|
9921
|
+
for (var _o = __values(HIGH_LEVEL_ABSTRACTIONS.filter(function (_a) {
|
|
9922
|
+
var type = _a.type;
|
|
9923
|
+
return type === 'SYNC';
|
|
9924
|
+
})), _p = _o.next(); !_p.done; _p = _o.next()) {
|
|
9925
|
+
var highLevelAbstraction = _p.value;
|
|
9926
|
+
highLevelAbstraction.$applyToPipelineJson($pipelineJson);
|
|
9927
|
+
}
|
|
9928
|
+
}
|
|
9929
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
9930
|
+
finally {
|
|
9931
|
+
try {
|
|
9932
|
+
if (_p && !_p.done && (_f = _o.return)) _f.call(_o);
|
|
9933
|
+
}
|
|
9934
|
+
finally { if (e_6) throw e_6.error; }
|
|
9935
|
+
}
|
|
9936
|
+
// =============================================================
|
|
9937
|
+
// Note: 🔟 Default formfactor
|
|
9938
|
+
// Note: [🔆] If formfactor is still not set, set it to 'GENERIC'
|
|
9939
|
+
if ($pipelineJson.formfactorName === undefined) {
|
|
9940
|
+
$pipelineJson.formfactorName = 'GENERIC';
|
|
9941
|
+
}
|
|
9533
9942
|
// =============================================================
|
|
9534
9943
|
// TODO: [🍙] Maybe do reorder of `$pipelineJson` here
|
|
9535
|
-
return
|
|
9944
|
+
return exportJson({
|
|
9945
|
+
name: 'pipelineJson',
|
|
9946
|
+
message: "Result of `pipelineStringToJsonSync`",
|
|
9947
|
+
order: ORDER_OF_PIPELINE_JSON,
|
|
9948
|
+
value: __assign({ formfactorName: 'GENERIC' }, $pipelineJson),
|
|
9949
|
+
});
|
|
9536
9950
|
}
|
|
9537
9951
|
/**
|
|
9952
|
+
* TODO: [🧠] Maybe more things here can be refactored as high-level abstractions
|
|
9538
9953
|
* TODO: [main] !!!! Warn if used only sync version
|
|
9539
9954
|
* TODO: [🚞] Report here line/column of error
|
|
9540
9955
|
* TODO: Use spaceTrim more effectively
|
|
@@ -9578,7 +9993,7 @@
|
|
|
9578
9993
|
pipelineJson = _a.sent();
|
|
9579
9994
|
_a.label = 2;
|
|
9580
9995
|
case 2:
|
|
9581
|
-
// Note: No need to use `$
|
|
9996
|
+
// Note: No need to use `$exportJson` because `pipelineStringToJsonSync` and `preparePipeline` already do that
|
|
9582
9997
|
return [2 /*return*/, pipelineJson];
|
|
9583
9998
|
}
|
|
9584
9999
|
});
|
|
@@ -10724,7 +11139,7 @@
|
|
|
10724
11139
|
return [3 /*break*/, 7];
|
|
10725
11140
|
case 6:
|
|
10726
11141
|
if (isVerbose) {
|
|
10727
|
-
console.info(colors__default["default"].gray("Skipped file ".concat(fileName.split('\\').join('/'), " \u2013\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060 Not a
|
|
11142
|
+
console.info(colors__default["default"].gray("Skipped file ".concat(fileName.split('\\').join('/'), " \u2013\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060\u2060 Not a book")));
|
|
10728
11143
|
}
|
|
10729
11144
|
_e.label = 7;
|
|
10730
11145
|
case 7:
|
|
@@ -10771,7 +11186,7 @@
|
|
|
10771
11186
|
if (!(error_1 instanceof Error)) {
|
|
10772
11187
|
throw error_1;
|
|
10773
11188
|
}
|
|
10774
|
-
wrappedErrorMessage = spaceTrim__default["default"](function (block) { return "\n ".concat(error_1.name, " in pipeline ").concat(fileName.split('\\').join('/'), "\u2060:\n\n ").concat(block(error_1.message), "\n\n "); });
|
|
11189
|
+
wrappedErrorMessage = spaceTrim__default["default"](function (block) { return "\n ".concat(error_1.name, " in pipeline ").concat(fileName.split('\\').join('/'), "\u2060:\n\n Original error message:\n ").concat(block(error_1.message), "\n\n Original stack trace:\n ").concat(block(error_1.stack || ''), "\n\n ---\n\n "); }) + '\n';
|
|
10775
11190
|
if (isCrashedOnError) {
|
|
10776
11191
|
throw new CollectionError(wrappedErrorMessage);
|
|
10777
11192
|
}
|
|
@@ -11651,6 +12066,122 @@
|
|
|
11651
12066
|
* TODO: [🧠] Should be in generated file GENERATOR_WARNING
|
|
11652
12067
|
*/
|
|
11653
12068
|
|
|
12069
|
+
/**
|
|
12070
|
+
* Run the interactive chatbot in CLI
|
|
12071
|
+
*
|
|
12072
|
+
* @returns Never-ending promise or process exit
|
|
12073
|
+
* @private internal function of `promptbookCli` and `initializeRunCommand`
|
|
12074
|
+
*/
|
|
12075
|
+
function runInteractiveChatbot(options) {
|
|
12076
|
+
var _a;
|
|
12077
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
12078
|
+
var pipeline, pipelineExecutor, isVerbose, ongoingParameters, initialMessage, _loop_1, state_1;
|
|
12079
|
+
return __generator(this, function (_b) {
|
|
12080
|
+
switch (_b.label) {
|
|
12081
|
+
case 0:
|
|
12082
|
+
pipeline = options.pipeline, pipelineExecutor = options.pipelineExecutor, isVerbose = options.isVerbose;
|
|
12083
|
+
ongoingParameters = {
|
|
12084
|
+
/**
|
|
12085
|
+
* Title of the conversation
|
|
12086
|
+
*/
|
|
12087
|
+
title: '',
|
|
12088
|
+
/**
|
|
12089
|
+
* Summary of the conversation
|
|
12090
|
+
*/
|
|
12091
|
+
conversationSummary: '',
|
|
12092
|
+
/**
|
|
12093
|
+
* Chatbot response
|
|
12094
|
+
*/
|
|
12095
|
+
chatbotResponse: '',
|
|
12096
|
+
};
|
|
12097
|
+
if (isVerbose) {
|
|
12098
|
+
console.info(colors__default["default"].gray('--- Running interactive chatbot ---'));
|
|
12099
|
+
}
|
|
12100
|
+
initialMessage = (((_a = pipeline.parameters.find(function (_a) {
|
|
12101
|
+
var name = _a.name;
|
|
12102
|
+
return name === 'chatbotResponse';
|
|
12103
|
+
})) === null || _a === void 0 ? void 0 : _a.exampleValues) || [])[0];
|
|
12104
|
+
if (initialMessage) {
|
|
12105
|
+
console.info("\n");
|
|
12106
|
+
console.info(spaceTrim__default["default"](function (block) { return "\n\n ".concat(colors__default["default"].bold(colors__default["default"].green('Chatbot:')), "\n ").concat(block(colors__default["default"].green(initialMessage)), "\n\n "); }));
|
|
12107
|
+
}
|
|
12108
|
+
_loop_1 = function () {
|
|
12109
|
+
var title_1, conversationSummary_1, response, userMessage_1, inputParameters, result_1, error_1;
|
|
12110
|
+
return __generator(this, function (_c) {
|
|
12111
|
+
switch (_c.label) {
|
|
12112
|
+
case 0:
|
|
12113
|
+
_c.trys.push([0, 4, , 5]);
|
|
12114
|
+
return [4 /*yield*/, waitasecond.forTime(100)];
|
|
12115
|
+
case 1:
|
|
12116
|
+
_c.sent();
|
|
12117
|
+
title_1 = ongoingParameters.title, conversationSummary_1 = ongoingParameters.conversationSummary;
|
|
12118
|
+
console.info("\n");
|
|
12119
|
+
if (title_1 !== '' &&
|
|
12120
|
+
just(false) /* <- TODO: [⛲️] Some better way how to show the title of ongoing conversation */) {
|
|
12121
|
+
console.info(colors__default["default"].gray("--- ".concat(title_1, " ---")));
|
|
12122
|
+
}
|
|
12123
|
+
else {
|
|
12124
|
+
console.info(colors__default["default"].gray("---"));
|
|
12125
|
+
}
|
|
12126
|
+
return [4 /*yield*/, prompts__default["default"]({
|
|
12127
|
+
type: 'text',
|
|
12128
|
+
name: 'userMessage',
|
|
12129
|
+
message: 'User message',
|
|
12130
|
+
hint: spaceTrim__default["default"](function (block) { return "\n Type \"exit\" to exit,\n\n previousTitle\n ".concat(block(title_1), "\n\n previousConversationSummary\n ").concat(block(conversationSummary_1), "\n\n "); }),
|
|
12131
|
+
})];
|
|
12132
|
+
case 2:
|
|
12133
|
+
response = _c.sent();
|
|
12134
|
+
userMessage_1 = response.userMessage;
|
|
12135
|
+
if (userMessage_1 === 'exit' || userMessage_1 === 'quit' || userMessage_1 === undefined) {
|
|
12136
|
+
return [2 /*return*/, { value: process.exit(0) }];
|
|
12137
|
+
}
|
|
12138
|
+
console.info("\n");
|
|
12139
|
+
console.info(spaceTrim__default["default"](function (block) { return "\n\n ".concat(colors__default["default"].bold(colors__default["default"].blue('User:')), "\n ").concat(block(colors__default["default"].blue(userMessage_1)), "\n\n "); }));
|
|
12140
|
+
inputParameters = {
|
|
12141
|
+
previousTitle: title_1,
|
|
12142
|
+
previousConversationSummary: conversationSummary_1,
|
|
12143
|
+
userMessage: userMessage_1,
|
|
12144
|
+
};
|
|
12145
|
+
return [4 /*yield*/, pipelineExecutor(inputParameters)];
|
|
12146
|
+
case 3:
|
|
12147
|
+
result_1 = _c.sent();
|
|
12148
|
+
assertsExecutionSuccessful(result_1);
|
|
12149
|
+
console.info("\n");
|
|
12150
|
+
console.info(spaceTrim__default["default"](function (block) { return "\n\n ".concat(colors__default["default"].bold(colors__default["default"].green('Chatbot:')), "\n ").concat(block(colors__default["default"].green(result_1.outputParameters.chatbotResponse)), "\n\n "); }));
|
|
12151
|
+
ongoingParameters = result_1.outputParameters;
|
|
12152
|
+
return [3 /*break*/, 5];
|
|
12153
|
+
case 4:
|
|
12154
|
+
error_1 = _c.sent();
|
|
12155
|
+
if (!(error_1 instanceof Error)) {
|
|
12156
|
+
throw error_1;
|
|
12157
|
+
}
|
|
12158
|
+
// TODO: Allow to ressurect the chatbot after an error - prompt the user to continue
|
|
12159
|
+
console.error(colors__default["default"].red(error_1.stack || error_1.message));
|
|
12160
|
+
return [2 /*return*/, { value: process.exit(1) }];
|
|
12161
|
+
case 5: return [2 /*return*/];
|
|
12162
|
+
}
|
|
12163
|
+
});
|
|
12164
|
+
};
|
|
12165
|
+
_b.label = 1;
|
|
12166
|
+
case 1:
|
|
12167
|
+
if (!just(true)) return [3 /*break*/, 3];
|
|
12168
|
+
return [5 /*yield**/, _loop_1()];
|
|
12169
|
+
case 2:
|
|
12170
|
+
state_1 = _b.sent();
|
|
12171
|
+
if (typeof state_1 === "object")
|
|
12172
|
+
return [2 /*return*/, state_1.value];
|
|
12173
|
+
return [3 /*break*/, 1];
|
|
12174
|
+
case 3: return [2 /*return*/];
|
|
12175
|
+
}
|
|
12176
|
+
});
|
|
12177
|
+
});
|
|
12178
|
+
}
|
|
12179
|
+
/**
|
|
12180
|
+
* TODO: Saving reports from the chatbot conversation
|
|
12181
|
+
* TODO: [⛲️] This is the right place to start implementing INK
|
|
12182
|
+
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
12183
|
+
*/
|
|
12184
|
+
|
|
11654
12185
|
/**
|
|
11655
12186
|
* Initializes `run` command for Promptbook CLI utilities
|
|
11656
12187
|
*
|
|
@@ -11667,15 +12198,16 @@
|
|
|
11667
12198
|
runCommand.option('-r, --reload', "Call LLM models even if same prompt with result is in the cache", false);
|
|
11668
12199
|
runCommand.option('-v, --verbose', "Is output verbose", false);
|
|
11669
12200
|
runCommand.option('--no-interactive', "Input is not interactive, if true you need to pass all the input parameters through --json");
|
|
12201
|
+
runCommand.option('--no-formfactor', "When set, behavior of the interactive mode is not changed by the formfactor of the pipeline");
|
|
11670
12202
|
runCommand.option('-j, --json <json>', "Pass all or some input parameters as JSON record, if used the output is also returned as JSON");
|
|
11671
12203
|
runCommand.option('-s, --save-report <path>', "Save report to file");
|
|
11672
12204
|
runCommand.action(function (filePathRaw, options) { return __awaiter(_this, void 0, void 0, function () {
|
|
11673
|
-
var isCacheReloaded, isInteractive, json, isVerbose, saveReport, inputParameters, prepareAndScrapeOptions, fs, filePath, filePathCandidates, filePathCandidates_1, filePathCandidates_1_1, filePathCandidate, e_1_1, llm, executables, tools, pipelineString, pipeline, error_1, pipelineExecutor, questions, response, result, isSuccessful, errors, warnings, outputParameters, executionReport, executionReportString, _a, _b, error, _c, _d, warning, _e, _f, key, value, separator;
|
|
12205
|
+
var isCacheReloaded, isInteractive, isFormfactorUsed, json, isVerbose, saveReport, inputParameters, prepareAndScrapeOptions, fs, filePath, filePathCandidates, filePathCandidates_1, filePathCandidates_1_1, filePathCandidate, e_1_1, llm, executables, tools, pipelineString, pipeline, error_1, pipelineExecutor, questions, response, result, isSuccessful, errors, warnings, outputParameters, executionReport, executionReportString, _a, _b, error, _c, _d, warning, _e, _f, key, value, separator;
|
|
11674
12206
|
var e_1, _g, _h, e_2, _j, e_3, _k, e_4, _l;
|
|
11675
12207
|
return __generator(this, function (_m) {
|
|
11676
12208
|
switch (_m.label) {
|
|
11677
12209
|
case 0:
|
|
11678
|
-
isCacheReloaded = options.reload, isInteractive = options.interactive, json = options.json, isVerbose = options.verbose, saveReport = options.saveReport;
|
|
12210
|
+
isCacheReloaded = options.reload, isInteractive = options.interactive, isFormfactorUsed = options.formfactor, json = options.json, isVerbose = options.verbose, saveReport = options.saveReport;
|
|
11679
12211
|
if (saveReport && !saveReport.endsWith('.json') && !saveReport.endsWith('.md')) {
|
|
11680
12212
|
console.error(colors__default["default"].red("Report file must be .json or .md"));
|
|
11681
12213
|
return [2 /*return*/, process.exit(1)];
|
|
@@ -11744,7 +12276,7 @@
|
|
|
11744
12276
|
if (!error.message.includes('No LLM tools')) {
|
|
11745
12277
|
throw error;
|
|
11746
12278
|
}
|
|
11747
|
-
console.error(colors__default["default"].red(spaceTrim__default["default"](function (block) { return "\n You need to configure LLM tools first\n\n 1) Create .env file at the root of your project\n 2) Configure API keys for LLM tools\n
|
|
12279
|
+
console.error(colors__default["default"].red(spaceTrim__default["default"](function (block) { return "\n You need to configure LLM tools first\n\n 1) Create .env file at the root of your project\n 2) Configure API keys for LLM tools\n\n For example:\n ".concat(block($llmToolsMetadataRegister
|
|
11748
12280
|
.list()
|
|
11749
12281
|
.map(function (_a) {
|
|
11750
12282
|
var title = _a.title, envVariables = _a.envVariables;
|
|
@@ -11807,6 +12339,10 @@
|
|
|
11807
12339
|
// <- TODO: Why "LLM execution failed undefinedx"
|
|
11808
12340
|
maxParallelCount: 1, // <- TODO: Pass CLI argument
|
|
11809
12341
|
});
|
|
12342
|
+
// TODO: Make some better system for formfactors and interactive mode - here is just a quick hardcoded solution for chatbot
|
|
12343
|
+
if (isInteractive === true && isFormfactorUsed === true && pipeline.formfactorName === 'CHATBOT') {
|
|
12344
|
+
return [2 /*return*/, /* not await */ runInteractiveChatbot({ pipeline: pipeline, pipelineExecutor: pipelineExecutor, isVerbose: isVerbose })];
|
|
12345
|
+
}
|
|
11810
12346
|
if (isVerbose) {
|
|
11811
12347
|
console.info(colors__default["default"].gray('--- Getting input parameters ---'));
|
|
11812
12348
|
}
|
|
@@ -12267,7 +12803,7 @@
|
|
|
12267
12803
|
isAnonymous: true,
|
|
12268
12804
|
userId: this.options.userId,
|
|
12269
12805
|
llmToolsConfiguration: this.options.llmToolsConfiguration,
|
|
12270
|
-
} /* <-
|
|
12806
|
+
} /* <- Note: [🤛] */);
|
|
12271
12807
|
}
|
|
12272
12808
|
else {
|
|
12273
12809
|
socket.emit('listModels-request', {
|
|
@@ -12275,7 +12811,7 @@
|
|
|
12275
12811
|
appId: this.options.appId,
|
|
12276
12812
|
userId: this.options.userId,
|
|
12277
12813
|
customOptions: this.options.customOptions,
|
|
12278
|
-
} /* <-
|
|
12814
|
+
} /* <- Note: [🤛] */);
|
|
12279
12815
|
}
|
|
12280
12816
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
12281
12817
|
socket.on('listModels-response', function (response) {
|
|
@@ -12363,7 +12899,7 @@
|
|
|
12363
12899
|
userId: this.options.userId,
|
|
12364
12900
|
llmToolsConfiguration: this.options.llmToolsConfiguration,
|
|
12365
12901
|
prompt: prompt,
|
|
12366
|
-
} /* <-
|
|
12902
|
+
} /* <- Note: [🤛] */);
|
|
12367
12903
|
}
|
|
12368
12904
|
else {
|
|
12369
12905
|
socket.emit('prompt-request', {
|
|
@@ -12372,7 +12908,7 @@
|
|
|
12372
12908
|
userId: this.options.userId,
|
|
12373
12909
|
customOptions: this.options.customOptions,
|
|
12374
12910
|
prompt: prompt,
|
|
12375
|
-
} /* <-
|
|
12911
|
+
} /* <- Note: [🤛] */);
|
|
12376
12912
|
}
|
|
12377
12913
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
12378
12914
|
socket.on('prompt-response', function (response) {
|
|
@@ -12395,7 +12931,7 @@
|
|
|
12395
12931
|
return RemoteLlmExecutionTools;
|
|
12396
12932
|
}());
|
|
12397
12933
|
/**
|
|
12398
|
-
* TODO: Maybe use `$
|
|
12934
|
+
* TODO: Maybe use `$exportJson`
|
|
12399
12935
|
* TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
|
|
12400
12936
|
* TODO: [🍓] Allow to list compatible models with each variant
|
|
12401
12937
|
* TODO: [🗯] RemoteLlmExecutionTools should extend Destroyable and implement IDestroyable
|
|
@@ -12421,72 +12957,75 @@
|
|
|
12421
12957
|
* @see https://docs.anthropic.com/en/docs/models-overview
|
|
12422
12958
|
* @public exported from `@promptbook/anthropic-claude`
|
|
12423
12959
|
*/
|
|
12424
|
-
var ANTHROPIC_CLAUDE_MODELS =
|
|
12425
|
-
|
|
12426
|
-
|
|
12427
|
-
|
|
12428
|
-
|
|
12429
|
-
|
|
12430
|
-
|
|
12431
|
-
|
|
12960
|
+
var ANTHROPIC_CLAUDE_MODELS = exportJson({
|
|
12961
|
+
name: 'ANTHROPIC_CLAUDE_MODELS',
|
|
12962
|
+
value: [
|
|
12963
|
+
{
|
|
12964
|
+
modelVariant: 'CHAT',
|
|
12965
|
+
modelTitle: 'Claude 3.5 Sonnet',
|
|
12966
|
+
modelName: 'claude-3-5-sonnet-20240620',
|
|
12967
|
+
pricing: {
|
|
12968
|
+
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
12969
|
+
output: computeUsage("$15.00 / 1M tokens"),
|
|
12970
|
+
},
|
|
12432
12971
|
},
|
|
12433
|
-
|
|
12434
|
-
|
|
12435
|
-
|
|
12436
|
-
|
|
12437
|
-
|
|
12438
|
-
|
|
12439
|
-
|
|
12440
|
-
|
|
12972
|
+
{
|
|
12973
|
+
modelVariant: 'CHAT',
|
|
12974
|
+
modelTitle: 'Claude 3 Opus',
|
|
12975
|
+
modelName: 'claude-3-opus-20240229',
|
|
12976
|
+
pricing: {
|
|
12977
|
+
prompt: computeUsage("$15.00 / 1M tokens"),
|
|
12978
|
+
output: computeUsage("$75.00 / 1M tokens"),
|
|
12979
|
+
},
|
|
12441
12980
|
},
|
|
12442
|
-
|
|
12443
|
-
|
|
12444
|
-
|
|
12445
|
-
|
|
12446
|
-
|
|
12447
|
-
|
|
12448
|
-
|
|
12449
|
-
|
|
12981
|
+
{
|
|
12982
|
+
modelVariant: 'CHAT',
|
|
12983
|
+
modelTitle: 'Claude 3 Sonnet',
|
|
12984
|
+
modelName: 'claude-3-sonnet-20240229',
|
|
12985
|
+
pricing: {
|
|
12986
|
+
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
12987
|
+
output: computeUsage("$15.00 / 1M tokens"),
|
|
12988
|
+
},
|
|
12450
12989
|
},
|
|
12451
|
-
|
|
12452
|
-
|
|
12453
|
-
|
|
12454
|
-
|
|
12455
|
-
|
|
12456
|
-
|
|
12457
|
-
|
|
12458
|
-
|
|
12990
|
+
{
|
|
12991
|
+
modelVariant: 'CHAT',
|
|
12992
|
+
modelTitle: 'Claude 3 Haiku',
|
|
12993
|
+
modelName: ' claude-3-haiku-20240307',
|
|
12994
|
+
pricing: {
|
|
12995
|
+
prompt: computeUsage("$0.25 / 1M tokens"),
|
|
12996
|
+
output: computeUsage("$1.25 / 1M tokens"),
|
|
12997
|
+
},
|
|
12459
12998
|
},
|
|
12460
|
-
|
|
12461
|
-
|
|
12462
|
-
|
|
12463
|
-
|
|
12464
|
-
|
|
12465
|
-
|
|
12466
|
-
|
|
12467
|
-
|
|
12999
|
+
{
|
|
13000
|
+
modelVariant: 'CHAT',
|
|
13001
|
+
modelTitle: 'Claude 2.1',
|
|
13002
|
+
modelName: 'claude-2.1',
|
|
13003
|
+
pricing: {
|
|
13004
|
+
prompt: computeUsage("$8.00 / 1M tokens"),
|
|
13005
|
+
output: computeUsage("$24.00 / 1M tokens"),
|
|
13006
|
+
},
|
|
12468
13007
|
},
|
|
12469
|
-
|
|
12470
|
-
|
|
12471
|
-
|
|
12472
|
-
|
|
12473
|
-
|
|
12474
|
-
|
|
12475
|
-
|
|
12476
|
-
|
|
13008
|
+
{
|
|
13009
|
+
modelVariant: 'CHAT',
|
|
13010
|
+
modelTitle: 'Claude 2',
|
|
13011
|
+
modelName: 'claude-2.0',
|
|
13012
|
+
pricing: {
|
|
13013
|
+
prompt: computeUsage("$8.00 / 1M tokens"),
|
|
13014
|
+
output: computeUsage("$24.00 / 1M tokens"),
|
|
13015
|
+
},
|
|
12477
13016
|
},
|
|
12478
|
-
|
|
12479
|
-
|
|
12480
|
-
|
|
12481
|
-
|
|
12482
|
-
|
|
12483
|
-
|
|
12484
|
-
|
|
12485
|
-
|
|
13017
|
+
{
|
|
13018
|
+
modelVariant: 'CHAT',
|
|
13019
|
+
modelTitle: ' Claude Instant 1.2',
|
|
13020
|
+
modelName: 'claude-instant-1.2',
|
|
13021
|
+
pricing: {
|
|
13022
|
+
prompt: computeUsage("$0.80 / 1M tokens"),
|
|
13023
|
+
output: computeUsage("$2.40 / 1M tokens"),
|
|
13024
|
+
},
|
|
12486
13025
|
},
|
|
12487
|
-
|
|
12488
|
-
|
|
12489
|
-
|
|
13026
|
+
// TODO: [main] !!! Claude 1 and 2 has also completion versions - ask Hoagy
|
|
13027
|
+
],
|
|
13028
|
+
});
|
|
12490
13029
|
/**
|
|
12491
13030
|
* Note: [🤖] Add models of new variant
|
|
12492
13031
|
* TODO: [🧠][main] !!! Add embedding models OR Anthropic has only chat+completion models?
|
|
@@ -12706,18 +13245,23 @@
|
|
|
12706
13245
|
// eslint-disable-next-line prefer-const
|
|
12707
13246
|
complete = $getCurrentDate();
|
|
12708
13247
|
usage = computeAnthropicClaudeUsage(rawPromptContent || '', resultContent || '', rawResponse);
|
|
12709
|
-
return [2 /*return*/,
|
|
12710
|
-
|
|
12711
|
-
|
|
12712
|
-
|
|
12713
|
-
|
|
12714
|
-
|
|
13248
|
+
return [2 /*return*/, exportJson({
|
|
13249
|
+
name: 'promptResult',
|
|
13250
|
+
message: "Result of `AzureOpenAiExecutionTools.callChatModel`",
|
|
13251
|
+
order: [],
|
|
13252
|
+
value: {
|
|
13253
|
+
content: resultContent,
|
|
13254
|
+
modelName: rawResponse.model,
|
|
13255
|
+
timing: {
|
|
13256
|
+
start: start,
|
|
13257
|
+
complete: complete,
|
|
13258
|
+
},
|
|
13259
|
+
usage: usage,
|
|
13260
|
+
rawPromptContent: rawPromptContent,
|
|
13261
|
+
rawRequest: rawRequest,
|
|
13262
|
+
rawResponse: rawResponse,
|
|
13263
|
+
// <- [🗯]
|
|
12715
13264
|
},
|
|
12716
|
-
usage: usage,
|
|
12717
|
-
rawPromptContent: rawPromptContent,
|
|
12718
|
-
rawRequest: rawRequest,
|
|
12719
|
-
rawResponse: rawResponse,
|
|
12720
|
-
// <- [🗯]
|
|
12721
13265
|
})];
|
|
12722
13266
|
}
|
|
12723
13267
|
});
|
|
@@ -12787,7 +13331,7 @@
|
|
|
12787
13331
|
|
|
12788
13332
|
|
|
12789
13333
|
|
|
12790
|
-
return $
|
|
13334
|
+
return $exportJson({ name: 'promptResult',message: Result of \`AzureOpenAiExecutionTools callChatModel\`, order: [],value:{
|
|
12791
13335
|
content: resultContent,
|
|
12792
13336
|
modelName: rawResponse.model || model,
|
|
12793
13337
|
timing: {
|
|
@@ -12956,381 +13500,384 @@
|
|
|
12956
13500
|
* @see https://openai.com/api/pricing/
|
|
12957
13501
|
* @public exported from `@promptbook/openai`
|
|
12958
13502
|
*/
|
|
12959
|
-
var OPENAI_MODELS =
|
|
12960
|
-
|
|
13503
|
+
var OPENAI_MODELS = exportJson({
|
|
13504
|
+
name: 'OPENAI_MODELS',
|
|
13505
|
+
value: [
|
|
13506
|
+
/*/
|
|
13507
|
+
{
|
|
13508
|
+
modelTitle: 'dall-e-3',
|
|
13509
|
+
modelName: 'dall-e-3',
|
|
13510
|
+
},
|
|
13511
|
+
/**/
|
|
13512
|
+
/*/
|
|
13513
|
+
{
|
|
13514
|
+
modelTitle: 'whisper-1',
|
|
13515
|
+
modelName: 'whisper-1',
|
|
13516
|
+
},
|
|
13517
|
+
/**/
|
|
13518
|
+
/**/
|
|
13519
|
+
{
|
|
13520
|
+
modelVariant: 'COMPLETION',
|
|
13521
|
+
modelTitle: 'davinci-002',
|
|
13522
|
+
modelName: 'davinci-002',
|
|
13523
|
+
pricing: {
|
|
13524
|
+
prompt: computeUsage("$2.00 / 1M tokens"),
|
|
13525
|
+
output: computeUsage("$2.00 / 1M tokens"), // <- not sure
|
|
13526
|
+
},
|
|
13527
|
+
},
|
|
13528
|
+
/**/
|
|
13529
|
+
/*/
|
|
13530
|
+
{
|
|
13531
|
+
modelTitle: 'dall-e-2',
|
|
13532
|
+
modelName: 'dall-e-2',
|
|
13533
|
+
},
|
|
13534
|
+
/**/
|
|
13535
|
+
/**/
|
|
13536
|
+
{
|
|
13537
|
+
modelVariant: 'CHAT',
|
|
13538
|
+
modelTitle: 'gpt-3.5-turbo-16k',
|
|
13539
|
+
modelName: 'gpt-3.5-turbo-16k',
|
|
13540
|
+
pricing: {
|
|
13541
|
+
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
13542
|
+
output: computeUsage("$4.00 / 1M tokens"),
|
|
13543
|
+
},
|
|
13544
|
+
},
|
|
13545
|
+
/**/
|
|
13546
|
+
/*/
|
|
12961
13547
|
{
|
|
12962
|
-
modelTitle: '
|
|
12963
|
-
modelName: '
|
|
13548
|
+
modelTitle: 'tts-1-hd-1106',
|
|
13549
|
+
modelName: 'tts-1-hd-1106',
|
|
12964
13550
|
},
|
|
12965
13551
|
/**/
|
|
12966
|
-
|
|
13552
|
+
/*/
|
|
12967
13553
|
{
|
|
12968
|
-
modelTitle: '
|
|
12969
|
-
modelName: '
|
|
13554
|
+
modelTitle: 'tts-1-hd',
|
|
13555
|
+
modelName: 'tts-1-hd',
|
|
12970
13556
|
},
|
|
12971
|
-
|
|
12972
|
-
|
|
12973
|
-
|
|
12974
|
-
|
|
12975
|
-
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
},
|
|
12982
|
-
/**/
|
|
12983
|
-
/*/
|
|
12984
|
-
{
|
|
12985
|
-
modelTitle: 'dall-e-2',
|
|
12986
|
-
modelName: 'dall-e-2',
|
|
12987
|
-
},
|
|
12988
|
-
/**/
|
|
12989
|
-
/**/
|
|
12990
|
-
{
|
|
12991
|
-
modelVariant: 'CHAT',
|
|
12992
|
-
modelTitle: 'gpt-3.5-turbo-16k',
|
|
12993
|
-
modelName: 'gpt-3.5-turbo-16k',
|
|
12994
|
-
pricing: {
|
|
12995
|
-
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
12996
|
-
output: computeUsage("$4.00 / 1M tokens"),
|
|
12997
|
-
},
|
|
12998
|
-
},
|
|
12999
|
-
/**/
|
|
13000
|
-
/*/
|
|
13001
|
-
{
|
|
13002
|
-
modelTitle: 'tts-1-hd-1106',
|
|
13003
|
-
modelName: 'tts-1-hd-1106',
|
|
13004
|
-
},
|
|
13005
|
-
/**/
|
|
13006
|
-
/*/
|
|
13007
|
-
{
|
|
13008
|
-
modelTitle: 'tts-1-hd',
|
|
13009
|
-
modelName: 'tts-1-hd',
|
|
13010
|
-
},
|
|
13011
|
-
/**/
|
|
13012
|
-
/**/
|
|
13013
|
-
{
|
|
13014
|
-
modelVariant: 'CHAT',
|
|
13015
|
-
modelTitle: 'gpt-4',
|
|
13016
|
-
modelName: 'gpt-4',
|
|
13017
|
-
pricing: {
|
|
13018
|
-
prompt: computeUsage("$30.00 / 1M tokens"),
|
|
13019
|
-
output: computeUsage("$60.00 / 1M tokens"),
|
|
13557
|
+
/**/
|
|
13558
|
+
/**/
|
|
13559
|
+
{
|
|
13560
|
+
modelVariant: 'CHAT',
|
|
13561
|
+
modelTitle: 'gpt-4',
|
|
13562
|
+
modelName: 'gpt-4',
|
|
13563
|
+
pricing: {
|
|
13564
|
+
prompt: computeUsage("$30.00 / 1M tokens"),
|
|
13565
|
+
output: computeUsage("$60.00 / 1M tokens"),
|
|
13566
|
+
},
|
|
13020
13567
|
},
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
|
|
13026
|
-
|
|
13027
|
-
|
|
13028
|
-
|
|
13029
|
-
|
|
13030
|
-
|
|
13568
|
+
/**/
|
|
13569
|
+
/**/
|
|
13570
|
+
{
|
|
13571
|
+
modelVariant: 'CHAT',
|
|
13572
|
+
modelTitle: 'gpt-4-32k',
|
|
13573
|
+
modelName: 'gpt-4-32k',
|
|
13574
|
+
pricing: {
|
|
13575
|
+
prompt: computeUsage("$60.00 / 1M tokens"),
|
|
13576
|
+
output: computeUsage("$120.00 / 1M tokens"),
|
|
13577
|
+
},
|
|
13031
13578
|
},
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
13037
|
-
|
|
13038
|
-
|
|
13039
|
-
|
|
13040
|
-
|
|
13041
|
-
|
|
13579
|
+
/**/
|
|
13580
|
+
/*/
|
|
13581
|
+
{
|
|
13582
|
+
modelVariant: 'CHAT',
|
|
13583
|
+
modelTitle: 'gpt-4-0613',
|
|
13584
|
+
modelName: 'gpt-4-0613',
|
|
13585
|
+
pricing: {
|
|
13586
|
+
prompt: computeUsage(` / 1M tokens`),
|
|
13587
|
+
output: computeUsage(` / 1M tokens`),
|
|
13588
|
+
},
|
|
13042
13589
|
},
|
|
13043
|
-
|
|
13044
|
-
|
|
13045
|
-
|
|
13046
|
-
|
|
13047
|
-
|
|
13048
|
-
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13590
|
+
/**/
|
|
13591
|
+
/**/
|
|
13592
|
+
{
|
|
13593
|
+
modelVariant: 'CHAT',
|
|
13594
|
+
modelTitle: 'gpt-4-turbo-2024-04-09',
|
|
13595
|
+
modelName: 'gpt-4-turbo-2024-04-09',
|
|
13596
|
+
pricing: {
|
|
13597
|
+
prompt: computeUsage("$10.00 / 1M tokens"),
|
|
13598
|
+
output: computeUsage("$30.00 / 1M tokens"),
|
|
13599
|
+
},
|
|
13053
13600
|
},
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13062
|
-
|
|
13063
|
-
|
|
13601
|
+
/**/
|
|
13602
|
+
/**/
|
|
13603
|
+
{
|
|
13604
|
+
modelVariant: 'CHAT',
|
|
13605
|
+
modelTitle: 'gpt-3.5-turbo-1106',
|
|
13606
|
+
modelName: 'gpt-3.5-turbo-1106',
|
|
13607
|
+
pricing: {
|
|
13608
|
+
prompt: computeUsage("$1.00 / 1M tokens"),
|
|
13609
|
+
output: computeUsage("$2.00 / 1M tokens"),
|
|
13610
|
+
},
|
|
13064
13611
|
},
|
|
13065
|
-
|
|
13066
|
-
|
|
13067
|
-
|
|
13068
|
-
|
|
13069
|
-
|
|
13070
|
-
|
|
13071
|
-
|
|
13072
|
-
|
|
13073
|
-
|
|
13074
|
-
|
|
13612
|
+
/**/
|
|
13613
|
+
/**/
|
|
13614
|
+
{
|
|
13615
|
+
modelVariant: 'CHAT',
|
|
13616
|
+
modelTitle: 'gpt-4-turbo',
|
|
13617
|
+
modelName: 'gpt-4-turbo',
|
|
13618
|
+
pricing: {
|
|
13619
|
+
prompt: computeUsage("$10.00 / 1M tokens"),
|
|
13620
|
+
output: computeUsage("$30.00 / 1M tokens"),
|
|
13621
|
+
},
|
|
13075
13622
|
},
|
|
13076
|
-
|
|
13077
|
-
|
|
13078
|
-
|
|
13079
|
-
|
|
13080
|
-
|
|
13081
|
-
|
|
13082
|
-
|
|
13083
|
-
|
|
13084
|
-
|
|
13085
|
-
|
|
13623
|
+
/**/
|
|
13624
|
+
/**/
|
|
13625
|
+
{
|
|
13626
|
+
modelVariant: 'COMPLETION',
|
|
13627
|
+
modelTitle: 'gpt-3.5-turbo-instruct-0914',
|
|
13628
|
+
modelName: 'gpt-3.5-turbo-instruct-0914',
|
|
13629
|
+
pricing: {
|
|
13630
|
+
prompt: computeUsage("$1.50 / 1M tokens"),
|
|
13631
|
+
output: computeUsage("$2.00 / 1M tokens"), // <- For gpt-3.5-turbo-instruct
|
|
13632
|
+
},
|
|
13086
13633
|
},
|
|
13087
|
-
|
|
13088
|
-
|
|
13089
|
-
|
|
13090
|
-
|
|
13091
|
-
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
|
|
13095
|
-
|
|
13096
|
-
|
|
13634
|
+
/**/
|
|
13635
|
+
/**/
|
|
13636
|
+
{
|
|
13637
|
+
modelVariant: 'COMPLETION',
|
|
13638
|
+
modelTitle: 'gpt-3.5-turbo-instruct',
|
|
13639
|
+
modelName: 'gpt-3.5-turbo-instruct',
|
|
13640
|
+
pricing: {
|
|
13641
|
+
prompt: computeUsage("$1.50 / 1M tokens"),
|
|
13642
|
+
output: computeUsage("$2.00 / 1M tokens"),
|
|
13643
|
+
},
|
|
13097
13644
|
},
|
|
13098
|
-
|
|
13099
|
-
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
|
|
13107
|
-
|
|
13108
|
-
|
|
13109
|
-
|
|
13110
|
-
|
|
13111
|
-
|
|
13112
|
-
|
|
13113
|
-
|
|
13645
|
+
/**/
|
|
13646
|
+
/*/
|
|
13647
|
+
{
|
|
13648
|
+
modelTitle: 'tts-1',
|
|
13649
|
+
modelName: 'tts-1',
|
|
13650
|
+
},
|
|
13651
|
+
/**/
|
|
13652
|
+
/**/
|
|
13653
|
+
{
|
|
13654
|
+
modelVariant: 'CHAT',
|
|
13655
|
+
modelTitle: 'gpt-3.5-turbo',
|
|
13656
|
+
modelName: 'gpt-3.5-turbo',
|
|
13657
|
+
pricing: {
|
|
13658
|
+
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
13659
|
+
output: computeUsage("$6.00 / 1M tokens"), // <- Not sure, refer to gpt-3.5-turbo in Fine-tuning models
|
|
13660
|
+
},
|
|
13114
13661
|
},
|
|
13115
|
-
|
|
13116
|
-
|
|
13117
|
-
|
|
13118
|
-
|
|
13119
|
-
|
|
13120
|
-
|
|
13121
|
-
|
|
13122
|
-
|
|
13123
|
-
|
|
13124
|
-
|
|
13662
|
+
/**/
|
|
13663
|
+
/**/
|
|
13664
|
+
{
|
|
13665
|
+
modelVariant: 'CHAT',
|
|
13666
|
+
modelTitle: 'gpt-3.5-turbo-0301',
|
|
13667
|
+
modelName: 'gpt-3.5-turbo-0301',
|
|
13668
|
+
pricing: {
|
|
13669
|
+
prompt: computeUsage("$1.50 / 1M tokens"),
|
|
13670
|
+
output: computeUsage("$2.00 / 1M tokens"),
|
|
13671
|
+
},
|
|
13125
13672
|
},
|
|
13126
|
-
|
|
13127
|
-
|
|
13128
|
-
|
|
13129
|
-
|
|
13130
|
-
|
|
13131
|
-
|
|
13132
|
-
|
|
13133
|
-
|
|
13134
|
-
|
|
13135
|
-
|
|
13673
|
+
/**/
|
|
13674
|
+
/**/
|
|
13675
|
+
{
|
|
13676
|
+
modelVariant: 'COMPLETION',
|
|
13677
|
+
modelTitle: 'babbage-002',
|
|
13678
|
+
modelName: 'babbage-002',
|
|
13679
|
+
pricing: {
|
|
13680
|
+
prompt: computeUsage("$0.40 / 1M tokens"),
|
|
13681
|
+
output: computeUsage("$0.40 / 1M tokens"), // <- Not sure
|
|
13682
|
+
},
|
|
13136
13683
|
},
|
|
13137
|
-
|
|
13138
|
-
|
|
13139
|
-
|
|
13140
|
-
|
|
13141
|
-
|
|
13142
|
-
|
|
13143
|
-
|
|
13144
|
-
|
|
13145
|
-
|
|
13146
|
-
|
|
13684
|
+
/**/
|
|
13685
|
+
/**/
|
|
13686
|
+
{
|
|
13687
|
+
modelVariant: 'CHAT',
|
|
13688
|
+
modelTitle: 'gpt-4-1106-preview',
|
|
13689
|
+
modelName: 'gpt-4-1106-preview',
|
|
13690
|
+
pricing: {
|
|
13691
|
+
prompt: computeUsage("$10.00 / 1M tokens"),
|
|
13692
|
+
output: computeUsage("$30.00 / 1M tokens"),
|
|
13693
|
+
},
|
|
13147
13694
|
},
|
|
13148
|
-
|
|
13149
|
-
|
|
13150
|
-
|
|
13151
|
-
|
|
13152
|
-
|
|
13153
|
-
|
|
13154
|
-
|
|
13155
|
-
|
|
13156
|
-
|
|
13157
|
-
|
|
13695
|
+
/**/
|
|
13696
|
+
/**/
|
|
13697
|
+
{
|
|
13698
|
+
modelVariant: 'CHAT',
|
|
13699
|
+
modelTitle: 'gpt-4-0125-preview',
|
|
13700
|
+
modelName: 'gpt-4-0125-preview',
|
|
13701
|
+
pricing: {
|
|
13702
|
+
prompt: computeUsage("$10.00 / 1M tokens"),
|
|
13703
|
+
output: computeUsage("$30.00 / 1M tokens"),
|
|
13704
|
+
},
|
|
13158
13705
|
},
|
|
13159
|
-
|
|
13160
|
-
|
|
13161
|
-
|
|
13162
|
-
|
|
13163
|
-
|
|
13164
|
-
|
|
13165
|
-
|
|
13166
|
-
|
|
13167
|
-
|
|
13168
|
-
|
|
13169
|
-
|
|
13170
|
-
|
|
13171
|
-
|
|
13172
|
-
|
|
13173
|
-
|
|
13174
|
-
|
|
13706
|
+
/**/
|
|
13707
|
+
/*/
|
|
13708
|
+
{
|
|
13709
|
+
modelTitle: 'tts-1-1106',
|
|
13710
|
+
modelName: 'tts-1-1106',
|
|
13711
|
+
},
|
|
13712
|
+
/**/
|
|
13713
|
+
/**/
|
|
13714
|
+
{
|
|
13715
|
+
modelVariant: 'CHAT',
|
|
13716
|
+
modelTitle: 'gpt-3.5-turbo-0125',
|
|
13717
|
+
modelName: 'gpt-3.5-turbo-0125',
|
|
13718
|
+
pricing: {
|
|
13719
|
+
prompt: computeUsage("$0.50 / 1M tokens"),
|
|
13720
|
+
output: computeUsage("$1.50 / 1M tokens"),
|
|
13721
|
+
},
|
|
13175
13722
|
},
|
|
13176
|
-
|
|
13177
|
-
|
|
13178
|
-
|
|
13179
|
-
|
|
13180
|
-
|
|
13181
|
-
|
|
13182
|
-
|
|
13183
|
-
|
|
13184
|
-
|
|
13185
|
-
|
|
13723
|
+
/**/
|
|
13724
|
+
/**/
|
|
13725
|
+
{
|
|
13726
|
+
modelVariant: 'CHAT',
|
|
13727
|
+
modelTitle: 'gpt-4-turbo-preview',
|
|
13728
|
+
modelName: 'gpt-4-turbo-preview',
|
|
13729
|
+
pricing: {
|
|
13730
|
+
prompt: computeUsage("$10.00 / 1M tokens"),
|
|
13731
|
+
output: computeUsage("$30.00 / 1M tokens"), // <- Not sure, just for gpt-4-turbo
|
|
13732
|
+
},
|
|
13186
13733
|
},
|
|
13187
|
-
|
|
13188
|
-
|
|
13189
|
-
|
|
13190
|
-
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
|
|
13194
|
-
|
|
13195
|
-
|
|
13196
|
-
|
|
13197
|
-
|
|
13734
|
+
/**/
|
|
13735
|
+
/**/
|
|
13736
|
+
{
|
|
13737
|
+
modelVariant: 'EMBEDDING',
|
|
13738
|
+
modelTitle: 'text-embedding-3-large',
|
|
13739
|
+
modelName: 'text-embedding-3-large',
|
|
13740
|
+
pricing: {
|
|
13741
|
+
prompt: computeUsage("$0.13 / 1M tokens"),
|
|
13742
|
+
// TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
|
|
13743
|
+
output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
|
|
13744
|
+
},
|
|
13198
13745
|
},
|
|
13199
|
-
|
|
13200
|
-
|
|
13201
|
-
|
|
13202
|
-
|
|
13203
|
-
|
|
13204
|
-
|
|
13205
|
-
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13746
|
+
/**/
|
|
13747
|
+
/**/
|
|
13748
|
+
{
|
|
13749
|
+
modelVariant: 'EMBEDDING',
|
|
13750
|
+
modelTitle: 'text-embedding-3-small',
|
|
13751
|
+
modelName: 'text-embedding-3-small',
|
|
13752
|
+
pricing: {
|
|
13753
|
+
prompt: computeUsage("$0.02 / 1M tokens"),
|
|
13754
|
+
// TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
|
|
13755
|
+
output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
|
|
13756
|
+
},
|
|
13210
13757
|
},
|
|
13211
|
-
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
|
|
13215
|
-
|
|
13216
|
-
|
|
13217
|
-
|
|
13218
|
-
|
|
13219
|
-
|
|
13220
|
-
|
|
13758
|
+
/**/
|
|
13759
|
+
/**/
|
|
13760
|
+
{
|
|
13761
|
+
modelVariant: 'CHAT',
|
|
13762
|
+
modelTitle: 'gpt-3.5-turbo-0613',
|
|
13763
|
+
modelName: 'gpt-3.5-turbo-0613',
|
|
13764
|
+
pricing: {
|
|
13765
|
+
prompt: computeUsage("$1.50 / 1M tokens"),
|
|
13766
|
+
output: computeUsage("$2.00 / 1M tokens"),
|
|
13767
|
+
},
|
|
13221
13768
|
},
|
|
13222
|
-
|
|
13223
|
-
|
|
13224
|
-
|
|
13225
|
-
|
|
13226
|
-
|
|
13227
|
-
|
|
13228
|
-
|
|
13229
|
-
|
|
13230
|
-
|
|
13231
|
-
|
|
13232
|
-
|
|
13769
|
+
/**/
|
|
13770
|
+
/**/
|
|
13771
|
+
{
|
|
13772
|
+
modelVariant: 'EMBEDDING',
|
|
13773
|
+
modelTitle: 'text-embedding-ada-002',
|
|
13774
|
+
modelName: 'text-embedding-ada-002',
|
|
13775
|
+
pricing: {
|
|
13776
|
+
prompt: computeUsage("$0.1 / 1M tokens"),
|
|
13777
|
+
// TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
|
|
13778
|
+
output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
|
|
13779
|
+
},
|
|
13233
13780
|
},
|
|
13234
|
-
|
|
13235
|
-
|
|
13236
|
-
|
|
13237
|
-
|
|
13238
|
-
|
|
13239
|
-
|
|
13240
|
-
modelName: 'gpt-4-1106-vision-preview',
|
|
13241
|
-
},
|
|
13242
|
-
/**/
|
|
13243
|
-
/*/
|
|
13244
|
-
{
|
|
13245
|
-
modelVariant: 'CHAT',
|
|
13246
|
-
modelTitle: 'gpt-4-vision-preview',
|
|
13247
|
-
modelName: 'gpt-4-vision-preview',
|
|
13248
|
-
pricing: {
|
|
13249
|
-
prompt: computeUsage(`$10.00 / 1M tokens`),
|
|
13250
|
-
output: computeUsage(`$30.00 / 1M tokens`),
|
|
13781
|
+
/**/
|
|
13782
|
+
/*/
|
|
13783
|
+
{
|
|
13784
|
+
modelVariant: 'CHAT',
|
|
13785
|
+
modelTitle: 'gpt-4-1106-vision-preview',
|
|
13786
|
+
modelName: 'gpt-4-1106-vision-preview',
|
|
13251
13787
|
},
|
|
13252
|
-
|
|
13253
|
-
|
|
13254
|
-
|
|
13255
|
-
|
|
13256
|
-
|
|
13257
|
-
|
|
13258
|
-
|
|
13259
|
-
|
|
13260
|
-
|
|
13261
|
-
|
|
13788
|
+
/**/
|
|
13789
|
+
/*/
|
|
13790
|
+
{
|
|
13791
|
+
modelVariant: 'CHAT',
|
|
13792
|
+
modelTitle: 'gpt-4-vision-preview',
|
|
13793
|
+
modelName: 'gpt-4-vision-preview',
|
|
13794
|
+
pricing: {
|
|
13795
|
+
prompt: computeUsage(`$10.00 / 1M tokens`),
|
|
13796
|
+
output: computeUsage(`$30.00 / 1M tokens`),
|
|
13797
|
+
},
|
|
13798
|
+
},
|
|
13799
|
+
/**/
|
|
13800
|
+
/**/
|
|
13801
|
+
{
|
|
13802
|
+
modelVariant: 'CHAT',
|
|
13803
|
+
modelTitle: 'gpt-4o-2024-05-13',
|
|
13804
|
+
modelName: 'gpt-4o-2024-05-13',
|
|
13805
|
+
pricing: {
|
|
13806
|
+
prompt: computeUsage("$5.00 / 1M tokens"),
|
|
13807
|
+
output: computeUsage("$15.00 / 1M tokens"),
|
|
13808
|
+
},
|
|
13809
|
+
//TODO: [main] !!! Add gpt-4o-mini-2024-07-18 and all others to be up to date
|
|
13262
13810
|
},
|
|
13263
|
-
|
|
13264
|
-
|
|
13265
|
-
|
|
13266
|
-
|
|
13267
|
-
|
|
13268
|
-
|
|
13269
|
-
|
|
13270
|
-
|
|
13271
|
-
|
|
13272
|
-
|
|
13273
|
-
output: computeUsage("$15.00 / 1M tokens"),
|
|
13811
|
+
/**/
|
|
13812
|
+
/**/
|
|
13813
|
+
{
|
|
13814
|
+
modelVariant: 'CHAT',
|
|
13815
|
+
modelTitle: 'gpt-4o',
|
|
13816
|
+
modelName: 'gpt-4o',
|
|
13817
|
+
pricing: {
|
|
13818
|
+
prompt: computeUsage("$5.00 / 1M tokens"),
|
|
13819
|
+
output: computeUsage("$15.00 / 1M tokens"),
|
|
13820
|
+
},
|
|
13274
13821
|
},
|
|
13275
|
-
|
|
13276
|
-
|
|
13277
|
-
|
|
13278
|
-
|
|
13279
|
-
|
|
13280
|
-
|
|
13281
|
-
|
|
13282
|
-
|
|
13283
|
-
|
|
13284
|
-
|
|
13822
|
+
/**/
|
|
13823
|
+
/**/
|
|
13824
|
+
{
|
|
13825
|
+
modelVariant: 'CHAT',
|
|
13826
|
+
modelTitle: 'o1-preview',
|
|
13827
|
+
modelName: 'o1-preview',
|
|
13828
|
+
pricing: {
|
|
13829
|
+
prompt: computeUsage("$15.00 / 1M tokens"),
|
|
13830
|
+
output: computeUsage("$60.00 / 1M tokens"),
|
|
13831
|
+
},
|
|
13285
13832
|
},
|
|
13286
|
-
|
|
13287
|
-
|
|
13288
|
-
|
|
13289
|
-
|
|
13290
|
-
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
|
|
13294
|
-
|
|
13295
|
-
|
|
13296
|
-
|
|
13833
|
+
/**/
|
|
13834
|
+
/**/
|
|
13835
|
+
{
|
|
13836
|
+
modelVariant: 'CHAT',
|
|
13837
|
+
modelTitle: 'o1-preview-2024-09-12',
|
|
13838
|
+
modelName: 'o1-preview-2024-09-12',
|
|
13839
|
+
// <- TODO: [💩] Some better system to organize theese date suffixes and versions
|
|
13840
|
+
pricing: {
|
|
13841
|
+
prompt: computeUsage("$15.00 / 1M tokens"),
|
|
13842
|
+
output: computeUsage("$60.00 / 1M tokens"),
|
|
13843
|
+
},
|
|
13297
13844
|
},
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
|
|
13301
|
-
|
|
13302
|
-
|
|
13303
|
-
|
|
13304
|
-
|
|
13305
|
-
|
|
13306
|
-
|
|
13307
|
-
|
|
13845
|
+
/**/
|
|
13846
|
+
/**/
|
|
13847
|
+
{
|
|
13848
|
+
modelVariant: 'CHAT',
|
|
13849
|
+
modelTitle: 'o1-mini',
|
|
13850
|
+
modelName: 'o1-mini',
|
|
13851
|
+
pricing: {
|
|
13852
|
+
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
13853
|
+
output: computeUsage("$12.00 / 1M tokens"),
|
|
13854
|
+
},
|
|
13308
13855
|
},
|
|
13309
|
-
|
|
13310
|
-
|
|
13311
|
-
|
|
13312
|
-
|
|
13313
|
-
|
|
13314
|
-
|
|
13315
|
-
|
|
13316
|
-
|
|
13317
|
-
|
|
13318
|
-
|
|
13856
|
+
/**/
|
|
13857
|
+
/**/
|
|
13858
|
+
{
|
|
13859
|
+
modelVariant: 'CHAT',
|
|
13860
|
+
modelTitle: 'o1-mini-2024-09-12',
|
|
13861
|
+
modelName: 'o1-mini-2024-09-12',
|
|
13862
|
+
pricing: {
|
|
13863
|
+
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
13864
|
+
output: computeUsage("$12.00 / 1M tokens"),
|
|
13865
|
+
},
|
|
13319
13866
|
},
|
|
13320
|
-
|
|
13321
|
-
|
|
13322
|
-
|
|
13323
|
-
|
|
13324
|
-
|
|
13325
|
-
|
|
13326
|
-
|
|
13327
|
-
|
|
13328
|
-
|
|
13329
|
-
|
|
13867
|
+
/**/
|
|
13868
|
+
/**/
|
|
13869
|
+
{
|
|
13870
|
+
modelVariant: 'CHAT',
|
|
13871
|
+
modelTitle: 'gpt-3.5-turbo-16k-0613',
|
|
13872
|
+
modelName: 'gpt-3.5-turbo-16k-0613',
|
|
13873
|
+
pricing: {
|
|
13874
|
+
prompt: computeUsage("$3.00 / 1M tokens"),
|
|
13875
|
+
output: computeUsage("$4.00 / 1M tokens"),
|
|
13876
|
+
},
|
|
13330
13877
|
},
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
13878
|
+
/**/
|
|
13879
|
+
],
|
|
13880
|
+
});
|
|
13334
13881
|
/**
|
|
13335
13882
|
* Note: [🤖] Add models of new variant
|
|
13336
13883
|
* TODO: [🧠] Some mechanism to propagate unsureness
|
|
@@ -13505,18 +14052,23 @@
|
|
|
13505
14052
|
input: __assign({ tokensCount: uncertainNumber((_b = rawResponse.usage) === null || _b === void 0 ? void 0 : _b.promptTokens) }, computeUsageCounts(prompt.content)),
|
|
13506
14053
|
output: __assign({ tokensCount: uncertainNumber((_c = rawResponse.usage) === null || _c === void 0 ? void 0 : _c.completionTokens) }, computeUsageCounts(prompt.content)),
|
|
13507
14054
|
};
|
|
13508
|
-
return [2 /*return*/,
|
|
13509
|
-
|
|
13510
|
-
|
|
13511
|
-
|
|
13512
|
-
|
|
13513
|
-
|
|
14055
|
+
return [2 /*return*/, exportJson({
|
|
14056
|
+
name: 'promptResult',
|
|
14057
|
+
message: "Result of `AzureOpenAiExecutionTools.callChatModel`",
|
|
14058
|
+
order: [],
|
|
14059
|
+
value: {
|
|
14060
|
+
content: resultContent,
|
|
14061
|
+
modelName: modelName,
|
|
14062
|
+
timing: {
|
|
14063
|
+
start: start,
|
|
14064
|
+
complete: complete,
|
|
14065
|
+
},
|
|
14066
|
+
usage: usage,
|
|
14067
|
+
rawPromptContent: rawPromptContent,
|
|
14068
|
+
rawRequest: rawRequest,
|
|
14069
|
+
rawResponse: __assign(__assign({}, rawResponse), { created: rawResponse.created.toISOString() }),
|
|
14070
|
+
// <- [🗯]
|
|
13514
14071
|
},
|
|
13515
|
-
usage: usage,
|
|
13516
|
-
rawPromptContent: rawPromptContent,
|
|
13517
|
-
rawRequest: rawRequest,
|
|
13518
|
-
rawResponse: __assign(__assign({}, rawResponse), { created: rawResponse.created.toISOString() }),
|
|
13519
|
-
// <- [🗯]
|
|
13520
14072
|
})];
|
|
13521
14073
|
case 4:
|
|
13522
14074
|
error_1 = _d.sent();
|
|
@@ -13598,18 +14150,23 @@
|
|
|
13598
14150
|
input: __assign({ tokensCount: uncertainNumber((_b = rawResponse.usage) === null || _b === void 0 ? void 0 : _b.promptTokens) }, computeUsageCounts(prompt.content)),
|
|
13599
14151
|
output: __assign({ tokensCount: uncertainNumber((_c = rawResponse.usage) === null || _c === void 0 ? void 0 : _c.completionTokens) }, computeUsageCounts(prompt.content)),
|
|
13600
14152
|
};
|
|
13601
|
-
return [2 /*return*/,
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
|
|
14153
|
+
return [2 /*return*/, exportJson({
|
|
14154
|
+
name: 'promptResult',
|
|
14155
|
+
message: "Result of `AzureOpenAiExecutionTools.callCompletionModel`",
|
|
14156
|
+
order: [],
|
|
14157
|
+
value: {
|
|
14158
|
+
content: resultContent,
|
|
14159
|
+
modelName: modelName,
|
|
14160
|
+
timing: {
|
|
14161
|
+
start: start,
|
|
14162
|
+
complete: complete,
|
|
14163
|
+
},
|
|
14164
|
+
usage: usage,
|
|
14165
|
+
rawPromptContent: rawPromptContent,
|
|
14166
|
+
rawRequest: rawRequest,
|
|
14167
|
+
rawResponse: __assign(__assign({}, rawResponse), { created: rawResponse.created.toISOString() }),
|
|
14168
|
+
// <- [🗯]
|
|
13607
14169
|
},
|
|
13608
|
-
usage: usage,
|
|
13609
|
-
rawPromptContent: rawPromptContent,
|
|
13610
|
-
rawRequest: rawRequest,
|
|
13611
|
-
rawResponse: __assign(__assign({}, rawResponse), { created: rawResponse.created.toISOString() }),
|
|
13612
|
-
// <- [🗯]
|
|
13613
14170
|
})];
|
|
13614
14171
|
case 4:
|
|
13615
14172
|
error_2 = _d.sent();
|
|
@@ -13824,7 +14381,7 @@
|
|
|
13824
14381
|
return modelVariant === 'CHAT';
|
|
13825
14382
|
})) === null || _a === void 0 ? void 0 : _a.modelName);
|
|
13826
14383
|
if (!modelName) {
|
|
13827
|
-
throw new PipelineExecutionError(spaceTrim__default["default"]("\n Can not determine which model to use.\n\n You need to provide at least one of:\n 1) In `createExecutionToolsFromVercelProvider` options, provide `availableModels` with at least one model\n 2) In `prompt.modelRequirements`, provide `modelName` with the name of the model to use\n
|
|
14384
|
+
throw new PipelineExecutionError(spaceTrim__default["default"]("\n Can not determine which model to use.\n\n You need to provide at least one of:\n 1) In `createExecutionToolsFromVercelProvider` options, provide `availableModels` with at least one model\n 2) In `prompt.modelRequirements`, provide `modelName` with the name of the model to use\n\n "));
|
|
13828
14385
|
}
|
|
13829
14386
|
return [4 /*yield*/, vercelProvider.chat(modelName, __assign({ user: (userId === null || userId === void 0 ? void 0 : userId.toString()) || undefined }, additionalChatSettings))];
|
|
13830
14387
|
case 1:
|
|
@@ -13887,18 +14444,22 @@
|
|
|
13887
14444
|
}
|
|
13888
14445
|
complete = $getCurrentDate();
|
|
13889
14446
|
usage = UNCERTAIN_USAGE;
|
|
13890
|
-
return [2 /*return*/,
|
|
13891
|
-
|
|
13892
|
-
|
|
13893
|
-
|
|
13894
|
-
|
|
13895
|
-
|
|
14447
|
+
return [2 /*return*/, exportJson({
|
|
14448
|
+
name: 'promptResult',
|
|
14449
|
+
message: "Result of `createExecutionToolsFromVercelProvider.callChatModel`",
|
|
14450
|
+
value: {
|
|
14451
|
+
content: rawResponse.text,
|
|
14452
|
+
modelName: modelName,
|
|
14453
|
+
timing: {
|
|
14454
|
+
start: start,
|
|
14455
|
+
complete: complete,
|
|
14456
|
+
},
|
|
14457
|
+
usage: usage,
|
|
14458
|
+
rawPromptContent: rawPromptContent,
|
|
14459
|
+
rawRequest: rawRequest,
|
|
14460
|
+
rawResponse: asSerializable(rawResponse),
|
|
14461
|
+
// <- [🗯]
|
|
13896
14462
|
},
|
|
13897
|
-
usage: usage,
|
|
13898
|
-
rawPromptContent: rawPromptContent,
|
|
13899
|
-
rawRequest: rawRequest,
|
|
13900
|
-
rawResponse: asSerializable(rawResponse),
|
|
13901
|
-
// <- [🗯]
|
|
13902
14463
|
})];
|
|
13903
14464
|
}
|
|
13904
14465
|
});
|
|
@@ -14265,18 +14826,23 @@
|
|
|
14265
14826
|
if (resultContent === null) {
|
|
14266
14827
|
throw new PipelineExecutionError('No response message from OpenAI');
|
|
14267
14828
|
}
|
|
14268
|
-
return [2 /*return*/,
|
|
14269
|
-
|
|
14270
|
-
|
|
14271
|
-
|
|
14272
|
-
|
|
14273
|
-
|
|
14829
|
+
return [2 /*return*/, exportJson({
|
|
14830
|
+
name: 'promptResult',
|
|
14831
|
+
message: "Result of `OpenAiExecutionTools.callChatModel`",
|
|
14832
|
+
order: [],
|
|
14833
|
+
value: {
|
|
14834
|
+
content: resultContent,
|
|
14835
|
+
modelName: rawResponse.model || modelName,
|
|
14836
|
+
timing: {
|
|
14837
|
+
start: start,
|
|
14838
|
+
complete: complete,
|
|
14839
|
+
},
|
|
14840
|
+
usage: usage,
|
|
14841
|
+
rawPromptContent: rawPromptContent,
|
|
14842
|
+
rawRequest: rawRequest,
|
|
14843
|
+
rawResponse: rawResponse,
|
|
14844
|
+
// <- [🗯]
|
|
14274
14845
|
},
|
|
14275
|
-
usage: usage,
|
|
14276
|
-
rawPromptContent: rawPromptContent,
|
|
14277
|
-
rawRequest: rawRequest,
|
|
14278
|
-
rawResponse: rawResponse,
|
|
14279
|
-
// <- [🗯]
|
|
14280
14846
|
})];
|
|
14281
14847
|
}
|
|
14282
14848
|
});
|
|
@@ -14341,18 +14907,23 @@
|
|
|
14341
14907
|
// eslint-disable-next-line prefer-const
|
|
14342
14908
|
complete = $getCurrentDate();
|
|
14343
14909
|
usage = computeOpenAiUsage(content || '', resultContent || '', rawResponse);
|
|
14344
|
-
return [2 /*return*/,
|
|
14345
|
-
|
|
14346
|
-
|
|
14347
|
-
|
|
14348
|
-
|
|
14349
|
-
|
|
14910
|
+
return [2 /*return*/, exportJson({
|
|
14911
|
+
name: 'promptResult',
|
|
14912
|
+
message: "Result of `OpenAiExecutionTools.callCompletionModel`",
|
|
14913
|
+
order: [],
|
|
14914
|
+
value: {
|
|
14915
|
+
content: resultContent,
|
|
14916
|
+
modelName: rawResponse.model || modelName,
|
|
14917
|
+
timing: {
|
|
14918
|
+
start: start,
|
|
14919
|
+
complete: complete,
|
|
14920
|
+
},
|
|
14921
|
+
usage: usage,
|
|
14922
|
+
rawPromptContent: rawPromptContent,
|
|
14923
|
+
rawRequest: rawRequest,
|
|
14924
|
+
rawResponse: rawResponse,
|
|
14925
|
+
// <- [🗯]
|
|
14350
14926
|
},
|
|
14351
|
-
usage: usage,
|
|
14352
|
-
rawPromptContent: rawPromptContent,
|
|
14353
|
-
rawRequest: rawRequest,
|
|
14354
|
-
rawResponse: rawResponse,
|
|
14355
|
-
// <- [🗯]
|
|
14356
14927
|
})];
|
|
14357
14928
|
}
|
|
14358
14929
|
});
|
|
@@ -14409,18 +14980,23 @@
|
|
|
14409
14980
|
usage = computeOpenAiUsage(content || '', '',
|
|
14410
14981
|
// <- Note: Embedding does not have result content
|
|
14411
14982
|
rawResponse);
|
|
14412
|
-
return [2 /*return*/,
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
|
|
14416
|
-
|
|
14417
|
-
|
|
14983
|
+
return [2 /*return*/, exportJson({
|
|
14984
|
+
name: 'promptResult',
|
|
14985
|
+
message: "Result of `OpenAiExecutionTools.callEmbeddingModel`",
|
|
14986
|
+
order: [],
|
|
14987
|
+
value: {
|
|
14988
|
+
content: resultContent,
|
|
14989
|
+
modelName: rawResponse.model || modelName,
|
|
14990
|
+
timing: {
|
|
14991
|
+
start: start,
|
|
14992
|
+
complete: complete,
|
|
14993
|
+
},
|
|
14994
|
+
usage: usage,
|
|
14995
|
+
rawPromptContent: rawPromptContent,
|
|
14996
|
+
rawRequest: rawRequest,
|
|
14997
|
+
rawResponse: rawResponse,
|
|
14998
|
+
// <- [🗯]
|
|
14418
14999
|
},
|
|
14419
|
-
usage: usage,
|
|
14420
|
-
rawPromptContent: rawPromptContent,
|
|
14421
|
-
rawRequest: rawRequest,
|
|
14422
|
-
rawResponse: rawResponse,
|
|
14423
|
-
// <- [🗯]
|
|
14424
15000
|
})];
|
|
14425
15001
|
}
|
|
14426
15002
|
});
|
|
@@ -14616,20 +15192,25 @@
|
|
|
14616
15192
|
if (resultContent === null) {
|
|
14617
15193
|
throw new PipelineExecutionError('No response message from OpenAI');
|
|
14618
15194
|
}
|
|
14619
|
-
return [2 /*return*/,
|
|
14620
|
-
|
|
14621
|
-
|
|
14622
|
-
|
|
14623
|
-
|
|
14624
|
-
|
|
14625
|
-
|
|
14626
|
-
|
|
15195
|
+
return [2 /*return*/, exportJson({
|
|
15196
|
+
name: 'promptResult',
|
|
15197
|
+
message: "Result of `OpenAiAssistantExecutionTools.callChatModel`",
|
|
15198
|
+
order: [],
|
|
15199
|
+
value: {
|
|
15200
|
+
content: resultContent,
|
|
15201
|
+
modelName: 'assistant',
|
|
15202
|
+
// <- TODO: [🥘] Detect used model in assistant
|
|
15203
|
+
// ?> model: rawResponse.model || modelName,
|
|
15204
|
+
timing: {
|
|
15205
|
+
start: start,
|
|
15206
|
+
complete: complete,
|
|
15207
|
+
},
|
|
15208
|
+
usage: usage,
|
|
15209
|
+
rawPromptContent: rawPromptContent,
|
|
15210
|
+
rawRequest: rawRequest,
|
|
15211
|
+
rawResponse: rawResponse,
|
|
15212
|
+
// <- [🗯]
|
|
14627
15213
|
},
|
|
14628
|
-
usage: usage,
|
|
14629
|
-
rawPromptContent: rawPromptContent,
|
|
14630
|
-
rawRequest: rawRequest,
|
|
14631
|
-
rawResponse: rawResponse,
|
|
14632
|
-
// <- [🗯]
|
|
14633
15214
|
})];
|
|
14634
15215
|
}
|
|
14635
15216
|
});
|
|
@@ -14953,7 +15534,7 @@
|
|
|
14953
15534
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
14954
15535
|
isAvilableInBrowser: true,
|
|
14955
15536
|
requiredExecutables: [],
|
|
14956
|
-
}); /* <-
|
|
15537
|
+
}); /* <- Note: [🤛] */
|
|
14957
15538
|
/**
|
|
14958
15539
|
* Registration of known scraper metadata
|
|
14959
15540
|
*
|
|
@@ -15150,7 +15731,7 @@
|
|
|
15150
15731
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
15151
15732
|
isAvilableInBrowser: false,
|
|
15152
15733
|
requiredExecutables: ['Pandoc'],
|
|
15153
|
-
}); /* <-
|
|
15734
|
+
}); /* <- Note: [🤛] */
|
|
15154
15735
|
/**
|
|
15155
15736
|
* Registration of known scraper metadata
|
|
15156
15737
|
*
|
|
@@ -15317,7 +15898,7 @@
|
|
|
15317
15898
|
'LibreOffice',
|
|
15318
15899
|
// <- TODO: [🧠] Should be 'LibreOffice' here, its dependency of dependency
|
|
15319
15900
|
],
|
|
15320
|
-
}); /* <-
|
|
15901
|
+
}); /* <- Note: [🤛] */
|
|
15321
15902
|
/**
|
|
15322
15903
|
* Registration of known scraper metadata
|
|
15323
15904
|
*
|
|
@@ -15483,7 +16064,7 @@
|
|
|
15483
16064
|
*/
|
|
15484
16065
|
var createLegacyDocumentScraper = Object.assign(function (tools, options) {
|
|
15485
16066
|
return new LegacyDocumentScraper(tools, options);
|
|
15486
|
-
}, legacyDocumentScraperMetadata); /* <-
|
|
16067
|
+
}, legacyDocumentScraperMetadata); /* <- Note: [🤛] */
|
|
15487
16068
|
/**
|
|
15488
16069
|
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
15489
16070
|
*/
|
|
@@ -15509,7 +16090,7 @@
|
|
|
15509
16090
|
*/
|
|
15510
16091
|
var createDocumentScraper = Object.assign(function (tools, options) {
|
|
15511
16092
|
return new DocumentScraper(tools, options);
|
|
15512
|
-
}, documentScraperMetadata); /* <-
|
|
16093
|
+
}, documentScraperMetadata); /* <- Note: [🤛] */
|
|
15513
16094
|
/**
|
|
15514
16095
|
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
15515
16096
|
*/
|
|
@@ -15535,7 +16116,7 @@
|
|
|
15535
16116
|
*/
|
|
15536
16117
|
var createMarkdownScraper = Object.assign(function (tools, options) {
|
|
15537
16118
|
return new MarkdownScraper(tools, options);
|
|
15538
|
-
}, markdownScraperMetadata); /* <-
|
|
16119
|
+
}, markdownScraperMetadata); /* <- Note: [🤛] */
|
|
15539
16120
|
/**
|
|
15540
16121
|
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
15541
16122
|
*/
|
|
@@ -15567,7 +16148,7 @@
|
|
|
15567
16148
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
15568
16149
|
isAvilableInBrowser: true,
|
|
15569
16150
|
requiredExecutables: [],
|
|
15570
|
-
}); /* <-
|
|
16151
|
+
}); /* <- Note: [🤛] */
|
|
15571
16152
|
/**
|
|
15572
16153
|
* Registration of known scraper metadata
|
|
15573
16154
|
*
|
|
@@ -15647,7 +16228,7 @@
|
|
|
15647
16228
|
*/
|
|
15648
16229
|
var createPdfScraper = Object.assign(function (tools, options) {
|
|
15649
16230
|
return new PdfScraper(tools, options);
|
|
15650
|
-
}, pdfScraperMetadata); /* <-
|
|
16231
|
+
}, pdfScraperMetadata); /* <- Note: [🤛] */
|
|
15651
16232
|
/**
|
|
15652
16233
|
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
15653
16234
|
*/
|
|
@@ -15679,7 +16260,7 @@
|
|
|
15679
16260
|
documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
|
|
15680
16261
|
isAvilableInBrowser: false,
|
|
15681
16262
|
requiredExecutables: [],
|
|
15682
|
-
}); /* <-
|
|
16263
|
+
}); /* <- Note: [🤛] */
|
|
15683
16264
|
/**
|
|
15684
16265
|
* Registration of known scraper metadata
|
|
15685
16266
|
*
|
|
@@ -15848,7 +16429,7 @@
|
|
|
15848
16429
|
*/
|
|
15849
16430
|
var createWebsiteScraper = Object.assign(function (tools, options) {
|
|
15850
16431
|
return new WebsiteScraper(tools, options);
|
|
15851
|
-
}, websiteScraperMetadata); /* <-
|
|
16432
|
+
}, websiteScraperMetadata); /* <- Note: [🤛] */
|
|
15852
16433
|
/**
|
|
15853
16434
|
* TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
|
|
15854
16435
|
*/
|