@promptbook/core 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/esm/index.es.js +67 -34
- 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 +1 -1
- package/umd/index.umd.js +67 -34
- 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/esm/index.es.js
CHANGED
|
@@ -199,7 +199,7 @@ var PromptbookSyntaxError = /** @class */ (function (_super) {
|
|
|
199
199
|
return PromptbookSyntaxError;
|
|
200
200
|
}(Error));
|
|
201
201
|
|
|
202
|
-
var promptbookLibrary = [{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0-
|
|
202
|
+
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:[]}];
|
|
203
203
|
|
|
204
204
|
/**
|
|
205
205
|
* This error indicates errors during the execution of the promptbook
|
|
@@ -523,7 +523,7 @@ function isValidJsonString(value /* <-[👨⚖️] */) {
|
|
|
523
523
|
/**
|
|
524
524
|
* The version of the Promptbook library
|
|
525
525
|
*/
|
|
526
|
-
var PROMPTBOOK_VERSION = '0.59.0-
|
|
526
|
+
var PROMPTBOOK_VERSION = '0.59.0-29';
|
|
527
527
|
|
|
528
528
|
/**
|
|
529
529
|
* Function `addUsage` will add multiple usages into one
|
|
@@ -1996,7 +1996,7 @@ function normalizeToKebabCase(sentence) {
|
|
|
1996
1996
|
|
|
1997
1997
|
function prepareKnowledgeFromMarkdown(options) {
|
|
1998
1998
|
return __awaiter(this, void 0, void 0, function () {
|
|
1999
|
-
var content, llmTools, _a, isVerbose, library,
|
|
1999
|
+
var content, llmTools, _a, isVerbose, library, prepareKnowledgeFromMarkdownPromptbook, prepareKnowledgeFromMarkdownExecutor, prepareKeywordsPromptbook, prepareKeywordsExecutor, result, outputParameters, knowledgeRaw, knowledgeTextPieces, knowledge;
|
|
2000
2000
|
var _this = this;
|
|
2001
2001
|
return __generator(this, function (_b) {
|
|
2002
2002
|
switch (_b.label) {
|
|
@@ -2005,9 +2005,9 @@ function prepareKnowledgeFromMarkdown(options) {
|
|
|
2005
2005
|
library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false));
|
|
2006
2006
|
return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
|
|
2007
2007
|
case 1:
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
promptbook:
|
|
2008
|
+
prepareKnowledgeFromMarkdownPromptbook = _b.sent();
|
|
2009
|
+
prepareKnowledgeFromMarkdownExecutor = createPromptbookExecutor({
|
|
2010
|
+
promptbook: prepareKnowledgeFromMarkdownPromptbook,
|
|
2011
2011
|
tools: {
|
|
2012
2012
|
llm: llmTools,
|
|
2013
2013
|
script: [
|
|
@@ -2015,8 +2015,20 @@ function prepareKnowledgeFromMarkdown(options) {
|
|
|
2015
2015
|
],
|
|
2016
2016
|
},
|
|
2017
2017
|
});
|
|
2018
|
-
return [4 /*yield*/,
|
|
2018
|
+
return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-keywords.ptbk.md')];
|
|
2019
2019
|
case 2:
|
|
2020
|
+
prepareKeywordsPromptbook = _b.sent();
|
|
2021
|
+
prepareKeywordsExecutor = createPromptbookExecutor({
|
|
2022
|
+
promptbook: prepareKeywordsPromptbook,
|
|
2023
|
+
tools: {
|
|
2024
|
+
llm: llmTools,
|
|
2025
|
+
script: [
|
|
2026
|
+
/* <- TODO: Allow to just keep script undefined */
|
|
2027
|
+
],
|
|
2028
|
+
},
|
|
2029
|
+
});
|
|
2030
|
+
return [4 /*yield*/, prepareKnowledgeFromMarkdownExecutor({ content: content })];
|
|
2031
|
+
case 3:
|
|
2020
2032
|
result = _b.sent();
|
|
2021
2033
|
assertsExecutionSuccessful(result);
|
|
2022
2034
|
outputParameters = result.outputParameters;
|
|
@@ -2026,36 +2038,57 @@ function prepareKnowledgeFromMarkdown(options) {
|
|
|
2026
2038
|
console.info('knowledgeTextPieces:', knowledgeTextPieces);
|
|
2027
2039
|
}
|
|
2028
2040
|
return [4 /*yield*/, Promise.all(knowledgeTextPieces.map(function (knowledgeTextPiece, i) { return __awaiter(_this, void 0, void 0, function () {
|
|
2029
|
-
var name, title, content, keywords, index, sources;
|
|
2030
|
-
return __generator(this, function (
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2041
|
+
var name, title, content, keywords, index, sources, result_1, _a, outputParameters_1, keywordsRaw, error_1;
|
|
2042
|
+
return __generator(this, function (_b) {
|
|
2043
|
+
switch (_b.label) {
|
|
2044
|
+
case 0:
|
|
2045
|
+
name = "piece-".concat(i);
|
|
2046
|
+
title = spaceTrim$1(knowledgeTextPiece.substring(0, 100));
|
|
2047
|
+
content = spaceTrim$1(knowledgeTextPiece);
|
|
2048
|
+
keywords = [];
|
|
2049
|
+
index = [];
|
|
2050
|
+
sources = [];
|
|
2051
|
+
_b.label = 1;
|
|
2052
|
+
case 1:
|
|
2053
|
+
_b.trys.push([1, 3, , 4]);
|
|
2054
|
+
// TODO: !!!! Summarize name and title from the content
|
|
2055
|
+
title = spaceTrim$1(knowledgeTextPiece.substring(0, 30));
|
|
2056
|
+
name = normalizeToKebabCase(title);
|
|
2057
|
+
return [4 /*yield*/, prepareKeywordsExecutor({ content: content })];
|
|
2058
|
+
case 2:
|
|
2059
|
+
result_1 = _b.sent();
|
|
2060
|
+
_a = result_1.outputParameters, outputParameters_1 = _a === void 0 ? {} : _a;
|
|
2061
|
+
keywordsRaw = outputParameters_1.keywords;
|
|
2062
|
+
keywords = (keywordsRaw || '')
|
|
2063
|
+
.split(',')
|
|
2064
|
+
.map(function (keyword) { return keyword.trim(); })
|
|
2065
|
+
.filter(function (keyword) { return keyword !== ''; });
|
|
2066
|
+
if (isVerbose) {
|
|
2067
|
+
console.info("Keywords for \"".concat(title, "\":"), keywords);
|
|
2068
|
+
}
|
|
2069
|
+
// ---
|
|
2070
|
+
// TODO: !!!! Index through LLM model
|
|
2071
|
+
index.push({
|
|
2072
|
+
modelName: 'fake-model',
|
|
2073
|
+
position: new Array(25).fill(0).map(function () { return Math.random() * 2 - 1; }),
|
|
2074
|
+
});
|
|
2075
|
+
return [3 /*break*/, 4];
|
|
2076
|
+
case 3:
|
|
2077
|
+
error_1 = _b.sent();
|
|
2078
|
+
console.error(error_1);
|
|
2079
|
+
return [3 /*break*/, 4];
|
|
2080
|
+
case 4: return [2 /*return*/, {
|
|
2081
|
+
name: name,
|
|
2082
|
+
title: title,
|
|
2083
|
+
content: content,
|
|
2084
|
+
keywords: keywords,
|
|
2085
|
+
index: index,
|
|
2086
|
+
sources: sources,
|
|
2087
|
+
}];
|
|
2047
2088
|
}
|
|
2048
|
-
return [2 /*return*/, {
|
|
2049
|
-
name: name,
|
|
2050
|
-
title: title,
|
|
2051
|
-
content: content,
|
|
2052
|
-
keywords: keywords,
|
|
2053
|
-
index: index,
|
|
2054
|
-
sources: sources,
|
|
2055
|
-
}];
|
|
2056
2089
|
});
|
|
2057
2090
|
}); }))];
|
|
2058
|
-
case
|
|
2091
|
+
case 4:
|
|
2059
2092
|
knowledge = _b.sent();
|
|
2060
2093
|
return [2 /*return*/, knowledge];
|
|
2061
2094
|
}
|