@promptbook/cli 0.59.0-29 → 0.59.0-30
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 +55 -0
- package/esm/index.es.js +68 -35
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/config.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -0
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +8 -0
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +1 -1
- package/esm/typings/src/types/PromptbookJson/MaterialKnowledgePieceJson.d.ts +2 -2
- package/package.json +2 -2
- package/umd/index.umd.js +68 -35
- package/umd/index.umd.js.map +1 -1
- package/umd/typings/src/config.d.ts +1 -1
- package/umd/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -0
- package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +8 -0
- package/umd/typings/src/llm-providers/openai/openai-models.d.ts +1 -0
- package/umd/typings/src/types/ModelRequirements.d.ts +1 -1
- package/umd/typings/src/types/PromptbookJson/MaterialKnowledgePieceJson.d.ts +2 -2
- /package/esm/typings/promptbook-library/{promptbook-library.d.ts → index.d.ts} +0 -0
- /package/umd/typings/promptbook-library/{promptbook-library.d.ts → index.d.ts} +0 -0
package/umd/index.umd.js
CHANGED
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
/**
|
|
148
148
|
* The version of the Promptbook library
|
|
149
149
|
*/
|
|
150
|
-
var PROMPTBOOK_VERSION = '0.59.0-
|
|
150
|
+
var PROMPTBOOK_VERSION = '0.59.0-29';
|
|
151
151
|
|
|
152
152
|
/**
|
|
153
153
|
* Initializes testing `hello` command for Promptbook CLI utilities
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
/**
|
|
187
187
|
* The name of the builded promptbook library made by CLI `promptbook make` and for lookup in `createLibraryFromDirectory`
|
|
188
188
|
*/
|
|
189
|
-
var PROMPTBOOK_MAKED_BASE_FILENAME = "
|
|
189
|
+
var PROMPTBOOK_MAKED_BASE_FILENAME = "index";
|
|
190
190
|
|
|
191
191
|
/**
|
|
192
192
|
* This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
|
|
@@ -441,7 +441,7 @@
|
|
|
441
441
|
* > ex port function validatePromptbook(promptbook: unknown): asserts promptbook is PromptbookJson {
|
|
442
442
|
*/
|
|
443
443
|
|
|
444
|
-
var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-
|
|
444
|
+
var promptbookLibrary = [{title:"Prepare Keywords",promptbookUrl:"https://promptbook.studio/promptbook/prepare-keywords.ptbk.md",promptbookVersion:"0.59.0-29",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",resultingParameterName:"keywords"}],knowledge:[]},{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-29",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},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> {content}",resultingParameterName:"knowledge"}],knowledge:[]}];
|
|
445
445
|
|
|
446
446
|
/**
|
|
447
447
|
* This error indicates errors during the execution of the promptbook
|
|
@@ -2000,7 +2000,7 @@
|
|
|
2000
2000
|
|
|
2001
2001
|
function prepareKnowledgeFromMarkdown(options) {
|
|
2002
2002
|
return __awaiter(this, void 0, void 0, function () {
|
|
2003
|
-
var content, llmTools, _a, isVerbose, library,
|
|
2003
|
+
var content, llmTools, _a, isVerbose, library, prepareKnowledgeFromMarkdownPromptbook, prepareKnowledgeFromMarkdownExecutor, prepareKeywordsPromptbook, prepareKeywordsExecutor, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
|
|
2004
2004
|
var _this = this;
|
|
2005
2005
|
return __generator(this, function (_b) {
|
|
2006
2006
|
switch (_b.label) {
|
|
@@ -2009,9 +2009,9 @@
|
|
|
2009
2009
|
library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false));
|
|
2010
2010
|
return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
|
|
2011
2011
|
case 1:
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
promptbook:
|
|
2012
|
+
prepareKnowledgeFromMarkdownPromptbook = _b.sent();
|
|
2013
|
+
prepareKnowledgeFromMarkdownExecutor = createPromptbookExecutor({
|
|
2014
|
+
promptbook: prepareKnowledgeFromMarkdownPromptbook,
|
|
2015
2015
|
tools: {
|
|
2016
2016
|
llm: llmTools,
|
|
2017
2017
|
script: [
|
|
@@ -2019,8 +2019,20 @@
|
|
|
2019
2019
|
],
|
|
2020
2020
|
},
|
|
2021
2021
|
});
|
|
2022
|
-
return [4 /*yield*/,
|
|
2022
|
+
return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-keywords.ptbk.md')];
|
|
2023
2023
|
case 2:
|
|
2024
|
+
prepareKeywordsPromptbook = _b.sent();
|
|
2025
|
+
prepareKeywordsExecutor = createPromptbookExecutor({
|
|
2026
|
+
promptbook: prepareKeywordsPromptbook,
|
|
2027
|
+
tools: {
|
|
2028
|
+
llm: llmTools,
|
|
2029
|
+
script: [
|
|
2030
|
+
/* <- TODO: Allow to just keep script undefined */
|
|
2031
|
+
],
|
|
2032
|
+
},
|
|
2033
|
+
});
|
|
2034
|
+
return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ content: content })];
|
|
2035
|
+
case 3:
|
|
2024
2036
|
result = _b.sent();
|
|
2025
2037
|
assertsExecutionSuccessful(result);
|
|
2026
2038
|
outputParameters = result.outputParameters;
|
|
@@ -2030,36 +2042,57 @@
|
|
|
2030
2042
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
2031
2043
|
}
|
|
2032
2044
|
return [4 /*yield*/, Promise.all(knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
|
|
2033
|
-
var name, title, content, keywords, index, sources;
|
|
2034
|
-
return __generator(this, function (
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2045
|
+
var name, title, content, keywords, index, sources, result_1, _a, outputParameters_1, keywordsRaw, error_1;
|
|
2046
|
+
return __generator(this, function (_b) {
|
|
2047
|
+
switch (_b.label) {
|
|
2048
|
+
case 0:
|
|
2049
|
+
name = "piece-".concat(i);
|
|
2050
|
+
title = spaceTrim__default["default"](knowledgeTextPiece.substring(0, 100));
|
|
2051
|
+
content = spaceTrim__default["default"](knowledgeTextPiece);
|
|
2052
|
+
keywords = [];
|
|
2053
|
+
index = [];
|
|
2054
|
+
sources = [];
|
|
2055
|
+
_b.label = 1;
|
|
2056
|
+
case 1:
|
|
2057
|
+
_b.trys.push([1, 3, , 4]);
|
|
2058
|
+
// TODO: !!!! Summarize name and title from the content
|
|
2059
|
+
title = spaceTrim__default["default"](knowledgeTextPiece.substring(0, 30));
|
|
2060
|
+
name = normalizeToKebabCase(title);
|
|
2061
|
+
return [4 /*yield*/, prepareKeywordsExecutor({ content: content })];
|
|
2062
|
+
case 2:
|
|
2063
|
+
result_1 = _b.sent();
|
|
2064
|
+
_a = result_1.outputParameters, outputParameters_1 = _a === void 0 ? {} : _a;
|
|
2065
|
+
keywordsRaw = outputParameters_1.keywords;
|
|
2066
|
+
keywords = (keywordsRaw || '')
|
|
2067
|
+
.split(',')
|
|
2068
|
+
.map(function (keyword) { return keyword.trim(); })
|
|
2069
|
+
.filter(function (keyword) { return keyword !== ''; });
|
|
2070
|
+
if (isVerbose) {
|
|
2071
|
+
console.info("Keywords for \"".concat(title, "\":"), keywords);
|
|
2072
|
+
}
|
|
2073
|
+
// ---
|
|
2074
|
+
// TODO: !!!! Index through LLM model
|
|
2075
|
+
index.push({
|
|
2076
|
+
modelName: 'fake-model',
|
|
2077
|
+
position: new Array(25).fill(0).map(function () { return Math.random() * 2 - 1; }),
|
|
2078
|
+
});
|
|
2079
|
+
return [3 /*break*/, 4];
|
|
2080
|
+
case 3:
|
|
2081
|
+
error_1 = _b.sent();
|
|
2082
|
+
console.error(error_1);
|
|
2083
|
+
return [3 /*break*/, 4];
|
|
2084
|
+
case 4: return [2 /*return*/, {
|
|
2085
|
+
name: name,
|
|
2086
|
+
title: title,
|
|
2087
|
+
content: content,
|
|
2088
|
+
keywords: keywords,
|
|
2089
|
+
index: index,
|
|
2090
|
+
sources: sources,
|
|
2091
|
+
}];
|
|
2051
2092
|
}
|
|
2052
|
-
return [2 /*return*/, {
|
|
2053
|
-
name: name,
|
|
2054
|
-
title: title,
|
|
2055
|
-
content: content,
|
|
2056
|
-
keywords: keywords,
|
|
2057
|
-
index: index,
|
|
2058
|
-
sources: sources,
|
|
2059
|
-
}];
|
|
2060
2093
|
});
|
|
2061
2094
|
}); }))];
|
|
2062
|
-
case
|
|
2095
|
+
case 4:
|
|
2063
2096
|
knowledge = _b.sent();
|
|
2064
2097
|
return [2 /*return*/, knowledge];
|
|
2065
2098
|
}
|