@promptbook/core 0.92.0-19 → 0.92.0-21

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
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-19';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-21';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -462,6 +462,14 @@ const DEFAULT_IS_AUTO_INSTALLED = false;
462
462
  * @public exported from `@promptbook/core`
463
463
  */
464
464
  const DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME = `getPipelineCollection`;
465
+ /**
466
+ * Default rate limits (requests per minute)
467
+ *
468
+ * Note: Adjust based on the provider tier you are have
469
+ *
470
+ * @public exported from `@promptbook/core`
471
+ */
472
+ const DEFAULT_RPM = 60;
465
473
  /**
466
474
  * @@@
467
475
  *
@@ -2185,15 +2193,12 @@ function jsonParse(value) {
2185
2193
  }
2186
2194
  throw new Error(spaceTrim((block) => `
2187
2195
  ${block(error.message)}
2188
-
2196
+
2189
2197
  The JSON text:
2190
2198
  ${block(value)}
2191
2199
  `));
2192
2200
  }
2193
2201
  }
2194
- /**
2195
- * TODO: !!!! Use in Promptbook.studio
2196
- */
2197
2202
 
2198
2203
  /**
2199
2204
  * Recursively converts JSON strings to JSON objects
@@ -7212,6 +7217,43 @@ const ChatbotFormfactorDefinition = {
7212
7217
  },
7213
7218
  };
7214
7219
 
7220
+ /**
7221
+ * Completion is formfactor that emulates completion models
7222
+ *
7223
+ * @public exported from `@promptbook/core`
7224
+ */
7225
+ const CompletionFormfactorDefinition = {
7226
+ name: 'COMPLETION',
7227
+ description: `@@@`,
7228
+ documentationUrl: `https://github.com/webgptorg/promptbook/discussions/@@`,
7229
+ // <- TODO: https://github.com/webgptorg/promptbook/discussions/new?category=concepts
7230
+ // "🔠 Completion Formfactor"
7231
+ pipelineInterface: {
7232
+ inputParameters: [
7233
+ {
7234
+ name: 'inputText',
7235
+ description: `Input text to be completed`,
7236
+ isInput: true,
7237
+ isOutput: false,
7238
+ },
7239
+ {
7240
+ name: 'instructions',
7241
+ description: `Additional instructions for the model, for example the required length, empty by default`,
7242
+ isInput: true,
7243
+ isOutput: false,
7244
+ },
7245
+ ],
7246
+ outputParameters: [
7247
+ {
7248
+ name: 'followingText',
7249
+ description: `Text that follows the input text`,
7250
+ isInput: false,
7251
+ isOutput: true,
7252
+ },
7253
+ ],
7254
+ },
7255
+ };
7256
+
7215
7257
  /**
7216
7258
  * Generator is form of app that @@@
7217
7259
  *
@@ -7396,6 +7438,8 @@ const FORMFACTOR_DEFINITIONS = [
7396
7438
  MatcherFormfactorDefinition,
7397
7439
  GeneratorFormfactorDefinition,
7398
7440
  ImageGeneratorFormfactorDefinition,
7441
+ CompletionFormfactorDefinition,
7442
+ // <- [🛬] When making new formfactor, copy the _boilerplate and link it here
7399
7443
  ];
7400
7444
  /**
7401
7445
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -10888,6 +10932,7 @@ const _OpenAiMetadataRegistration = $llmToolsMetadataRegister.register({
10888
10932
  className: 'OpenAiExecutionTools',
10889
10933
  options: {
10890
10934
  apiKey: 'sk-',
10935
+ maxRequestsPerMinute: DEFAULT_RPM,
10891
10936
  },
10892
10937
  };
10893
10938
  },
@@ -10957,6 +11002,52 @@ const _OpenAiAssistantMetadataRegistration = $llmToolsMetadataRegister.register(
10957
11002
  * Note: [💞] Ignore a discrepancy between file name and entity name
10958
11003
  */
10959
11004
 
11005
+ /**
11006
+ * Migrates the pipeline to the latest version
11007
+ *
11008
+ * Note: Migration does not do heavy lifting like calling the LLMs, just lightweight changes of the structure
11009
+ *
11010
+ * @public exported from `@promptbook/core`
11011
+ */
11012
+ function migratePipeline(deprecatedPipeline) {
11013
+ /* eslint-disable prefer-const */
11014
+ let { pipelineUrl, sourceFile, title, bookVersion, description, formfactorName, parameters, tasks, knowledgeSources, knowledgePieces, personas, preparations, sources, } = deprecatedPipeline;
11015
+ let isChanged = false;
11016
+ personas = personas.map((persona) => {
11017
+ const migratedPersona = { ...persona }; /* <- TODO: [🌪] */
11018
+ if (migratedPersona.modelRequirements !== undefined) {
11019
+ isChanged = true;
11020
+ migratedPersona.modelsRequirements = [migratedPersona.modelRequirements];
11021
+ delete migratedPersona.modelRequirements;
11022
+ }
11023
+ return migratedPersona;
11024
+ });
11025
+ if (!isChanged) {
11026
+ // Note: If nothing to migrate, return the same pipeline
11027
+ return deprecatedPipeline;
11028
+ }
11029
+ const migratedPipeline = {
11030
+ pipelineUrl,
11031
+ sourceFile,
11032
+ title,
11033
+ bookVersion,
11034
+ description,
11035
+ formfactorName,
11036
+ parameters,
11037
+ tasks,
11038
+ knowledgeSources,
11039
+ knowledgePieces,
11040
+ personas,
11041
+ preparations,
11042
+ sources,
11043
+ // <- TODO: [🍙] Make some standard order of json properties
11044
+ };
11045
+ console.info(`Book automatically migrated`, { deprecatedPipeline, migratedPipeline });
11046
+ // console.info(`Book automatically migrated from ${} -> ${}`, {deprecatedPipeline,migratedPipeline})
11047
+ // <- TODO: Report the versions of the migration, DO not migrate backwards, throw `CompatibilityError` when given newer version than current version of the engine and link the NPM + Docker packages
11048
+ return migratedPipeline;
11049
+ }
11050
+
10960
11051
  /**
10961
11052
  * Function `isValidPipelineString` will validate the if the string is a valid pipeline string
10962
11053
  * 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.
@@ -11389,5 +11480,5 @@ class PrefixStorage {
11389
11480
  }
11390
11481
  }
11391
11482
 
11392
- export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, AuthenticationError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CLI_APP_ID, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatError, CsvFormatParser, DEFAULT_BOOKS_DIRNAME, DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, DEFAULT_BOOK_TITLE, DEFAULT_CSV_SETTINGS, DEFAULT_DOWNLOAD_CACHE_DIRNAME, DEFAULT_EXECUTION_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_FILE_SIZE, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_SERVER_URL, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_ORDER, MODEL_TRUST_LEVEL, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PLAYGROUND_APP_ID, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, PromptbookFetchError, REMOTE_SERVER_URLS, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatParser, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UNCERTAIN_ZERO_VALUE, UnexpectedError, WrappedError, ZERO_USAGE, ZERO_VALUE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _BoilerplateScraperMetadataRegistration, _DeepseekMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _MarkitdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, book, cacheLlmTools, collectionToJson, compilePipeline, computeCosineSimilarity, countUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, filterModels, getPipelineInterface, identificationToPromptbookToken, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, parsePipeline, pipelineJsonToString, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, promptbookFetch, promptbookTokenToIdentification, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline, validatePipelineString };
11483
+ export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, AuthenticationError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CLI_APP_ID, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CompletionFormfactorDefinition, CsvFormatError, CsvFormatParser, DEFAULT_BOOKS_DIRNAME, DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, DEFAULT_BOOK_TITLE, DEFAULT_CSV_SETTINGS, DEFAULT_DOWNLOAD_CACHE_DIRNAME, DEFAULT_EXECUTION_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_FILE_SIZE, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_SERVER_URL, DEFAULT_RPM, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_ORDER, MODEL_TRUST_LEVEL, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PLAYGROUND_APP_ID, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, PromptbookFetchError, REMOTE_SERVER_URLS, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatParser, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UNCERTAIN_ZERO_VALUE, UnexpectedError, WrappedError, ZERO_USAGE, ZERO_VALUE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _BoilerplateScraperMetadataRegistration, _DeepseekMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _MarkitdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, book, cacheLlmTools, collectionToJson, compilePipeline, computeCosineSimilarity, countUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, filterModels, getPipelineInterface, identificationToPromptbookToken, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, migratePipeline, parsePipeline, pipelineJsonToString, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, promptbookFetch, promptbookTokenToIdentification, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline, validatePipelineString };
11393
11484
  //# sourceMappingURL=index.es.js.map