@promptbook/cli 0.98.0-3 โ 0.98.0-5
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 +71 -19
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/cli.index.d.ts +2 -0
- package/esm/typings/src/_packages/openai.index.d.ts +2 -0
- package/esm/typings/src/_packages/wizard.index.d.ts +2 -0
- package/esm/typings/src/config.d.ts +1 -1
- package/esm/typings/src/execution/createPipelineExecutor/$OngoingTaskResult.d.ts +7 -0
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +10 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +71 -18
- package/umd/index.umd.js.map +1 -1
|
@@ -15,6 +15,7 @@ import { _OpenAiAssistantMetadataRegistration } from '../llm-providers/openai/re
|
|
|
15
15
|
import { _OpenAiCompatibleMetadataRegistration } from '../llm-providers/openai/register-configuration';
|
|
16
16
|
import { _OpenAiRegistration } from '../llm-providers/openai/register-constructor';
|
|
17
17
|
import { _OpenAiAssistantRegistration } from '../llm-providers/openai/register-constructor';
|
|
18
|
+
import { _OpenAiCompatibleRegistration } from '../llm-providers/openai/register-constructor';
|
|
18
19
|
import { _BoilerplateScraperRegistration } from '../scrapers/_boilerplate/register-constructor';
|
|
19
20
|
import { _BoilerplateScraperMetadataRegistration } from '../scrapers/_boilerplate/register-metadata';
|
|
20
21
|
import { _LegacyDocumentScraperRegistration } from '../scrapers/document-legacy/register-constructor';
|
|
@@ -46,6 +47,7 @@ export { _OpenAiAssistantMetadataRegistration };
|
|
|
46
47
|
export { _OpenAiCompatibleMetadataRegistration };
|
|
47
48
|
export { _OpenAiRegistration };
|
|
48
49
|
export { _OpenAiAssistantRegistration };
|
|
50
|
+
export { _OpenAiCompatibleRegistration };
|
|
49
51
|
export { _BoilerplateScraperRegistration };
|
|
50
52
|
export { _BoilerplateScraperMetadataRegistration };
|
|
51
53
|
export { _LegacyDocumentScraperRegistration };
|
|
@@ -11,6 +11,7 @@ import { OpenAiExecutionTools } from '../llm-providers/openai/OpenAiExecutionToo
|
|
|
11
11
|
import type { OpenAiExecutionToolsOptions } from '../llm-providers/openai/OpenAiExecutionToolsOptions';
|
|
12
12
|
import { _OpenAiRegistration } from '../llm-providers/openai/register-constructor';
|
|
13
13
|
import { _OpenAiAssistantRegistration } from '../llm-providers/openai/register-constructor';
|
|
14
|
+
import { _OpenAiCompatibleRegistration } from '../llm-providers/openai/register-constructor';
|
|
14
15
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
15
16
|
export { createOpenAiAssistantExecutionTools };
|
|
16
17
|
export { createOpenAiCompatibleExecutionTools };
|
|
@@ -24,3 +25,4 @@ export { OpenAiExecutionTools };
|
|
|
24
25
|
export type { OpenAiExecutionToolsOptions };
|
|
25
26
|
export { _OpenAiRegistration };
|
|
26
27
|
export { _OpenAiAssistantRegistration };
|
|
28
|
+
export { _OpenAiCompatibleRegistration };
|
|
@@ -14,6 +14,7 @@ import { _OpenAiAssistantMetadataRegistration } from '../llm-providers/openai/re
|
|
|
14
14
|
import { _OpenAiCompatibleMetadataRegistration } from '../llm-providers/openai/register-configuration';
|
|
15
15
|
import { _OpenAiRegistration } from '../llm-providers/openai/register-constructor';
|
|
16
16
|
import { _OpenAiAssistantRegistration } from '../llm-providers/openai/register-constructor';
|
|
17
|
+
import { _OpenAiCompatibleRegistration } from '../llm-providers/openai/register-constructor';
|
|
17
18
|
import { _BoilerplateScraperRegistration } from '../scrapers/_boilerplate/register-constructor';
|
|
18
19
|
import { _BoilerplateScraperMetadataRegistration } from '../scrapers/_boilerplate/register-metadata';
|
|
19
20
|
import { _LegacyDocumentScraperRegistration } from '../scrapers/document-legacy/register-constructor';
|
|
@@ -45,6 +46,7 @@ export { _OpenAiAssistantMetadataRegistration };
|
|
|
45
46
|
export { _OpenAiCompatibleMetadataRegistration };
|
|
46
47
|
export { _OpenAiRegistration };
|
|
47
48
|
export { _OpenAiAssistantRegistration };
|
|
49
|
+
export { _OpenAiCompatibleRegistration };
|
|
48
50
|
export { _BoilerplateScraperRegistration };
|
|
49
51
|
export { _BoilerplateScraperMetadataRegistration };
|
|
50
52
|
export { _LegacyDocumentScraperRegistration };
|
|
@@ -176,7 +176,7 @@ export declare const DEFAULT_MAX_PARALLEL_COUNT = 5;
|
|
|
176
176
|
*
|
|
177
177
|
* @public exported from `@promptbook/core`
|
|
178
178
|
*/
|
|
179
|
-
export declare const DEFAULT_MAX_EXECUTION_ATTEMPTS =
|
|
179
|
+
export declare const DEFAULT_MAX_EXECUTION_ATTEMPTS = 3;
|
|
180
180
|
/**
|
|
181
181
|
* The maximum depth to which knowledge sources will be scraped when building a knowledge base.
|
|
182
182
|
* This prevents infinite recursion and limits resource usage.
|
|
@@ -45,4 +45,11 @@ export type $OngoingTaskResult = {
|
|
|
45
45
|
* List of errors encountered during script postprocessing or execution.
|
|
46
46
|
*/
|
|
47
47
|
$scriptPipelineExecutionErrors: Array<Error>;
|
|
48
|
+
/**
|
|
49
|
+
* Array of all failed attempts, storing both the result string and the error for each failure
|
|
50
|
+
*/
|
|
51
|
+
$failedResults: Array<{
|
|
52
|
+
result: string | null;
|
|
53
|
+
error: ExpectError;
|
|
54
|
+
}>;
|
|
48
55
|
};
|
|
@@ -19,6 +19,16 @@ export declare const _OpenAiRegistration: Registration;
|
|
|
19
19
|
* @public exported from `@promptbook/cli`
|
|
20
20
|
*/
|
|
21
21
|
export declare const _OpenAiAssistantRegistration: Registration;
|
|
22
|
+
/**
|
|
23
|
+
* Registration of the OpenAI Compatible provider
|
|
24
|
+
*
|
|
25
|
+
* Note: [๐] Configurations registrations are done in register-constructor.ts BUT constructor register-constructor.ts
|
|
26
|
+
*
|
|
27
|
+
* @public exported from `@promptbook/openai`
|
|
28
|
+
* @public exported from `@promptbook/wizard`
|
|
29
|
+
* @public exported from `@promptbook/cli`
|
|
30
|
+
*/
|
|
31
|
+
export declare const _OpenAiCompatibleRegistration: Registration;
|
|
22
32
|
/**
|
|
23
33
|
* Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be registered directly.
|
|
24
34
|
* It serves as a base class for OpenAiExecutionTools and other compatible implementations.
|
|
@@ -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.98.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.98.0-4`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
* @generated
|
|
58
58
|
* @see https://github.com/webgptorg/promptbook
|
|
59
59
|
*/
|
|
60
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.98.0-
|
|
60
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.98.0-5';
|
|
61
61
|
/**
|
|
62
62
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
63
63
|
* Note: [๐] Ignore a discrepancy between file name and entity name
|
|
@@ -271,7 +271,7 @@
|
|
|
271
271
|
*
|
|
272
272
|
* @public exported from `@promptbook/core`
|
|
273
273
|
*/
|
|
274
|
-
const DEFAULT_MAX_EXECUTION_ATTEMPTS =
|
|
274
|
+
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [๐คนโโ๏ธ]
|
|
275
275
|
// <- TODO: [๐]
|
|
276
276
|
/**
|
|
277
277
|
* Where to store your books
|
|
@@ -6294,6 +6294,7 @@
|
|
|
6294
6294
|
$resultString: null,
|
|
6295
6295
|
$expectError: null,
|
|
6296
6296
|
$scriptPipelineExecutionErrors: [],
|
|
6297
|
+
$failedResults: [], // Track all failed attempts
|
|
6297
6298
|
};
|
|
6298
6299
|
// TODO: [๐] Make arrayable LLMs -> single LLM DRY
|
|
6299
6300
|
const _llms = arrayableToArray(tools.llm);
|
|
@@ -6539,6 +6540,14 @@
|
|
|
6539
6540
|
throw error;
|
|
6540
6541
|
}
|
|
6541
6542
|
$ongoingTaskResult.$expectError = error;
|
|
6543
|
+
// Store each failed attempt
|
|
6544
|
+
if (!Array.isArray($ongoingTaskResult.$failedResults)) {
|
|
6545
|
+
$ongoingTaskResult.$failedResults = [];
|
|
6546
|
+
}
|
|
6547
|
+
$ongoingTaskResult.$failedResults.push({
|
|
6548
|
+
result: $ongoingTaskResult.$resultString,
|
|
6549
|
+
error: error,
|
|
6550
|
+
});
|
|
6542
6551
|
}
|
|
6543
6552
|
finally {
|
|
6544
6553
|
if (!isJokerAttempt &&
|
|
@@ -6561,34 +6570,46 @@
|
|
|
6561
6570
|
}
|
|
6562
6571
|
}
|
|
6563
6572
|
if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
|
|
6573
|
+
// Store the current failure before throwing
|
|
6574
|
+
$ongoingTaskResult.$failedResults = $ongoingTaskResult.$failedResults || [];
|
|
6575
|
+
$ongoingTaskResult.$failedResults.push({
|
|
6576
|
+
result: $ongoingTaskResult.$resultString,
|
|
6577
|
+
error: $ongoingTaskResult.$expectError,
|
|
6578
|
+
});
|
|
6579
|
+
// Create a summary of all failures
|
|
6580
|
+
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
6581
|
+
.map((failure, index) => spaceTrim.spaceTrim((block) => {
|
|
6582
|
+
var _a, _b;
|
|
6583
|
+
return `
|
|
6584
|
+
Attempt ${index + 1}:
|
|
6585
|
+
Error ${((_a = failure.error) === null || _a === void 0 ? void 0 : _a.name) || ''}:
|
|
6586
|
+
${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split('\n').map((line) => `> ${line}`).join('\n'))}
|
|
6587
|
+
|
|
6588
|
+
Result:
|
|
6589
|
+
${block(failure.result === null
|
|
6590
|
+
? 'null'
|
|
6591
|
+
: spaceTrim.spaceTrim(failure.result)
|
|
6592
|
+
.split('\n')
|
|
6593
|
+
.map((line) => `> ${line}`)
|
|
6594
|
+
.join('\n'))}
|
|
6595
|
+
`;
|
|
6596
|
+
}))
|
|
6597
|
+
.join('\n\n---\n\n');
|
|
6564
6598
|
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => {
|
|
6565
|
-
var _a
|
|
6599
|
+
var _a;
|
|
6566
6600
|
return `
|
|
6567
6601
|
LLM execution failed ${maxExecutionAttempts}x
|
|
6568
6602
|
|
|
6569
6603
|
${block(pipelineIdentification)}
|
|
6570
6604
|
|
|
6571
|
-
---
|
|
6572
6605
|
The Prompt:
|
|
6573
6606
|
${block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
|
|
6574
6607
|
.split('\n')
|
|
6575
6608
|
.map((line) => `> ${line}`)
|
|
6576
6609
|
.join('\n'))}
|
|
6577
6610
|
|
|
6578
|
-
|
|
6579
|
-
${block(
|
|
6580
|
-
.split('\n')
|
|
6581
|
-
.map((line) => `> ${line}`)
|
|
6582
|
-
.join('\n'))}
|
|
6583
|
-
|
|
6584
|
-
Last result:
|
|
6585
|
-
${block($ongoingTaskResult.$resultString === null
|
|
6586
|
-
? 'null'
|
|
6587
|
-
: spaceTrim.spaceTrim($ongoingTaskResult.$resultString)
|
|
6588
|
-
.split('\n')
|
|
6589
|
-
.map((line) => `> ${line}`)
|
|
6590
|
-
.join('\n'))}
|
|
6591
|
-
---
|
|
6611
|
+
All Failed Attempts:
|
|
6612
|
+
${block(failuresSummary)}
|
|
6592
6613
|
`;
|
|
6593
6614
|
}));
|
|
6594
6615
|
}
|
|
@@ -18338,6 +18359,27 @@
|
|
|
18338
18359
|
* TODO: [๐ถ] Naming "constructor" vs "creator" vs "factory"
|
|
18339
18360
|
*/
|
|
18340
18361
|
|
|
18362
|
+
/**
|
|
18363
|
+
* Execution Tools for calling OpenAI compatible API
|
|
18364
|
+
*
|
|
18365
|
+
* Note: This can be used for any OpenAI compatible APIs
|
|
18366
|
+
*
|
|
18367
|
+
* @public exported from `@promptbook/openai`
|
|
18368
|
+
*/
|
|
18369
|
+
const createOpenAiCompatibleExecutionTools = Object.assign((options) => {
|
|
18370
|
+
if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
|
|
18371
|
+
options = { ...options, dangerouslyAllowBrowser: true };
|
|
18372
|
+
}
|
|
18373
|
+
return new OpenAiExecutionTools(options);
|
|
18374
|
+
}, {
|
|
18375
|
+
packageName: '@promptbook/openai',
|
|
18376
|
+
className: 'OpenAiCompatibleExecutionTools',
|
|
18377
|
+
});
|
|
18378
|
+
/**
|
|
18379
|
+
* TODO: [๐ฆบ] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
|
|
18380
|
+
* TODO: [๐ถ] Naming "constructor" vs "creator" vs "factory"
|
|
18381
|
+
*/
|
|
18382
|
+
|
|
18341
18383
|
/**
|
|
18342
18384
|
* Execution Tools for calling OpenAI API
|
|
18343
18385
|
*
|
|
@@ -18380,6 +18422,16 @@
|
|
|
18380
18422
|
* @public exported from `@promptbook/cli`
|
|
18381
18423
|
*/
|
|
18382
18424
|
const _OpenAiAssistantRegistration = $llmToolsRegister.register(createOpenAiAssistantExecutionTools);
|
|
18425
|
+
/**
|
|
18426
|
+
* Registration of the OpenAI Compatible provider
|
|
18427
|
+
*
|
|
18428
|
+
* Note: [๐] Configurations registrations are done in register-constructor.ts BUT constructor register-constructor.ts
|
|
18429
|
+
*
|
|
18430
|
+
* @public exported from `@promptbook/openai`
|
|
18431
|
+
* @public exported from `@promptbook/wizard`
|
|
18432
|
+
* @public exported from `@promptbook/cli`
|
|
18433
|
+
*/
|
|
18434
|
+
const _OpenAiCompatibleRegistration = $llmToolsRegister.register(createOpenAiCompatibleExecutionTools);
|
|
18383
18435
|
/**
|
|
18384
18436
|
* Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be registered directly.
|
|
18385
18437
|
* It serves as a base class for OpenAiExecutionTools and other compatible implementations.
|
|
@@ -19647,6 +19699,7 @@
|
|
|
19647
19699
|
exports._OpenAiAssistantMetadataRegistration = _OpenAiAssistantMetadataRegistration;
|
|
19648
19700
|
exports._OpenAiAssistantRegistration = _OpenAiAssistantRegistration;
|
|
19649
19701
|
exports._OpenAiCompatibleMetadataRegistration = _OpenAiCompatibleMetadataRegistration;
|
|
19702
|
+
exports._OpenAiCompatibleRegistration = _OpenAiCompatibleRegistration;
|
|
19650
19703
|
exports._OpenAiMetadataRegistration = _OpenAiMetadataRegistration;
|
|
19651
19704
|
exports._OpenAiRegistration = _OpenAiRegistration;
|
|
19652
19705
|
exports._PdfScraperMetadataRegistration = _PdfScraperMetadataRegistration;
|