@promptbook/core 0.98.0-3 โ 0.98.0-4
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 +39 -18
- 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 +39 -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-3`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.98.0-
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.98.0-4';
|
|
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
|
|
@@ -354,7 +354,7 @@
|
|
|
354
354
|
*
|
|
355
355
|
* @public exported from `@promptbook/core`
|
|
356
356
|
*/
|
|
357
|
-
const DEFAULT_MAX_EXECUTION_ATTEMPTS =
|
|
357
|
+
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [๐คนโโ๏ธ]
|
|
358
358
|
/**
|
|
359
359
|
* The maximum depth to which knowledge sources will be scraped when building a knowledge base.
|
|
360
360
|
* This prevents infinite recursion and limits resource usage.
|
|
@@ -4056,6 +4056,7 @@
|
|
|
4056
4056
|
$resultString: null,
|
|
4057
4057
|
$expectError: null,
|
|
4058
4058
|
$scriptPipelineExecutionErrors: [],
|
|
4059
|
+
$failedResults: [], // Track all failed attempts
|
|
4059
4060
|
};
|
|
4060
4061
|
// TODO: [๐] Make arrayable LLMs -> single LLM DRY
|
|
4061
4062
|
const _llms = arrayableToArray(tools.llm);
|
|
@@ -4301,6 +4302,14 @@
|
|
|
4301
4302
|
throw error;
|
|
4302
4303
|
}
|
|
4303
4304
|
$ongoingTaskResult.$expectError = error;
|
|
4305
|
+
// Store each failed attempt
|
|
4306
|
+
if (!Array.isArray($ongoingTaskResult.$failedResults)) {
|
|
4307
|
+
$ongoingTaskResult.$failedResults = [];
|
|
4308
|
+
}
|
|
4309
|
+
$ongoingTaskResult.$failedResults.push({
|
|
4310
|
+
result: $ongoingTaskResult.$resultString,
|
|
4311
|
+
error: error,
|
|
4312
|
+
});
|
|
4304
4313
|
}
|
|
4305
4314
|
finally {
|
|
4306
4315
|
if (!isJokerAttempt &&
|
|
@@ -4323,34 +4332,46 @@
|
|
|
4323
4332
|
}
|
|
4324
4333
|
}
|
|
4325
4334
|
if ($ongoingTaskResult.$expectError !== null && attempt === maxAttempts - 1) {
|
|
4335
|
+
// Store the current failure before throwing
|
|
4336
|
+
$ongoingTaskResult.$failedResults = $ongoingTaskResult.$failedResults || [];
|
|
4337
|
+
$ongoingTaskResult.$failedResults.push({
|
|
4338
|
+
result: $ongoingTaskResult.$resultString,
|
|
4339
|
+
error: $ongoingTaskResult.$expectError,
|
|
4340
|
+
});
|
|
4341
|
+
// Create a summary of all failures
|
|
4342
|
+
const failuresSummary = $ongoingTaskResult.$failedResults
|
|
4343
|
+
.map((failure, index) => spaceTrim.spaceTrim((block) => {
|
|
4344
|
+
var _a, _b;
|
|
4345
|
+
return `
|
|
4346
|
+
Attempt ${index + 1}:
|
|
4347
|
+
Error ${((_a = failure.error) === null || _a === void 0 ? void 0 : _a.name) || ''}:
|
|
4348
|
+
${block((_b = failure.error) === null || _b === void 0 ? void 0 : _b.message.split('\n').map((line) => `> ${line}`).join('\n'))}
|
|
4349
|
+
|
|
4350
|
+
Result:
|
|
4351
|
+
${block(failure.result === null
|
|
4352
|
+
? 'null'
|
|
4353
|
+
: spaceTrim.spaceTrim(failure.result)
|
|
4354
|
+
.split('\n')
|
|
4355
|
+
.map((line) => `> ${line}`)
|
|
4356
|
+
.join('\n'))}
|
|
4357
|
+
`;
|
|
4358
|
+
}))
|
|
4359
|
+
.join('\n\n---\n\n');
|
|
4326
4360
|
throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => {
|
|
4327
|
-
var _a
|
|
4361
|
+
var _a;
|
|
4328
4362
|
return `
|
|
4329
4363
|
LLM execution failed ${maxExecutionAttempts}x
|
|
4330
4364
|
|
|
4331
4365
|
${block(pipelineIdentification)}
|
|
4332
4366
|
|
|
4333
|
-
---
|
|
4334
4367
|
The Prompt:
|
|
4335
4368
|
${block((((_a = $ongoingTaskResult.$prompt) === null || _a === void 0 ? void 0 : _a.content) || '')
|
|
4336
4369
|
.split('\n')
|
|
4337
4370
|
.map((line) => `> ${line}`)
|
|
4338
4371
|
.join('\n'))}
|
|
4339
4372
|
|
|
4340
|
-
|
|
4341
|
-
${block(
|
|
4342
|
-
.split('\n')
|
|
4343
|
-
.map((line) => `> ${line}`)
|
|
4344
|
-
.join('\n'))}
|
|
4345
|
-
|
|
4346
|
-
Last result:
|
|
4347
|
-
${block($ongoingTaskResult.$resultString === null
|
|
4348
|
-
? 'null'
|
|
4349
|
-
: spaceTrim.spaceTrim($ongoingTaskResult.$resultString)
|
|
4350
|
-
.split('\n')
|
|
4351
|
-
.map((line) => `> ${line}`)
|
|
4352
|
-
.join('\n'))}
|
|
4353
|
-
---
|
|
4373
|
+
All Failed Attempts:
|
|
4374
|
+
${block(failuresSummary)}
|
|
4354
4375
|
`;
|
|
4355
4376
|
}));
|
|
4356
4377
|
}
|