@promptbook/markdown-utils 0.86.31 → 0.88.0-8
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/README.md +5 -3
- package/esm/index.es.js +51 -10
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/node.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/cli/cli-commands/common/handleActionErrors.d.ts +11 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +24 -0
- package/esm/typings/src/scrapers/_common/register/$provideScriptingForNode.d.ts +11 -0
- package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/javascript/JavascriptExecutionTools.d.ts +1 -1
- package/esm/typings/src/scripting/javascript/postprocessing-functions.d.ts +1 -1
- package/esm/typings/src/scripting/javascript/utils/extractVariablesFromJavascript.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +50 -9
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/_packages/{execute-javascript.index.d.ts → javascript.index.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
<blockquote style="color: #ff8811">
|
|
27
|
+
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
28
|
+
</blockquote>
|
|
29
|
+
|
|
26
30
|
## 📦 Package `@promptbook/markdown-utils`
|
|
27
31
|
|
|
28
32
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
|
@@ -249,7 +253,7 @@ Or you can install them separately:
|
|
|
249
253
|
- ⭐ **[@promptbook/utils](https://www.npmjs.com/package/@promptbook/utils)** - Utility functions used in the library but also useful for individual use in preprocessing and postprocessing LLM inputs and outputs
|
|
250
254
|
- **[@promptbook/markdown-utils](https://www.npmjs.com/package/@promptbook/markdown-utils)** - Utility functions used for processing markdown
|
|
251
255
|
- _(Not finished)_ **[@promptbook/wizzard](https://www.npmjs.com/package/@promptbook/wizzard)** - Wizard for creating+running promptbooks in single line
|
|
252
|
-
- **[@promptbook/
|
|
256
|
+
- **[@promptbook/javascript](https://www.npmjs.com/package/@promptbook/javascript)** - Execution tools for javascript inside promptbooks
|
|
253
257
|
- **[@promptbook/openai](https://www.npmjs.com/package/@promptbook/openai)** - Execution tools for OpenAI API, wrapper around OpenAI SDK
|
|
254
258
|
- **[@promptbook/anthropic-claude](https://www.npmjs.com/package/@promptbook/anthropic-claude)** - Execution tools for Anthropic Claude API, wrapper around Anthropic Claude SDK
|
|
255
259
|
- **[@promptbook/vercel](https://www.npmjs.com/package/@promptbook/vercel)** - Adapter for Vercel functionalities
|
|
@@ -405,8 +409,6 @@ Promptbook project is under [BUSL 1.1 is an SPDX license](https://spdx.org/licen
|
|
|
405
409
|
|
|
406
410
|
See [TODO.md](./TODO.md)
|
|
407
411
|
|
|
408
|
-
|
|
409
|
-
|
|
410
412
|
## 🤝 Partners
|
|
411
413
|
|
|
412
414
|
<div style="display: flex; align-items: center; gap: 20px;">
|
package/esm/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
2
2
|
import { format } from 'prettier';
|
|
3
3
|
import parserHtml from 'prettier/parser-html';
|
|
4
|
-
import {
|
|
4
|
+
import { Subject } from 'rxjs';
|
|
5
5
|
import { randomBytes } from 'crypto';
|
|
6
6
|
import { forTime } from 'waitasecond';
|
|
7
7
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
@@ -25,7 +25,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-8';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1993,21 +1993,41 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
1993
1993
|
function createTask(options) {
|
|
1994
1994
|
const { taskType, taskProcessCallback } = options;
|
|
1995
1995
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
1996
|
-
|
|
1996
|
+
let status = 'RUNNING';
|
|
1997
|
+
const createdAt = new Date();
|
|
1998
|
+
let updatedAt = createdAt;
|
|
1999
|
+
const errors = [];
|
|
2000
|
+
const warnings = [];
|
|
2001
|
+
const currentValue = {};
|
|
2002
|
+
const partialResultSubject = new Subject();
|
|
2003
|
+
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
1997
2004
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
2005
|
+
Object.assign(currentValue, newOngoingResult);
|
|
1998
2006
|
partialResultSubject.next(newOngoingResult);
|
|
1999
2007
|
});
|
|
2000
2008
|
finalResultPromise
|
|
2001
2009
|
.catch((error) => {
|
|
2010
|
+
errors.push(error);
|
|
2002
2011
|
partialResultSubject.error(error);
|
|
2003
2012
|
})
|
|
2004
|
-
.then((
|
|
2005
|
-
if (
|
|
2013
|
+
.then((executionResult) => {
|
|
2014
|
+
if (executionResult) {
|
|
2006
2015
|
try {
|
|
2007
|
-
|
|
2008
|
-
|
|
2016
|
+
updatedAt = new Date();
|
|
2017
|
+
errors.push(...executionResult.errors);
|
|
2018
|
+
warnings.push(...executionResult.warnings);
|
|
2019
|
+
// <- TODO: !!! Only unique errors and warnings should be added (or filtered)
|
|
2020
|
+
// TODO: [🧠] !!! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
|
|
2021
|
+
// Also maybe move `ExecutionTask.currentValue.usage` -> `ExecutionTask.usage`
|
|
2022
|
+
// And delete `ExecutionTask.currentValue.preparedPipeline`
|
|
2023
|
+
assertsTaskSuccessful(executionResult);
|
|
2024
|
+
status = 'FINISHED';
|
|
2025
|
+
Object.assign(currentValue, executionResult);
|
|
2026
|
+
partialResultSubject.next(executionResult);
|
|
2009
2027
|
}
|
|
2010
2028
|
catch (error) {
|
|
2029
|
+
status = 'ERROR';
|
|
2030
|
+
errors.push(error);
|
|
2011
2031
|
partialResultSubject.error(error);
|
|
2012
2032
|
}
|
|
2013
2033
|
}
|
|
@@ -2024,12 +2044,33 @@ function createTask(options) {
|
|
|
2024
2044
|
return {
|
|
2025
2045
|
taskType,
|
|
2026
2046
|
taskId,
|
|
2047
|
+
get status() {
|
|
2048
|
+
return status;
|
|
2049
|
+
// <- Note: [1] Theese must be getters to allow changing the value in the future
|
|
2050
|
+
},
|
|
2051
|
+
get createdAt() {
|
|
2052
|
+
return createdAt;
|
|
2053
|
+
// <- Note: [1]
|
|
2054
|
+
},
|
|
2055
|
+
get updatedAt() {
|
|
2056
|
+
return updatedAt;
|
|
2057
|
+
// <- Note: [1]
|
|
2058
|
+
},
|
|
2027
2059
|
asPromise,
|
|
2028
2060
|
asObservable() {
|
|
2029
2061
|
return partialResultSubject.asObservable();
|
|
2030
2062
|
},
|
|
2063
|
+
get errors() {
|
|
2064
|
+
return errors;
|
|
2065
|
+
// <- Note: [1]
|
|
2066
|
+
},
|
|
2067
|
+
get warnings() {
|
|
2068
|
+
return warnings;
|
|
2069
|
+
// <- Note: [1]
|
|
2070
|
+
},
|
|
2031
2071
|
get currentValue() {
|
|
2032
|
-
return
|
|
2072
|
+
return currentValue;
|
|
2073
|
+
// <- Note: [1]
|
|
2033
2074
|
},
|
|
2034
2075
|
};
|
|
2035
2076
|
}
|
|
@@ -3726,7 +3767,7 @@ function valueToString(value) {
|
|
|
3726
3767
|
* @param script from which to extract the variables
|
|
3727
3768
|
* @returns the list of variable names
|
|
3728
3769
|
* @throws {ParseError} if the script is invalid
|
|
3729
|
-
* @public exported from `@promptbook/
|
|
3770
|
+
* @public exported from `@promptbook/javascript`
|
|
3730
3771
|
*/
|
|
3731
3772
|
function extractVariablesFromJavascript(script) {
|
|
3732
3773
|
const variables = new Set();
|
|
@@ -4688,7 +4729,7 @@ async function executeAttempts(options) {
|
|
|
4688
4729
|
Last result:
|
|
4689
4730
|
${block($ongoingTaskResult.$resultString === null
|
|
4690
4731
|
? 'null'
|
|
4691
|
-
: $ongoingTaskResult.$resultString
|
|
4732
|
+
: spaceTrim$1($ongoingTaskResult.$resultString)
|
|
4692
4733
|
.split('\n')
|
|
4693
4734
|
.map((line) => `> ${line}`)
|
|
4694
4735
|
.join('\n'))}
|