@promptbook/node 0.81.0-13 → 0.81.0-15
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 +117 -27
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/_packages/utils.index.d.ts +2 -2
- package/esm/typings/src/formfactors/image-generator/ImageGeneratorFormfactorDefinition.d.ts +24 -0
- package/esm/typings/src/formfactors/index.d.ts +22 -5
- package/esm/typings/src/high-level-abstractions/index.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizzardOrCli.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -1
- package/esm/typings/src/other/templates/getBookTemplates.d.ts +1 -0
- package/esm/typings/src/utils/validators/filePath/{isPathRoot.d.ts → isRootPath.d.ts} +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +117 -27
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/utils/validators/filePath/{isPathRoot.test.d.ts → isRootPath.test.d.ts} +0 -0
package/esm/index.es.js
CHANGED
|
@@ -28,7 +28,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-
|
|
31
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-14';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -7037,6 +7037,35 @@ var GenericFormfactorDefinition = {
|
|
|
7037
7037
|
pipelineInterface: GENERIC_PIPELINE_INTERFACE,
|
|
7038
7038
|
};
|
|
7039
7039
|
|
|
7040
|
+
/**
|
|
7041
|
+
* Image generator is form of app that generates image from input message
|
|
7042
|
+
*
|
|
7043
|
+
* @public exported from `@promptbook/core`
|
|
7044
|
+
*/
|
|
7045
|
+
var ImageGeneratorFormfactorDefinition = {
|
|
7046
|
+
name: 'IMAGE_GENERATOR',
|
|
7047
|
+
description: "@@@",
|
|
7048
|
+
documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184",
|
|
7049
|
+
pipelineInterface: {
|
|
7050
|
+
inputParameters: [
|
|
7051
|
+
{
|
|
7052
|
+
name: 'inputMessage',
|
|
7053
|
+
description: "Input message to be image made from",
|
|
7054
|
+
isInput: true,
|
|
7055
|
+
isOutput: false,
|
|
7056
|
+
},
|
|
7057
|
+
],
|
|
7058
|
+
outputParameters: [
|
|
7059
|
+
{
|
|
7060
|
+
name: 'prompt',
|
|
7061
|
+
description: "Prompt to be used for image generation",
|
|
7062
|
+
isInput: false,
|
|
7063
|
+
isOutput: true,
|
|
7064
|
+
},
|
|
7065
|
+
],
|
|
7066
|
+
},
|
|
7067
|
+
};
|
|
7068
|
+
|
|
7040
7069
|
/**
|
|
7041
7070
|
* Matcher is form of app that @@@
|
|
7042
7071
|
*
|
|
@@ -7135,6 +7164,7 @@ var FORMFACTOR_DEFINITIONS = [
|
|
|
7135
7164
|
SheetsFormfactorDefinition,
|
|
7136
7165
|
MatcherFormfactorDefinition,
|
|
7137
7166
|
GeneratorFormfactorDefinition,
|
|
7167
|
+
ImageGeneratorFormfactorDefinition,
|
|
7138
7168
|
];
|
|
7139
7169
|
/**
|
|
7140
7170
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -9627,6 +9657,25 @@ var $llmToolsMetadataRegister = new $Register('llm_tools_metadata');
|
|
|
9627
9657
|
* TODO: [®] DRY Register logic
|
|
9628
9658
|
*/
|
|
9629
9659
|
|
|
9660
|
+
/**
|
|
9661
|
+
* Determines if the given path is a root path.
|
|
9662
|
+
*
|
|
9663
|
+
* Note: This does not check if the file exists only if the path is valid
|
|
9664
|
+
* @public exported from `@promptbook/utils`
|
|
9665
|
+
*/
|
|
9666
|
+
function isRootPath(value) {
|
|
9667
|
+
if (value === '/') {
|
|
9668
|
+
return true;
|
|
9669
|
+
}
|
|
9670
|
+
if (/^[A-Z]:\\$/i.test(value)) {
|
|
9671
|
+
return true;
|
|
9672
|
+
}
|
|
9673
|
+
return false;
|
|
9674
|
+
}
|
|
9675
|
+
/**
|
|
9676
|
+
* TODO: [🍏] Make for MacOS paths
|
|
9677
|
+
*/
|
|
9678
|
+
|
|
9630
9679
|
/**
|
|
9631
9680
|
* @@@
|
|
9632
9681
|
*
|
|
@@ -9641,17 +9690,46 @@ var $llmToolsMetadataRegister = new $Register('llm_tools_metadata');
|
|
|
9641
9690
|
* @public exported from `@promptbook/node`
|
|
9642
9691
|
*/
|
|
9643
9692
|
function $provideLlmToolsConfigurationFromEnv() {
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9693
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
9694
|
+
var rootDirname, i, envFilename, llmToolsConfiguration;
|
|
9695
|
+
return __generator(this, function (_a) {
|
|
9696
|
+
switch (_a.label) {
|
|
9697
|
+
case 0:
|
|
9698
|
+
if (!$isRunningInNode()) {
|
|
9699
|
+
throw new EnvironmentMismatchError('Function `$provideLlmToolsFromEnv` works only in Node.js environment');
|
|
9700
|
+
}
|
|
9701
|
+
rootDirname = process.cwd();
|
|
9702
|
+
i = 0;
|
|
9703
|
+
_a.label = 1;
|
|
9704
|
+
case 1:
|
|
9705
|
+
if (!(i < LOOP_LIMIT)) return [3 /*break*/, 4];
|
|
9706
|
+
envFilename = join(rootDirname, '.env' /* <- TODO: [🕝] Make here more candidates */);
|
|
9707
|
+
console.log({ rootDirname: rootDirname, envFilename: envFilename });
|
|
9708
|
+
return [4 /*yield*/, isFileExisting(envFilename, $provideFilesystemForNode())];
|
|
9709
|
+
case 2:
|
|
9710
|
+
// <- TODO: !!!!!!! Remove
|
|
9711
|
+
if (_a.sent()) {
|
|
9712
|
+
dotenv.config({ path: envFilename });
|
|
9713
|
+
return [3 /*break*/, 4];
|
|
9714
|
+
}
|
|
9715
|
+
if (isRootPath(rootDirname)) {
|
|
9716
|
+
return [3 /*break*/, 4];
|
|
9717
|
+
}
|
|
9718
|
+
// Note: If the directory does not exist, try the parent directory
|
|
9719
|
+
rootDirname = join(rootDirname, '..');
|
|
9720
|
+
_a.label = 3;
|
|
9721
|
+
case 3:
|
|
9722
|
+
i++;
|
|
9723
|
+
return [3 /*break*/, 1];
|
|
9724
|
+
case 4:
|
|
9725
|
+
llmToolsConfiguration = $llmToolsMetadataRegister
|
|
9726
|
+
.list()
|
|
9727
|
+
.map(function (metadata) { return metadata.createConfigurationFromEnv(process.env); })
|
|
9728
|
+
.filter(function (configuration) { return configuration !== null; });
|
|
9729
|
+
return [2 /*return*/, llmToolsConfiguration];
|
|
9730
|
+
}
|
|
9731
|
+
});
|
|
9732
|
+
});
|
|
9655
9733
|
}
|
|
9656
9734
|
/**
|
|
9657
9735
|
* TODO: [🧠][🪁] Maybe do allow to do auto-install if package not registered and not found
|
|
@@ -9874,18 +9952,28 @@ function createLlmToolsFromConfiguration(configuration, options) {
|
|
|
9874
9952
|
*/
|
|
9875
9953
|
function $provideLlmToolsFromEnv(options) {
|
|
9876
9954
|
if (options === void 0) { options = {}; }
|
|
9877
|
-
|
|
9878
|
-
|
|
9879
|
-
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
|
|
9955
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
9956
|
+
var configuration;
|
|
9957
|
+
return __generator(this, function (_a) {
|
|
9958
|
+
switch (_a.label) {
|
|
9959
|
+
case 0:
|
|
9960
|
+
if (!$isRunningInNode()) {
|
|
9961
|
+
throw new EnvironmentMismatchError('Function `$provideLlmToolsFromEnv` works only in Node.js environment');
|
|
9962
|
+
}
|
|
9963
|
+
return [4 /*yield*/, $provideLlmToolsConfigurationFromEnv()];
|
|
9964
|
+
case 1:
|
|
9965
|
+
configuration = _a.sent();
|
|
9966
|
+
if (configuration.length === 0) {
|
|
9967
|
+
if ($llmToolsMetadataRegister.list().length === 0) {
|
|
9968
|
+
throw new UnexpectedError(spaceTrim(function (block) { return "\n No LLM tools registered, this is probably a bug in the Promptbook library\n\n ".concat(block($registeredLlmToolsMessage()), "}\n "); }));
|
|
9969
|
+
}
|
|
9970
|
+
// TODO: [🥃]
|
|
9971
|
+
throw new Error(spaceTrim(function (block) { return "\n No LLM tools found in the environment\n\n ".concat(block($registeredLlmToolsMessage()), "}\n "); }));
|
|
9972
|
+
}
|
|
9973
|
+
return [2 /*return*/, createLlmToolsFromConfiguration(configuration, options)];
|
|
9974
|
+
}
|
|
9975
|
+
});
|
|
9976
|
+
});
|
|
9889
9977
|
}
|
|
9890
9978
|
/**
|
|
9891
9979
|
* TODO: @@@ write `$provideLlmToolsFromEnv` vs `$provideLlmToolsConfigurationFromEnv` vs `createLlmToolsFromConfiguration`
|
|
@@ -10450,9 +10538,11 @@ function $provideExecutionToolsForNode(options) {
|
|
|
10450
10538
|
throw new EnvironmentMismatchError('Function `$getExecutionToolsForNode` works only in Node.js environment');
|
|
10451
10539
|
}
|
|
10452
10540
|
fs = $provideFilesystemForNode();
|
|
10453
|
-
|
|
10454
|
-
return [4 /*yield*/, $provideExecutablesForNode(options)];
|
|
10541
|
+
return [4 /*yield*/, $provideLlmToolsFromEnv(options)];
|
|
10455
10542
|
case 1:
|
|
10543
|
+
llm = _b.sent();
|
|
10544
|
+
return [4 /*yield*/, $provideExecutablesForNode(options)];
|
|
10545
|
+
case 2:
|
|
10456
10546
|
executables = _b.sent();
|
|
10457
10547
|
_a = {
|
|
10458
10548
|
llm: llm,
|
|
@@ -10460,7 +10550,7 @@ function $provideExecutionToolsForNode(options) {
|
|
|
10460
10550
|
executables: executables
|
|
10461
10551
|
};
|
|
10462
10552
|
return [4 /*yield*/, $provideScrapersForNode({ fs: fs, llm: llm, executables: executables }, options)];
|
|
10463
|
-
case
|
|
10553
|
+
case 3:
|
|
10464
10554
|
tools = (_a.scrapers = _b.sent(),
|
|
10465
10555
|
_a.script = [new JavascriptExecutionTools(options)],
|
|
10466
10556
|
_a);
|