@promptbook/node 0.77.0-5 → 0.77.0
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 +0 -4
- package/esm/index.es.js +63 -23
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/execution/AvailableModel.d.ts +17 -3
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +1 -0
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +6 -3
- package/esm/typings/src/llm-providers/google/GoogleExecutionToolsOptions.d.ts +3 -6
- package/esm/typings/src/llm-providers/google/createGoogleExecutionTools.d.ts +0 -4
- package/esm/typings/src/llm-providers/vercel/VercelExecutionToolsOptions.d.ts +2 -1
- package/esm/typings/src/llm-providers/vercel/createExecutionToolsFromVercelProvider.d.ts +1 -1
- package/esm/typings/src/types/typeAliases.d.ts +7 -1
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +11 -0
- package/esm/typings/src/utils/serialization/asSerializable.test.d.ts +1 -0
- package/package.json +2 -2
- package/umd/index.umd.js +63 -23
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -23,10 +23,6 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
<blockquote style="color: #ff8811">
|
|
27
|
-
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
28
|
-
</blockquote>
|
|
29
|
-
|
|
30
26
|
## 📦 Package `@promptbook/node`
|
|
31
27
|
|
|
32
28
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
package/esm/index.es.js
CHANGED
|
@@ -26,7 +26,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
26
26
|
*
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.77.0-
|
|
29
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.77.0-6';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -8947,7 +8947,7 @@ function $provideLlmToolsConfigurationFromEnv() {
|
|
|
8947
8947
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
8948
8948
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
8949
8949
|
* TODO: This should be maybe not under `_common` but under `utils`
|
|
8950
|
-
* TODO: [🧠] Maybe pass env as argument
|
|
8950
|
+
* TODO: [🧠][⚛] Maybe pass env as argument
|
|
8951
8951
|
* TODO: [®] DRY Register logic */
|
|
8952
8952
|
|
|
8953
8953
|
/**
|
|
@@ -8971,20 +8971,28 @@ var $llmToolsRegister = new $Register('llm_execution_tools_constructors');
|
|
|
8971
8971
|
*/
|
|
8972
8972
|
function $registeredLlmToolsMessage() {
|
|
8973
8973
|
var e_1, _a, e_2, _b;
|
|
8974
|
+
var env;
|
|
8975
|
+
if ($isRunningInNode()) {
|
|
8976
|
+
env = process.env;
|
|
8977
|
+
// <- TODO: [⚛] Some DRY way how to get to `process.env` and pass it into functions - ACRY search for `env`
|
|
8978
|
+
}
|
|
8979
|
+
else {
|
|
8980
|
+
env = {};
|
|
8981
|
+
}
|
|
8974
8982
|
/**
|
|
8975
8983
|
* Mixes registered LLM tools from $llmToolsMetadataRegister and $llmToolsRegister
|
|
8976
8984
|
*/
|
|
8977
8985
|
var all = [];
|
|
8978
|
-
var _loop_1 = function (packageName, className, envVariables) {
|
|
8986
|
+
var _loop_1 = function (title, packageName, className, envVariables) {
|
|
8979
8987
|
if (all.some(function (item) { return item.packageName === packageName && item.className === className; })) {
|
|
8980
8988
|
return "continue";
|
|
8981
8989
|
}
|
|
8982
|
-
all.push({ packageName: packageName, className: className, envVariables: envVariables });
|
|
8990
|
+
all.push({ title: title, packageName: packageName, className: className, envVariables: envVariables });
|
|
8983
8991
|
};
|
|
8984
8992
|
try {
|
|
8985
8993
|
for (var _c = __values($llmToolsMetadataRegister.list()), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
8986
|
-
var _e = _d.value, packageName = _e.packageName, className = _e.className, envVariables = _e.envVariables;
|
|
8987
|
-
_loop_1(packageName, className, envVariables);
|
|
8994
|
+
var _e = _d.value, title = _e.title, packageName = _e.packageName, className = _e.className, envVariables = _e.envVariables;
|
|
8995
|
+
_loop_1(title, packageName, className, envVariables);
|
|
8988
8996
|
}
|
|
8989
8997
|
}
|
|
8990
8998
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -9014,6 +9022,7 @@ function $registeredLlmToolsMessage() {
|
|
|
9014
9022
|
finally { if (e_2) throw e_2.error; }
|
|
9015
9023
|
}
|
|
9016
9024
|
var metadata = all.map(function (metadata) {
|
|
9025
|
+
var _a, _b;
|
|
9017
9026
|
var isMetadataAviailable = $llmToolsMetadataRegister
|
|
9018
9027
|
.list()
|
|
9019
9028
|
.find(function (_a) {
|
|
@@ -9026,46 +9035,77 @@ function $registeredLlmToolsMessage() {
|
|
|
9026
9035
|
var packageName = _a.packageName, className = _a.className;
|
|
9027
9036
|
return metadata.packageName === packageName && metadata.className === className;
|
|
9028
9037
|
});
|
|
9029
|
-
|
|
9038
|
+
var isFullyConfigured = ((_a = metadata.envVariables) === null || _a === void 0 ? void 0 : _a.every(function (envVariableName) { return env[envVariableName] !== undefined; })) || false;
|
|
9039
|
+
var isPartiallyConfigured = ((_b = metadata.envVariables) === null || _b === void 0 ? void 0 : _b.some(function (envVariableName) { return env[envVariableName] !== undefined; })) || false;
|
|
9040
|
+
// <- Note: [🗨]
|
|
9041
|
+
return __assign(__assign({}, metadata), { isMetadataAviailable: isMetadataAviailable, isInstalled: isInstalled, isFullyConfigured: isFullyConfigured, isPartiallyConfigured: isPartiallyConfigured });
|
|
9030
9042
|
});
|
|
9031
9043
|
if (metadata.length === 0) {
|
|
9032
9044
|
return "No LLM providers are available.";
|
|
9033
9045
|
}
|
|
9034
|
-
return spaceTrim$1(function (block) { return "\n
|
|
9046
|
+
return spaceTrim$1(function (block) { return "\n Relevant environment variables:\n ".concat(block(Object.keys(env)
|
|
9047
|
+
.filter(function (envVariableName) {
|
|
9048
|
+
return metadata.some(function (_a) {
|
|
9049
|
+
var envVariables = _a.envVariables;
|
|
9050
|
+
return envVariables === null || envVariables === void 0 ? void 0 : envVariables.includes(envVariableName);
|
|
9051
|
+
});
|
|
9052
|
+
})
|
|
9053
|
+
.map(function (envVariableName) { return "- `".concat(envVariableName, "`"); })
|
|
9054
|
+
.join('\n')), "\n\n Available LLM providers are:\n ").concat(block(metadata
|
|
9035
9055
|
.map(function (_a, i) {
|
|
9036
|
-
var packageName = _a.packageName, className = _a.className, envVariables = _a.envVariables, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled;
|
|
9037
|
-
var
|
|
9038
|
-
if (just(false))
|
|
9039
|
-
more = '';
|
|
9040
|
-
}
|
|
9056
|
+
var title = _a.title, packageName = _a.packageName, className = _a.className, envVariables = _a.envVariables, isMetadataAviailable = _a.isMetadataAviailable, isInstalled = _a.isInstalled, isFullyConfigured = _a.isFullyConfigured, isPartiallyConfigured = _a.isPartiallyConfigured;
|
|
9057
|
+
var morePieces = [];
|
|
9058
|
+
if (just(false)) ;
|
|
9041
9059
|
else if (!isMetadataAviailable && !isInstalled) {
|
|
9042
9060
|
// TODO: [�][�] Maybe do allow to do auto-install if package not registered and not found
|
|
9043
|
-
|
|
9061
|
+
morePieces.push("Not installed and no metadata, looks like a unexpected behavior");
|
|
9044
9062
|
}
|
|
9045
9063
|
else if (isMetadataAviailable && !isInstalled) {
|
|
9046
9064
|
// TODO: [�][�]
|
|
9047
|
-
|
|
9065
|
+
morePieces.push("Not installed");
|
|
9048
9066
|
}
|
|
9049
9067
|
else if (!isMetadataAviailable && isInstalled) {
|
|
9050
|
-
|
|
9068
|
+
morePieces.push("No metadata but installed, looks like a unexpected behavior");
|
|
9051
9069
|
}
|
|
9052
9070
|
else if (isMetadataAviailable && isInstalled) {
|
|
9053
|
-
|
|
9071
|
+
morePieces.push("Installed");
|
|
9072
|
+
}
|
|
9073
|
+
else {
|
|
9074
|
+
morePieces.push("unknown state, looks like a unexpected behavior");
|
|
9075
|
+
} /* not else */
|
|
9076
|
+
if (isFullyConfigured) {
|
|
9077
|
+
morePieces.push("Configured");
|
|
9078
|
+
}
|
|
9079
|
+
else if (isPartiallyConfigured) {
|
|
9080
|
+
morePieces.push("Partially confugured, missing ".concat(envVariables === null || envVariables === void 0 ? void 0 : envVariables.filter(function (envVariable) { return env[envVariable] === undefined; }).join(' + ')));
|
|
9054
9081
|
}
|
|
9055
9082
|
else {
|
|
9056
|
-
|
|
9083
|
+
if (envVariables !== null) {
|
|
9084
|
+
morePieces.push("Not configured, to configure set env ".concat(envVariables === null || envVariables === void 0 ? void 0 : envVariables.join(' + ')));
|
|
9085
|
+
}
|
|
9086
|
+
else {
|
|
9087
|
+
morePieces.push("Not configured"); // <- Note: Can not be configured via environment variables
|
|
9088
|
+
}
|
|
9057
9089
|
}
|
|
9058
|
-
var
|
|
9059
|
-
if (
|
|
9060
|
-
|
|
9090
|
+
var providerMessage = spaceTrim$1("\n ".concat(i + 1, ") **").concat(title, "** `").concat(className, "` from `").concat(packageName, "`\n ").concat(morePieces.join('; '), "\n "));
|
|
9091
|
+
if ($isRunningInNode) {
|
|
9092
|
+
if (isInstalled && isFullyConfigured) {
|
|
9093
|
+
providerMessage = colors.green(providerMessage);
|
|
9094
|
+
}
|
|
9095
|
+
else if (isInstalled && isPartiallyConfigured) {
|
|
9096
|
+
providerMessage = colors.yellow(providerMessage);
|
|
9097
|
+
}
|
|
9098
|
+
else {
|
|
9099
|
+
providerMessage = colors.gray(providerMessage);
|
|
9100
|
+
}
|
|
9061
9101
|
}
|
|
9062
|
-
return
|
|
9063
|
-
// <- TODO: !!!!!! Is this indented correctly?
|
|
9102
|
+
return providerMessage;
|
|
9064
9103
|
})
|
|
9065
9104
|
.join('\n')), "\n "); });
|
|
9066
9105
|
}
|
|
9067
9106
|
/**
|
|
9068
9107
|
* TODO: [®] DRY Register logic
|
|
9108
|
+
* TODO: [🧠][⚛] Maybe pass env as argument
|
|
9069
9109
|
*/
|
|
9070
9110
|
|
|
9071
9111
|
/**
|