@promptbook/website-crawler 0.75.0-2 → 0.75.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/README.md +27 -17
- package/esm/index.es.js +46 -45
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +10 -4
- package/esm/typings/src/_packages/types.index.d.ts +8 -6
- package/esm/typings/src/commands/EXPECT/ExpectCommand.d.ts +1 -1
- package/esm/typings/src/commands/SECTION/SectionCommand.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +0 -2
- package/esm/typings/src/config.d.ts +9 -2
- package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -1
- package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +2 -2
- package/esm/typings/src/conversion/utils/extractParameterNamesFromTask.d.ts +3 -3
- package/esm/typings/src/conversion/utils/renameParameter.d.ts +2 -2
- package/esm/typings/src/dialogs/simple-prompt/SimplePromptInterfaceTools.d.ts +1 -1
- package/esm/typings/src/execution/ScriptExecutionTools.d.ts +1 -1
- package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +2 -2
- package/esm/typings/src/formfactors/_common/AbstractFormfactorDefinition.d.ts +3 -0
- package/esm/typings/src/formfactors/chatbot/ChatbotFormfactorDefinition.d.ts +32 -2
- package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +14 -0
- package/esm/typings/src/formfactors/generic/GenericFormfactorDefinition.d.ts +2 -2
- package/esm/typings/src/formfactors/index.d.ts +72 -10
- package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +2 -2
- package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +12 -2
- package/esm/typings/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +12 -2
- package/esm/typings/src/pipeline/PipelineInterface/PipelineInterface.d.ts +5 -4
- package/esm/typings/src/pipeline/PipelineInterface/constants.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/{TaskJsonCommon.d.ts → CommonTaskJson.d.ts} +13 -13
- package/esm/typings/src/pipeline/PipelineJson/DialogTaskJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/ParameterJson.d.ts +2 -0
- package/esm/typings/src/pipeline/PipelineJson/PersonaJson.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/PromptTaskJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/ScriptTaskJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/SimpleTaskJson.d.ts +2 -2
- package/esm/typings/src/pipeline/PipelineJson/TaskJson.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineString.d.ts +1 -1
- package/esm/typings/src/prepare/isPipelinePrepared.d.ts +1 -1
- package/esm/typings/src/prepare/prepareTasks.d.ts +5 -5
- package/esm/typings/src/types/Prompt.d.ts +3 -3
- package/esm/typings/src/types/SectionType.d.ts +21 -0
- package/esm/typings/src/types/TaskProgress.d.ts +1 -1
- package/esm/typings/src/types/TaskType.d.ts +15 -0
- package/esm/typings/src/types/typeAliases.d.ts +1 -1
- package/esm/typings/src/utils/organization/TODO_remove_as.d.ts +6 -0
- package/esm/typings/src/utils/parameters/extractParameterNames.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +46 -45
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/commands/SECTION/SectionType.d.ts +0 -13
- /package/esm/typings/{promptbook-collection → books}/index.d.ts +0 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
#  Promptbook
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
It's time for a paradigm shift! The future of software is in plain English, French or Latin.
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
@@ -51,25 +51,24 @@ Crawl knowledge from the web
|
|
|
51
51
|
|
|
52
52
|
Rest of the documentation is common for **entire promptbook ecosystem**:
|
|
53
53
|
|
|
54
|
-
## 🤍 The Promptbook Whitepaper
|
|
55
54
|
|
|
56
|
-
If you have a simple, single prompt for ChatGPT, GPT-4, Anthropic Claude, Google Gemini, Llama 3, or whatever, it doesn't matter how you integrate it. Whether it's calling a REST API directly, using the SDK, hardcoding the prompt into the source code, or importing a text file, the process remains the same.
|
|
57
55
|
|
|
58
|
-
But often you will struggle with the **limitations of LLMs**, such as **hallucinations, off-topic responses, poor quality output, language and prompt drift, word repetition repetition repetition repetition or misuse, lack of context, or just plain w𝒆𝐢rd resp0nses**. When this happens, you generally have three options:
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
## 🤍 The Book Abstract
|
|
58
|
+
|
|
59
|
+
> It's time for a paradigm shift! **The future of software is in plain English**, French or Latin.
|
|
60
|
+
|
|
61
|
+
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**!
|
|
62
|
+
|
|
63
|
+
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
|
+
|
|
65
|
+
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.
|
|
66
|
+
|
|
67
|
+
This shift is going to happen, whether we are ready for it or not. Our mission is to make it excellently, not just good.
|
|
68
|
+
|
|
69
|
+
> **Join us in this journey!**
|
|
63
70
|
|
|
64
|
-
In all of these situations, but especially in 3., the **✨ Promptbook can make your life waaaaaaaaaay easier**.
|
|
65
71
|
|
|
66
|
-
- [**Separates concerns**](https://github.com/webgptorg/promptbook/discussions/32) between prompt-engineer and programmer, between code files and prompt files, and between prompts and their execution logic. For this purpose, it introduces a new language called [the **💙 Book**](https://github.com/webgptorg/book).
|
|
67
|
-
- Book allows you to **focus on the business** logic without having to write code or deal with the technicalities of LLMs.
|
|
68
|
-
- **Forget** about **low-level details** like choosing the right model, tokens, context size, `temperature`, `top-k`, `top-p`, or kernel sampling. **Just write your intent** and [**persona**](https://github.com/webgptorg/promptbook/discussions/22) who should be responsible for the task and let the library do the rest.
|
|
69
|
-
- We have built-in **orchestration** of [pipeline](https://github.com/webgptorg/promptbook/discussions/64) execution and many tools to make the process easier, more reliable, and more efficient, such as caching, [compilation+preparation](https://github.com/webgptorg/promptbook/discussions/78), [just-in-time fine-tuning](https://github.com/webgptorg/promptbook/discussions/33), [expectation-aware generation](https://github.com/webgptorg/promptbook/discussions/37), [agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39), and more.
|
|
70
|
-
- Sometimes even the best prompts with the best framework like Promptbook `:)` can't avoid the problems. In this case, the library has built-in **[anomaly detection](https://github.com/webgptorg/promptbook/discussions/40) and logging** to help you find and fix the problems.
|
|
71
|
-
- Versioning is build in. You can test multiple **A/B versions** of pipelines and see which one works best.
|
|
72
|
-
- Promptbook is designed to use [**RAG** (Retrieval-Augmented Generation)](https://github.com/webgptorg/promptbook/discussions/41) and other advanced techniques to bring the context of your business to generic LLM. You can use **knowledge** to improve the quality of the output.
|
|
73
72
|
|
|
74
73
|
|
|
75
74
|
|
|
@@ -181,7 +180,9 @@ Reserved words:
|
|
|
181
180
|
|
|
182
181
|
#### Parameter notation
|
|
183
182
|
|
|
184
|
-
###
|
|
183
|
+
### Task
|
|
184
|
+
|
|
185
|
+
### Task type
|
|
185
186
|
|
|
186
187
|
Todo todo
|
|
187
188
|
|
|
@@ -242,6 +243,11 @@ Or you can install them separately:
|
|
|
242
243
|
|
|
243
244
|
## 📚 Dictionary
|
|
244
245
|
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
245
251
|
### 📚 Dictionary
|
|
246
252
|
|
|
247
253
|
The following glossary is used to clarify certain concepts:
|
|
@@ -257,6 +263,8 @@ The following glossary is used to clarify certain concepts:
|
|
|
257
263
|
- **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.
|
|
258
264
|
- **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.
|
|
259
265
|
|
|
266
|
+
|
|
267
|
+
|
|
260
268
|
_Note: Thos section is not complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
|
|
261
269
|
|
|
262
270
|
#### Promptbook core
|
|
@@ -293,7 +301,7 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
293
301
|
|
|
294
302
|
- [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)
|
|
295
303
|
- [📯 Pipeline](https://github.com/webgptorg/promptbook/discussions/64)
|
|
296
|
-
- [
|
|
304
|
+
- [🙇♂️ Tasks and pipeline sections](https://github.com/webgptorg/promptbook/discussions/88)
|
|
297
305
|
- [🤼 Personas](https://github.com/webgptorg/promptbook/discussions/22)
|
|
298
306
|
- [⭕ Parameters](https://github.com/webgptorg/promptbook/discussions/83)
|
|
299
307
|
- [🚀 Pipeline execution](https://github.com/webgptorg/promptbook/discussions/84)
|
|
@@ -317,6 +325,8 @@ _Note: Thos section is not complete dictionary, more list of general AI / LLM te
|
|
|
317
325
|
- [👮 Agent adversary expectations](https://github.com/webgptorg/promptbook/discussions/39)
|
|
318
326
|
- [view more](https://github.com/webgptorg/promptbook/discussions/categories/concepts)
|
|
319
327
|
|
|
328
|
+
|
|
329
|
+
|
|
320
330
|
### Terms specific to Promptbook TypeScript implementation
|
|
321
331
|
|
|
322
332
|
- Anonymous mode
|
package/esm/index.es.js
CHANGED
|
@@ -24,7 +24,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
24
24
|
*
|
|
25
25
|
* @see https://github.com/webgptorg/promptbook
|
|
26
26
|
*/
|
|
27
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.75.0-
|
|
27
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.75.0-3';
|
|
28
28
|
/**
|
|
29
29
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
30
30
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -401,7 +401,7 @@ var DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹♂️]
|
|
|
401
401
|
*
|
|
402
402
|
* @public exported from `@promptbook/core`
|
|
403
403
|
*/
|
|
404
|
-
var DEFAULT_SCRAPE_CACHE_DIRNAME = '
|
|
404
|
+
var DEFAULT_SCRAPE_CACHE_DIRNAME = './.promptbook/scrape-cache';
|
|
405
405
|
/**
|
|
406
406
|
* Nonce which is used for replacing things in strings
|
|
407
407
|
*
|
|
@@ -1193,7 +1193,7 @@ function getScraperIntermediateSource(source, options) {
|
|
|
1193
1193
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
1194
1194
|
*/
|
|
1195
1195
|
|
|
1196
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./
|
|
1196
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-persona.book.md"}];
|
|
1197
1197
|
|
|
1198
1198
|
/**
|
|
1199
1199
|
* Prettify the html code
|
|
@@ -1268,7 +1268,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
1268
1268
|
return isInput;
|
|
1269
1269
|
})), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
1270
1270
|
var parameter = _h.value;
|
|
1271
|
-
commands.push("INPUT PARAMETER ".concat(
|
|
1271
|
+
commands.push("INPUT PARAMETER ".concat(taskParameterJsonToString(parameter)));
|
|
1272
1272
|
}
|
|
1273
1273
|
}
|
|
1274
1274
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -1284,7 +1284,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
1284
1284
|
return isOutput;
|
|
1285
1285
|
})), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
1286
1286
|
var parameter = _k.value;
|
|
1287
|
-
commands.push("OUTPUT PARAMETER ".concat(
|
|
1287
|
+
commands.push("OUTPUT PARAMETER ".concat(taskParameterJsonToString(parameter)));
|
|
1288
1288
|
}
|
|
1289
1289
|
}
|
|
1290
1290
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -1298,12 +1298,12 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
1298
1298
|
pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
|
|
1299
1299
|
try {
|
|
1300
1300
|
for (var tasks_1 = __values(tasks), tasks_1_1 = tasks_1.next(); !tasks_1_1.done; tasks_1_1 = tasks_1.next()) {
|
|
1301
|
-
var
|
|
1301
|
+
var task = tasks_1_1.value;
|
|
1302
1302
|
var
|
|
1303
1303
|
/* Note: Not using:> name, */
|
|
1304
|
-
title_1 =
|
|
1304
|
+
title_1 = task.title, description_1 = task.description,
|
|
1305
1305
|
/* Note: dependentParameterNames, */
|
|
1306
|
-
jokers =
|
|
1306
|
+
jokers = task.jokerParameterNames, taskType = task.taskType, content = task.content, postprocessing = task.postprocessingFunctionNames, expectations = task.expectations, format = task.format, resultingParameterName = task.resultingParameterName;
|
|
1307
1307
|
pipelineString += '\n\n';
|
|
1308
1308
|
pipelineString += "## ".concat(title_1);
|
|
1309
1309
|
if (description_1) {
|
|
@@ -1313,9 +1313,10 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
1313
1313
|
var commands_1 = [];
|
|
1314
1314
|
var contentLanguage = 'text';
|
|
1315
1315
|
if (taskType === 'PROMPT_TASK') {
|
|
1316
|
-
var modelRequirements =
|
|
1316
|
+
var modelRequirements = task.modelRequirements;
|
|
1317
1317
|
var _l = modelRequirements || {}, modelName = _l.modelName, modelVariant = _l.modelVariant;
|
|
1318
|
-
|
|
1318
|
+
// Note: Do nothing, it is default
|
|
1319
|
+
// commands.push(`PROMPT`);
|
|
1319
1320
|
if (modelVariant) {
|
|
1320
1321
|
commands_1.push("MODEL VARIANT ".concat(capitalize(modelVariant)));
|
|
1321
1322
|
}
|
|
@@ -1328,16 +1329,16 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
1328
1329
|
// Note: Nothing special here
|
|
1329
1330
|
}
|
|
1330
1331
|
else if (taskType === 'SCRIPT_TASK') {
|
|
1331
|
-
commands_1.push("SCRIPT
|
|
1332
|
-
if (
|
|
1333
|
-
contentLanguage =
|
|
1332
|
+
commands_1.push("SCRIPT");
|
|
1333
|
+
if (task.contentLanguage) {
|
|
1334
|
+
contentLanguage = task.contentLanguage;
|
|
1334
1335
|
}
|
|
1335
1336
|
else {
|
|
1336
1337
|
contentLanguage = '';
|
|
1337
1338
|
}
|
|
1338
1339
|
}
|
|
1339
1340
|
else if (taskType === 'DIALOG_TASK') {
|
|
1340
|
-
commands_1.push("DIALOG
|
|
1341
|
+
commands_1.push("DIALOG");
|
|
1341
1342
|
// Note: Nothing special here
|
|
1342
1343
|
} // <- }else if([🅱]
|
|
1343
1344
|
if (jokers) {
|
|
@@ -1412,7 +1413,7 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
1412
1413
|
pipelineString += '\n';
|
|
1413
1414
|
pipelineString += '```';
|
|
1414
1415
|
pipelineString += '\n\n';
|
|
1415
|
-
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use
|
|
1416
|
+
pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: [main] !!! If the parameter here has description, add it and use taskParameterJsonToString
|
|
1416
1417
|
}
|
|
1417
1418
|
}
|
|
1418
1419
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
@@ -1427,8 +1428,8 @@ function pipelineJsonToString(pipelineJson) {
|
|
|
1427
1428
|
/**
|
|
1428
1429
|
* @private internal utility of `pipelineJsonToString`
|
|
1429
1430
|
*/
|
|
1430
|
-
function
|
|
1431
|
-
var name =
|
|
1431
|
+
function taskParameterJsonToString(taskParameterJson) {
|
|
1432
|
+
var name = taskParameterJson.name, description = taskParameterJson.description;
|
|
1432
1433
|
var parameterString = "{".concat(name, "}");
|
|
1433
1434
|
if (description) {
|
|
1434
1435
|
parameterString = "".concat(parameterString, " ").concat(description);
|
|
@@ -1436,7 +1437,7 @@ function templateParameterJsonToString(templateParameterJson) {
|
|
|
1436
1437
|
return parameterString;
|
|
1437
1438
|
}
|
|
1438
1439
|
/**
|
|
1439
|
-
* TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `
|
|
1440
|
+
* TODO: [🛋] Implement new features and commands into `pipelineJsonToString` + `taskParameterJsonToString` , use `stringifyCommand`
|
|
1440
1441
|
* TODO: [🧠] Is there a way to auto-detect missing features in pipelineJsonToString
|
|
1441
1442
|
* TODO: [🏛] Maybe make some markdown builder
|
|
1442
1443
|
* TODO: [🏛] Escape all
|
|
@@ -1805,20 +1806,20 @@ function validatePipelineCore(pipeline) {
|
|
|
1805
1806
|
}
|
|
1806
1807
|
finally { if (e_3) throw e_3.error; }
|
|
1807
1808
|
}
|
|
1808
|
-
var
|
|
1809
|
+
var unresovedTasks = __spreadArray([], __read(pipeline.tasks), false);
|
|
1809
1810
|
var loopLimit = LOOP_LIMIT;
|
|
1810
1811
|
var _loop_3 = function () {
|
|
1811
1812
|
if (loopLimit-- < 0) {
|
|
1812
1813
|
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
1813
1814
|
throw new UnexpectedError(spaceTrim(function (block) { return "\n Loop limit reached during detection of circular dependencies in `validatePipeline`\n\n ".concat(block(pipelineIdentification), "\n "); }));
|
|
1814
1815
|
}
|
|
1815
|
-
var
|
|
1816
|
+
var currentlyResovedTasks = unresovedTasks.filter(function (task) {
|
|
1816
1817
|
return task.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
|
|
1817
1818
|
});
|
|
1818
|
-
if (
|
|
1819
|
+
if (currentlyResovedTasks.length === 0) {
|
|
1819
1820
|
throw new PipelineLogicError(
|
|
1820
1821
|
// TODO: [🐎] DRY
|
|
1821
|
-
spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(
|
|
1822
|
+
spaceTrim(function (block) { return "\n\n Can not resolve some parameters:\n Either you are using a parameter that is not defined, or there are some circular dependencies.\n\n ".concat(block(pipelineIdentification), "\n\n **Can not resolve:**\n ").concat(block(unresovedTasks
|
|
1822
1823
|
.map(function (_a) {
|
|
1823
1824
|
var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
|
|
1824
1825
|
return "- Parameter `{".concat(resultingParameterName, "}` which depends on ").concat(dependentParameterNames
|
|
@@ -1837,13 +1838,13 @@ function validatePipelineCore(pipeline) {
|
|
|
1837
1838
|
.map(function (name) { return "- Parameter `{".concat(name, "}`"); })
|
|
1838
1839
|
.join('\n')), "\n\n\n "); }));
|
|
1839
1840
|
}
|
|
1840
|
-
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(
|
|
1841
|
+
resovedParameters = __spreadArray(__spreadArray([], __read(resovedParameters), false), __read(currentlyResovedTasks.map(function (_a) {
|
|
1841
1842
|
var resultingParameterName = _a.resultingParameterName;
|
|
1842
1843
|
return resultingParameterName;
|
|
1843
1844
|
})), false);
|
|
1844
|
-
|
|
1845
|
+
unresovedTasks = unresovedTasks.filter(function (task) { return !currentlyResovedTasks.includes(task); });
|
|
1845
1846
|
};
|
|
1846
|
-
while (
|
|
1847
|
+
while (unresovedTasks.length > 0) {
|
|
1847
1848
|
_loop_3();
|
|
1848
1849
|
}
|
|
1849
1850
|
// TODO: !!!!!! Test that pipeline interface implements declared formfactor interface
|
|
@@ -1905,7 +1906,7 @@ var PipelineUrlError = /** @class */ (function (_super) {
|
|
|
1905
1906
|
/**
|
|
1906
1907
|
* Parses the task and returns the list of all parameter names
|
|
1907
1908
|
*
|
|
1908
|
-
* @param template the
|
|
1909
|
+
* @param template the string template with parameters in {curly} braces
|
|
1909
1910
|
* @returns the list of parameter names
|
|
1910
1911
|
* @public exported from `@promptbook/utils`
|
|
1911
1912
|
*/
|
|
@@ -1939,13 +1940,13 @@ function unpreparePipeline(pipeline) {
|
|
|
1939
1940
|
var personas = pipeline.personas, knowledgeSources = pipeline.knowledgeSources, tasks = pipeline.tasks;
|
|
1940
1941
|
personas = personas.map(function (persona) { return (__assign(__assign({}, persona), { modelRequirements: undefined, preparationIds: undefined })); });
|
|
1941
1942
|
knowledgeSources = knowledgeSources.map(function (knowledgeSource) { return (__assign(__assign({}, knowledgeSource), { preparationIds: undefined })); });
|
|
1942
|
-
tasks = tasks.map(function (
|
|
1943
|
-
var dependentParameterNames =
|
|
1944
|
-
var parameterNames = extractParameterNames(
|
|
1943
|
+
tasks = tasks.map(function (task) {
|
|
1944
|
+
var dependentParameterNames = task.dependentParameterNames;
|
|
1945
|
+
var parameterNames = extractParameterNames(task.preparedContent || '');
|
|
1945
1946
|
dependentParameterNames = dependentParameterNames.filter(function (dependentParameterName) { return !parameterNames.has(dependentParameterName); });
|
|
1946
|
-
var
|
|
1947
|
-
delete
|
|
1948
|
-
return
|
|
1947
|
+
var taskUnprepared = __assign(__assign({}, task), { dependentParameterNames: dependentParameterNames });
|
|
1948
|
+
delete taskUnprepared.preparedContent;
|
|
1949
|
+
return taskUnprepared;
|
|
1949
1950
|
});
|
|
1950
1951
|
return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
|
|
1951
1952
|
}
|
|
@@ -2238,7 +2239,7 @@ function isPipelinePrepared(pipeline) {
|
|
|
2238
2239
|
* TODO: [🐠] Maybe base this on `makeValidator`
|
|
2239
2240
|
* TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
|
|
2240
2241
|
* TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
|
|
2241
|
-
* - [🏍] ? Is context in each
|
|
2242
|
+
* - [🏍] ? Is context in each task
|
|
2242
2243
|
* - [♨] Are examples prepared
|
|
2243
2244
|
* - [♨] Are tasks prepared
|
|
2244
2245
|
*/
|
|
@@ -3445,10 +3446,10 @@ function prepareTasks(pipeline, tools, options) {
|
|
|
3445
3446
|
_a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
|
|
3446
3447
|
tasks = pipeline.tasks, pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
|
|
3447
3448
|
tasksPrepared = new Array(tasks.length);
|
|
3448
|
-
return [4 /*yield*/, forEachAsync(tasks, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (
|
|
3449
|
-
var dependentParameterNames, preparedContent,
|
|
3449
|
+
return [4 /*yield*/, forEachAsync(tasks, { maxParallelCount: maxParallelCount /* <- TODO: [🪂] When there are subtasks, this maximul limit can be broken */ }, function (task, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
3450
|
+
var dependentParameterNames, preparedContent, preparedTask;
|
|
3450
3451
|
return __generator(this, function (_a) {
|
|
3451
|
-
dependentParameterNames =
|
|
3452
|
+
dependentParameterNames = task.dependentParameterNames;
|
|
3452
3453
|
preparedContent = undefined;
|
|
3453
3454
|
if (knowledgePiecesCount > 0 && !dependentParameterNames.includes('knowledge')) {
|
|
3454
3455
|
preparedContent = spaceTrim("\n {content}\n\n ## Knowledge\n\n {knowledge}\n ");
|
|
@@ -3457,8 +3458,8 @@ function prepareTasks(pipeline, tools, options) {
|
|
|
3457
3458
|
'knowledge',
|
|
3458
3459
|
], false);
|
|
3459
3460
|
}
|
|
3460
|
-
|
|
3461
|
-
tasksPrepared[index] =
|
|
3461
|
+
preparedTask = __assign(__assign({}, task), { dependentParameterNames: dependentParameterNames, preparedContent: preparedContent });
|
|
3462
|
+
tasksPrepared[index] = preparedTask;
|
|
3462
3463
|
return [2 /*return*/];
|
|
3463
3464
|
});
|
|
3464
3465
|
}); })];
|
|
@@ -3470,8 +3471,8 @@ function prepareTasks(pipeline, tools, options) {
|
|
|
3470
3471
|
});
|
|
3471
3472
|
}
|
|
3472
3473
|
/**
|
|
3473
|
-
* TODO: [🧠] Add context to each
|
|
3474
|
-
* TODO: [🧠] What is better name `
|
|
3474
|
+
* TODO: [🧠] Add context to each task (if missing)
|
|
3475
|
+
* TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
|
|
3475
3476
|
* TODO: [♨][main] !!! Prepare index the examples and maybe tasks
|
|
3476
3477
|
* TODO: Write tests for `preparePipeline`
|
|
3477
3478
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
@@ -3557,7 +3558,7 @@ function preparePipeline(pipeline, tools, options) {
|
|
|
3557
3558
|
})];
|
|
3558
3559
|
case 3:
|
|
3559
3560
|
tasksPrepared = (_c.sent()).tasksPrepared;
|
|
3560
|
-
// ----- /
|
|
3561
|
+
// ----- /Tasks preparation -----
|
|
3561
3562
|
// Note: Count total usage
|
|
3562
3563
|
currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
|
|
3563
3564
|
return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
|
|
@@ -3626,16 +3627,16 @@ function extractVariables(script) {
|
|
|
3626
3627
|
*/
|
|
3627
3628
|
|
|
3628
3629
|
/**
|
|
3629
|
-
* Parses the
|
|
3630
|
+
* Parses the task and returns the set of all used parameters
|
|
3630
3631
|
*
|
|
3631
|
-
* @param
|
|
3632
|
+
* @param task the task with used parameters
|
|
3632
3633
|
* @returns the set of parameter names
|
|
3633
3634
|
* @throws {ParseError} if the script is invalid
|
|
3634
3635
|
* @public exported from `@promptbook/utils`
|
|
3635
3636
|
*/
|
|
3636
|
-
function extractParameterNamesFromTask(
|
|
3637
|
+
function extractParameterNamesFromTask(task) {
|
|
3637
3638
|
var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
|
|
3638
|
-
var title =
|
|
3639
|
+
var title = task.title, description = task.description, taskType = task.taskType, content = task.content, preparedContent = task.preparedContent, jokerParameterNames = task.jokerParameterNames, foreach = task.foreach;
|
|
3639
3640
|
var parameterNames = new Set();
|
|
3640
3641
|
try {
|
|
3641
3642
|
for (var _e = __values(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read(extractParameterNames(title)), false), __read(extractParameterNames(description || '')), false), __read(extractParameterNames(content)), false), __read(extractParameterNames(preparedContent || '')), false)), _f = _e.next(); !_f.done; _f = _e.next()) {
|