@promptbook/cli 0.85.0-1 → 0.85.0-2
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/bin/promptbook-cli.js +1 -0
- package/esm/index.es.js +29 -7
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/utils.index.d.ts +2 -0
- package/esm/typings/src/utils/normalization/suffixUrl.d.ts +7 -0
- package/esm/typings/src/utils/normalization/suffixUrl.test.d.ts +1 -0
- package/package.json +1 -1
- package/umd/index.umd.js +29 -7
- package/umd/index.umd.js.map +1 -1
package/bin/promptbook-cli.js
CHANGED
package/esm/index.es.js
CHANGED
|
@@ -43,7 +43,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
43
43
|
* @generated
|
|
44
44
|
* @see https://github.com/webgptorg/promptbook
|
|
45
45
|
*/
|
|
46
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-
|
|
46
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.85.0-1';
|
|
47
47
|
/**
|
|
48
48
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
49
49
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -11416,6 +11416,17 @@ function normalizeWhitespaces(sentence) {
|
|
|
11416
11416
|
return sentence.replace(/\s+/gs, ' ').trim();
|
|
11417
11417
|
}
|
|
11418
11418
|
|
|
11419
|
+
/**
|
|
11420
|
+
* Adds suffix to the URL
|
|
11421
|
+
*
|
|
11422
|
+
* @public exported from `@promptbook/utils`
|
|
11423
|
+
*/
|
|
11424
|
+
function suffixUrl(value, suffix) {
|
|
11425
|
+
var baseUrl = value.href.endsWith('/') ? value.href.slice(0, -1) : value.href;
|
|
11426
|
+
var normalizedSuffix = suffix.replace(/\/+/g, '/');
|
|
11427
|
+
return (baseUrl + normalizedSuffix);
|
|
11428
|
+
}
|
|
11429
|
+
|
|
11419
11430
|
/**
|
|
11420
11431
|
* Function trimCodeBlock will trim starting and ending code block from the string if it is present.
|
|
11421
11432
|
*
|
|
@@ -14174,19 +14185,31 @@ function $initializeStartServerCommand(program) {
|
|
|
14174
14185
|
// <- TODO: [🧟♂️] Unite path to promptbook collection argument
|
|
14175
14186
|
'Path to promptbook collection directory', DEFAULT_BOOKS_DIRNAME);
|
|
14176
14187
|
startServerCommand.option('--port <port>', "Port to start the server on", '4460');
|
|
14188
|
+
startServerCommand.option('-u, --url', spaceTrim("\n Public root url of the server\n It is used for following purposes:\n\n 1) It is suffixed with /books and used as rootUrl for all served books\n 2) Path (if not just /) is used as rootPath for the server\n "));
|
|
14177
14189
|
startServerCommand.option('--allow-anonymous', "Is anonymous mode allowed", false);
|
|
14178
14190
|
startServerCommand.option('-r, --reload', "Call LLM models even if same prompt with result is in the cache", false);
|
|
14179
14191
|
startServerCommand.option('-v, --verbose', "Is output verbose", false);
|
|
14180
14192
|
startServerCommand.description(spaceTrim("\n Starts a remote server to execute books\n "));
|
|
14181
14193
|
startServerCommand.action(function (path, _a) {
|
|
14182
|
-
var port = _a.port, isAnonymousModeAllowed = _a.allowAnonymous, isCacheReloaded = _a.reload, isVerbose = _a.verbose;
|
|
14194
|
+
var port = _a.port, rawUrl = _a.url, isAnonymousModeAllowed = _a.allowAnonymous, isCacheReloaded = _a.reload, isVerbose = _a.verbose;
|
|
14183
14195
|
return __awaiter(_this, void 0, void 0, function () {
|
|
14184
|
-
var prepareAndScrapeOptions, fs, llm, executables, tools, collection;
|
|
14196
|
+
var url, rootUrl, rootPath, prepareAndScrapeOptions, fs, llm, executables, tools, collection;
|
|
14185
14197
|
var _b;
|
|
14186
14198
|
return __generator(this, function (_c) {
|
|
14187
14199
|
switch (_c.label) {
|
|
14188
14200
|
case 0:
|
|
14189
|
-
|
|
14201
|
+
url = !rawUrl ? null : new URL(rawUrl);
|
|
14202
|
+
if (url !== null && url.port !== port) {
|
|
14203
|
+
console.warn(colors.yellow("Port in --url is different from --port which the server will listen on, this is ok only if you proxy from one port to another, for exaple via nginx or docker"));
|
|
14204
|
+
}
|
|
14205
|
+
rootUrl = undefined;
|
|
14206
|
+
if (url !== null) {
|
|
14207
|
+
rootUrl = suffixUrl(url, '/books');
|
|
14208
|
+
}
|
|
14209
|
+
rootPath = '/';
|
|
14210
|
+
if (url !== null) {
|
|
14211
|
+
rootPath = url.pathname;
|
|
14212
|
+
}
|
|
14190
14213
|
prepareAndScrapeOptions = {
|
|
14191
14214
|
isVerbose: isVerbose,
|
|
14192
14215
|
isCacheReloaded: isCacheReloaded,
|
|
@@ -14211,8 +14234,7 @@ function $initializeStartServerCommand(program) {
|
|
|
14211
14234
|
_b);
|
|
14212
14235
|
return [4 /*yield*/, createCollectionFromDirectory(path, tools, {
|
|
14213
14236
|
isVerbose: isVerbose,
|
|
14214
|
-
|
|
14215
|
-
// rootUrl: `http://localhost:${port}/books`,
|
|
14237
|
+
rootUrl: rootUrl,
|
|
14216
14238
|
isRecursive: true,
|
|
14217
14239
|
isLazyLoaded: false,
|
|
14218
14240
|
isCrashedOnError: true,
|
|
@@ -14221,7 +14243,7 @@ function $initializeStartServerCommand(program) {
|
|
|
14221
14243
|
case 4:
|
|
14222
14244
|
collection = _c.sent();
|
|
14223
14245
|
startRemoteServer({
|
|
14224
|
-
rootPath:
|
|
14246
|
+
rootPath: rootPath,
|
|
14225
14247
|
port: parseInt(port, 10),
|
|
14226
14248
|
isAnonymousModeAllowed: isAnonymousModeAllowed,
|
|
14227
14249
|
isApplicationModeAllowed: true,
|