@promptbook/core 0.100.0-45 → 0.100.0-46
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 +80 -62
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -6
- package/esm/typings/src/book-2.0/commitments/_misc/AgentModelRequirements.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +4 -10
- package/esm/typings/src/book-components/Chat/interfaces/ChatMessage.d.ts +12 -26
- package/esm/typings/src/book-components/Chat/interfaces/ChatParticipant.d.ts +12 -0
- package/esm/typings/src/config.d.ts +7 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +8 -0
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +8 -0
- package/esm/typings/src/playground/permanent/error-handling-playground.d.ts +5 -0
- package/esm/typings/src/utils/organization/preserve.d.ts +21 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -2
- package/umd/index.umd.js +84 -65
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +0 -14
package/esm/index.es.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import spaceTrim$1, { spaceTrim } from 'spacetrim';
|
|
2
|
-
import { format } from 'prettier';
|
|
3
2
|
import parserHtml from 'prettier/parser-html';
|
|
3
|
+
import parserMarkdown from 'prettier/parser-markdown';
|
|
4
|
+
import { format } from 'prettier/standalone';
|
|
4
5
|
import { randomBytes } from 'crypto';
|
|
5
6
|
import { Subject } from 'rxjs';
|
|
6
7
|
import { forTime } from 'waitasecond';
|
|
@@ -27,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
27
28
|
* @generated
|
|
28
29
|
* @see https://github.com/webgptorg/promptbook
|
|
29
30
|
*/
|
|
30
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-46';
|
|
31
32
|
/**
|
|
32
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -706,6 +707,13 @@ const DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME = `getPipelineCollection`;
|
|
|
706
707
|
* @public exported from `@promptbook/core`
|
|
707
708
|
*/
|
|
708
709
|
const DEFAULT_MAX_REQUESTS_PER_MINUTE = 60;
|
|
710
|
+
/**
|
|
711
|
+
* API request timeout in milliseconds
|
|
712
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
713
|
+
*
|
|
714
|
+
* @public exported from `@promptbook/core`
|
|
715
|
+
*/
|
|
716
|
+
const API_REQUEST_TIMEOUT = parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
709
717
|
/**
|
|
710
718
|
* URL of the Promptbook logo
|
|
711
719
|
*
|
|
@@ -2735,7 +2743,7 @@ function prettifyMarkdown(content) {
|
|
|
2735
2743
|
try {
|
|
2736
2744
|
return format(content, {
|
|
2737
2745
|
parser: 'markdown',
|
|
2738
|
-
plugins: [parserHtml],
|
|
2746
|
+
plugins: [parserMarkdown, parserHtml],
|
|
2739
2747
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
2740
2748
|
endOfLine: 'lf',
|
|
2741
2749
|
tabWidth: 4,
|
|
@@ -7318,64 +7326,74 @@ function createPipelineExecutor(options) {
|
|
|
7318
7326
|
});
|
|
7319
7327
|
});
|
|
7320
7328
|
};
|
|
7321
|
-
const pipelineExecutor = (inputParameters) =>
|
|
7322
|
-
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
// Find current task being executed (first task not yet completed)
|
|
7341
|
-
const remainingTasks = pipeline.tasks.filter((task) => !executedTaskTitles.has(task.title));
|
|
7342
|
-
if (remainingTasks.length > 0) {
|
|
7343
|
-
currentTaskName = remainingTasks[0].name;
|
|
7329
|
+
const pipelineExecutor = (inputParameters) => {
|
|
7330
|
+
const startTime = new Date().getTime();
|
|
7331
|
+
return createTask({
|
|
7332
|
+
taskType: 'EXECUTION',
|
|
7333
|
+
title: pipeline.title,
|
|
7334
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
7335
|
+
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
7336
|
+
var _a, _b;
|
|
7337
|
+
updateOngoingResult(newOngoingResult);
|
|
7338
|
+
// Calculate and update tldr based on pipeline progress
|
|
7339
|
+
const cv = newOngoingResult;
|
|
7340
|
+
// Calculate progress based on parameters resolved vs total parameters
|
|
7341
|
+
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
7342
|
+
let resolvedParameters = 0;
|
|
7343
|
+
let currentTaskTitle = '';
|
|
7344
|
+
// Get the resolved parameters from output parameters
|
|
7345
|
+
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
7346
|
+
// Count how many output parameters have non-empty values
|
|
7347
|
+
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
7344
7348
|
}
|
|
7345
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7349
|
+
// Try to determine current task from execution report
|
|
7350
|
+
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
7351
|
+
const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
|
|
7352
|
+
if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
|
|
7353
|
+
currentTaskTitle = lastExecution.prompt.title;
|
|
7354
|
+
}
|
|
7355
|
+
}
|
|
7356
|
+
// Calculate base progress percentage
|
|
7357
|
+
let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
|
|
7358
|
+
// Add time-based progress for current task if we haven't completed all parameters
|
|
7359
|
+
if (resolvedParameters < totalParameters) {
|
|
7360
|
+
const elapsedMs = new Date().getTime() - startTime;
|
|
7361
|
+
const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
|
|
7362
|
+
const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
|
|
7363
|
+
// If we have time progress but no parameter progress, show time progress
|
|
7364
|
+
if (percent === 0 && timeProgress > 0) {
|
|
7365
|
+
percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
|
|
7366
|
+
}
|
|
7367
|
+
else if (percent < 1) {
|
|
7368
|
+
// Add partial progress for current task
|
|
7369
|
+
const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
|
|
7370
|
+
percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
|
|
7371
|
+
}
|
|
7372
|
+
}
|
|
7373
|
+
// Clamp to [0,1]
|
|
7374
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
7375
|
+
// Generate message
|
|
7376
|
+
let message = '';
|
|
7377
|
+
if (currentTaskTitle) {
|
|
7378
|
+
message = `Executing: ${currentTaskTitle}`;
|
|
7379
|
+
}
|
|
7380
|
+
else if (resolvedParameters === 0) {
|
|
7381
|
+
message = 'Starting pipeline execution';
|
|
7382
|
+
}
|
|
7383
|
+
else if (resolvedParameters < totalParameters) {
|
|
7384
|
+
message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
|
|
7385
|
+
}
|
|
7386
|
+
else {
|
|
7387
|
+
message = 'Completing pipeline execution';
|
|
7388
|
+
}
|
|
7389
|
+
updateTldr({
|
|
7390
|
+
percent: percent,
|
|
7391
|
+
message,
|
|
7392
|
+
});
|
|
7375
7393
|
});
|
|
7376
|
-
}
|
|
7377
|
-
}
|
|
7378
|
-
}
|
|
7394
|
+
},
|
|
7395
|
+
});
|
|
7396
|
+
};
|
|
7379
7397
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
7380
7398
|
return pipelineExecutor;
|
|
7381
7399
|
}
|
|
@@ -7511,7 +7529,7 @@ async function preparePersona(personaDescription, tools, options) {
|
|
|
7511
7529
|
const result = await preparePersonaExecutor({
|
|
7512
7530
|
availableModels /* <- Note: Passing as JSON */,
|
|
7513
7531
|
personaDescription,
|
|
7514
|
-
}).asPromise();
|
|
7532
|
+
}).asPromise({ isCrashedOnError: true });
|
|
7515
7533
|
const { outputParameters } = result;
|
|
7516
7534
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
7517
7535
|
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
@@ -8376,7 +8394,7 @@ async function preparePipeline(pipeline, tools, options) {
|
|
|
8376
8394
|
});
|
|
8377
8395
|
const result = await prepareTitleExecutor({
|
|
8378
8396
|
book: sources.map(({ content }) => content).join('\n\n'),
|
|
8379
|
-
}).asPromise();
|
|
8397
|
+
}).asPromise({ isCrashedOnError: true });
|
|
8380
8398
|
const { outputParameters } = result;
|
|
8381
8399
|
const { title: titleRaw } = outputParameters;
|
|
8382
8400
|
if (isVerbose) {
|
|
@@ -14107,5 +14125,5 @@ class PrefixStorage {
|
|
|
14107
14125
|
}
|
|
14108
14126
|
}
|
|
14109
14127
|
|
|
14110
|
-
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, AuthenticationError, BIG_DATASET_TRESHOLD, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CLI_APP_ID, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CompletionFormfactorDefinition, CsvFormatError, CsvFormatParser, DEFAULT_BOOK, 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_MAX_REQUESTS_PER_MINUTE, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_SERVER_URL, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_SIMULATED_DURATION_MS, DEFAULT_TASK_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FAILED_VALUE_PLACEHOLDER, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_ORDERS, MODEL_TRUST_LEVELS, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedCommitmentDefinition, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PENDING_VALUE_PLACEHOLDER, PLAYGROUND_APP_ID, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, PROMPTBOOK_LOGO_URL, 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, _OllamaMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiCompatibleMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, book, cacheLlmTools, collectionToJson, compilePipeline, computeCosineSimilarity, countUsage, createAgentModelRequirements, createBasicAgentModelRequirements, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createEmptyAgentModelRequirements, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, filterModels, getAllCommitmentDefinitions, getAllCommitmentTypes, getCommitmentDefinition, getPipelineInterface, identificationToPromptbookToken, isCommitmentSupported, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidBook, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, migratePipeline, parseAgentSource, parsePipeline, pipelineJsonToString, prepareKnowledgePieces, preparePersona, preparePipeline, prettifyPipelineString, promptbookFetch, promptbookTokenToIdentification, unpreparePipeline, usageToHuman, usageToWorktime, validateBook, validatePipeline, validatePipelineString };
|
|
14128
|
+
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, API_REQUEST_TIMEOUT, AbstractFormatError, AuthenticationError, BIG_DATASET_TRESHOLD, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CLI_APP_ID, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CompletionFormfactorDefinition, CsvFormatError, CsvFormatParser, DEFAULT_BOOK, 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_MAX_REQUESTS_PER_MINUTE, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_SERVER_URL, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_SIMULATED_DURATION_MS, DEFAULT_TASK_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FAILED_VALUE_PLACEHOLDER, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_ORDERS, MODEL_TRUST_LEVELS, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedCommitmentDefinition, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PENDING_VALUE_PLACEHOLDER, PLAYGROUND_APP_ID, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, PROMPTBOOK_LOGO_URL, 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, _OllamaMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiCompatibleMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, book, cacheLlmTools, collectionToJson, compilePipeline, computeCosineSimilarity, countUsage, createAgentModelRequirements, createBasicAgentModelRequirements, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createEmptyAgentModelRequirements, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, filterModels, getAllCommitmentDefinitions, getAllCommitmentTypes, getCommitmentDefinition, getPipelineInterface, identificationToPromptbookToken, isCommitmentSupported, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidBook, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, migratePipeline, parseAgentSource, parsePipeline, pipelineJsonToString, prepareKnowledgePieces, preparePersona, preparePipeline, prettifyPipelineString, promptbookFetch, promptbookTokenToIdentification, unpreparePipeline, usageToHuman, usageToWorktime, validateBook, validatePipeline, validatePipelineString };
|
|
14111
14129
|
//# sourceMappingURL=index.es.js.map
|