@promptbook/cli 0.79.0 → 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.
Files changed (33) hide show
  1. package/README.md +4 -0
  2. package/esm/index.es.js +1277 -885
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/books/index.d.ts +6 -6
  5. package/esm/typings/src/_packages/core.index.d.ts +4 -2
  6. package/esm/typings/src/_packages/types.index.d.ts +10 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +4 -0
  8. package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +32 -0
  9. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +3 -0
  10. package/esm/typings/src/config.d.ts +0 -25
  11. package/esm/typings/src/constants.d.ts +35 -0
  12. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -0
  13. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -0
  14. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +20 -0
  15. package/esm/typings/src/high-level-abstractions/implicit-formfactor/ImplicitFormfactorHla.d.ts +10 -0
  16. package/esm/typings/src/high-level-abstractions/index.d.ts +44 -0
  17. package/esm/typings/src/high-level-abstractions/quick-chatbot/QuickChatbotHla.d.ts +10 -0
  18. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
  19. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  20. package/esm/typings/src/prepare/prepareTasks.d.ts +1 -0
  21. package/esm/typings/src/types/typeAliases.d.ts +1 -1
  22. package/esm/typings/src/utils/normalization/orderJson.d.ts +21 -0
  23. package/esm/typings/src/utils/normalization/orderJson.test.d.ts +4 -0
  24. package/esm/typings/src/utils/organization/keepTypeImported.d.ts +9 -0
  25. package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +1 -1
  26. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +20 -2
  27. package/esm/typings/src/utils/serialization/deepClone.test.d.ts +1 -0
  28. package/esm/typings/src/utils/serialization/exportJson.d.ts +29 -0
  29. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +2 -1
  30. package/package.json +2 -1
  31. package/umd/index.umd.js +1277 -885
  32. package/umd/index.umd.js.map +1 -1
  33. package/esm/typings/src/utils/serialization/$asDeeplyFrozenSerializableJson.d.ts +0 -17
package/esm/index.es.js CHANGED
@@ -37,7 +37,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
37
37
  *
38
38
  * @see https://github.com/webgptorg/promptbook
39
39
  */
40
- var PROMPTBOOK_ENGINE_VERSION = '0.78.4';
40
+ var PROMPTBOOK_ENGINE_VERSION = '0.79.0';
41
41
  /**
42
42
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
43
43
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -308,41 +308,6 @@ var DEFAULT_SCRAPE_CACHE_DIRNAME = './.promptbook/scrape-cache';
308
308
  * @public exported from `@promptbook/core`
309
309
  */
310
310
  var DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME = "index";
311
- /**
312
- * Nonce which is used for replacing things in strings
313
- *
314
- * @private within the repository
315
- */
316
- var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
317
- /**
318
- * The names of the parameters that are reserved for special purposes
319
- *
320
- * @public exported from `@promptbook/core`
321
- */
322
- var RESERVED_PARAMETER_NAMES =
323
- /* !!!!!! $asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', _____ as const); */ [
324
- 'content',
325
- 'context',
326
- 'knowledge',
327
- 'examples',
328
- 'modelName',
329
- 'currentDate',
330
- // <- TODO: list here all command names
331
- // <- TODO: Add more like 'date', 'modelName',...
332
- // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
333
- ];
334
- /**
335
- * @@@
336
- *
337
- * @private within the repository
338
- */
339
- var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
340
- /**
341
- * @@@
342
- *
343
- * @private within the repository
344
- */
345
- var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
346
311
  /**
347
312
  * The thresholds for the relative time in the `moment` NPM package.
348
313
  *
@@ -398,7 +363,6 @@ var IS_PIPELINE_LOGIC_VALIDATED = just(
398
363
  // Note: In normal situations, we check the pipeline logic:
399
364
  true);
400
365
  /**
401
- * TODO: Extract `constants.ts` from `config.ts`
402
366
  * Note: [💞] Ignore a discrepancy between file name and entity name
403
367
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
404
368
  */
@@ -524,6 +488,56 @@ function $provideFilesystemForNode(options) {
524
488
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
525
489
  */
526
490
 
491
+ /**
492
+ * Orders JSON object by keys
493
+ *
494
+ * @returns The same type of object as the input re-ordered
495
+ * @public exported from `@promptbook/utils`
496
+ */
497
+ function orderJson(options) {
498
+ var value = options.value, order = options.order;
499
+ var orderedValue = __assign(__assign({}, (order === undefined ? {} : Object.fromEntries(order.map(function (key) { return [key, undefined]; })))), value);
500
+ return orderedValue;
501
+ }
502
+
503
+ /**
504
+ * Freezes the given object and all its nested objects recursively
505
+ *
506
+ * Note: `$` is used to indicate that this function is not a pure function - it mutates given object
507
+ * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
508
+ *
509
+ * @returns The same object as the input, but deeply frozen
510
+ * @public exported from `@promptbook/utils`
511
+ */
512
+ function $deepFreeze(objectValue) {
513
+ var e_1, _a;
514
+ if (Array.isArray(objectValue)) {
515
+ return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
516
+ }
517
+ var propertyNames = Object.getOwnPropertyNames(objectValue);
518
+ try {
519
+ for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
520
+ var propertyName = propertyNames_1_1.value;
521
+ var value = objectValue[propertyName];
522
+ if (value && typeof value === 'object') {
523
+ $deepFreeze(value);
524
+ }
525
+ }
526
+ }
527
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
528
+ finally {
529
+ try {
530
+ if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
531
+ }
532
+ finally { if (e_1) throw e_1.error; }
533
+ }
534
+ Object.freeze(objectValue);
535
+ return objectValue;
536
+ }
537
+ /**
538
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
539
+ */
540
+
527
541
  /**
528
542
  * Make error report URL for the given error
529
543
  *
@@ -578,8 +592,9 @@ var UnexpectedError = /** @class */ (function (_super) {
578
592
  * @throws UnexpectedError if the value is not serializable as JSON
579
593
  * @public exported from `@promptbook/utils`
580
594
  */
581
- function checkSerializableAsJson(name, value) {
595
+ function checkSerializableAsJson(options) {
582
596
  var e_1, _a;
597
+ var value = options.value, name = options.name, message = options.message;
583
598
  if (value === undefined) {
584
599
  throw new UnexpectedError("".concat(name, " is undefined"));
585
600
  }
@@ -603,12 +618,12 @@ function checkSerializableAsJson(name, value) {
603
618
  }
604
619
  else if (typeof value === 'object' && Array.isArray(value)) {
605
620
  for (var i = 0; i < value.length; i++) {
606
- checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
621
+ checkSerializableAsJson({ name: "".concat(name, "[").concat(i, "]"), value: value[i], message: message });
607
622
  }
608
623
  }
609
624
  else if (typeof value === 'object') {
610
625
  if (value instanceof Date) {
611
- throw new UnexpectedError(spaceTrim("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
626
+ throw new UnexpectedError(spaceTrim(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 "); }));
612
627
  }
613
628
  else if (value instanceof Map) {
614
629
  throw new UnexpectedError("".concat(name, " is Map"));
@@ -620,7 +635,7 @@ function checkSerializableAsJson(name, value) {
620
635
  throw new UnexpectedError("".concat(name, " is RegExp"));
621
636
  }
622
637
  else if (value instanceof Error) {
623
- throw new UnexpectedError(spaceTrim("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
638
+ throw new UnexpectedError(spaceTrim(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 "); }));
624
639
  }
625
640
  else {
626
641
  try {
@@ -630,7 +645,7 @@ function checkSerializableAsJson(name, value) {
630
645
  // Note: undefined in object is serializable - it is just omited
631
646
  continue;
632
647
  }
633
- checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
648
+ checkSerializableAsJson({ name: "".concat(name, ".").concat(subName), value: subValue, message: message });
634
649
  }
635
650
  }
636
651
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -647,7 +662,7 @@ function checkSerializableAsJson(name, value) {
647
662
  if (!(error instanceof Error)) {
648
663
  throw error;
649
664
  }
650
- throw new UnexpectedError(spaceTrim(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
665
+ throw new UnexpectedError(spaceTrim(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 "); }));
651
666
  }
652
667
  /*
653
668
  TODO: [0] Is there some more elegant way to check circular references?
@@ -672,15 +687,134 @@ function checkSerializableAsJson(name, value) {
672
687
  }
673
688
  }
674
689
  else {
675
- throw new UnexpectedError("".concat(name, " is unknown"));
690
+ throw new UnexpectedError(spaceTrim(function (block) { return "\n `".concat(name, "` is unknown type\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
676
691
  }
677
692
  }
678
693
  /**
679
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
694
+ * TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
680
695
  * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
681
696
  * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
682
697
  */
683
698
 
699
+ /**
700
+ * @@@
701
+ *
702
+ * @public exported from `@promptbook/utils`
703
+ */
704
+ function deepClone(objectValue) {
705
+ return JSON.parse(JSON.stringify(objectValue));
706
+ /*
707
+ !!!!!!!!
708
+ TODO: [🧠] Is there a better implementation?
709
+ > const propertyNames = Object.getOwnPropertyNames(objectValue);
710
+ > for (const propertyName of propertyNames) {
711
+ > const value = (objectValue as really_any)[propertyName];
712
+ > if (value && typeof value === 'object') {
713
+ > deepClone(value);
714
+ > }
715
+ > }
716
+ > return Object.assign({}, objectValue);
717
+ */
718
+ }
719
+ /**
720
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
721
+ */
722
+
723
+ /**
724
+ * Utility to export a JSON object from a function
725
+ *
726
+ * 1) Checks if the value is serializable as JSON
727
+ * 2) Makes a deep clone of the object
728
+ * 2) Orders the object properties
729
+ * 2) Deeply freezes the cloned object
730
+ *
731
+ * Note: This function does not mutates the given object
732
+ *
733
+ * @returns The same type of object as the input but read-only and re-ordered
734
+ * @public exported from `@promptbook/utils`
735
+ */
736
+ function exportJson(options) {
737
+ var name = options.name, value = options.value, order = options.order, message = options.message;
738
+ checkSerializableAsJson({ name: name, value: value, message: message });
739
+ var orderedValue =
740
+ // TODO: Fix error "Type instantiation is excessively deep and possibly infinite."
741
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
742
+ // @ts-ignore
743
+ order === undefined
744
+ ? deepClone(value)
745
+ : orderJson({
746
+ value: value,
747
+ // <- Note: checkSerializableAsJson asserts that the value is serializable as JSON
748
+ order: order,
749
+ });
750
+ $deepFreeze(orderedValue);
751
+ return orderedValue;
752
+ }
753
+ /**
754
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
755
+ */
756
+
757
+ /**
758
+ * Order of keys in the pipeline JSON
759
+ *
760
+ * @public exported from `@promptbook/core`
761
+ */
762
+ var ORDER_OF_PIPELINE_JSON = [
763
+ 'title',
764
+ 'pipelineUrl',
765
+ 'bookVersion',
766
+ 'description',
767
+ 'formfactorName',
768
+ 'parameters',
769
+ 'tasks',
770
+ 'personas',
771
+ 'preparations',
772
+ 'knowledgeSources',
773
+ 'knowledgePieces',
774
+ ];
775
+ /**
776
+ * Nonce which is used for replacing things in strings
777
+ *
778
+ * @private within the repository
779
+ */
780
+ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
781
+ /**
782
+ * @@@
783
+ *
784
+ * @private within the repository
785
+ */
786
+ var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
787
+ /**
788
+ * @@@
789
+ *
790
+ * @private within the repository
791
+ */
792
+ var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
793
+ /**
794
+ * The names of the parameters that are reserved for special purposes
795
+ *
796
+ * @public exported from `@promptbook/core`
797
+ */
798
+ var RESERVED_PARAMETER_NAMES = exportJson({
799
+ name: 'RESERVED_PARAMETER_NAMES',
800
+ message: "The names of the parameters that are reserved for special purposes",
801
+ value: [
802
+ 'content',
803
+ 'context',
804
+ 'knowledge',
805
+ 'examples',
806
+ 'modelName',
807
+ 'currentDate',
808
+ // <- TODO: list here all command names
809
+ // <- TODO: Add more like 'date', 'modelName',...
810
+ // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
811
+ ],
812
+ });
813
+ /**
814
+ * Note: [💞] Ignore a discrepancy between file name and entity name
815
+ */
816
+
817
+ // <- TODO: !!!!!!! Auto convert to type `import { ... } from 'type-fest';`
684
818
  /**
685
819
  * Tests if the value is [🚉] serializable as JSON
686
820
  *
@@ -702,7 +836,7 @@ function checkSerializableAsJson(name, value) {
702
836
  */
703
837
  function isSerializableAsJson(value) {
704
838
  try {
705
- checkSerializableAsJson('', value);
839
+ checkSerializableAsJson({ value: value });
706
840
  return true;
707
841
  }
708
842
  catch (error) {
@@ -1500,66 +1634,6 @@ function cacheLlmTools(llmTools, options) {
1500
1634
  * @@@ write how to combine multiple interceptors
1501
1635
  */
1502
1636
 
1503
- /**
1504
- * @@@
1505
- *
1506
- * @public exported from `@promptbook/utils`
1507
- */
1508
- function deepClone(objectValue) {
1509
- return JSON.parse(JSON.stringify(objectValue));
1510
- /*
1511
- TODO: [🧠] Is there a better implementation?
1512
- > const propertyNames = Object.getOwnPropertyNames(objectValue);
1513
- > for (const propertyName of propertyNames) {
1514
- > const value = (objectValue as really_any)[propertyName];
1515
- > if (value && typeof value === 'object') {
1516
- > deepClone(value);
1517
- > }
1518
- > }
1519
- > return Object.assign({}, objectValue);
1520
- */
1521
- }
1522
- /**
1523
- * TODO: [🧠] Is there a way how to meaningfully test this utility
1524
- */
1525
-
1526
- /**
1527
- * @@@
1528
- *
1529
- * Note: `$` is used to indicate that this function is not a pure function - it mutates given object
1530
- * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
1531
- *
1532
- * @returns The same object as the input, but deeply frozen
1533
- * @public exported from `@promptbook/utils`
1534
- */
1535
- function $deepFreeze(objectValue) {
1536
- var e_1, _a;
1537
- if (Array.isArray(objectValue)) {
1538
- return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
1539
- }
1540
- var propertyNames = Object.getOwnPropertyNames(objectValue);
1541
- try {
1542
- for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
1543
- var propertyName = propertyNames_1_1.value;
1544
- var value = objectValue[propertyName];
1545
- if (value && typeof value === 'object') {
1546
- $deepFreeze(value);
1547
- }
1548
- }
1549
- }
1550
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1551
- finally {
1552
- try {
1553
- if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
1554
- }
1555
- finally { if (e_1) throw e_1.error; }
1556
- }
1557
- return Object.freeze(objectValue);
1558
- }
1559
- /**
1560
- * TODO: [🧠] Is there a way how to meaningfully test this utility
1561
- */
1562
-
1563
1637
  /**
1564
1638
  * Represents the usage with no resources consumed
1565
1639
  *
@@ -2624,6 +2698,7 @@ function capitalize(word) {
2624
2698
  /**
2625
2699
  * Converts promptbook in JSON format to string format
2626
2700
  *
2701
+ * @deprecated TODO: [🥍][🧠] Backup original files in `PipelineJson` same as in Promptbook.studio
2627
2702
  * @param pipelineJson Promptbook in JSON format (.book.json)
2628
2703
  * @returns Promptbook in string format (.book.md)
2629
2704
  * @public exported from `@promptbook/core`
@@ -2919,7 +2994,7 @@ function forEachAsync(array, options, callbackfunction) {
2919
2994
  });
2920
2995
  }
2921
2996
 
2922
- 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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],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"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-persona.book.md"}];
2997
+ 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"}];
2923
2998
 
2924
2999
  /**
2925
3000
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
@@ -3164,6 +3239,21 @@ function validatePipelineCore(pipeline) {
3164
3239
  }
3165
3240
  };
3166
3241
  try {
3242
+ /*
3243
+ TODO: [🧠][🅾] Should be empty pipeline valid or not
3244
+ // Note: Check that pipeline has some tasks
3245
+ if (pipeline.tasks.length === 0) {
3246
+ throw new PipelineLogicError(
3247
+ spaceTrim(
3248
+ (block) => `
3249
+ Pipeline must have at least one task
3250
+
3251
+ ${block(pipelineIdentification)}
3252
+ `,
3253
+ ),
3254
+ );
3255
+ }
3256
+ */
3167
3257
  // Note: Check each parameter individually
3168
3258
  for (var _d = __values(pipeline.parameters), _e = _d.next(); !_e.done; _e = _d.next()) {
3169
3259
  var parameter = _e.value;
@@ -3324,6 +3414,9 @@ function validatePipelineCore(pipeline) {
3324
3414
  while (unresovedTasks.length > 0) {
3325
3415
  _loop_3();
3326
3416
  }
3417
+ // Note: Check that formfactor is corresponding to the pipeline interface
3418
+ // TODO: !!!!!! Implement this
3419
+ // pipeline.formfactorName
3327
3420
  }
3328
3421
  /**
3329
3422
  * TODO: !! [🧞‍♀️] Do not allow joker + foreach
@@ -3407,26 +3500,6 @@ function extractParameterNames(template) {
3407
3500
  return parameterNames;
3408
3501
  }
3409
3502
 
3410
- /**
3411
- * @@@
3412
- * @@@
3413
- *
3414
- * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
3415
- *
3416
- * @param name - Name of the object for debugging purposes
3417
- * @param objectValue - Object to be deeply frozen
3418
- * @returns The same object as the input, but deeply frozen
3419
- * @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
3420
- */
3421
- function $asDeeplyFrozenSerializableJson(name, objectValue) {
3422
- checkSerializableAsJson(name, objectValue);
3423
- return $deepFreeze(objectValue);
3424
- }
3425
- /**
3426
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
3427
- * TODO: [🧠] Is there a way how to meaningfully test this utility
3428
- */
3429
-
3430
3503
  /**
3431
3504
  * Unprepare just strips the preparation data of the pipeline
3432
3505
  *
@@ -3444,7 +3517,12 @@ function unpreparePipeline(pipeline) {
3444
3517
  delete taskUnprepared.preparedContent;
3445
3518
  return taskUnprepared;
3446
3519
  });
3447
- return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
3520
+ return exportJson({
3521
+ name: 'pipelineJson',
3522
+ message: "Result of `unpreparePipeline`",
3523
+ order: ORDER_OF_PIPELINE_JSON,
3524
+ value: __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }),
3525
+ });
3448
3526
  }
3449
3527
  /**
3450
3528
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -5512,16 +5590,21 @@ function executePipeline(options) {
5512
5590
  // Note: Wait a short time to prevent race conditions
5513
5591
  _g.sent();
5514
5592
  _g.label = 6;
5515
- case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
5516
- isSuccessful: false,
5517
- errors: __spreadArray([
5518
- new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
5519
- ], __read(errors), false).map(serializeError),
5520
- warnings: [],
5521
- executionReport: executionReport,
5522
- outputParameters: {},
5523
- usage: ZERO_USAGE,
5524
- preparedPipeline: preparedPipeline,
5593
+ case 6: return [2 /*return*/, exportJson({
5594
+ name: "executionReport",
5595
+ message: "Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"),
5596
+ order: [],
5597
+ value: {
5598
+ isSuccessful: false,
5599
+ errors: __spreadArray([
5600
+ new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
5601
+ ], __read(errors), false).map(serializeError),
5602
+ warnings: [],
5603
+ executionReport: executionReport,
5604
+ outputParameters: {},
5605
+ usage: ZERO_USAGE,
5606
+ preparedPipeline: preparedPipeline,
5607
+ },
5525
5608
  })];
5526
5609
  case 7:
5527
5610
  _b = _a.next();
@@ -5560,16 +5643,21 @@ function executePipeline(options) {
5560
5643
  // Note: Wait a short time to prevent race conditions
5561
5644
  _h.sent();
5562
5645
  _h.label = 3;
5563
- case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim$1(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
5564
- isSuccessful: false,
5565
- errors: __spreadArray([
5566
- new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
5567
- ], __read(errors), false).map(serializeError),
5568
- warnings: warnings.map(serializeError),
5569
- executionReport: executionReport,
5570
- outputParameters: {},
5571
- usage: ZERO_USAGE,
5572
- preparedPipeline: preparedPipeline,
5646
+ case 3: return [2 /*return*/, { value: exportJson({
5647
+ name: 'pipelineExecutorResult',
5648
+ message: spaceTrim$1(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }),
5649
+ order: [],
5650
+ value: {
5651
+ isSuccessful: false,
5652
+ errors: __spreadArray([
5653
+ new PipelineExecutionError(spaceTrim$1(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
5654
+ ], __read(errors), false).map(serializeError),
5655
+ warnings: warnings.map(serializeError),
5656
+ executionReport: executionReport,
5657
+ outputParameters: {},
5658
+ usage: ZERO_USAGE,
5659
+ preparedPipeline: preparedPipeline,
5660
+ },
5573
5661
  }) }];
5574
5662
  case 4: return [2 /*return*/];
5575
5663
  }
@@ -5723,14 +5811,19 @@ function executePipeline(options) {
5723
5811
  // Note: Wait a short time to prevent race conditions
5724
5812
  _g.sent();
5725
5813
  _g.label = 27;
5726
- case 27: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
5727
- isSuccessful: false,
5728
- errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
5729
- warnings: warnings.map(serializeError),
5730
- usage: usage_1,
5731
- executionReport: executionReport,
5732
- outputParameters: outputParameters_1,
5733
- preparedPipeline: preparedPipeline,
5814
+ case 27: return [2 /*return*/, exportJson({
5815
+ name: 'pipelineExecutorResult',
5816
+ message: "Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult",
5817
+ order: [],
5818
+ value: {
5819
+ isSuccessful: false,
5820
+ errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
5821
+ warnings: warnings.map(serializeError),
5822
+ usage: usage_1,
5823
+ executionReport: executionReport,
5824
+ outputParameters: outputParameters_1,
5825
+ preparedPipeline: preparedPipeline,
5826
+ },
5734
5827
  })];
5735
5828
  case 28:
5736
5829
  usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
@@ -5751,14 +5844,19 @@ function executePipeline(options) {
5751
5844
  // Note: Wait a short time to prevent race conditions
5752
5845
  _g.sent();
5753
5846
  _g.label = 30;
5754
- case 30: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
5755
- isSuccessful: true,
5756
- errors: errors.map(serializeError),
5757
- warnings: warnings.map(serializeError),
5758
- usage: usage,
5759
- executionReport: executionReport,
5760
- outputParameters: outputParameters,
5761
- preparedPipeline: preparedPipeline,
5847
+ case 30: return [2 /*return*/, exportJson({
5848
+ name: 'pipelineExecutorResult',
5849
+ message: "Successful PipelineExecutorResult",
5850
+ order: [],
5851
+ value: {
5852
+ isSuccessful: true,
5853
+ errors: errors.map(serializeError),
5854
+ warnings: warnings.map(serializeError),
5855
+ usage: usage,
5856
+ executionReport: executionReport,
5857
+ outputParameters: outputParameters,
5858
+ preparedPipeline: preparedPipeline,
5859
+ },
5762
5860
  })];
5763
5861
  }
5764
5862
  });
@@ -6360,36 +6458,6 @@ TODO: [🧊] This is how it can look in future
6360
6458
  * [ ] One piece can have multiple sources
6361
6459
  */
6362
6460
 
6363
- /**
6364
- * @@@
6365
- *
6366
- * Note: It is usefull @@@
6367
- *
6368
- * @param pipeline
6369
- * @public exported from `@promptbook/utils`
6370
- */
6371
- function clonePipeline(pipeline) {
6372
- // Note: Not using spread operator (...) because @@@
6373
- 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;
6374
- return {
6375
- pipelineUrl: pipelineUrl,
6376
- sourceFile: sourceFile,
6377
- title: title,
6378
- bookVersion: bookVersion,
6379
- description: description,
6380
- formfactorName: formfactorName,
6381
- parameters: parameters,
6382
- tasks: tasks,
6383
- knowledgeSources: knowledgeSources,
6384
- knowledgePieces: knowledgePieces,
6385
- personas: personas,
6386
- preparations: preparations,
6387
- };
6388
- }
6389
- /**
6390
- * TODO: [🍙] Make some standard order of json properties
6391
- */
6392
-
6393
6461
  /**
6394
6462
  * @@@
6395
6463
  *
@@ -6430,6 +6498,7 @@ function prepareTasks(pipeline, tools, options) {
6430
6498
  });
6431
6499
  }
6432
6500
  /**
6501
+ * TODO: [😂] Adding knowledge should be convert to async high-level abstractions, simmilar thing with expectations to sync high-level abstractions
6433
6502
  * TODO: [🧠] Add context to each task (if missing)
6434
6503
  * TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
6435
6504
  * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
@@ -6518,11 +6587,19 @@ function preparePipeline(pipeline, tools, options) {
6518
6587
  case 3:
6519
6588
  tasksPrepared = (_c.sent()).tasksPrepared;
6520
6589
  // ----- /Tasks preparation -----
6590
+ // TODO: [😂] Use here all `AsyncHighLevelAbstraction`
6521
6591
  // Note: Count total usage
6522
6592
  currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
6523
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
6524
- // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
6525
- knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
6593
+ return [2 /*return*/, exportJson({
6594
+ name: 'pipelineJson',
6595
+ message: "Result of `preparePipeline`",
6596
+ order: ORDER_OF_PIPELINE_JSON,
6597
+ value: __assign(__assign({}, pipeline), {
6598
+ // <- TODO: Probbably deeply clone the pipeline because `$exportJson` freezes the subobjects
6599
+ knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, tasks: __spreadArray([], __read(tasksPrepared), false),
6600
+ // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
6601
+ personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }),
6602
+ })];
6526
6603
  }
6527
6604
  });
6528
6605
  });
@@ -6537,138 +6614,11 @@ function preparePipeline(pipeline, tools, options) {
6537
6614
  */
6538
6615
 
6539
6616
  /**
6540
- * @@@
6617
+ * All available task types
6541
6618
  *
6542
- * @deprecated https://github.com/webgptorg/promptbook/pull/186
6543
- * @see https://github.com/webgptorg/promptbook/discussions/171
6544
- *
6545
- * @public exported from `@promptbook/core`
6546
- */
6547
- function getPipelineInterface(pipeline) {
6548
- var e_1, _a, e_2, _b;
6549
- var pipelineInterface = {
6550
- inputParameters: [],
6551
- outputParameters: [],
6552
- };
6553
- try {
6554
- for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
6555
- var parameter = _d.value;
6556
- var isInput = parameter.isInput, isOutput = parameter.isOutput;
6557
- if (isInput) {
6558
- pipelineInterface.inputParameters.push(deepClone(parameter));
6559
- }
6560
- if (isOutput) {
6561
- pipelineInterface.outputParameters.push(deepClone(parameter));
6562
- }
6563
- }
6564
- }
6565
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
6566
- finally {
6567
- try {
6568
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
6569
- }
6570
- finally { if (e_1) throw e_1.error; }
6571
- }
6572
- try {
6573
- for (var _e = __values(['inputParameters', 'outputParameters']), _f = _e.next(); !_f.done; _f = _e.next()) {
6574
- var key = _f.value;
6575
- pipelineInterface[key].sort(function (_a, _b) {
6576
- var name1 = _a.name;
6577
- var name2 = _b.name;
6578
- return name1.localeCompare(name2);
6579
- });
6580
- }
6581
- }
6582
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
6583
- finally {
6584
- try {
6585
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
6586
- }
6587
- finally { if (e_2) throw e_2.error; }
6588
- }
6589
- return $deepFreeze(pipelineInterface);
6590
- }
6591
-
6592
- /**
6593
- * @@@
6594
- *
6595
- * @deprecated https://github.com/webgptorg/promptbook/pull/186
6596
- * @see https://github.com/webgptorg/promptbook/discussions/171
6597
- *
6598
- * @public exported from `@promptbook/core`
6599
- */
6600
- function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
6601
- var e_1, _a, e_2, _b;
6602
- try {
6603
- for (var _c = __values(['inputParameters', 'outputParameters']), _d = _c.next(); !_d.done; _d = _c.next()) {
6604
- var whichParameters = _d.value;
6605
- var parameters1 = pipelineInterface1[whichParameters]; // <- Note: `isPipelineInterfacesEqual` is just temporary solution, no need to fix this
6606
- var parameters2 = pipelineInterface2[whichParameters];
6607
- if (parameters1.length !== parameters2.length) {
6608
- return false;
6609
- }
6610
- var _loop_1 = function (parameter) {
6611
- var matchingParameter = parameters2.find(function (_a) {
6612
- var name = _a.name;
6613
- return name === parameter.name;
6614
- });
6615
- if (!matchingParameter) {
6616
- return { value: false };
6617
- }
6618
- // Note: Do not compare description, it is not relevant for compatibility
6619
- if (matchingParameter.isInput !== parameter.isInput) {
6620
- return { value: false };
6621
- }
6622
- if (matchingParameter.isOutput !== parameter.isOutput) {
6623
- return { value: false };
6624
- }
6625
- };
6626
- try {
6627
- 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()) {
6628
- var parameter = parameters1_1_1.value;
6629
- var state_1 = _loop_1(parameter);
6630
- if (typeof state_1 === "object")
6631
- return state_1.value;
6632
- }
6633
- }
6634
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
6635
- finally {
6636
- try {
6637
- if (parameters1_1_1 && !parameters1_1_1.done && (_b = parameters1_1.return)) _b.call(parameters1_1);
6638
- }
6639
- finally { if (e_2) throw e_2.error; }
6640
- }
6641
- }
6642
- }
6643
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
6644
- finally {
6645
- try {
6646
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
6647
- }
6648
- finally { if (e_1) throw e_1.error; }
6649
- }
6650
- return true;
6651
- }
6652
-
6653
- /**
6654
- * @@@
6655
- *
6656
- * @deprecated https://github.com/webgptorg/promptbook/pull/186
6657
- * @see https://github.com/webgptorg/promptbook/discussions/171
6658
- *
6659
- * @public exported from `@promptbook/core`
6660
- */
6661
- function isPipelineImplementingInterface(options) {
6662
- var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
6663
- return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
6664
- }
6665
-
6666
- /**
6667
- * All available task types
6668
- *
6669
- * There is is distinction between task types and section types
6670
- * - Every section in markdown has its SectionType
6671
- * - Some sections are tasks but other can be non-task sections
6619
+ * There is is distinction between task types and section types
6620
+ * - Every section in markdown has its SectionType
6621
+ * - Some sections are tasks but other can be non-task sections
6672
6622
  *
6673
6623
  * @public exported from `@promptbook/core`
6674
6624
  */
@@ -6913,7 +6863,8 @@ var sectionCommandParser = {
6913
6863
  expectResultingParameterName();
6914
6864
  var parameter = $pipelineJson.parameters.find(function (param) { return param.name === $taskJson.resultingParameterName; });
6915
6865
  if (parameter === undefined) {
6916
- throw new ParseError("Can not find parameter {".concat($taskJson.resultingParameterName, "} to assign example value on it"));
6866
+ // TODO: !!!!!! Change to logic error for higher level abstractions to work
6867
+ throw new ParseError("Parameter `{".concat($taskJson.resultingParameterName, "}` is not defined so can not define example value of it"));
6917
6868
  }
6918
6869
  parameter.exampleValues = parameter.exampleValues || [];
6919
6870
  parameter.exampleValues.push($taskJson.content);
@@ -9021,6 +8972,295 @@ function parseCommandVariant(input) {
9021
8972
  return null;
9022
8973
  }
9023
8974
 
8975
+ /**
8976
+ * @@@
8977
+ *
8978
+ * @deprecated https://github.com/webgptorg/promptbook/pull/186
8979
+ * @see https://github.com/webgptorg/promptbook/discussions/171
8980
+ *
8981
+ * @public exported from `@promptbook/core`
8982
+ */
8983
+ function getPipelineInterface(pipeline) {
8984
+ var e_1, _a, e_2, _b;
8985
+ var pipelineInterface = {
8986
+ inputParameters: [],
8987
+ outputParameters: [],
8988
+ };
8989
+ try {
8990
+ for (var _c = __values(pipeline.parameters), _d = _c.next(); !_d.done; _d = _c.next()) {
8991
+ var parameter = _d.value;
8992
+ var isInput = parameter.isInput, isOutput = parameter.isOutput;
8993
+ if (isInput) {
8994
+ pipelineInterface.inputParameters.push(deepClone(parameter));
8995
+ }
8996
+ if (isOutput) {
8997
+ pipelineInterface.outputParameters.push(deepClone(parameter));
8998
+ }
8999
+ }
9000
+ }
9001
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
9002
+ finally {
9003
+ try {
9004
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
9005
+ }
9006
+ finally { if (e_1) throw e_1.error; }
9007
+ }
9008
+ try {
9009
+ for (var _e = __values(['inputParameters', 'outputParameters']), _f = _e.next(); !_f.done; _f = _e.next()) {
9010
+ var key = _f.value;
9011
+ pipelineInterface[key].sort(function (_a, _b) {
9012
+ var name1 = _a.name;
9013
+ var name2 = _b.name;
9014
+ return name1.localeCompare(name2);
9015
+ });
9016
+ }
9017
+ }
9018
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
9019
+ finally {
9020
+ try {
9021
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
9022
+ }
9023
+ finally { if (e_2) throw e_2.error; }
9024
+ }
9025
+ return exportJson({
9026
+ name: "pipelineInterface",
9027
+ message: "Result of `getPipelineInterface`",
9028
+ order: ['inputParameters', 'outputParameters'],
9029
+ value: pipelineInterface,
9030
+ });
9031
+ }
9032
+
9033
+ /**
9034
+ * @@@
9035
+ *
9036
+ * @deprecated https://github.com/webgptorg/promptbook/pull/186
9037
+ * @see https://github.com/webgptorg/promptbook/discussions/171
9038
+ *
9039
+ * @public exported from `@promptbook/core`
9040
+ */
9041
+ function isPipelineInterfacesEqual(pipelineInterface1, pipelineInterface2) {
9042
+ var e_1, _a, e_2, _b;
9043
+ try {
9044
+ for (var _c = __values(['inputParameters', 'outputParameters']), _d = _c.next(); !_d.done; _d = _c.next()) {
9045
+ var whichParameters = _d.value;
9046
+ var parameters1 = pipelineInterface1[whichParameters]; // <- Note: `isPipelineInterfacesEqual` is just temporary solution, no need to fix this
9047
+ var parameters2 = pipelineInterface2[whichParameters];
9048
+ if (parameters1.length !== parameters2.length) {
9049
+ return false;
9050
+ }
9051
+ var _loop_1 = function (parameter) {
9052
+ var matchingParameter = parameters2.find(function (_a) {
9053
+ var name = _a.name;
9054
+ return name === parameter.name;
9055
+ });
9056
+ if (!matchingParameter) {
9057
+ return { value: false };
9058
+ }
9059
+ // Note: Do not compare description, it is not relevant for compatibility
9060
+ if (matchingParameter.isInput !== parameter.isInput) {
9061
+ return { value: false };
9062
+ }
9063
+ if (matchingParameter.isOutput !== parameter.isOutput) {
9064
+ return { value: false };
9065
+ }
9066
+ };
9067
+ try {
9068
+ 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()) {
9069
+ var parameter = parameters1_1_1.value;
9070
+ var state_1 = _loop_1(parameter);
9071
+ if (typeof state_1 === "object")
9072
+ return state_1.value;
9073
+ }
9074
+ }
9075
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
9076
+ finally {
9077
+ try {
9078
+ if (parameters1_1_1 && !parameters1_1_1.done && (_b = parameters1_1.return)) _b.call(parameters1_1);
9079
+ }
9080
+ finally { if (e_2) throw e_2.error; }
9081
+ }
9082
+ }
9083
+ }
9084
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
9085
+ finally {
9086
+ try {
9087
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
9088
+ }
9089
+ finally { if (e_1) throw e_1.error; }
9090
+ }
9091
+ return true;
9092
+ }
9093
+
9094
+ /**
9095
+ * @@@
9096
+ *
9097
+ * @deprecated https://github.com/webgptorg/promptbook/pull/186
9098
+ * @see https://github.com/webgptorg/promptbook/discussions/171
9099
+ *
9100
+ * @public exported from `@promptbook/core`
9101
+ */
9102
+ function isPipelineImplementingInterface(options) {
9103
+ var pipeline = options.pipeline, pipelineInterface = options.pipelineInterface;
9104
+ return isPipelineInterfacesEqual(getPipelineInterface(pipeline), pipelineInterface);
9105
+ }
9106
+
9107
+ /**
9108
+ * Set formfactor based on the pipeline interface e
9109
+ *
9110
+ * @private
9111
+ */
9112
+ var ImplicitFormfactorHla = {
9113
+ type: 'SYNC',
9114
+ $applyToPipelineJson: function ($pipelineJson) {
9115
+ var e_1, _a;
9116
+ if ($pipelineJson.formfactorName !== undefined) {
9117
+ // Note: When formfactor is already set, do nothing
9118
+ return;
9119
+ }
9120
+ try {
9121
+ for (var _b = __values(FORMFACTOR_DEFINITIONS.filter(function (_a) {
9122
+ var name = _a.name;
9123
+ return name !== 'GENERIC';
9124
+ })), _c = _b.next(); !_c.done; _c = _b.next()) {
9125
+ var formfactorDefinition = _c.value;
9126
+ // <- Note: [♓️][💩] This is the order of the formfactors, make some explicit priority
9127
+ var name_1 = formfactorDefinition.name, pipelineInterface = formfactorDefinition.pipelineInterface;
9128
+ var isCompatible = isPipelineImplementingInterface({
9129
+ pipeline: __assign({ formfactorName: name_1 }, $pipelineJson),
9130
+ pipelineInterface: pipelineInterface,
9131
+ });
9132
+ /*/
9133
+ console.log({
9134
+ subject: `${$pipelineJson.title} implements ${name}`,
9135
+ pipelineTitle: $pipelineJson.title,
9136
+ formfactorName: name,
9137
+ isCompatible,
9138
+ formfactorInterface: pipelineInterface,
9139
+ pipelineInterface: getPipelineInterface($pipelineJson as PipelineJson),
9140
+ });
9141
+ /**/
9142
+ if (isCompatible) {
9143
+ $pipelineJson.formfactorName = name_1;
9144
+ return;
9145
+ }
9146
+ }
9147
+ }
9148
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
9149
+ finally {
9150
+ try {
9151
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
9152
+ }
9153
+ finally { if (e_1) throw e_1.error; }
9154
+ }
9155
+ },
9156
+ };
9157
+
9158
+ /**
9159
+ * Allow to define chatbot with no need to write full interface
9160
+ *
9161
+ * @private
9162
+ */
9163
+ var QuickChatbotHla = {
9164
+ type: 'SYNC',
9165
+ $applyToPipelineJson: function ($pipelineJson) {
9166
+ if ($pipelineJson.tasks.length !== 0) {
9167
+ // Note: When there are already tasks, do nothing
9168
+ return;
9169
+ }
9170
+ if ($pipelineJson.parameters.length !== 0) {
9171
+ // Note: When there are already parameters, do nothing
9172
+ return;
9173
+ }
9174
+ if ($pipelineJson.personas.length === 0) {
9175
+ // Note: When no personas defined, do nothing
9176
+ return;
9177
+ }
9178
+ var personaName = $pipelineJson.personas[0].name;
9179
+ $pipelineJson.formfactorName = 'CHATBOT';
9180
+ $pipelineJson.parameters.push({
9181
+ name: 'previousTitle',
9182
+ description: 'Previous title of the conversation',
9183
+ isInput: true,
9184
+ isOutput: false,
9185
+ }, {
9186
+ name: 'previousConversationSummary',
9187
+ description: 'Previous conversation summary',
9188
+ isInput: true,
9189
+ isOutput: false,
9190
+ }, {
9191
+ name: 'userMessage',
9192
+ description: 'User message',
9193
+ isInput: true,
9194
+ isOutput: false,
9195
+ }, {
9196
+ name: 'title',
9197
+ description: 'Title of the conversation',
9198
+ isInput: false,
9199
+ isOutput: true,
9200
+ }, {
9201
+ name: 'conversationSummary',
9202
+ description: 'Summary of the conversation',
9203
+ isInput: false,
9204
+ isOutput: true,
9205
+ }, {
9206
+ name: 'chatbotResponse',
9207
+ description: 'Chatbot response',
9208
+ isInput: false,
9209
+ isOutput: true,
9210
+ exampleValues: ['Hello, I am a Pavol`s virtual avatar. How can I help you?'],
9211
+ });
9212
+ // TODO: !!!!!! spaceTrim
9213
+ $pipelineJson.tasks.push({
9214
+ taskType: 'PROMPT_TASK',
9215
+ name: 'create-an-answer',
9216
+ title: 'Create an answer',
9217
+ content: 'Write a response to the user message:\n\n**Question from user**\n\n> {userMessage}\n\n**Previous conversation**\n\n> {previousConversationSummary}',
9218
+ resultingParameterName: 'chatbotResponse',
9219
+ personaName: personaName,
9220
+ dependentParameterNames: ['userMessage', 'previousConversationSummary' /* !!!!!!, 'knowledge'*/],
9221
+ // !!!!!! preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
9222
+ }, {
9223
+ taskType: 'PROMPT_TASK',
9224
+ name: 'summarize-the-conversation',
9225
+ title: 'Summarize the conversation',
9226
+ 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}',
9227
+ resultingParameterName: 'conversationSummary',
9228
+ personaName: personaName,
9229
+ expectations: {
9230
+ words: {
9231
+ min: 1,
9232
+ max: 10,
9233
+ },
9234
+ },
9235
+ dependentParameterNames: ['userMessage', 'chatbotResponse' /* !!!!!!, 'knowledge'*/],
9236
+ // !!!!!! preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
9237
+ }, {
9238
+ taskType: 'SIMPLE_TASK',
9239
+ name: 'title',
9240
+ title: 'Title',
9241
+ content: '{conversationSummary}',
9242
+ resultingParameterName: 'title',
9243
+ dependentParameterNames: ['conversationSummary' /* !!!!!!, 'knowledge'*/],
9244
+ // !!!!!! preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
9245
+ });
9246
+ },
9247
+ };
9248
+
9249
+ /**
9250
+ * All high-level abstractions
9251
+ *
9252
+ * @private internal index of `pipelineStringToJsonSync` (= used for sync) and `preparePipeline` (= used for async)
9253
+ */
9254
+ var HIGH_LEVEL_ABSTRACTIONS = [
9255
+ ImplicitFormfactorHla,
9256
+ QuickChatbotHla,
9257
+ // <- Note: [♓️][💩] This is the order of the application of high-level abstractions application on pipeline JSON
9258
+ ];
9259
+ /**
9260
+ * TODO: Test that all sync high-level abstractions are before async high-level abstractions
9261
+ * Note: [💞] Ignore a discrepancy between file name and entity name
9262
+ */
9263
+
9024
9264
  /**
9025
9265
  * Supported script languages
9026
9266
  *
@@ -9371,7 +9611,7 @@ function pipelineStringToJsonSync(pipelineString) {
9371
9611
  }
9372
9612
  try {
9373
9613
  commandParser.$applyToPipelineJson(command, $pipelineJson);
9374
- // <- Note: [🦦] Its strange that this assertion must be here, [🦦][4] should do this assertion implicitelly
9614
+ // <- Note: [🦦] Its strange that this assertion must be here, [🦦][4] should do this assertion implicitly
9375
9615
  }
9376
9616
  catch (error) {
9377
9617
  if (!(error instanceof ParseError)) {
@@ -9428,10 +9668,10 @@ function pipelineStringToJsonSync(pipelineString) {
9428
9668
  return nameWithSuffix;
9429
9669
  };
9430
9670
  var _loop_2 = function (section) {
9431
- var e_7, _o, e_8, _p;
9671
+ var e_7, _q, e_8, _r;
9432
9672
  // TODO: Parse section's description (the content out of the codeblock and lists)
9433
9673
  var listItems_2 = extractAllListItemsFromMarkdown(section.content);
9434
- var _q = extractOneBlockFromMarkdown(section.content), language = _q.language, content = _q.content;
9674
+ var _s = extractOneBlockFromMarkdown(section.content), language = _s.language, content = _s.content;
9435
9675
  // TODO: [🎾][1] DRY description
9436
9676
  var description_1 = section.content;
9437
9677
  // Note: Remove codeblocks - TODO: [🎾]
@@ -9479,7 +9719,7 @@ function pipelineStringToJsonSync(pipelineString) {
9479
9719
  }
9480
9720
  try {
9481
9721
  commandParser.$applyToTaskJson(
9482
- // <- Note: [🦦] Its strange that this assertion must be here, [🦦][4] should do this assertion implicitelly
9722
+ // <- Note: [🦦] Its strange that this assertion must be here, [🦦][4] should do this assertion implicitly
9483
9723
  command, $taskJson, $pipelineJson);
9484
9724
  }
9485
9725
  catch (error) {
@@ -9496,14 +9736,14 @@ function pipelineStringToJsonSync(pipelineString) {
9496
9736
  try {
9497
9737
  // TODO [♓️] List commands and before apply order them to achieve order-agnostic commands
9498
9738
  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()) {
9499
- var _r = commands_1_1.value, listItem = _r.listItem, command = _r.command;
9739
+ var _t = commands_1_1.value, listItem = _t.listItem, command = _t.command;
9500
9740
  _loop_4(listItem, command);
9501
9741
  }
9502
9742
  }
9503
9743
  catch (e_7_1) { e_7 = { error: e_7_1 }; }
9504
9744
  finally {
9505
9745
  try {
9506
- if (commands_1_1 && !commands_1_1.done && (_o = commands_1.return)) _o.call(commands_1);
9746
+ if (commands_1_1 && !commands_1_1.done && (_q = commands_1.return)) _q.call(commands_1);
9507
9747
  }
9508
9748
  finally { if (e_7) throw e_7.error; }
9509
9749
  }
@@ -9519,8 +9759,8 @@ function pipelineStringToJsonSync(pipelineString) {
9519
9759
  }
9520
9760
  $taskJson.dependentParameterNames = Array.from(extractParameterNamesFromTask($taskJson));
9521
9761
  try {
9522
- for (var _s = (e_8 = void 0, __values($taskJson.dependentParameterNames)), _t = _s.next(); !_t.done; _t = _s.next()) {
9523
- var parameterName = _t.value;
9762
+ for (var _u = (e_8 = void 0, __values($taskJson.dependentParameterNames)), _v = _u.next(); !_v.done; _v = _u.next()) {
9763
+ var parameterName = _v.value;
9524
9764
  // TODO: [🧠] This definition should be made first in the task
9525
9765
  defineParam({
9526
9766
  parameterName: parameterName,
@@ -9534,7 +9774,7 @@ function pipelineStringToJsonSync(pipelineString) {
9534
9774
  catch (e_8_1) { e_8 = { error: e_8_1 }; }
9535
9775
  finally {
9536
9776
  try {
9537
- if (_t && !_t.done && (_p = _s.return)) _p.call(_s);
9777
+ if (_v && !_v.done && (_r = _u.return)) _r.call(_u);
9538
9778
  }
9539
9779
  finally { if (e_8) throw e_8.error; }
9540
9780
  }
@@ -9665,53 +9905,39 @@ function pipelineStringToJsonSync(pipelineString) {
9665
9905
  });
9666
9906
  try {
9667
9907
  // =============================================================
9668
- // Note: 9️⃣ Implicit and default formfactor
9669
- for (var FORMFACTOR_DEFINITIONS_1 = __values(FORMFACTOR_DEFINITIONS), FORMFACTOR_DEFINITIONS_1_1 = FORMFACTOR_DEFINITIONS_1.next(); !FORMFACTOR_DEFINITIONS_1_1.done; FORMFACTOR_DEFINITIONS_1_1 = FORMFACTOR_DEFINITIONS_1.next()) {
9670
- var formfactorDefinition = FORMFACTOR_DEFINITIONS_1_1.value;
9671
- // <- Note: [♓️][💩] This is the order of the formfactors, make some explicit priority
9672
- var name_2 = formfactorDefinition.name, pipelineInterface = formfactorDefinition.pipelineInterface;
9673
- // Note: Skip GENERIC formfactor, it will be used as a fallback if no other formfactor is compatible
9674
- if (name_2 === 'GENERIC') {
9675
- continue;
9676
- }
9677
- var isCompatible = isPipelineImplementingInterface({
9678
- pipeline: __assign({ formfactorName: name_2 }, $pipelineJson),
9679
- pipelineInterface: pipelineInterface,
9680
- });
9681
- /*/
9682
- console.log({
9683
- subject: `${$pipelineJson.title} implements ${name}`,
9684
- pipelineTitle: $pipelineJson.title,
9685
- formfactorName: name,
9686
- isCompatible,
9687
- formfactorInterface: pipelineInterface,
9688
- pipelineInterface: getPipelineInterface($pipelineJson as PipelineJson),
9689
- });
9690
- /**/
9691
- if (isCompatible) {
9692
- $pipelineJson.formfactorName = name_2;
9693
- break;
9694
- }
9908
+ // Note: 9️⃣ Apply sync high-level abstractions
9909
+ for (var _o = __values(HIGH_LEVEL_ABSTRACTIONS.filter(function (_a) {
9910
+ var type = _a.type;
9911
+ return type === 'SYNC';
9912
+ })), _p = _o.next(); !_p.done; _p = _o.next()) {
9913
+ var highLevelAbstraction = _p.value;
9914
+ highLevelAbstraction.$applyToPipelineJson($pipelineJson);
9695
9915
  }
9696
9916
  }
9697
9917
  catch (e_6_1) { e_6 = { error: e_6_1 }; }
9698
9918
  finally {
9699
9919
  try {
9700
- if (FORMFACTOR_DEFINITIONS_1_1 && !FORMFACTOR_DEFINITIONS_1_1.done && (_f = FORMFACTOR_DEFINITIONS_1.return)) _f.call(FORMFACTOR_DEFINITIONS_1);
9920
+ if (_p && !_p.done && (_f = _o.return)) _f.call(_o);
9701
9921
  }
9702
9922
  finally { if (e_6) throw e_6.error; }
9703
9923
  }
9924
+ // =============================================================
9925
+ // Note: 🔟 Default formfactor
9704
9926
  // Note: [🔆] If formfactor is still not set, set it to 'GENERIC'
9705
9927
  if ($pipelineJson.formfactorName === undefined) {
9706
9928
  $pipelineJson.formfactorName = 'GENERIC';
9707
9929
  }
9708
9930
  // =============================================================
9709
9931
  // TODO: [🍙] Maybe do reorder of `$pipelineJson` here
9710
- return $asDeeplyFrozenSerializableJson('pipelineJson', __assign({ title: DEFAULT_TITLE, pipelineUrl: undefined, bookVersion: undefined, description: undefined, formfactorName: 'GENERIC',
9711
- // <- Note: [🔆] Setting `formfactorName` is redundant to satisfy the typescript
9712
- parameters: [], tasks: [], knowledgeSources: [], knowledgePieces: [], personas: [], preparations: [] }, $pipelineJson));
9932
+ return exportJson({
9933
+ name: 'pipelineJson',
9934
+ message: "Result of `pipelineStringToJsonSync`",
9935
+ order: ORDER_OF_PIPELINE_JSON,
9936
+ value: __assign({ formfactorName: 'GENERIC' }, $pipelineJson),
9937
+ });
9713
9938
  }
9714
9939
  /**
9940
+ * TODO: [🧠] Maybe more things here can be refactored as high-level abstractions
9715
9941
  * TODO: [main] !!!! Warn if used only sync version
9716
9942
  * TODO: [🚞] Report here line/column of error
9717
9943
  * TODO: Use spaceTrim more effectively
@@ -9755,7 +9981,7 @@ function pipelineStringToJson(pipelineString, tools, options) {
9755
9981
  pipelineJson = _a.sent();
9756
9982
  _a.label = 2;
9757
9983
  case 2:
9758
- // Note: No need to use `$asDeeplyFrozenSerializableJson` because `pipelineStringToJsonSync` and `preparePipeline` already do that
9984
+ // Note: No need to use `$exportJson` because `pipelineStringToJsonSync` and `preparePipeline` already do that
9759
9985
  return [2 /*return*/, pipelineJson];
9760
9986
  }
9761
9987
  });
@@ -11823,9 +12049,125 @@ function executionReportJsonToString(executionReportJson, options) {
11823
12049
  return executionReportString;
11824
12050
  }
11825
12051
  /**
11826
- * TODO: Add mermaid chart for every report
11827
- * TODO: [🧠] Allow to filter out some parts of the report by options
11828
- * TODO: [🧠] Should be in generated file GENERATOR_WARNING
12052
+ * TODO: Add mermaid chart for every report
12053
+ * TODO: [🧠] Allow to filter out some parts of the report by options
12054
+ * TODO: [🧠] Should be in generated file GENERATOR_WARNING
12055
+ */
12056
+
12057
+ /**
12058
+ * Run the interactive chatbot in CLI
12059
+ *
12060
+ * @returns Never-ending promise or process exit
12061
+ * @private internal function of `promptbookCli` and `initializeRunCommand`
12062
+ */
12063
+ function runInteractiveChatbot(options) {
12064
+ var _a;
12065
+ return __awaiter(this, void 0, void 0, function () {
12066
+ var pipeline, pipelineExecutor, isVerbose, ongoingParameters, initialMessage, _loop_1, state_1;
12067
+ return __generator(this, function (_b) {
12068
+ switch (_b.label) {
12069
+ case 0:
12070
+ pipeline = options.pipeline, pipelineExecutor = options.pipelineExecutor, isVerbose = options.isVerbose;
12071
+ ongoingParameters = {
12072
+ /**
12073
+ * Title of the conversation
12074
+ */
12075
+ title: '',
12076
+ /**
12077
+ * Summary of the conversation
12078
+ */
12079
+ conversationSummary: '',
12080
+ /**
12081
+ * Chatbot response
12082
+ */
12083
+ chatbotResponse: '',
12084
+ };
12085
+ if (isVerbose) {
12086
+ console.info(colors.gray('--- Running interactive chatbot ---'));
12087
+ }
12088
+ initialMessage = (((_a = pipeline.parameters.find(function (_a) {
12089
+ var name = _a.name;
12090
+ return name === 'chatbotResponse';
12091
+ })) === null || _a === void 0 ? void 0 : _a.exampleValues) || [])[0];
12092
+ if (initialMessage) {
12093
+ console.info("\n");
12094
+ console.info(spaceTrim(function (block) { return "\n\n ".concat(colors.bold(colors.green('Chatbot:')), "\n ").concat(block(colors.green(initialMessage)), "\n\n "); }));
12095
+ }
12096
+ _loop_1 = function () {
12097
+ var title_1, conversationSummary_1, response, userMessage_1, inputParameters, result_1, error_1;
12098
+ return __generator(this, function (_c) {
12099
+ switch (_c.label) {
12100
+ case 0:
12101
+ _c.trys.push([0, 4, , 5]);
12102
+ return [4 /*yield*/, forTime(100)];
12103
+ case 1:
12104
+ _c.sent();
12105
+ title_1 = ongoingParameters.title, conversationSummary_1 = ongoingParameters.conversationSummary;
12106
+ console.info("\n");
12107
+ if (title_1 !== '' &&
12108
+ just(false) /* <- TODO: [⛲️] Some better way how to show the title of ongoing conversation */) {
12109
+ console.info(colors.gray("--- ".concat(title_1, " ---")));
12110
+ }
12111
+ else {
12112
+ console.info(colors.gray("---"));
12113
+ }
12114
+ return [4 /*yield*/, prompts({
12115
+ type: 'text',
12116
+ name: 'userMessage',
12117
+ message: 'User message',
12118
+ hint: spaceTrim(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 "); }),
12119
+ })];
12120
+ case 2:
12121
+ response = _c.sent();
12122
+ userMessage_1 = response.userMessage;
12123
+ if (userMessage_1 === 'exit' || userMessage_1 === 'quit' || userMessage_1 === undefined) {
12124
+ return [2 /*return*/, { value: process.exit(0) }];
12125
+ }
12126
+ console.info("\n");
12127
+ console.info(spaceTrim(function (block) { return "\n\n ".concat(colors.bold(colors.blue('User:')), "\n ").concat(block(colors.blue(userMessage_1)), "\n\n "); }));
12128
+ inputParameters = {
12129
+ previousTitle: title_1,
12130
+ previousConversationSummary: conversationSummary_1,
12131
+ userMessage: userMessage_1,
12132
+ };
12133
+ return [4 /*yield*/, pipelineExecutor(inputParameters)];
12134
+ case 3:
12135
+ result_1 = _c.sent();
12136
+ assertsExecutionSuccessful(result_1);
12137
+ console.info("\n");
12138
+ console.info(spaceTrim(function (block) { return "\n\n ".concat(colors.bold(colors.green('Chatbot:')), "\n ").concat(block(colors.green(result_1.outputParameters.chatbotResponse)), "\n\n "); }));
12139
+ ongoingParameters = result_1.outputParameters;
12140
+ return [3 /*break*/, 5];
12141
+ case 4:
12142
+ error_1 = _c.sent();
12143
+ if (!(error_1 instanceof Error)) {
12144
+ throw error_1;
12145
+ }
12146
+ // TODO: Allow to ressurect the chatbot after an error - prompt the user to continue
12147
+ console.error(colors.red(error_1.stack || error_1.message));
12148
+ return [2 /*return*/, { value: process.exit(1) }];
12149
+ case 5: return [2 /*return*/];
12150
+ }
12151
+ });
12152
+ };
12153
+ _b.label = 1;
12154
+ case 1:
12155
+ if (!just(true)) return [3 /*break*/, 3];
12156
+ return [5 /*yield**/, _loop_1()];
12157
+ case 2:
12158
+ state_1 = _b.sent();
12159
+ if (typeof state_1 === "object")
12160
+ return [2 /*return*/, state_1.value];
12161
+ return [3 /*break*/, 1];
12162
+ case 3: return [2 /*return*/];
12163
+ }
12164
+ });
12165
+ });
12166
+ }
12167
+ /**
12168
+ * TODO: Saving reports from the chatbot conversation
12169
+ * TODO: [⛲️] This is the right place to start implementing INK
12170
+ * Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
11829
12171
  */
11830
12172
 
11831
12173
  /**
@@ -11844,15 +12186,16 @@ function initializeRunCommand(program) {
11844
12186
  runCommand.option('-r, --reload', "Call LLM models even if same prompt with result is in the cache", false);
11845
12187
  runCommand.option('-v, --verbose', "Is output verbose", false);
11846
12188
  runCommand.option('--no-interactive', "Input is not interactive, if true you need to pass all the input parameters through --json");
12189
+ runCommand.option('--no-formfactor', "When set, behavior of the interactive mode is not changed by the formfactor of the pipeline");
11847
12190
  runCommand.option('-j, --json <json>', "Pass all or some input parameters as JSON record, if used the output is also returned as JSON");
11848
12191
  runCommand.option('-s, --save-report <path>', "Save report to file");
11849
12192
  runCommand.action(function (filePathRaw, options) { return __awaiter(_this, void 0, void 0, function () {
11850
- 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;
12193
+ 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;
11851
12194
  var e_1, _g, _h, e_2, _j, e_3, _k, e_4, _l;
11852
12195
  return __generator(this, function (_m) {
11853
12196
  switch (_m.label) {
11854
12197
  case 0:
11855
- isCacheReloaded = options.reload, isInteractive = options.interactive, json = options.json, isVerbose = options.verbose, saveReport = options.saveReport;
12198
+ isCacheReloaded = options.reload, isInteractive = options.interactive, isFormfactorUsed = options.formfactor, json = options.json, isVerbose = options.verbose, saveReport = options.saveReport;
11856
12199
  if (saveReport && !saveReport.endsWith('.json') && !saveReport.endsWith('.md')) {
11857
12200
  console.error(colors.red("Report file must be .json or .md"));
11858
12201
  return [2 /*return*/, process.exit(1)];
@@ -11921,7 +12264,7 @@ function initializeRunCommand(program) {
11921
12264
  if (!error.message.includes('No LLM tools')) {
11922
12265
  throw error;
11923
12266
  }
11924
- console.error(colors.red(spaceTrim(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
12267
+ console.error(colors.red(spaceTrim(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
11925
12268
  .list()
11926
12269
  .map(function (_a) {
11927
12270
  var title = _a.title, envVariables = _a.envVariables;
@@ -11984,6 +12327,10 @@ function initializeRunCommand(program) {
11984
12327
  // <- TODO: Why "LLM execution failed undefinedx"
11985
12328
  maxParallelCount: 1, // <- TODO: Pass CLI argument
11986
12329
  });
12330
+ // TODO: Make some better system for formfactors and interactive mode - here is just a quick hardcoded solution for chatbot
12331
+ if (isInteractive === true && isFormfactorUsed === true && pipeline.formfactorName === 'CHATBOT') {
12332
+ return [2 /*return*/, /* not await */ runInteractiveChatbot({ pipeline: pipeline, pipelineExecutor: pipelineExecutor, isVerbose: isVerbose })];
12333
+ }
11987
12334
  if (isVerbose) {
11988
12335
  console.info(colors.gray('--- Getting input parameters ---'));
11989
12336
  }
@@ -12444,7 +12791,7 @@ var RemoteLlmExecutionTools = /** @class */ (function () {
12444
12791
  isAnonymous: true,
12445
12792
  userId: this.options.userId,
12446
12793
  llmToolsConfiguration: this.options.llmToolsConfiguration,
12447
- } /* <- TODO: [🤛] */);
12794
+ } /* <- Note: [🤛] */);
12448
12795
  }
12449
12796
  else {
12450
12797
  socket.emit('listModels-request', {
@@ -12452,7 +12799,7 @@ var RemoteLlmExecutionTools = /** @class */ (function () {
12452
12799
  appId: this.options.appId,
12453
12800
  userId: this.options.userId,
12454
12801
  customOptions: this.options.customOptions,
12455
- } /* <- TODO: [🤛] */);
12802
+ } /* <- Note: [🤛] */);
12456
12803
  }
12457
12804
  return [4 /*yield*/, new Promise(function (resolve, reject) {
12458
12805
  socket.on('listModels-response', function (response) {
@@ -12540,7 +12887,7 @@ var RemoteLlmExecutionTools = /** @class */ (function () {
12540
12887
  userId: this.options.userId,
12541
12888
  llmToolsConfiguration: this.options.llmToolsConfiguration,
12542
12889
  prompt: prompt,
12543
- } /* <- TODO: [🤛] */);
12890
+ } /* <- Note: [🤛] */);
12544
12891
  }
12545
12892
  else {
12546
12893
  socket.emit('prompt-request', {
@@ -12549,7 +12896,7 @@ var RemoteLlmExecutionTools = /** @class */ (function () {
12549
12896
  userId: this.options.userId,
12550
12897
  customOptions: this.options.customOptions,
12551
12898
  prompt: prompt,
12552
- } /* <- TODO: [🤛] */);
12899
+ } /* <- Note: [🤛] */);
12553
12900
  }
12554
12901
  return [4 /*yield*/, new Promise(function (resolve, reject) {
12555
12902
  socket.on('prompt-response', function (response) {
@@ -12572,7 +12919,7 @@ var RemoteLlmExecutionTools = /** @class */ (function () {
12572
12919
  return RemoteLlmExecutionTools;
12573
12920
  }());
12574
12921
  /**
12575
- * TODO: Maybe use `$asDeeplyFrozenSerializableJson`
12922
+ * TODO: Maybe use `$exportJson`
12576
12923
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
12577
12924
  * TODO: [🍓] Allow to list compatible models with each variant
12578
12925
  * TODO: [🗯] RemoteLlmExecutionTools should extend Destroyable and implement IDestroyable
@@ -12598,72 +12945,75 @@ function computeUsage(value) {
12598
12945
  * @see https://docs.anthropic.com/en/docs/models-overview
12599
12946
  * @public exported from `@promptbook/anthropic-claude`
12600
12947
  */
12601
- var ANTHROPIC_CLAUDE_MODELS = $asDeeplyFrozenSerializableJson('ANTHROPIC_CLAUDE_MODELS', [
12602
- {
12603
- modelVariant: 'CHAT',
12604
- modelTitle: 'Claude 3.5 Sonnet',
12605
- modelName: 'claude-3-5-sonnet-20240620',
12606
- pricing: {
12607
- prompt: computeUsage("$3.00 / 1M tokens"),
12608
- output: computeUsage("$15.00 / 1M tokens"),
12948
+ var ANTHROPIC_CLAUDE_MODELS = exportJson({
12949
+ name: 'ANTHROPIC_CLAUDE_MODELS',
12950
+ value: [
12951
+ {
12952
+ modelVariant: 'CHAT',
12953
+ modelTitle: 'Claude 3.5 Sonnet',
12954
+ modelName: 'claude-3-5-sonnet-20240620',
12955
+ pricing: {
12956
+ prompt: computeUsage("$3.00 / 1M tokens"),
12957
+ output: computeUsage("$15.00 / 1M tokens"),
12958
+ },
12609
12959
  },
12610
- },
12611
- {
12612
- modelVariant: 'CHAT',
12613
- modelTitle: 'Claude 3 Opus',
12614
- modelName: 'claude-3-opus-20240229',
12615
- pricing: {
12616
- prompt: computeUsage("$15.00 / 1M tokens"),
12617
- output: computeUsage("$75.00 / 1M tokens"),
12960
+ {
12961
+ modelVariant: 'CHAT',
12962
+ modelTitle: 'Claude 3 Opus',
12963
+ modelName: 'claude-3-opus-20240229',
12964
+ pricing: {
12965
+ prompt: computeUsage("$15.00 / 1M tokens"),
12966
+ output: computeUsage("$75.00 / 1M tokens"),
12967
+ },
12618
12968
  },
12619
- },
12620
- {
12621
- modelVariant: 'CHAT',
12622
- modelTitle: 'Claude 3 Sonnet',
12623
- modelName: 'claude-3-sonnet-20240229',
12624
- pricing: {
12625
- prompt: computeUsage("$3.00 / 1M tokens"),
12626
- output: computeUsage("$15.00 / 1M tokens"),
12969
+ {
12970
+ modelVariant: 'CHAT',
12971
+ modelTitle: 'Claude 3 Sonnet',
12972
+ modelName: 'claude-3-sonnet-20240229',
12973
+ pricing: {
12974
+ prompt: computeUsage("$3.00 / 1M tokens"),
12975
+ output: computeUsage("$15.00 / 1M tokens"),
12976
+ },
12627
12977
  },
12628
- },
12629
- {
12630
- modelVariant: 'CHAT',
12631
- modelTitle: 'Claude 3 Haiku',
12632
- modelName: ' claude-3-haiku-20240307',
12633
- pricing: {
12634
- prompt: computeUsage("$0.25 / 1M tokens"),
12635
- output: computeUsage("$1.25 / 1M tokens"),
12978
+ {
12979
+ modelVariant: 'CHAT',
12980
+ modelTitle: 'Claude 3 Haiku',
12981
+ modelName: ' claude-3-haiku-20240307',
12982
+ pricing: {
12983
+ prompt: computeUsage("$0.25 / 1M tokens"),
12984
+ output: computeUsage("$1.25 / 1M tokens"),
12985
+ },
12636
12986
  },
12637
- },
12638
- {
12639
- modelVariant: 'CHAT',
12640
- modelTitle: 'Claude 2.1',
12641
- modelName: 'claude-2.1',
12642
- pricing: {
12643
- prompt: computeUsage("$8.00 / 1M tokens"),
12644
- output: computeUsage("$24.00 / 1M tokens"),
12987
+ {
12988
+ modelVariant: 'CHAT',
12989
+ modelTitle: 'Claude 2.1',
12990
+ modelName: 'claude-2.1',
12991
+ pricing: {
12992
+ prompt: computeUsage("$8.00 / 1M tokens"),
12993
+ output: computeUsage("$24.00 / 1M tokens"),
12994
+ },
12645
12995
  },
12646
- },
12647
- {
12648
- modelVariant: 'CHAT',
12649
- modelTitle: 'Claude 2',
12650
- modelName: 'claude-2.0',
12651
- pricing: {
12652
- prompt: computeUsage("$8.00 / 1M tokens"),
12653
- output: computeUsage("$24.00 / 1M tokens"),
12996
+ {
12997
+ modelVariant: 'CHAT',
12998
+ modelTitle: 'Claude 2',
12999
+ modelName: 'claude-2.0',
13000
+ pricing: {
13001
+ prompt: computeUsage("$8.00 / 1M tokens"),
13002
+ output: computeUsage("$24.00 / 1M tokens"),
13003
+ },
12654
13004
  },
12655
- },
12656
- {
12657
- modelVariant: 'CHAT',
12658
- modelTitle: ' Claude Instant 1.2',
12659
- modelName: 'claude-instant-1.2',
12660
- pricing: {
12661
- prompt: computeUsage("$0.80 / 1M tokens"),
12662
- output: computeUsage("$2.40 / 1M tokens"),
13005
+ {
13006
+ modelVariant: 'CHAT',
13007
+ modelTitle: ' Claude Instant 1.2',
13008
+ modelName: 'claude-instant-1.2',
13009
+ pricing: {
13010
+ prompt: computeUsage("$0.80 / 1M tokens"),
13011
+ output: computeUsage("$2.40 / 1M tokens"),
13012
+ },
12663
13013
  },
12664
- },
12665
- // TODO: [main] !!! Claude 1 and 2 has also completion versions - ask Hoagy
12666
- ]);
13014
+ // TODO: [main] !!! Claude 1 and 2 has also completion versions - ask Hoagy
13015
+ ],
13016
+ });
12667
13017
  /**
12668
13018
  * Note: [🤖] Add models of new variant
12669
13019
  * TODO: [🧠][main] !!! Add embedding models OR Anthropic has only chat+completion models?
@@ -12883,18 +13233,23 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
12883
13233
  // eslint-disable-next-line prefer-const
12884
13234
  complete = $getCurrentDate();
12885
13235
  usage = computeAnthropicClaudeUsage(rawPromptContent || '', resultContent || '', rawResponse);
12886
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('AnthropicClaudeExecutionTools ChatPromptResult', {
12887
- content: resultContent,
12888
- modelName: rawResponse.model,
12889
- timing: {
12890
- start: start,
12891
- complete: complete,
13236
+ return [2 /*return*/, exportJson({
13237
+ name: 'promptResult',
13238
+ message: "Result of `AzureOpenAiExecutionTools.callChatModel`",
13239
+ order: [],
13240
+ value: {
13241
+ content: resultContent,
13242
+ modelName: rawResponse.model,
13243
+ timing: {
13244
+ start: start,
13245
+ complete: complete,
13246
+ },
13247
+ usage: usage,
13248
+ rawPromptContent: rawPromptContent,
13249
+ rawRequest: rawRequest,
13250
+ rawResponse: rawResponse,
13251
+ // <- [🗯]
12892
13252
  },
12893
- usage: usage,
12894
- rawPromptContent: rawPromptContent,
12895
- rawRequest: rawRequest,
12896
- rawResponse: rawResponse,
12897
- // <- [🗯]
12898
13253
  })];
12899
13254
  }
12900
13255
  });
@@ -12964,7 +13319,7 @@ var AnthropicClaudeExecutionTools = /** @class */ (function () {
12964
13319
 
12965
13320
 
12966
13321
 
12967
- return $asDeeplyFrozenSerializableJson('AnthropicClaudeExecutionTools CompletionPromptResult',{
13322
+ return $exportJson({ name: 'promptResult',message: Result of \`AzureOpenAiExecutionTools callChatModel\`, order: [],value:{
12968
13323
  content: resultContent,
12969
13324
  modelName: rawResponse.model || model,
12970
13325
  timing: {
@@ -13133,381 +13488,384 @@ var _AzureOpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
13133
13488
  * @see https://openai.com/api/pricing/
13134
13489
  * @public exported from `@promptbook/openai`
13135
13490
  */
13136
- var OPENAI_MODELS = $asDeeplyFrozenSerializableJson('OPENAI_MODELS', [
13137
- /*/
13491
+ var OPENAI_MODELS = exportJson({
13492
+ name: 'OPENAI_MODELS',
13493
+ value: [
13494
+ /*/
13495
+ {
13496
+ modelTitle: 'dall-e-3',
13497
+ modelName: 'dall-e-3',
13498
+ },
13499
+ /**/
13500
+ /*/
13501
+ {
13502
+ modelTitle: 'whisper-1',
13503
+ modelName: 'whisper-1',
13504
+ },
13505
+ /**/
13506
+ /**/
13507
+ {
13508
+ modelVariant: 'COMPLETION',
13509
+ modelTitle: 'davinci-002',
13510
+ modelName: 'davinci-002',
13511
+ pricing: {
13512
+ prompt: computeUsage("$2.00 / 1M tokens"),
13513
+ output: computeUsage("$2.00 / 1M tokens"), // <- not sure
13514
+ },
13515
+ },
13516
+ /**/
13517
+ /*/
13138
13518
  {
13139
- modelTitle: 'dall-e-3',
13140
- modelName: 'dall-e-3',
13519
+ modelTitle: 'dall-e-2',
13520
+ modelName: 'dall-e-2',
13141
13521
  },
13142
13522
  /**/
13143
- /*/
13523
+ /**/
13524
+ {
13525
+ modelVariant: 'CHAT',
13526
+ modelTitle: 'gpt-3.5-turbo-16k',
13527
+ modelName: 'gpt-3.5-turbo-16k',
13528
+ pricing: {
13529
+ prompt: computeUsage("$3.00 / 1M tokens"),
13530
+ output: computeUsage("$4.00 / 1M tokens"),
13531
+ },
13532
+ },
13533
+ /**/
13534
+ /*/
13144
13535
  {
13145
- modelTitle: 'whisper-1',
13146
- modelName: 'whisper-1',
13536
+ modelTitle: 'tts-1-hd-1106',
13537
+ modelName: 'tts-1-hd-1106',
13147
13538
  },
13148
- /**/
13149
- /**/
13150
- {
13151
- modelVariant: 'COMPLETION',
13152
- modelTitle: 'davinci-002',
13153
- modelName: 'davinci-002',
13154
- pricing: {
13155
- prompt: computeUsage("$2.00 / 1M tokens"),
13156
- output: computeUsage("$2.00 / 1M tokens"), // <- not sure
13157
- },
13158
- },
13159
- /**/
13160
- /*/
13161
- {
13162
- modelTitle: 'dall-e-2',
13163
- modelName: 'dall-e-2',
13164
- },
13165
- /**/
13166
- /**/
13167
- {
13168
- modelVariant: 'CHAT',
13169
- modelTitle: 'gpt-3.5-turbo-16k',
13170
- modelName: 'gpt-3.5-turbo-16k',
13171
- pricing: {
13172
- prompt: computeUsage("$3.00 / 1M tokens"),
13173
- output: computeUsage("$4.00 / 1M tokens"),
13174
- },
13175
- },
13176
- /**/
13177
- /*/
13178
- {
13179
- modelTitle: 'tts-1-hd-1106',
13180
- modelName: 'tts-1-hd-1106',
13181
- },
13182
- /**/
13183
- /*/
13184
- {
13185
- modelTitle: 'tts-1-hd',
13186
- modelName: 'tts-1-hd',
13187
- },
13188
- /**/
13189
- /**/
13190
- {
13191
- modelVariant: 'CHAT',
13192
- modelTitle: 'gpt-4',
13193
- modelName: 'gpt-4',
13194
- pricing: {
13195
- prompt: computeUsage("$30.00 / 1M tokens"),
13196
- output: computeUsage("$60.00 / 1M tokens"),
13539
+ /**/
13540
+ /*/
13541
+ {
13542
+ modelTitle: 'tts-1-hd',
13543
+ modelName: 'tts-1-hd',
13544
+ },
13545
+ /**/
13546
+ /**/
13547
+ {
13548
+ modelVariant: 'CHAT',
13549
+ modelTitle: 'gpt-4',
13550
+ modelName: 'gpt-4',
13551
+ pricing: {
13552
+ prompt: computeUsage("$30.00 / 1M tokens"),
13553
+ output: computeUsage("$60.00 / 1M tokens"),
13554
+ },
13197
13555
  },
13198
- },
13199
- /**/
13200
- /**/
13201
- {
13202
- modelVariant: 'CHAT',
13203
- modelTitle: 'gpt-4-32k',
13204
- modelName: 'gpt-4-32k',
13205
- pricing: {
13206
- prompt: computeUsage("$60.00 / 1M tokens"),
13207
- output: computeUsage("$120.00 / 1M tokens"),
13556
+ /**/
13557
+ /**/
13558
+ {
13559
+ modelVariant: 'CHAT',
13560
+ modelTitle: 'gpt-4-32k',
13561
+ modelName: 'gpt-4-32k',
13562
+ pricing: {
13563
+ prompt: computeUsage("$60.00 / 1M tokens"),
13564
+ output: computeUsage("$120.00 / 1M tokens"),
13565
+ },
13208
13566
  },
13209
- },
13210
- /**/
13211
- /*/
13212
- {
13213
- modelVariant: 'CHAT',
13214
- modelTitle: 'gpt-4-0613',
13215
- modelName: 'gpt-4-0613',
13216
- pricing: {
13217
- prompt: computeUsage(` / 1M tokens`),
13218
- output: computeUsage(` / 1M tokens`),
13567
+ /**/
13568
+ /*/
13569
+ {
13570
+ modelVariant: 'CHAT',
13571
+ modelTitle: 'gpt-4-0613',
13572
+ modelName: 'gpt-4-0613',
13573
+ pricing: {
13574
+ prompt: computeUsage(` / 1M tokens`),
13575
+ output: computeUsage(` / 1M tokens`),
13576
+ },
13219
13577
  },
13220
- },
13221
- /**/
13222
- /**/
13223
- {
13224
- modelVariant: 'CHAT',
13225
- modelTitle: 'gpt-4-turbo-2024-04-09',
13226
- modelName: 'gpt-4-turbo-2024-04-09',
13227
- pricing: {
13228
- prompt: computeUsage("$10.00 / 1M tokens"),
13229
- output: computeUsage("$30.00 / 1M tokens"),
13578
+ /**/
13579
+ /**/
13580
+ {
13581
+ modelVariant: 'CHAT',
13582
+ modelTitle: 'gpt-4-turbo-2024-04-09',
13583
+ modelName: 'gpt-4-turbo-2024-04-09',
13584
+ pricing: {
13585
+ prompt: computeUsage("$10.00 / 1M tokens"),
13586
+ output: computeUsage("$30.00 / 1M tokens"),
13587
+ },
13230
13588
  },
13231
- },
13232
- /**/
13233
- /**/
13234
- {
13235
- modelVariant: 'CHAT',
13236
- modelTitle: 'gpt-3.5-turbo-1106',
13237
- modelName: 'gpt-3.5-turbo-1106',
13238
- pricing: {
13239
- prompt: computeUsage("$1.00 / 1M tokens"),
13240
- output: computeUsage("$2.00 / 1M tokens"),
13589
+ /**/
13590
+ /**/
13591
+ {
13592
+ modelVariant: 'CHAT',
13593
+ modelTitle: 'gpt-3.5-turbo-1106',
13594
+ modelName: 'gpt-3.5-turbo-1106',
13595
+ pricing: {
13596
+ prompt: computeUsage("$1.00 / 1M tokens"),
13597
+ output: computeUsage("$2.00 / 1M tokens"),
13598
+ },
13241
13599
  },
13242
- },
13243
- /**/
13244
- /**/
13245
- {
13246
- modelVariant: 'CHAT',
13247
- modelTitle: 'gpt-4-turbo',
13248
- modelName: 'gpt-4-turbo',
13249
- pricing: {
13250
- prompt: computeUsage("$10.00 / 1M tokens"),
13251
- output: computeUsage("$30.00 / 1M tokens"),
13600
+ /**/
13601
+ /**/
13602
+ {
13603
+ modelVariant: 'CHAT',
13604
+ modelTitle: 'gpt-4-turbo',
13605
+ modelName: 'gpt-4-turbo',
13606
+ pricing: {
13607
+ prompt: computeUsage("$10.00 / 1M tokens"),
13608
+ output: computeUsage("$30.00 / 1M tokens"),
13609
+ },
13252
13610
  },
13253
- },
13254
- /**/
13255
- /**/
13256
- {
13257
- modelVariant: 'COMPLETION',
13258
- modelTitle: 'gpt-3.5-turbo-instruct-0914',
13259
- modelName: 'gpt-3.5-turbo-instruct-0914',
13260
- pricing: {
13261
- prompt: computeUsage("$1.50 / 1M tokens"),
13262
- output: computeUsage("$2.00 / 1M tokens"), // <- For gpt-3.5-turbo-instruct
13611
+ /**/
13612
+ /**/
13613
+ {
13614
+ modelVariant: 'COMPLETION',
13615
+ modelTitle: 'gpt-3.5-turbo-instruct-0914',
13616
+ modelName: 'gpt-3.5-turbo-instruct-0914',
13617
+ pricing: {
13618
+ prompt: computeUsage("$1.50 / 1M tokens"),
13619
+ output: computeUsage("$2.00 / 1M tokens"), // <- For gpt-3.5-turbo-instruct
13620
+ },
13263
13621
  },
13264
- },
13265
- /**/
13266
- /**/
13267
- {
13268
- modelVariant: 'COMPLETION',
13269
- modelTitle: 'gpt-3.5-turbo-instruct',
13270
- modelName: 'gpt-3.5-turbo-instruct',
13271
- pricing: {
13272
- prompt: computeUsage("$1.50 / 1M tokens"),
13273
- output: computeUsage("$2.00 / 1M tokens"),
13622
+ /**/
13623
+ /**/
13624
+ {
13625
+ modelVariant: 'COMPLETION',
13626
+ modelTitle: 'gpt-3.5-turbo-instruct',
13627
+ modelName: 'gpt-3.5-turbo-instruct',
13628
+ pricing: {
13629
+ prompt: computeUsage("$1.50 / 1M tokens"),
13630
+ output: computeUsage("$2.00 / 1M tokens"),
13631
+ },
13274
13632
  },
13275
- },
13276
- /**/
13277
- /*/
13278
- {
13279
- modelTitle: 'tts-1',
13280
- modelName: 'tts-1',
13281
- },
13282
- /**/
13283
- /**/
13284
- {
13285
- modelVariant: 'CHAT',
13286
- modelTitle: 'gpt-3.5-turbo',
13287
- modelName: 'gpt-3.5-turbo',
13288
- pricing: {
13289
- prompt: computeUsage("$3.00 / 1M tokens"),
13290
- output: computeUsage("$6.00 / 1M tokens"), // <- Not sure, refer to gpt-3.5-turbo in Fine-tuning models
13633
+ /**/
13634
+ /*/
13635
+ {
13636
+ modelTitle: 'tts-1',
13637
+ modelName: 'tts-1',
13638
+ },
13639
+ /**/
13640
+ /**/
13641
+ {
13642
+ modelVariant: 'CHAT',
13643
+ modelTitle: 'gpt-3.5-turbo',
13644
+ modelName: 'gpt-3.5-turbo',
13645
+ pricing: {
13646
+ prompt: computeUsage("$3.00 / 1M tokens"),
13647
+ output: computeUsage("$6.00 / 1M tokens"), // <- Not sure, refer to gpt-3.5-turbo in Fine-tuning models
13648
+ },
13291
13649
  },
13292
- },
13293
- /**/
13294
- /**/
13295
- {
13296
- modelVariant: 'CHAT',
13297
- modelTitle: 'gpt-3.5-turbo-0301',
13298
- modelName: 'gpt-3.5-turbo-0301',
13299
- pricing: {
13300
- prompt: computeUsage("$1.50 / 1M tokens"),
13301
- output: computeUsage("$2.00 / 1M tokens"),
13650
+ /**/
13651
+ /**/
13652
+ {
13653
+ modelVariant: 'CHAT',
13654
+ modelTitle: 'gpt-3.5-turbo-0301',
13655
+ modelName: 'gpt-3.5-turbo-0301',
13656
+ pricing: {
13657
+ prompt: computeUsage("$1.50 / 1M tokens"),
13658
+ output: computeUsage("$2.00 / 1M tokens"),
13659
+ },
13302
13660
  },
13303
- },
13304
- /**/
13305
- /**/
13306
- {
13307
- modelVariant: 'COMPLETION',
13308
- modelTitle: 'babbage-002',
13309
- modelName: 'babbage-002',
13310
- pricing: {
13311
- prompt: computeUsage("$0.40 / 1M tokens"),
13312
- output: computeUsage("$0.40 / 1M tokens"), // <- Not sure
13661
+ /**/
13662
+ /**/
13663
+ {
13664
+ modelVariant: 'COMPLETION',
13665
+ modelTitle: 'babbage-002',
13666
+ modelName: 'babbage-002',
13667
+ pricing: {
13668
+ prompt: computeUsage("$0.40 / 1M tokens"),
13669
+ output: computeUsage("$0.40 / 1M tokens"), // <- Not sure
13670
+ },
13313
13671
  },
13314
- },
13315
- /**/
13316
- /**/
13317
- {
13318
- modelVariant: 'CHAT',
13319
- modelTitle: 'gpt-4-1106-preview',
13320
- modelName: 'gpt-4-1106-preview',
13321
- pricing: {
13322
- prompt: computeUsage("$10.00 / 1M tokens"),
13323
- output: computeUsage("$30.00 / 1M tokens"),
13672
+ /**/
13673
+ /**/
13674
+ {
13675
+ modelVariant: 'CHAT',
13676
+ modelTitle: 'gpt-4-1106-preview',
13677
+ modelName: 'gpt-4-1106-preview',
13678
+ pricing: {
13679
+ prompt: computeUsage("$10.00 / 1M tokens"),
13680
+ output: computeUsage("$30.00 / 1M tokens"),
13681
+ },
13324
13682
  },
13325
- },
13326
- /**/
13327
- /**/
13328
- {
13329
- modelVariant: 'CHAT',
13330
- modelTitle: 'gpt-4-0125-preview',
13331
- modelName: 'gpt-4-0125-preview',
13332
- pricing: {
13333
- prompt: computeUsage("$10.00 / 1M tokens"),
13334
- output: computeUsage("$30.00 / 1M tokens"),
13683
+ /**/
13684
+ /**/
13685
+ {
13686
+ modelVariant: 'CHAT',
13687
+ modelTitle: 'gpt-4-0125-preview',
13688
+ modelName: 'gpt-4-0125-preview',
13689
+ pricing: {
13690
+ prompt: computeUsage("$10.00 / 1M tokens"),
13691
+ output: computeUsage("$30.00 / 1M tokens"),
13692
+ },
13335
13693
  },
13336
- },
13337
- /**/
13338
- /*/
13339
- {
13340
- modelTitle: 'tts-1-1106',
13341
- modelName: 'tts-1-1106',
13342
- },
13343
- /**/
13344
- /**/
13345
- {
13346
- modelVariant: 'CHAT',
13347
- modelTitle: 'gpt-3.5-turbo-0125',
13348
- modelName: 'gpt-3.5-turbo-0125',
13349
- pricing: {
13350
- prompt: computeUsage("$0.50 / 1M tokens"),
13351
- output: computeUsage("$1.50 / 1M tokens"),
13694
+ /**/
13695
+ /*/
13696
+ {
13697
+ modelTitle: 'tts-1-1106',
13698
+ modelName: 'tts-1-1106',
13699
+ },
13700
+ /**/
13701
+ /**/
13702
+ {
13703
+ modelVariant: 'CHAT',
13704
+ modelTitle: 'gpt-3.5-turbo-0125',
13705
+ modelName: 'gpt-3.5-turbo-0125',
13706
+ pricing: {
13707
+ prompt: computeUsage("$0.50 / 1M tokens"),
13708
+ output: computeUsage("$1.50 / 1M tokens"),
13709
+ },
13352
13710
  },
13353
- },
13354
- /**/
13355
- /**/
13356
- {
13357
- modelVariant: 'CHAT',
13358
- modelTitle: 'gpt-4-turbo-preview',
13359
- modelName: 'gpt-4-turbo-preview',
13360
- pricing: {
13361
- prompt: computeUsage("$10.00 / 1M tokens"),
13362
- output: computeUsage("$30.00 / 1M tokens"), // <- Not sure, just for gpt-4-turbo
13711
+ /**/
13712
+ /**/
13713
+ {
13714
+ modelVariant: 'CHAT',
13715
+ modelTitle: 'gpt-4-turbo-preview',
13716
+ modelName: 'gpt-4-turbo-preview',
13717
+ pricing: {
13718
+ prompt: computeUsage("$10.00 / 1M tokens"),
13719
+ output: computeUsage("$30.00 / 1M tokens"), // <- Not sure, just for gpt-4-turbo
13720
+ },
13363
13721
  },
13364
- },
13365
- /**/
13366
- /**/
13367
- {
13368
- modelVariant: 'EMBEDDING',
13369
- modelTitle: 'text-embedding-3-large',
13370
- modelName: 'text-embedding-3-large',
13371
- pricing: {
13372
- prompt: computeUsage("$0.13 / 1M tokens"),
13373
- // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
13374
- output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
13722
+ /**/
13723
+ /**/
13724
+ {
13725
+ modelVariant: 'EMBEDDING',
13726
+ modelTitle: 'text-embedding-3-large',
13727
+ modelName: 'text-embedding-3-large',
13728
+ pricing: {
13729
+ prompt: computeUsage("$0.13 / 1M tokens"),
13730
+ // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
13731
+ output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
13732
+ },
13375
13733
  },
13376
- },
13377
- /**/
13378
- /**/
13379
- {
13380
- modelVariant: 'EMBEDDING',
13381
- modelTitle: 'text-embedding-3-small',
13382
- modelName: 'text-embedding-3-small',
13383
- pricing: {
13384
- prompt: computeUsage("$0.02 / 1M tokens"),
13385
- // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
13386
- output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
13734
+ /**/
13735
+ /**/
13736
+ {
13737
+ modelVariant: 'EMBEDDING',
13738
+ modelTitle: 'text-embedding-3-small',
13739
+ modelName: 'text-embedding-3-small',
13740
+ pricing: {
13741
+ prompt: computeUsage("$0.02 / 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
+ },
13387
13745
  },
13388
- },
13389
- /**/
13390
- /**/
13391
- {
13392
- modelVariant: 'CHAT',
13393
- modelTitle: 'gpt-3.5-turbo-0613',
13394
- modelName: 'gpt-3.5-turbo-0613',
13395
- pricing: {
13396
- prompt: computeUsage("$1.50 / 1M tokens"),
13397
- output: computeUsage("$2.00 / 1M tokens"),
13746
+ /**/
13747
+ /**/
13748
+ {
13749
+ modelVariant: 'CHAT',
13750
+ modelTitle: 'gpt-3.5-turbo-0613',
13751
+ modelName: 'gpt-3.5-turbo-0613',
13752
+ pricing: {
13753
+ prompt: computeUsage("$1.50 / 1M tokens"),
13754
+ output: computeUsage("$2.00 / 1M tokens"),
13755
+ },
13398
13756
  },
13399
- },
13400
- /**/
13401
- /**/
13402
- {
13403
- modelVariant: 'EMBEDDING',
13404
- modelTitle: 'text-embedding-ada-002',
13405
- modelName: 'text-embedding-ada-002',
13406
- pricing: {
13407
- prompt: computeUsage("$0.1 / 1M tokens"),
13408
- // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
13409
- output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
13757
+ /**/
13758
+ /**/
13759
+ {
13760
+ modelVariant: 'EMBEDDING',
13761
+ modelTitle: 'text-embedding-ada-002',
13762
+ modelName: 'text-embedding-ada-002',
13763
+ pricing: {
13764
+ prompt: computeUsage("$0.1 / 1M tokens"),
13765
+ // TODO: [🏏] Leverage the batch API @see https://platform.openai.com/docs/guides/batch
13766
+ output: 0, // <- Note: [🆖] In Embedding models you dont pay for output
13767
+ },
13410
13768
  },
13411
- },
13412
- /**/
13413
- /*/
13414
- {
13415
- modelVariant: 'CHAT',
13416
- modelTitle: 'gpt-4-1106-vision-preview',
13417
- modelName: 'gpt-4-1106-vision-preview',
13418
- },
13419
- /**/
13420
- /*/
13421
- {
13422
- modelVariant: 'CHAT',
13423
- modelTitle: 'gpt-4-vision-preview',
13424
- modelName: 'gpt-4-vision-preview',
13425
- pricing: {
13426
- prompt: computeUsage(`$10.00 / 1M tokens`),
13427
- output: computeUsage(`$30.00 / 1M tokens`),
13769
+ /**/
13770
+ /*/
13771
+ {
13772
+ modelVariant: 'CHAT',
13773
+ modelTitle: 'gpt-4-1106-vision-preview',
13774
+ modelName: 'gpt-4-1106-vision-preview',
13428
13775
  },
13429
- },
13430
- /**/
13431
- /**/
13432
- {
13433
- modelVariant: 'CHAT',
13434
- modelTitle: 'gpt-4o-2024-05-13',
13435
- modelName: 'gpt-4o-2024-05-13',
13436
- pricing: {
13437
- prompt: computeUsage("$5.00 / 1M tokens"),
13438
- output: computeUsage("$15.00 / 1M tokens"),
13776
+ /**/
13777
+ /*/
13778
+ {
13779
+ modelVariant: 'CHAT',
13780
+ modelTitle: 'gpt-4-vision-preview',
13781
+ modelName: 'gpt-4-vision-preview',
13782
+ pricing: {
13783
+ prompt: computeUsage(`$10.00 / 1M tokens`),
13784
+ output: computeUsage(`$30.00 / 1M tokens`),
13785
+ },
13786
+ },
13787
+ /**/
13788
+ /**/
13789
+ {
13790
+ modelVariant: 'CHAT',
13791
+ modelTitle: 'gpt-4o-2024-05-13',
13792
+ modelName: 'gpt-4o-2024-05-13',
13793
+ pricing: {
13794
+ prompt: computeUsage("$5.00 / 1M tokens"),
13795
+ output: computeUsage("$15.00 / 1M tokens"),
13796
+ },
13797
+ //TODO: [main] !!! Add gpt-4o-mini-2024-07-18 and all others to be up to date
13439
13798
  },
13440
- //TODO: [main] !!! Add gpt-4o-mini-2024-07-18 and all others to be up to date
13441
- },
13442
- /**/
13443
- /**/
13444
- {
13445
- modelVariant: 'CHAT',
13446
- modelTitle: 'gpt-4o',
13447
- modelName: 'gpt-4o',
13448
- pricing: {
13449
- prompt: computeUsage("$5.00 / 1M tokens"),
13450
- output: computeUsage("$15.00 / 1M tokens"),
13799
+ /**/
13800
+ /**/
13801
+ {
13802
+ modelVariant: 'CHAT',
13803
+ modelTitle: 'gpt-4o',
13804
+ modelName: 'gpt-4o',
13805
+ pricing: {
13806
+ prompt: computeUsage("$5.00 / 1M tokens"),
13807
+ output: computeUsage("$15.00 / 1M tokens"),
13808
+ },
13451
13809
  },
13452
- },
13453
- /**/
13454
- /**/
13455
- {
13456
- modelVariant: 'CHAT',
13457
- modelTitle: 'o1-preview',
13458
- modelName: 'o1-preview',
13459
- pricing: {
13460
- prompt: computeUsage("$15.00 / 1M tokens"),
13461
- output: computeUsage("$60.00 / 1M tokens"),
13810
+ /**/
13811
+ /**/
13812
+ {
13813
+ modelVariant: 'CHAT',
13814
+ modelTitle: 'o1-preview',
13815
+ modelName: 'o1-preview',
13816
+ pricing: {
13817
+ prompt: computeUsage("$15.00 / 1M tokens"),
13818
+ output: computeUsage("$60.00 / 1M tokens"),
13819
+ },
13462
13820
  },
13463
- },
13464
- /**/
13465
- /**/
13466
- {
13467
- modelVariant: 'CHAT',
13468
- modelTitle: 'o1-preview-2024-09-12',
13469
- modelName: 'o1-preview-2024-09-12',
13470
- // <- TODO: [💩] Some better system to organize theese date suffixes and versions
13471
- pricing: {
13472
- prompt: computeUsage("$15.00 / 1M tokens"),
13473
- output: computeUsage("$60.00 / 1M tokens"),
13821
+ /**/
13822
+ /**/
13823
+ {
13824
+ modelVariant: 'CHAT',
13825
+ modelTitle: 'o1-preview-2024-09-12',
13826
+ modelName: 'o1-preview-2024-09-12',
13827
+ // <- TODO: [💩] Some better system to organize theese date suffixes and versions
13828
+ pricing: {
13829
+ prompt: computeUsage("$15.00 / 1M tokens"),
13830
+ output: computeUsage("$60.00 / 1M tokens"),
13831
+ },
13474
13832
  },
13475
- },
13476
- /**/
13477
- /**/
13478
- {
13479
- modelVariant: 'CHAT',
13480
- modelTitle: 'o1-mini',
13481
- modelName: 'o1-mini',
13482
- pricing: {
13483
- prompt: computeUsage("$3.00 / 1M tokens"),
13484
- output: computeUsage("$12.00 / 1M tokens"),
13833
+ /**/
13834
+ /**/
13835
+ {
13836
+ modelVariant: 'CHAT',
13837
+ modelTitle: 'o1-mini',
13838
+ modelName: 'o1-mini',
13839
+ pricing: {
13840
+ prompt: computeUsage("$3.00 / 1M tokens"),
13841
+ output: computeUsage("$12.00 / 1M tokens"),
13842
+ },
13485
13843
  },
13486
- },
13487
- /**/
13488
- /**/
13489
- {
13490
- modelVariant: 'CHAT',
13491
- modelTitle: 'o1-mini-2024-09-12',
13492
- modelName: 'o1-mini-2024-09-12',
13493
- pricing: {
13494
- prompt: computeUsage("$3.00 / 1M tokens"),
13495
- output: computeUsage("$12.00 / 1M tokens"),
13844
+ /**/
13845
+ /**/
13846
+ {
13847
+ modelVariant: 'CHAT',
13848
+ modelTitle: 'o1-mini-2024-09-12',
13849
+ modelName: 'o1-mini-2024-09-12',
13850
+ pricing: {
13851
+ prompt: computeUsage("$3.00 / 1M tokens"),
13852
+ output: computeUsage("$12.00 / 1M tokens"),
13853
+ },
13496
13854
  },
13497
- },
13498
- /**/
13499
- /**/
13500
- {
13501
- modelVariant: 'CHAT',
13502
- modelTitle: 'gpt-3.5-turbo-16k-0613',
13503
- modelName: 'gpt-3.5-turbo-16k-0613',
13504
- pricing: {
13505
- prompt: computeUsage("$3.00 / 1M tokens"),
13506
- output: computeUsage("$4.00 / 1M tokens"),
13855
+ /**/
13856
+ /**/
13857
+ {
13858
+ modelVariant: 'CHAT',
13859
+ modelTitle: 'gpt-3.5-turbo-16k-0613',
13860
+ modelName: 'gpt-3.5-turbo-16k-0613',
13861
+ pricing: {
13862
+ prompt: computeUsage("$3.00 / 1M tokens"),
13863
+ output: computeUsage("$4.00 / 1M tokens"),
13864
+ },
13507
13865
  },
13508
- },
13509
- /**/
13510
- ]);
13866
+ /**/
13867
+ ],
13868
+ });
13511
13869
  /**
13512
13870
  * Note: [🤖] Add models of new variant
13513
13871
  * TODO: [🧠] Some mechanism to propagate unsureness
@@ -13682,18 +14040,23 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
13682
14040
  input: __assign({ tokensCount: uncertainNumber((_b = rawResponse.usage) === null || _b === void 0 ? void 0 : _b.promptTokens) }, computeUsageCounts(prompt.content)),
13683
14041
  output: __assign({ tokensCount: uncertainNumber((_c = rawResponse.usage) === null || _c === void 0 ? void 0 : _c.completionTokens) }, computeUsageCounts(prompt.content)),
13684
14042
  };
13685
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('AzureOpenAiExecutionTools ChatPromptResult', {
13686
- content: resultContent,
13687
- modelName: modelName,
13688
- timing: {
13689
- start: start,
13690
- complete: complete,
14043
+ return [2 /*return*/, exportJson({
14044
+ name: 'promptResult',
14045
+ message: "Result of `AzureOpenAiExecutionTools.callChatModel`",
14046
+ order: [],
14047
+ value: {
14048
+ content: resultContent,
14049
+ modelName: modelName,
14050
+ timing: {
14051
+ start: start,
14052
+ complete: complete,
14053
+ },
14054
+ usage: usage,
14055
+ rawPromptContent: rawPromptContent,
14056
+ rawRequest: rawRequest,
14057
+ rawResponse: __assign(__assign({}, rawResponse), { created: rawResponse.created.toISOString() }),
14058
+ // <- [🗯]
13691
14059
  },
13692
- usage: usage,
13693
- rawPromptContent: rawPromptContent,
13694
- rawRequest: rawRequest,
13695
- rawResponse: __assign(__assign({}, rawResponse), { created: rawResponse.created.toISOString() }),
13696
- // <- [🗯]
13697
14060
  })];
13698
14061
  case 4:
13699
14062
  error_1 = _d.sent();
@@ -13775,18 +14138,23 @@ var AzureOpenAiExecutionTools = /** @class */ (function () {
13775
14138
  input: __assign({ tokensCount: uncertainNumber((_b = rawResponse.usage) === null || _b === void 0 ? void 0 : _b.promptTokens) }, computeUsageCounts(prompt.content)),
13776
14139
  output: __assign({ tokensCount: uncertainNumber((_c = rawResponse.usage) === null || _c === void 0 ? void 0 : _c.completionTokens) }, computeUsageCounts(prompt.content)),
13777
14140
  };
13778
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('AzureOpenAiExecutionTools CompletionPromptResult', {
13779
- content: resultContent,
13780
- modelName: modelName,
13781
- timing: {
13782
- start: start,
13783
- complete: complete,
14141
+ return [2 /*return*/, exportJson({
14142
+ name: 'promptResult',
14143
+ message: "Result of `AzureOpenAiExecutionTools.callCompletionModel`",
14144
+ order: [],
14145
+ value: {
14146
+ content: resultContent,
14147
+ modelName: modelName,
14148
+ timing: {
14149
+ start: start,
14150
+ complete: complete,
14151
+ },
14152
+ usage: usage,
14153
+ rawPromptContent: rawPromptContent,
14154
+ rawRequest: rawRequest,
14155
+ rawResponse: __assign(__assign({}, rawResponse), { created: rawResponse.created.toISOString() }),
14156
+ // <- [🗯]
13784
14157
  },
13785
- usage: usage,
13786
- rawPromptContent: rawPromptContent,
13787
- rawRequest: rawRequest,
13788
- rawResponse: __assign(__assign({}, rawResponse), { created: rawResponse.created.toISOString() }),
13789
- // <- [🗯]
13790
14158
  })];
13791
14159
  case 4:
13792
14160
  error_2 = _d.sent();
@@ -14001,7 +14369,7 @@ function createExecutionToolsFromVercelProvider(options) {
14001
14369
  return modelVariant === 'CHAT';
14002
14370
  })) === null || _a === void 0 ? void 0 : _a.modelName);
14003
14371
  if (!modelName) {
14004
- throw new PipelineExecutionError(spaceTrim("\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 "));
14372
+ throw new PipelineExecutionError(spaceTrim("\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 "));
14005
14373
  }
14006
14374
  return [4 /*yield*/, vercelProvider.chat(modelName, __assign({ user: (userId === null || userId === void 0 ? void 0 : userId.toString()) || undefined }, additionalChatSettings))];
14007
14375
  case 1:
@@ -14064,18 +14432,22 @@ function createExecutionToolsFromVercelProvider(options) {
14064
14432
  }
14065
14433
  complete = $getCurrentDate();
14066
14434
  usage = UNCERTAIN_USAGE;
14067
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('createExecutionToolsFromVercelProvider ChatPromptResult', {
14068
- content: rawResponse.text,
14069
- modelName: modelName,
14070
- timing: {
14071
- start: start,
14072
- complete: complete,
14435
+ return [2 /*return*/, exportJson({
14436
+ name: 'promptResult',
14437
+ message: "Result of `createExecutionToolsFromVercelProvider.callChatModel`",
14438
+ value: {
14439
+ content: rawResponse.text,
14440
+ modelName: modelName,
14441
+ timing: {
14442
+ start: start,
14443
+ complete: complete,
14444
+ },
14445
+ usage: usage,
14446
+ rawPromptContent: rawPromptContent,
14447
+ rawRequest: rawRequest,
14448
+ rawResponse: asSerializable(rawResponse),
14449
+ // <- [🗯]
14073
14450
  },
14074
- usage: usage,
14075
- rawPromptContent: rawPromptContent,
14076
- rawRequest: rawRequest,
14077
- rawResponse: asSerializable(rawResponse),
14078
- // <- [🗯]
14079
14451
  })];
14080
14452
  }
14081
14453
  });
@@ -14442,18 +14814,23 @@ var OpenAiExecutionTools = /** @class */ (function () {
14442
14814
  if (resultContent === null) {
14443
14815
  throw new PipelineExecutionError('No response message from OpenAI');
14444
14816
  }
14445
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiExecutionTools ChatPromptResult', {
14446
- content: resultContent,
14447
- modelName: rawResponse.model || modelName,
14448
- timing: {
14449
- start: start,
14450
- complete: complete,
14817
+ return [2 /*return*/, exportJson({
14818
+ name: 'promptResult',
14819
+ message: "Result of `OpenAiExecutionTools.callChatModel`",
14820
+ order: [],
14821
+ value: {
14822
+ content: resultContent,
14823
+ modelName: rawResponse.model || modelName,
14824
+ timing: {
14825
+ start: start,
14826
+ complete: complete,
14827
+ },
14828
+ usage: usage,
14829
+ rawPromptContent: rawPromptContent,
14830
+ rawRequest: rawRequest,
14831
+ rawResponse: rawResponse,
14832
+ // <- [🗯]
14451
14833
  },
14452
- usage: usage,
14453
- rawPromptContent: rawPromptContent,
14454
- rawRequest: rawRequest,
14455
- rawResponse: rawResponse,
14456
- // <- [🗯]
14457
14834
  })];
14458
14835
  }
14459
14836
  });
@@ -14518,18 +14895,23 @@ var OpenAiExecutionTools = /** @class */ (function () {
14518
14895
  // eslint-disable-next-line prefer-const
14519
14896
  complete = $getCurrentDate();
14520
14897
  usage = computeOpenAiUsage(content || '', resultContent || '', rawResponse);
14521
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiExecutionTools CompletionPromptResult', {
14522
- content: resultContent,
14523
- modelName: rawResponse.model || modelName,
14524
- timing: {
14525
- start: start,
14526
- complete: complete,
14898
+ return [2 /*return*/, exportJson({
14899
+ name: 'promptResult',
14900
+ message: "Result of `OpenAiExecutionTools.callCompletionModel`",
14901
+ order: [],
14902
+ value: {
14903
+ content: resultContent,
14904
+ modelName: rawResponse.model || modelName,
14905
+ timing: {
14906
+ start: start,
14907
+ complete: complete,
14908
+ },
14909
+ usage: usage,
14910
+ rawPromptContent: rawPromptContent,
14911
+ rawRequest: rawRequest,
14912
+ rawResponse: rawResponse,
14913
+ // <- [🗯]
14527
14914
  },
14528
- usage: usage,
14529
- rawPromptContent: rawPromptContent,
14530
- rawRequest: rawRequest,
14531
- rawResponse: rawResponse,
14532
- // <- [🗯]
14533
14915
  })];
14534
14916
  }
14535
14917
  });
@@ -14586,18 +14968,23 @@ var OpenAiExecutionTools = /** @class */ (function () {
14586
14968
  usage = computeOpenAiUsage(content || '', '',
14587
14969
  // <- Note: Embedding does not have result content
14588
14970
  rawResponse);
14589
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiExecutionTools EmbeddingPromptResult', {
14590
- content: resultContent,
14591
- modelName: rawResponse.model || modelName,
14592
- timing: {
14593
- start: start,
14594
- complete: complete,
14971
+ return [2 /*return*/, exportJson({
14972
+ name: 'promptResult',
14973
+ message: "Result of `OpenAiExecutionTools.callEmbeddingModel`",
14974
+ order: [],
14975
+ value: {
14976
+ content: resultContent,
14977
+ modelName: rawResponse.model || modelName,
14978
+ timing: {
14979
+ start: start,
14980
+ complete: complete,
14981
+ },
14982
+ usage: usage,
14983
+ rawPromptContent: rawPromptContent,
14984
+ rawRequest: rawRequest,
14985
+ rawResponse: rawResponse,
14986
+ // <- [🗯]
14595
14987
  },
14596
- usage: usage,
14597
- rawPromptContent: rawPromptContent,
14598
- rawRequest: rawRequest,
14599
- rawResponse: rawResponse,
14600
- // <- [🗯]
14601
14988
  })];
14602
14989
  }
14603
14990
  });
@@ -14793,20 +15180,25 @@ var OpenAiAssistantExecutionTools = /** @class */ (function (_super) {
14793
15180
  if (resultContent === null) {
14794
15181
  throw new PipelineExecutionError('No response message from OpenAI');
14795
15182
  }
14796
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('OpenAiAssistantExecutionTools ChatPromptResult', {
14797
- content: resultContent,
14798
- modelName: 'assistant',
14799
- // <- TODO: [🥘] Detect used model in assistant
14800
- // ?> model: rawResponse.model || modelName,
14801
- timing: {
14802
- start: start,
14803
- complete: complete,
15183
+ return [2 /*return*/, exportJson({
15184
+ name: 'promptResult',
15185
+ message: "Result of `OpenAiAssistantExecutionTools.callChatModel`",
15186
+ order: [],
15187
+ value: {
15188
+ content: resultContent,
15189
+ modelName: 'assistant',
15190
+ // <- TODO: [🥘] Detect used model in assistant
15191
+ // ?> model: rawResponse.model || modelName,
15192
+ timing: {
15193
+ start: start,
15194
+ complete: complete,
15195
+ },
15196
+ usage: usage,
15197
+ rawPromptContent: rawPromptContent,
15198
+ rawRequest: rawRequest,
15199
+ rawResponse: rawResponse,
15200
+ // <- [🗯]
14804
15201
  },
14805
- usage: usage,
14806
- rawPromptContent: rawPromptContent,
14807
- rawRequest: rawRequest,
14808
- rawResponse: rawResponse,
14809
- // <- [🗯]
14810
15202
  })];
14811
15203
  }
14812
15204
  });
@@ -15130,7 +15522,7 @@ var markdownScraperMetadata = $deepFreeze({
15130
15522
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
15131
15523
  isAvilableInBrowser: true,
15132
15524
  requiredExecutables: [],
15133
- }); /* <- TODO: [🤛] */
15525
+ }); /* <- Note: [🤛] */
15134
15526
  /**
15135
15527
  * Registration of known scraper metadata
15136
15528
  *
@@ -15327,7 +15719,7 @@ var documentScraperMetadata = $deepFreeze({
15327
15719
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
15328
15720
  isAvilableInBrowser: false,
15329
15721
  requiredExecutables: ['Pandoc'],
15330
- }); /* <- TODO: [🤛] */
15722
+ }); /* <- Note: [🤛] */
15331
15723
  /**
15332
15724
  * Registration of known scraper metadata
15333
15725
  *
@@ -15494,7 +15886,7 @@ var legacyDocumentScraperMetadata = $deepFreeze({
15494
15886
  'LibreOffice',
15495
15887
  // <- TODO: [🧠] Should be 'LibreOffice' here, its dependency of dependency
15496
15888
  ],
15497
- }); /* <- TODO: [🤛] */
15889
+ }); /* <- Note: [🤛] */
15498
15890
  /**
15499
15891
  * Registration of known scraper metadata
15500
15892
  *
@@ -15660,7 +16052,7 @@ var LegacyDocumentScraper = /** @class */ (function () {
15660
16052
  */
15661
16053
  var createLegacyDocumentScraper = Object.assign(function (tools, options) {
15662
16054
  return new LegacyDocumentScraper(tools, options);
15663
- }, legacyDocumentScraperMetadata); /* <- TODO: [🤛] */
16055
+ }, legacyDocumentScraperMetadata); /* <- Note: [🤛] */
15664
16056
  /**
15665
16057
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
15666
16058
  */
@@ -15686,7 +16078,7 @@ var _LegacyDocumentScraperRegistration = $scrapersRegister.register(createLegacy
15686
16078
  */
15687
16079
  var createDocumentScraper = Object.assign(function (tools, options) {
15688
16080
  return new DocumentScraper(tools, options);
15689
- }, documentScraperMetadata); /* <- TODO: [🤛] */
16081
+ }, documentScraperMetadata); /* <- Note: [🤛] */
15690
16082
  /**
15691
16083
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
15692
16084
  */
@@ -15712,7 +16104,7 @@ var _DocumentScraperRegistration = $scrapersRegister.register(createDocumentScra
15712
16104
  */
15713
16105
  var createMarkdownScraper = Object.assign(function (tools, options) {
15714
16106
  return new MarkdownScraper(tools, options);
15715
- }, markdownScraperMetadata); /* <- TODO: [🤛] */
16107
+ }, markdownScraperMetadata); /* <- Note: [🤛] */
15716
16108
  /**
15717
16109
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
15718
16110
  */
@@ -15744,7 +16136,7 @@ var pdfScraperMetadata = $deepFreeze({
15744
16136
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
15745
16137
  isAvilableInBrowser: true,
15746
16138
  requiredExecutables: [],
15747
- }); /* <- TODO: [🤛] */
16139
+ }); /* <- Note: [🤛] */
15748
16140
  /**
15749
16141
  * Registration of known scraper metadata
15750
16142
  *
@@ -15824,7 +16216,7 @@ var PdfScraper = /** @class */ (function () {
15824
16216
  */
15825
16217
  var createPdfScraper = Object.assign(function (tools, options) {
15826
16218
  return new PdfScraper(tools, options);
15827
- }, pdfScraperMetadata); /* <- TODO: [🤛] */
16219
+ }, pdfScraperMetadata); /* <- Note: [🤛] */
15828
16220
  /**
15829
16221
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
15830
16222
  */
@@ -15856,7 +16248,7 @@ var websiteScraperMetadata = $deepFreeze({
15856
16248
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
15857
16249
  isAvilableInBrowser: false,
15858
16250
  requiredExecutables: [],
15859
- }); /* <- TODO: [🤛] */
16251
+ }); /* <- Note: [🤛] */
15860
16252
  /**
15861
16253
  * Registration of known scraper metadata
15862
16254
  *
@@ -16025,7 +16417,7 @@ var WebsiteScraper = /** @class */ (function () {
16025
16417
  */
16026
16418
  var createWebsiteScraper = Object.assign(function (tools, options) {
16027
16419
  return new WebsiteScraper(tools, options);
16028
- }, websiteScraperMetadata); /* <- TODO: [🤛] */
16420
+ }, websiteScraperMetadata); /* <- Note: [🤛] */
16029
16421
  /**
16030
16422
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
16031
16423
  */