@promptbook/legacy-documents 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 +88 -64
- 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 +2 -3
- package/umd/index.umd.js +92 -68
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +0 -14
|
@@ -11,6 +11,8 @@ import type { BookEditorProps } from '../book-components/BookEditor/BookEditor';
|
|
|
11
11
|
import { BookEditor } from '../book-components/BookEditor/BookEditor';
|
|
12
12
|
import { DEFAULT_BOOK_FONT_CLASS } from '../book-components/BookEditor/config';
|
|
13
13
|
import { Chat } from '../book-components/Chat/Chat/Chat';
|
|
14
|
+
import type { ChatMessage } from '../book-components/Chat/interfaces/ChatMessage';
|
|
15
|
+
import type { ChatParticipant } from '../book-components/Chat/interfaces/ChatParticipant';
|
|
14
16
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
15
17
|
export type { AvatarChipProps };
|
|
16
18
|
export { AvatarChip };
|
|
@@ -24,3 +26,5 @@ export type { BookEditorProps };
|
|
|
24
26
|
export { BookEditor };
|
|
25
27
|
export { DEFAULT_BOOK_FONT_CLASS };
|
|
26
28
|
export { Chat };
|
|
29
|
+
export type { ChatMessage };
|
|
30
|
+
export type { ChatParticipant };
|
|
@@ -49,6 +49,7 @@ import { DEFAULT_IS_AUTO_INSTALLED } from '../config';
|
|
|
49
49
|
import { DEFAULT_TASK_SIMULATED_DURATION_MS } from '../config';
|
|
50
50
|
import { DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME } from '../config';
|
|
51
51
|
import { DEFAULT_MAX_REQUESTS_PER_MINUTE } from '../config';
|
|
52
|
+
import { API_REQUEST_TIMEOUT } from '../config';
|
|
52
53
|
import { PROMPTBOOK_LOGO_URL } from '../config';
|
|
53
54
|
import { MODEL_TRUST_LEVELS } from '../constants';
|
|
54
55
|
import { MODEL_ORDERS } from '../constants';
|
|
@@ -212,6 +213,7 @@ export { DEFAULT_IS_AUTO_INSTALLED };
|
|
|
212
213
|
export { DEFAULT_TASK_SIMULATED_DURATION_MS };
|
|
213
214
|
export { DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME };
|
|
214
215
|
export { DEFAULT_MAX_REQUESTS_PER_MINUTE };
|
|
216
|
+
export { API_REQUEST_TIMEOUT };
|
|
215
217
|
export { PROMPTBOOK_LOGO_URL };
|
|
216
218
|
export { MODEL_TRUST_LEVELS };
|
|
217
219
|
export { MODEL_ORDERS };
|
|
@@ -17,9 +17,7 @@ import type { AvatarProfileProps } from '../book-components/AvatarProfile/Avatar
|
|
|
17
17
|
import type { AvatarProfileFromSourceProps } from '../book-components/AvatarProfile/AvatarProfile/AvatarProfileFromSource';
|
|
18
18
|
import type { BookEditorProps } from '../book-components/BookEditor/BookEditor';
|
|
19
19
|
import type { ChatMessage } from '../book-components/Chat/interfaces/ChatMessage';
|
|
20
|
-
import type {
|
|
21
|
-
import type { PromptbookPersonaChatMessage } from '../book-components/Chat/interfaces/ChatMessage';
|
|
22
|
-
import type { CompleteChatMessage } from '../book-components/Chat/interfaces/ChatMessage';
|
|
20
|
+
import type { ChatParticipant } from '../book-components/Chat/interfaces/ChatParticipant';
|
|
23
21
|
import type { PipelineCollection } from '../collection/PipelineCollection';
|
|
24
22
|
import type { Command } from '../commands/_common/types/Command';
|
|
25
23
|
import type { CommandParser } from '../commands/_common/types/CommandParser';
|
|
@@ -344,9 +342,7 @@ export type { AvatarProfileProps };
|
|
|
344
342
|
export type { AvatarProfileFromSourceProps };
|
|
345
343
|
export type { BookEditorProps };
|
|
346
344
|
export type { ChatMessage };
|
|
347
|
-
export type {
|
|
348
|
-
export type { PromptbookPersonaChatMessage };
|
|
349
|
-
export type { CompleteChatMessage };
|
|
345
|
+
export type { ChatParticipant };
|
|
350
346
|
export type { PipelineCollection };
|
|
351
347
|
export type { Command };
|
|
352
348
|
export type { CommandParser };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import type { Promisable } from 'type-fest';
|
|
3
3
|
import type { ChatMessage } from '../interfaces/ChatMessage';
|
|
4
|
+
import type { ChatParticipant } from '../interfaces/ChatParticipant';
|
|
4
5
|
/**
|
|
5
6
|
* @deprecated use `isComplete` instead
|
|
6
7
|
* @private util of `<Chat />`
|
|
@@ -11,11 +12,11 @@ interface ChatProps {
|
|
|
11
12
|
* Optional callback to create a new agent from the template.
|
|
12
13
|
* If provided, renders the [Use this template] button.
|
|
13
14
|
*/
|
|
14
|
-
onUseTemplate
|
|
15
|
+
onUseTemplate?(): void;
|
|
15
16
|
/**
|
|
16
17
|
* Messages to render - they are rendered as they are
|
|
17
18
|
*/
|
|
18
|
-
readonly messages:
|
|
19
|
+
readonly messages: ReadonlyArray<ChatMessage>;
|
|
19
20
|
/**
|
|
20
21
|
* Called every time the user types or dictated a message
|
|
21
22
|
*/
|
|
@@ -38,10 +39,6 @@ interface ChatProps {
|
|
|
38
39
|
* The language code to use for voice recognition
|
|
39
40
|
*/
|
|
40
41
|
readonly voiceLanguage?: string;
|
|
41
|
-
/**
|
|
42
|
-
* Avatars for each user
|
|
43
|
-
*/
|
|
44
|
-
readonly avatars?: Partial<Record<ChatMessage['from'], string>>;
|
|
45
42
|
/**
|
|
46
43
|
* Optional placeholder message for the textarea
|
|
47
44
|
*
|
|
@@ -105,10 +102,7 @@ interface ChatProps {
|
|
|
105
102
|
* Optional mapping of participant IDs (message.from) to display metadata for exports.
|
|
106
103
|
* Keys should match ChatMessage.from values (e.g., 'USER', 'AGENT_{id}', etc.)
|
|
107
104
|
*/
|
|
108
|
-
readonly participants?:
|
|
109
|
-
name: string;
|
|
110
|
-
avatarUrl?: string;
|
|
111
|
-
}>;
|
|
105
|
+
readonly participants?: ReadonlyArray<ChatParticipant>;
|
|
112
106
|
}
|
|
113
107
|
/**
|
|
114
108
|
* Renders a chat with messages and input for new messages
|
|
@@ -1,30 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
isVoiceCall?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export interface PromptbookPersonaChatMessage {
|
|
1
|
+
import type { string_markdown } from '../../../types/typeAliases';
|
|
2
|
+
import type { string_name } from '../../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* A message in the chat
|
|
5
|
+
*
|
|
6
|
+
* @public exported from `@promptbook/components`
|
|
7
|
+
*/
|
|
8
|
+
export type ChatMessage = {
|
|
12
9
|
id: string;
|
|
13
10
|
date: Date;
|
|
14
|
-
from:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
width?: number;
|
|
18
|
-
height?: number;
|
|
19
|
-
};
|
|
20
|
-
content: string;
|
|
21
|
-
isComplete: boolean;
|
|
11
|
+
from: string_name;
|
|
12
|
+
content: string_markdown;
|
|
13
|
+
isComplete?: boolean;
|
|
22
14
|
expectedAnswer?: string;
|
|
23
15
|
isVoiceCall?: boolean;
|
|
24
|
-
}
|
|
25
|
-
export interface CompleteChatMessage {
|
|
26
|
-
isComplete: true;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* TODO: [🧠] ACRY Rename PROMPTBOOK_PERSONA + USER, Teacher, teacher to sth else
|
|
30
|
-
*/
|
|
16
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { string_name } from '../../../types/typeAliases';
|
|
2
|
+
import type { string_url_image } from '../../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* A participant in the chat
|
|
5
|
+
*
|
|
6
|
+
* @public exported from `@promptbook/components`
|
|
7
|
+
*/
|
|
8
|
+
export type ChatParticipant = {
|
|
9
|
+
name: string_name;
|
|
10
|
+
avatarUrl?: string_url_image;
|
|
11
|
+
color: string;
|
|
12
|
+
};
|
|
@@ -301,6 +301,13 @@ export declare const DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME = "getPipelin
|
|
|
301
301
|
* @public exported from `@promptbook/core`
|
|
302
302
|
*/
|
|
303
303
|
export declare const DEFAULT_MAX_REQUESTS_PER_MINUTE = 60;
|
|
304
|
+
/**
|
|
305
|
+
* API request timeout in milliseconds
|
|
306
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
307
|
+
*
|
|
308
|
+
* @public exported from `@promptbook/core`
|
|
309
|
+
*/
|
|
310
|
+
export declare const API_REQUEST_TIMEOUT: number;
|
|
304
311
|
/**
|
|
305
312
|
* URL of the Promptbook logo
|
|
306
313
|
*
|
|
@@ -110,6 +110,14 @@ export type AbstractTask<TTaskResult extends AbstractTaskResult> = {
|
|
|
110
110
|
* Gets a promise that resolves with the task result
|
|
111
111
|
*/
|
|
112
112
|
asPromise(options?: {
|
|
113
|
+
/**
|
|
114
|
+
* Do the task throws on error
|
|
115
|
+
*
|
|
116
|
+
* - If `true` when error occurs the returned promise will rejects
|
|
117
|
+
* - If `false` the promise will resolve with object with all listed errors and warnings and partial result
|
|
118
|
+
*
|
|
119
|
+
* @default true
|
|
120
|
+
*/
|
|
113
121
|
readonly isCrashedOnError?: boolean;
|
|
114
122
|
}): Promise<TTaskResult>;
|
|
115
123
|
/**
|
|
@@ -82,6 +82,14 @@ export declare abstract class OpenAiCompatibleExecutionTools implements LlmExecu
|
|
|
82
82
|
* Default model for completion variant.
|
|
83
83
|
*/
|
|
84
84
|
protected abstract getDefaultEmbeddingModel(): AvailableModel;
|
|
85
|
+
/**
|
|
86
|
+
* Makes a request with retry logic for network errors like ECONNRESET
|
|
87
|
+
*/
|
|
88
|
+
private makeRequestWithRetry;
|
|
89
|
+
/**
|
|
90
|
+
* Determines if an error is retryable (network-related errors)
|
|
91
|
+
*/
|
|
92
|
+
private isRetryableNetworkError;
|
|
85
93
|
}
|
|
86
94
|
/**
|
|
87
95
|
* TODO: [🛄] Some way how to re-wrap the errors from `OpenAiCompatibleExecutionTools`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { really_any } from './really_any';
|
|
2
|
+
/**
|
|
3
|
+
* Does nothing, but preserves the function in the bundle
|
|
4
|
+
* Compiler is tricked into thinking the function is used
|
|
5
|
+
*
|
|
6
|
+
* @param value any function to preserve
|
|
7
|
+
* @returns nothing
|
|
8
|
+
* @private within the repository
|
|
9
|
+
*/
|
|
10
|
+
export declare function $preserve(...value: Array<really_any>): void;
|
|
11
|
+
/**
|
|
12
|
+
* DO NOT USE THIS FUNCTION
|
|
13
|
+
* Only purpose of this function is to trick the compiler and javascript engine
|
|
14
|
+
* that `_preserved` array can be used in the future and should not be garbage collected
|
|
15
|
+
*
|
|
16
|
+
* @private internal for `preserve`
|
|
17
|
+
*/
|
|
18
|
+
export declare function __DO_NOT_USE_getPreserved(): Array<really_any>;
|
|
19
|
+
/**
|
|
20
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
21
|
+
*/
|
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.100.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.100.0-45`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/legacy-documents",
|
|
3
|
-
"version": "0.100.0-
|
|
3
|
+
"version": "0.100.0-46",
|
|
4
4
|
"description": "Promptbook: Run AI apps in plain human language across multiple models and platforms",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -95,14 +95,13 @@
|
|
|
95
95
|
"module": "./esm/index.es.js",
|
|
96
96
|
"typings": "./esm/typings/src/_packages/legacy-documents.index.d.ts",
|
|
97
97
|
"peerDependencies": {
|
|
98
|
-
"@promptbook/core": "0.100.0-
|
|
98
|
+
"@promptbook/core": "0.100.0-46"
|
|
99
99
|
},
|
|
100
100
|
"dependencies": {
|
|
101
101
|
"colors": "1.4.0",
|
|
102
102
|
"crypto": "1.0.1",
|
|
103
103
|
"crypto-js": "4.2.0",
|
|
104
104
|
"papaparse": "5.4.1",
|
|
105
|
-
"prettier": "2.8.1",
|
|
106
105
|
"rxjs": "7.8.1",
|
|
107
106
|
"spacetrim": "0.11.59",
|
|
108
107
|
"waitasecond": "1.11.83"
|
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('path'), require('spacetrim'), require('child_process'), require('colors'), require('waitasecond'), require('crypto-js'), require('crypto-js/enc-hex'), require('prettier'), require('prettier/parser-
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'path', 'spacetrim', 'child_process', 'colors', 'waitasecond', 'crypto-js', 'crypto-js/enc-hex', 'prettier', 'prettier/parser-
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-legacy-documents"] = {}, global.promises, global.path, global.spaceTrim, global.child_process, global.colors, global.waitasecond, global.cryptoJs, global.hexEncoder, global.
|
|
5
|
-
})(this, (function (exports, promises, path, spaceTrim, child_process, colors, waitasecond, cryptoJs, hexEncoder,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('fs/promises'), require('path'), require('spacetrim'), require('child_process'), require('colors'), require('waitasecond'), require('crypto-js'), require('crypto-js/enc-hex'), require('prettier/parser-html'), require('prettier/parser-markdown'), require('prettier/standalone'), require('crypto'), require('rxjs'), require('crypto-js/sha256'), require('mime-types'), require('papaparse')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'fs/promises', 'path', 'spacetrim', 'child_process', 'colors', 'waitasecond', 'crypto-js', 'crypto-js/enc-hex', 'prettier/parser-html', 'prettier/parser-markdown', 'prettier/standalone', 'crypto', 'rxjs', 'crypto-js/sha256', 'mime-types', 'papaparse'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-legacy-documents"] = {}, global.promises, global.path, global.spaceTrim, global.child_process, global.colors, global.waitasecond, global.cryptoJs, global.hexEncoder, global.parserHtml, global.parserMarkdown, global.standalone, global.crypto, global.rxjs, global.sha256, global.mimeTypes, global.papaparse));
|
|
5
|
+
})(this, (function (exports, promises, path, spaceTrim, child_process, colors, waitasecond, cryptoJs, hexEncoder, parserHtml, parserMarkdown, standalone, crypto, rxjs, sha256, mimeTypes, papaparse) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
|
|
11
11
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
12
12
|
var parserHtml__default = /*#__PURE__*/_interopDefaultLegacy(parserHtml);
|
|
13
|
+
var parserMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(parserMarkdown);
|
|
13
14
|
var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
|
|
14
15
|
|
|
15
16
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
* @generated
|
|
27
28
|
* @see https://github.com/webgptorg/promptbook
|
|
28
29
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.100.0-46';
|
|
30
31
|
/**
|
|
31
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -224,6 +225,13 @@
|
|
|
224
225
|
* @public exported from `@promptbook/core`
|
|
225
226
|
*/
|
|
226
227
|
const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
|
|
228
|
+
/**
|
|
229
|
+
* API request timeout in milliseconds
|
|
230
|
+
* Can be overridden via API_REQUEST_TIMEOUT environment variable
|
|
231
|
+
*
|
|
232
|
+
* @public exported from `@promptbook/core`
|
|
233
|
+
*/
|
|
234
|
+
parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
227
235
|
/**
|
|
228
236
|
* Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
|
|
229
237
|
*
|
|
@@ -1215,9 +1223,9 @@
|
|
|
1215
1223
|
*/
|
|
1216
1224
|
function prettifyMarkdown(content) {
|
|
1217
1225
|
try {
|
|
1218
|
-
return
|
|
1226
|
+
return standalone.format(content, {
|
|
1219
1227
|
parser: 'markdown',
|
|
1220
|
-
plugins: [parserHtml__default["default"]],
|
|
1228
|
+
plugins: [parserMarkdown__default["default"], parserHtml__default["default"]],
|
|
1221
1229
|
// TODO: DRY - make some import or auto-copy of .prettierrc
|
|
1222
1230
|
endOfLine: 'lf',
|
|
1223
1231
|
tabWidth: 4,
|
|
@@ -3339,7 +3347,7 @@
|
|
|
3339
3347
|
const result = await preparePersonaExecutor({
|
|
3340
3348
|
availableModels /* <- Note: Passing as JSON */,
|
|
3341
3349
|
personaDescription,
|
|
3342
|
-
}).asPromise();
|
|
3350
|
+
}).asPromise({ isCrashedOnError: true });
|
|
3343
3351
|
const { outputParameters } = result;
|
|
3344
3352
|
const { modelsRequirements: modelsRequirementsJson } = outputParameters;
|
|
3345
3353
|
let modelsRequirementsUnchecked = jsonParse(modelsRequirementsJson);
|
|
@@ -4093,7 +4101,7 @@
|
|
|
4093
4101
|
});
|
|
4094
4102
|
const result = await prepareTitleExecutor({
|
|
4095
4103
|
book: sources.map(({ content }) => content).join('\n\n'),
|
|
4096
|
-
}).asPromise();
|
|
4104
|
+
}).asPromise({ isCrashedOnError: true });
|
|
4097
4105
|
const { outputParameters } = result;
|
|
4098
4106
|
const { title: titleRaw } = outputParameters;
|
|
4099
4107
|
if (isVerbose) {
|
|
@@ -6308,64 +6316,74 @@
|
|
|
6308
6316
|
});
|
|
6309
6317
|
});
|
|
6310
6318
|
};
|
|
6311
|
-
const pipelineExecutor = (inputParameters) =>
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
// Find current task being executed (first task not yet completed)
|
|
6331
|
-
const remainingTasks = pipeline.tasks.filter((task) => !executedTaskTitles.has(task.title));
|
|
6332
|
-
if (remainingTasks.length > 0) {
|
|
6333
|
-
currentTaskName = remainingTasks[0].name;
|
|
6319
|
+
const pipelineExecutor = (inputParameters) => {
|
|
6320
|
+
const startTime = new Date().getTime();
|
|
6321
|
+
return createTask({
|
|
6322
|
+
taskType: 'EXECUTION',
|
|
6323
|
+
title: pipeline.title,
|
|
6324
|
+
taskProcessCallback(updateOngoingResult, updateTldr) {
|
|
6325
|
+
return pipelineExecutorWithCallback(inputParameters, async (newOngoingResult) => {
|
|
6326
|
+
var _a, _b;
|
|
6327
|
+
updateOngoingResult(newOngoingResult);
|
|
6328
|
+
// Calculate and update tldr based on pipeline progress
|
|
6329
|
+
const cv = newOngoingResult;
|
|
6330
|
+
// Calculate progress based on parameters resolved vs total parameters
|
|
6331
|
+
const totalParameters = pipeline.parameters.filter(p => !p.isInput).length;
|
|
6332
|
+
let resolvedParameters = 0;
|
|
6333
|
+
let currentTaskTitle = '';
|
|
6334
|
+
// Get the resolved parameters from output parameters
|
|
6335
|
+
if (cv === null || cv === void 0 ? void 0 : cv.outputParameters) {
|
|
6336
|
+
// Count how many output parameters have non-empty values
|
|
6337
|
+
resolvedParameters = Object.values(cv.outputParameters).filter(value => value !== undefined && value !== null && String(value).trim() !== '').length;
|
|
6334
6338
|
}
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6339
|
+
// Try to determine current task from execution report
|
|
6340
|
+
if (((_a = cv === null || cv === void 0 ? void 0 : cv.executionReport) === null || _a === void 0 ? void 0 : _a.promptExecutions) && cv.executionReport.promptExecutions.length > 0) {
|
|
6341
|
+
const lastExecution = cv.executionReport.promptExecutions[cv.executionReport.promptExecutions.length - 1];
|
|
6342
|
+
if ((_b = lastExecution === null || lastExecution === void 0 ? void 0 : lastExecution.prompt) === null || _b === void 0 ? void 0 : _b.title) {
|
|
6343
|
+
currentTaskTitle = lastExecution.prompt.title;
|
|
6344
|
+
}
|
|
6345
|
+
}
|
|
6346
|
+
// Calculate base progress percentage
|
|
6347
|
+
let percent = totalParameters > 0 ? resolvedParameters / totalParameters : 0;
|
|
6348
|
+
// Add time-based progress for current task if we haven't completed all parameters
|
|
6349
|
+
if (resolvedParameters < totalParameters) {
|
|
6350
|
+
const elapsedMs = new Date().getTime() - startTime;
|
|
6351
|
+
const estimatedTotalMs = totalParameters * 30 * 1000; // Estimate 30 seconds per parameter
|
|
6352
|
+
const timeProgress = Math.min(elapsedMs / estimatedTotalMs, 0.9); // Cap at 90% for time-based progress
|
|
6353
|
+
// If we have time progress but no parameter progress, show time progress
|
|
6354
|
+
if (percent === 0 && timeProgress > 0) {
|
|
6355
|
+
percent = Math.min(timeProgress, 0.1); // Show some progress but not more than 10%
|
|
6356
|
+
}
|
|
6357
|
+
else if (percent < 1) {
|
|
6358
|
+
// Add partial progress for current task
|
|
6359
|
+
const taskProgress = totalParameters > 0 ? (1 / totalParameters) * 0.5 : 0; // 50% of task progress
|
|
6360
|
+
percent = Math.min(percent + taskProgress, 0.95); // Cap at 95% until fully complete
|
|
6361
|
+
}
|
|
6362
|
+
}
|
|
6363
|
+
// Clamp to [0,1]
|
|
6364
|
+
percent = Math.min(Math.max(percent, 0), 1);
|
|
6365
|
+
// Generate message
|
|
6366
|
+
let message = '';
|
|
6367
|
+
if (currentTaskTitle) {
|
|
6368
|
+
message = `Executing: ${currentTaskTitle}`;
|
|
6369
|
+
}
|
|
6370
|
+
else if (resolvedParameters === 0) {
|
|
6371
|
+
message = 'Starting pipeline execution';
|
|
6372
|
+
}
|
|
6373
|
+
else if (resolvedParameters < totalParameters) {
|
|
6374
|
+
message = `Processing pipeline (${resolvedParameters}/${totalParameters} parameters resolved)`;
|
|
6375
|
+
}
|
|
6376
|
+
else {
|
|
6377
|
+
message = 'Completing pipeline execution';
|
|
6378
|
+
}
|
|
6379
|
+
updateTldr({
|
|
6380
|
+
percent: percent,
|
|
6381
|
+
message,
|
|
6382
|
+
});
|
|
6365
6383
|
});
|
|
6366
|
-
}
|
|
6367
|
-
}
|
|
6368
|
-
}
|
|
6384
|
+
},
|
|
6385
|
+
});
|
|
6386
|
+
};
|
|
6369
6387
|
// <- TODO: Make types such as there is no need to do `as` for `createTask`
|
|
6370
6388
|
return pipelineExecutor;
|
|
6371
6389
|
}
|
|
@@ -6450,7 +6468,9 @@
|
|
|
6450
6468
|
},
|
|
6451
6469
|
});
|
|
6452
6470
|
const knowledgeContent = await source.asText();
|
|
6453
|
-
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise(
|
|
6471
|
+
const result = await prepareKnowledgeFromMarkdownExecutor({ knowledgeContent }).asPromise({
|
|
6472
|
+
isCrashedOnError: true,
|
|
6473
|
+
});
|
|
6454
6474
|
const { outputParameters } = result;
|
|
6455
6475
|
const { knowledgePieces: knowledgePiecesRaw } = outputParameters;
|
|
6456
6476
|
const knowledgeTextPieces = (knowledgePiecesRaw || '').split('\n---\n');
|
|
@@ -6474,12 +6494,16 @@
|
|
|
6474
6494
|
];
|
|
6475
6495
|
*/
|
|
6476
6496
|
try {
|
|
6477
|
-
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise(
|
|
6497
|
+
const titleResult = await prepareTitleExecutor({ knowledgePieceContent }).asPromise({
|
|
6498
|
+
isCrashedOnError: true,
|
|
6499
|
+
});
|
|
6478
6500
|
const { title: titleRaw = 'Untitled' } = titleResult.outputParameters;
|
|
6479
6501
|
title = spaceTrim__default["default"](titleRaw) /* <- TODO: Maybe do in pipeline */;
|
|
6480
6502
|
name = titleToName(title);
|
|
6481
6503
|
// --- Keywords
|
|
6482
|
-
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise(
|
|
6504
|
+
const keywordsResult = await prepareKeywordsExecutor({ knowledgePieceContent }).asPromise({
|
|
6505
|
+
isCrashedOnError: true,
|
|
6506
|
+
});
|
|
6483
6507
|
const { keywords: keywordsRaw = '' } = keywordsResult.outputParameters;
|
|
6484
6508
|
keywords = (keywordsRaw || '')
|
|
6485
6509
|
.split(',')
|