@promptbook/core 0.81.0-16 → 0.81.0-18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/index.es.js CHANGED
@@ -25,7 +25,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- var PROMPTBOOK_ENGINE_VERSION = '0.81.0-15';
28
+ var PROMPTBOOK_ENGINE_VERSION = '0.81.0-17';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -148,6 +148,11 @@ function __spreadArray(to, from, pack) {
148
148
  }
149
149
  }
150
150
  return to.concat(ar || Array.prototype.slice.call(from));
151
+ }
152
+
153
+ function __makeTemplateObject(cooked, raw) {
154
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
155
+ return cooked;
151
156
  }
152
157
 
153
158
  /**
@@ -897,7 +902,6 @@ function checkSerializableAsJson(options) {
897
902
  function deepClone(objectValue) {
898
903
  return JSON.parse(JSON.stringify(objectValue));
899
904
  /*
900
- !!!!!!!!
901
905
  TODO: [🧠] Is there a better implementation?
902
906
  > const propertyNames = Object.getOwnPropertyNames(objectValue);
903
907
  > for (const propertyName of propertyNames) {
@@ -3546,6 +3550,23 @@ function arrayableToArray(input) {
3546
3550
  return [input];
3547
3551
  }
3548
3552
 
3553
+ /**
3554
+ * Just says that the variable is not used but should be kept
3555
+ * No side effects.
3556
+ *
3557
+ * Note: It can be usefull for:
3558
+ *
3559
+ * 1) Suppressing eager optimization of unused imports
3560
+ * 2) Suppressing eslint errors of unused variables in the tests
3561
+ * 3) Keeping the type of the variable for type testing
3562
+ *
3563
+ * @param value any values
3564
+ * @returns void
3565
+ * @private within the repository
3566
+ */
3567
+ function keepUnused() {
3568
+ }
3569
+
3549
3570
  /**
3550
3571
  * Replaces parameters in template with values from parameters object
3551
3572
  *
@@ -7344,20 +7365,24 @@ var ChatbotFormfactorDefinition = {
7344
7365
  */
7345
7366
  var GeneratorFormfactorDefinition = {
7346
7367
  name: 'GENERATOR',
7347
- description: "@@@",
7368
+ description: "Generates any kind (in HTML with possible scripts and css format) of content from input message",
7348
7369
  documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
7349
7370
  pipelineInterface: {
7350
7371
  inputParameters: [
7351
- /* @@@ */
7352
7372
  {
7353
- name: 'nonce',
7354
- description: 'Just to prevent GENERATOR to be set as implicit formfactor',
7373
+ name: 'inputMessage',
7374
+ description: "Input message to be image made from",
7355
7375
  isInput: true,
7356
7376
  isOutput: false,
7357
7377
  },
7358
7378
  ],
7359
7379
  outputParameters: [
7360
- /* @@@ */
7380
+ {
7381
+ name: 'result',
7382
+ description: "Result in HTML to be shown to user",
7383
+ isInput: false,
7384
+ isOutput: true,
7385
+ },
7361
7386
  ],
7362
7387
  },
7363
7388
  };
@@ -7396,7 +7421,7 @@ var GenericFormfactorDefinition = {
7396
7421
  */
7397
7422
  var ImageGeneratorFormfactorDefinition = {
7398
7423
  name: 'IMAGE_GENERATOR',
7399
- description: "@@@",
7424
+ description: "Generates prompt for image generation from input message",
7400
7425
  documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
7401
7426
  pipelineInterface: {
7402
7427
  inputParameters: [
@@ -8830,7 +8855,7 @@ var QuickChatbotHla = {
8830
8855
  isOutput: true,
8831
8856
  exampleValues: ['Hello, I am a Pavol`s virtual avatar. How can I help you?'],
8832
8857
  });
8833
- // TODO: !!!!!! spaceTrim
8858
+ // TODO: Use spaceTrim in multiline strings
8834
8859
  $pipelineJson.tasks.push({
8835
8860
  taskType: 'PROMPT_TASK',
8836
8861
  name: 'create-an-answer',
@@ -8838,8 +8863,11 @@ var QuickChatbotHla = {
8838
8863
  content: 'Write a response to the user message:\n\n**Question from user**\n\n> {userMessage}\n\n**Previous conversation**\n\n> {previousConversationSummary}',
8839
8864
  resultingParameterName: 'chatbotResponse',
8840
8865
  personaName: personaName,
8841
- dependentParameterNames: ['userMessage', 'previousConversationSummary' /* !!!!!!, 'knowledge'*/],
8842
- // !!!!!! preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
8866
+ dependentParameterNames: [
8867
+ 'userMessage',
8868
+ 'previousConversationSummary' /* TODO: [🧠][📛], 'knowledge'*/,
8869
+ ],
8870
+ // TODO: [🧠][📛] preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
8843
8871
  }, {
8844
8872
  taskType: 'PROMPT_TASK',
8845
8873
  name: 'summarize-the-conversation',
@@ -8853,19 +8881,22 @@ var QuickChatbotHla = {
8853
8881
  max: 10,
8854
8882
  },
8855
8883
  },
8856
- dependentParameterNames: ['userMessage', 'chatbotResponse' /* !!!!!!, 'knowledge'*/],
8857
- // !!!!!! preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
8884
+ dependentParameterNames: ['userMessage', 'chatbotResponse' /* TODO: [🧠][📛], 'knowledge'*/],
8885
+ // TODO: [🧠][📛] preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
8858
8886
  }, {
8859
8887
  taskType: 'SIMPLE_TASK',
8860
8888
  name: 'title',
8861
8889
  title: 'Title',
8862
8890
  content: '{conversationSummary}',
8863
8891
  resultingParameterName: 'title',
8864
- dependentParameterNames: ['conversationSummary' /* !!!!!!, 'knowledge'*/],
8865
- // !!!!!! preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
8892
+ dependentParameterNames: ['conversationSummary' /* TODO: [🧠][📛], 'knowledge'*/],
8893
+ // TODO: [🧠][📛] preparedContent: '{content}\n\n## Knowledge\n\n{knowledge}',
8866
8894
  });
8867
8895
  },
8868
8896
  };
8897
+ /**
8898
+ * TODO: [🧠][📛] Should this be here?
8899
+ */
8869
8900
 
8870
8901
  /**
8871
8902
  * All high-level abstractions
@@ -9106,13 +9137,13 @@ function flattenMarkdown(markdown) {
9106
9137
  */
9107
9138
 
9108
9139
  /**
9109
- * Removes HTML or Markdown comments from a string.
9140
+ * Removes Markdown (or HTML) comments
9110
9141
  *
9111
9142
  * @param {string} content - The string to remove comments from.
9112
9143
  * @returns {string} The input string with all comments removed.
9113
9144
  * @public exported from `@promptbook/markdown-utils`
9114
9145
  */
9115
- function removeContentComments(content) {
9146
+ function removeMarkdownComments(content) {
9116
9147
  return spaceTrim$1(content.replace(/<!--(.*?)-->/gs, ''));
9117
9148
  }
9118
9149
 
@@ -9197,7 +9228,7 @@ function precompilePipeline(pipelineString) {
9197
9228
  }
9198
9229
  pipelineString = restLines.join('\n');
9199
9230
  }
9200
- pipelineString = removeContentComments(pipelineString);
9231
+ pipelineString = removeMarkdownComments(pipelineString);
9201
9232
  pipelineString = spaceTrim$1(pipelineString);
9202
9233
  // ==============
9203
9234
  // Note: 1️⃣◽2️⃣ Process flat pipeline
@@ -9214,7 +9245,7 @@ function precompilePipeline(pipelineString) {
9214
9245
  var returnStatement_1 = pipelineStringLines.pop();
9215
9246
  var prompt_1 = spaceTrim$1(pipelineStringLines.join('\n'));
9216
9247
  pipelineString = spaceTrim$1(function (block) { return "\n # ".concat(DEFAULT_TITLE /* <- TODO: !!!!!! Title for flat pipelines */, "\n\n ## Prompt\n\n ```\n ").concat(block(prompt_1), "\n ```\n\n ").concat(returnStatement_1, "\n "); });
9217
- // <- TODO: !!!!!! Use `book notation
9248
+ // <- TODO: !!!!!! Use book` notation
9218
9249
  // console.log(pipelineString);
9219
9250
  }
9220
9251
  // ==============
@@ -9685,7 +9716,7 @@ function addAutoGeneratedSection(content, options) {
9685
9716
  return content.replace(sectionRegex, contentToInsert);
9686
9717
  }
9687
9718
  // Note: Following is the case when the section is not found in the file so we add it there
9688
- var placeForSection = removeContentComments(content).match(/^##.*$/im);
9719
+ var placeForSection = removeMarkdownComments(content).match(/^##.*$/im);
9689
9720
  if (placeForSection !== null) {
9690
9721
  var _a = __read(placeForSection, 1), heading_1 = _a[0];
9691
9722
  return content.replace(heading_1, spaceTrim$1(function (block) { return "\n ".concat(block(contentToInsert), "\n\n ").concat(block(heading_1), "\n "); }));
@@ -10947,6 +10978,48 @@ var _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register({
10947
10978
  * Note: [💞] Ignore a discrepancy between file name and entity name
10948
10979
  */
10949
10980
 
10981
+ /**
10982
+ * Function `isValidPipelineString` will validate the if the string is a valid pipeline string
10983
+ * It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
10984
+ *
10985
+ * @public exported from `@promptbook/core`
10986
+ */
10987
+ function isValidPipelineString(value) {
10988
+ // TODO: !!!!!! Implement the validation + add false tests
10989
+ return true;
10990
+ }
10991
+ /**
10992
+ * TODO: [🧠][🈴] Where is the best location for this file
10993
+ */
10994
+
10995
+ /**
10996
+ * Function for notating a pipeline with a book\`...\ notation as template literal
10997
+ *
10998
+ * @param strings @@@
10999
+ * @param values @@@
11000
+ * @returns the pipeline string
11001
+ * @public exported from `@promptbook/core`
11002
+ */
11003
+ function book(strings) {
11004
+ var values = [];
11005
+ for (var _i = 1; _i < arguments.length; _i++) {
11006
+ values[_i - 1] = arguments[_i];
11007
+ }
11008
+ if (strings.length !== 1 && values.length !== 0) {
11009
+ throw new NotYetImplementedError("Only one string without interpolated value is supported for now in book`...` notation");
11010
+ }
11011
+ var pipelineString = strings[0];
11012
+ pipelineString = spaceTrim(pipelineString);
11013
+ return pipelineString;
11014
+ }
11015
+ keepUnused(book(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n !!!!!! Remove\n"], ["\n !!!!!! Remove\n"]))));
11016
+ var templateObject_1;
11017
+ /**
11018
+ * TODO: !!!!!! Use book\`...\ notation instead of as PipelineString
11019
+ * TODO: [🧠][🈴] Where is the best location for this file
11020
+ * Note: [💞] Ignore a discrepancy between file name and entity name
11021
+ */
11022
+
10950
11023
  /**
10951
11024
  * Metadata of the scraper
10952
11025
  *
@@ -11074,7 +11147,10 @@ var websiteScraperMetadata = $deepFreeze({
11074
11147
  className: 'WebsiteScraper',
11075
11148
  mimeTypes: ['text/html'],
11076
11149
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
11077
- isAvilableInBrowser: false,
11150
+ isAvilableInBrowser: true,
11151
+ // <- TODO: !!!!!!! Is it available in browser?
11152
+ // <- TODO: !!!!!!! Is toggling this to true enough to make it available in browser?
11153
+ // <- TODO: Maybe make it available in browser
11078
11154
  requiredExecutables: [],
11079
11155
  }); /* <- Note: [🤛] */
11080
11156
  /**
@@ -11172,5 +11248,5 @@ var PrefixStorage = /** @class */ (function () {
11172
11248
  return PrefixStorage;
11173
11249
  }());
11174
11250
 
11175
- export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LOGO_DARK_SRC, LOGO_LIGHT_SRC, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, compilePipeline, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, getPipelineInterface, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, precompilePipeline, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
11251
+ export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LOGO_DARK_SRC, LOGO_LIGHT_SRC, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, book, cacheLlmTools, collectionToJson, compilePipeline, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, getPipelineInterface, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, precompilePipeline, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
11176
11252
  //# sourceMappingURL=index.es.js.map