@promptbook/markdown-utils 0.88.0-1 → 0.88.0-10
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 +16 -40
- package/esm/index.es.js +82 -9
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/_packages/utils.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/utils/serialization/jsonStringsToJsons.d.ts +9 -0
- package/esm/typings/src/utils/serialization/jsonStringsToJsons.test.d.ts +1 -0
- package/package.json +1 -1
- package/umd/index.umd.js +81 -8
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -58,8 +58,6 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
|
58
58
|
|
|
59
59
|
During the computer revolution, we have seen [multiple generations of computer languages](https://github.com/webgptorg/promptbook/discussions/180), from the physical rewiring of the vacuum tubes through low-level machine code to the high-level languages like Python or JavaScript. And now, we're on the edge of the **next revolution**!
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
61
|
It's a revolution of writing software in **plain human language** that is understandable and executable by both humans and machines – and it's going to change everything!
|
|
64
62
|
|
|
65
63
|
The incredible growth in power of microprocessors and the Moore's Law have been the driving force behind the ever-more powerful languages, and it's been an amazing journey! Similarly, the large language models (like GPT or Claude) are the next big thing in language technology, and they're set to transform the way we interact with computers.
|
|
@@ -116,27 +114,28 @@ Promptbook project is ecosystem of multiple projects and tools, following is a l
|
|
|
116
114
|
</tbody>
|
|
117
115
|
</table>
|
|
118
116
|
|
|
117
|
+
Hello world examples:
|
|
118
|
+
|
|
119
|
+
- [Hello world](https://github.com/webgptorg/hello-world)
|
|
120
|
+
- [Hello world in Node.js](https://github.com/webgptorg/hello-world-node-js)
|
|
121
|
+
- [Hello world in Next.js](https://github.com/webgptorg/hello-world-next-js)
|
|
122
|
+
|
|
119
123
|
We also have a community of developers and users of **Promptbook**:
|
|
120
124
|
|
|
121
125
|
- [Discord community](https://discord.gg/x3QWNaa89N)
|
|
122
126
|
- [Landing page `ptbk.io`](https://ptbk.io)
|
|
123
127
|
- [Github discussions](https://github.com/webgptorg/promptbook/discussions)
|
|
124
128
|
- [LinkedIn `Promptbook`](https://linkedin.com/company/promptbook)
|
|
125
|
-
- [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
|
|
129
|
+
- [Facebook `Promptbook`](https://www.facebook.com/61560776453536)
|
|
126
130
|
|
|
127
131
|
And **Promptbook.studio** branded socials:
|
|
128
132
|
|
|
129
|
-
|
|
130
|
-
|
|
131
133
|
- [Instagram `@promptbook.studio`](https://www.instagram.com/promptbook.studio/)
|
|
132
134
|
|
|
133
135
|
And **Promptujeme** sub-brand:
|
|
134
136
|
|
|
135
137
|
_/Subbrand for Czech clients/_
|
|
136
138
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
139
|
- [Promptujeme.cz](https://www.promptujeme.cz/)
|
|
141
140
|
- [Facebook `Promptujeme`](https://www.facebook.com/promptujeme/)
|
|
142
141
|
|
|
@@ -154,8 +153,6 @@ _/Sub-brand for images and graphics generated via Promptbook prompting/_
|
|
|
154
153
|
|
|
155
154
|
## 💙 The Book language
|
|
156
155
|
|
|
157
|
-
|
|
158
|
-
|
|
159
156
|
Following is the documentation and blueprint of the [Book language](https://github.com/webgptorg/book).
|
|
160
157
|
|
|
161
158
|
Book is a language that can be used to write AI applications, agents, workflows, automations, knowledgebases, translators, sheet processors, email automations and more. It allows you to harness the power of AI models in human-like terms, without the need to know the specifics and technicalities of the models.
|
|
@@ -205,8 +202,6 @@ Personas can have access to different knowledge, tools and actions. They can als
|
|
|
205
202
|
|
|
206
203
|
- [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
|
|
207
204
|
|
|
208
|
-
|
|
209
|
-
|
|
210
205
|
### **How:** Knowledge, Instruments and Actions
|
|
211
206
|
|
|
212
207
|
The resources used by the personas are used to do the work.
|
|
@@ -282,16 +277,9 @@ Or you can install them separately:
|
|
|
282
277
|
|
|
283
278
|
## 📚 Dictionary
|
|
284
279
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
### 📚 Dictionary
|
|
291
|
-
|
|
292
280
|
The following glossary is used to clarify certain concepts:
|
|
293
281
|
|
|
294
|
-
|
|
282
|
+
### General LLM / AI terms
|
|
295
283
|
|
|
296
284
|
- **Prompt drift** is a phenomenon where the AI model starts to generate outputs that are not aligned with the original prompt. This can happen due to the model's training data, the prompt's wording, or the model's architecture.
|
|
297
285
|
- **Pipeline, workflow or chain** is a sequence of tasks that are executed in a specific order. In the context of AI, a pipeline can refer to a sequence of AI models that are used to process data.
|
|
@@ -302,13 +290,9 @@ The following glossary is used to clarify certain concepts:
|
|
|
302
290
|
- **Retrieval-augmented generation** is a machine learning paradigm where a model generates text by retrieving relevant information from a large database of text. This approach combines the benefits of generative models and retrieval models.
|
|
303
291
|
- **Longtail** refers to non-common or rare events, items, or entities that are not well-represented in the training data of machine learning models. Longtail items are often challenging for models to predict accurately.
|
|
304
292
|
|
|
293
|
+
_Note: This section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
305
294
|
|
|
306
|
-
|
|
307
|
-
_Note: Thos section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
#### 💯 Core concepts
|
|
295
|
+
### 💯 Core concepts
|
|
312
296
|
|
|
313
297
|
- [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
|
|
314
298
|
- [📯 Pipeline](https://github.com/webgptorg/promptbook/discussions/64)
|
|
@@ -321,7 +305,7 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
321
305
|
- [🔣 Words not tokens](https://github.com/webgptorg/promptbook/discussions/29)
|
|
322
306
|
- [☯ Separation of concerns](https://github.com/webgptorg/promptbook/discussions/32)
|
|
323
307
|
|
|
324
|
-
|
|
308
|
+
#### Advanced concepts
|
|
325
309
|
|
|
326
310
|
- [📚 Knowledge (Retrieval-augmented generation)](https://github.com/webgptorg/promptbook/discussions/41)
|
|
327
311
|
- [🌏 Remote server](https://github.com/webgptorg/promptbook/discussions/89)
|
|
@@ -338,17 +322,9 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
338
322
|
|
|
339
323
|
|
|
340
324
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
- Anonymous mode
|
|
344
|
-
- Application mode
|
|
345
|
-
|
|
325
|
+
## 🚂 Promptbook Engine
|
|
346
326
|
|
|
347
|
-
|
|
348
|
-
## 🔌 Usage in Typescript / Javascript
|
|
349
|
-
|
|
350
|
-
- [Simple usage](./examples/usage/simple-script)
|
|
351
|
-
- [Usage with client and remote server](./examples/usage/remote)
|
|
327
|
+

|
|
352
328
|
|
|
353
329
|
## ➕➖ When to use Promptbook?
|
|
354
330
|
|
|
@@ -414,13 +390,13 @@ See [TODO.md](./TODO.md)
|
|
|
414
390
|
<div style="display: flex; align-items: center; gap: 20px;">
|
|
415
391
|
|
|
416
392
|
<a href="https://promptbook.studio/">
|
|
417
|
-
<img src="./design/promptbook-studio-logo.png" alt="Partner 3" height="
|
|
393
|
+
<img src="./design/promptbook-studio-logo.png" alt="Partner 3" height="70">
|
|
418
394
|
</a>
|
|
419
395
|
|
|
420
396
|
<a href="https://technologickainkubace.org/en/about-technology-incubation/about-the-project/">
|
|
421
|
-
<img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="
|
|
397
|
+
<img src="./other/partners/CI-Technology-Incubation.png" alt="Technology Incubation" height="70">
|
|
422
398
|
</a>
|
|
423
|
-
|
|
399
|
+
|
|
424
400
|
</div>
|
|
425
401
|
|
|
426
402
|
## 🖋️ Contributing
|
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.88.0-
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.88.0-10';
|
|
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
|
|
@@ -1741,6 +1741,36 @@ function $randomToken(randomness) {
|
|
|
1741
1741
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
1742
1742
|
*/
|
|
1743
1743
|
|
|
1744
|
+
/**
|
|
1745
|
+
* Recursively converts JSON strings to JSON objects
|
|
1746
|
+
|
|
1747
|
+
* @public exported from `@promptbook/utils`
|
|
1748
|
+
*/
|
|
1749
|
+
function jsonStringsToJsons(object) {
|
|
1750
|
+
if (object === null) {
|
|
1751
|
+
return object;
|
|
1752
|
+
}
|
|
1753
|
+
if (Array.isArray(object)) {
|
|
1754
|
+
return object.map(jsonStringsToJsons);
|
|
1755
|
+
}
|
|
1756
|
+
if (typeof object !== 'object') {
|
|
1757
|
+
return object;
|
|
1758
|
+
}
|
|
1759
|
+
const newObject = { ...object };
|
|
1760
|
+
for (const [key, value] of Object.entries(object)) {
|
|
1761
|
+
if (typeof value === 'string' && isValidJsonString(value)) {
|
|
1762
|
+
newObject[key] = JSON.parse(value);
|
|
1763
|
+
}
|
|
1764
|
+
else {
|
|
1765
|
+
newObject[key] = jsonStringsToJsons(value);
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
return newObject;
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* TODO: Type the return type correctly
|
|
1772
|
+
*/
|
|
1773
|
+
|
|
1744
1774
|
/**
|
|
1745
1775
|
* This error indicates problems parsing the format value
|
|
1746
1776
|
*
|
|
@@ -1993,21 +2023,43 @@ function assertsTaskSuccessful(executionResult) {
|
|
|
1993
2023
|
function createTask(options) {
|
|
1994
2024
|
const { taskType, taskProcessCallback } = options;
|
|
1995
2025
|
const taskId = `${taskType.toLowerCase().substring(0, 4)}-${$randomToken(8 /* <- TODO: To global config + Use Base58 to avoid simmilar char conflicts */)}`;
|
|
1996
|
-
|
|
2026
|
+
let status = 'RUNNING';
|
|
2027
|
+
const createdAt = new Date();
|
|
2028
|
+
let updatedAt = createdAt;
|
|
2029
|
+
const errors = [];
|
|
2030
|
+
const warnings = [];
|
|
2031
|
+
let currentValue = {};
|
|
2032
|
+
const partialResultSubject = new Subject();
|
|
2033
|
+
// <- Note: Not using `BehaviorSubject` because on error we can't access the last value
|
|
1997
2034
|
const finalResultPromise = /* not await */ taskProcessCallback((newOngoingResult) => {
|
|
2035
|
+
Object.assign(currentValue, newOngoingResult);
|
|
2036
|
+
// <- TODO: assign deep
|
|
1998
2037
|
partialResultSubject.next(newOngoingResult);
|
|
1999
2038
|
});
|
|
2000
2039
|
finalResultPromise
|
|
2001
2040
|
.catch((error) => {
|
|
2041
|
+
errors.push(error);
|
|
2002
2042
|
partialResultSubject.error(error);
|
|
2003
2043
|
})
|
|
2004
|
-
.then((
|
|
2005
|
-
if (
|
|
2044
|
+
.then((executionResult) => {
|
|
2045
|
+
if (executionResult) {
|
|
2006
2046
|
try {
|
|
2007
|
-
|
|
2008
|
-
|
|
2047
|
+
updatedAt = new Date();
|
|
2048
|
+
errors.push(...executionResult.errors);
|
|
2049
|
+
warnings.push(...executionResult.warnings);
|
|
2050
|
+
// <- TODO: !!! Only unique errors and warnings should be added (or filtered)
|
|
2051
|
+
// TODO: [🧠] !!! errors, warning, isSuccessful are redundant both in `ExecutionTask` and `ExecutionTask.currentValue`
|
|
2052
|
+
// Also maybe move `ExecutionTask.currentValue.usage` -> `ExecutionTask.usage`
|
|
2053
|
+
// And delete `ExecutionTask.currentValue.preparedPipeline`
|
|
2054
|
+
assertsTaskSuccessful(executionResult);
|
|
2055
|
+
status = 'FINISHED';
|
|
2056
|
+
currentValue = jsonStringsToJsons(executionResult);
|
|
2057
|
+
// <- TODO: [🧠] Is this a good idea to convert JSON strins to JSONs?
|
|
2058
|
+
partialResultSubject.next(executionResult);
|
|
2009
2059
|
}
|
|
2010
2060
|
catch (error) {
|
|
2061
|
+
status = 'ERROR';
|
|
2062
|
+
errors.push(error);
|
|
2011
2063
|
partialResultSubject.error(error);
|
|
2012
2064
|
}
|
|
2013
2065
|
}
|
|
@@ -2024,12 +2076,33 @@ function createTask(options) {
|
|
|
2024
2076
|
return {
|
|
2025
2077
|
taskType,
|
|
2026
2078
|
taskId,
|
|
2079
|
+
get status() {
|
|
2080
|
+
return status;
|
|
2081
|
+
// <- Note: [1] Theese must be getters to allow changing the value in the future
|
|
2082
|
+
},
|
|
2083
|
+
get createdAt() {
|
|
2084
|
+
return createdAt;
|
|
2085
|
+
// <- Note: [1]
|
|
2086
|
+
},
|
|
2087
|
+
get updatedAt() {
|
|
2088
|
+
return updatedAt;
|
|
2089
|
+
// <- Note: [1]
|
|
2090
|
+
},
|
|
2027
2091
|
asPromise,
|
|
2028
2092
|
asObservable() {
|
|
2029
2093
|
return partialResultSubject.asObservable();
|
|
2030
2094
|
},
|
|
2095
|
+
get errors() {
|
|
2096
|
+
return errors;
|
|
2097
|
+
// <- Note: [1]
|
|
2098
|
+
},
|
|
2099
|
+
get warnings() {
|
|
2100
|
+
return warnings;
|
|
2101
|
+
// <- Note: [1]
|
|
2102
|
+
},
|
|
2031
2103
|
get currentValue() {
|
|
2032
|
-
return
|
|
2104
|
+
return currentValue;
|
|
2105
|
+
// <- Note: [1]
|
|
2033
2106
|
},
|
|
2034
2107
|
};
|
|
2035
2108
|
}
|
|
@@ -4688,7 +4761,7 @@ async function executeAttempts(options) {
|
|
|
4688
4761
|
Last result:
|
|
4689
4762
|
${block($ongoingTaskResult.$resultString === null
|
|
4690
4763
|
? 'null'
|
|
4691
|
-
: $ongoingTaskResult.$resultString
|
|
4764
|
+
: spaceTrim$1($ongoingTaskResult.$resultString)
|
|
4692
4765
|
.split('\n')
|
|
4693
4766
|
.map((line) => `> ${line}`)
|
|
4694
4767
|
.join('\n'))}
|