@promptbook/remote-server 0.102.0-0 → 0.102.0-1
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 +107 -39
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/components.index.d.ts +34 -22
- package/esm/typings/src/_packages/types.index.d.ts +8 -8
- package/esm/typings/src/book-components/Chat/Chat/Chat.d.ts +2 -2
- package/esm/typings/src/book-components/{AvatarProfile/AvatarProfile → Chat/MockedChat}/MockedChat.d.ts +25 -8
- package/esm/typings/src/book-components/Chat/MockedChat/constants.d.ts +42 -0
- package/esm/typings/src/book-components/Chat/save/savePlugins.d.ts +105 -0
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +6 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +107 -39
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/index.d.ts +0 -3
- package/esm/typings/src/book-components/Chat/utils/savePlugins.d.ts +0 -55
package/esm/index.es.js
CHANGED
|
@@ -31,7 +31,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
31
31
|
* @generated
|
|
32
32
|
* @see https://github.com/webgptorg/promptbook
|
|
33
33
|
*/
|
|
34
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.102.0-
|
|
34
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.102.0-1';
|
|
35
35
|
/**
|
|
36
36
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
37
37
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -8246,57 +8246,125 @@ function startRemoteServer(options) {
|
|
|
8246
8246
|
if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.includes('socket.io')) {
|
|
8247
8247
|
return;
|
|
8248
8248
|
}
|
|
8249
|
-
|
|
8250
|
-
|
|
8249
|
+
if (options.isRichUi !== false) {
|
|
8250
|
+
// Serve rich React + Tailwind UI with server info injected
|
|
8251
|
+
const serverInfo = {
|
|
8252
|
+
bookLanguageVersion: BOOK_LANGUAGE_VERSION,
|
|
8253
|
+
promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
8254
|
+
nodeVersion: process.version,
|
|
8255
|
+
port,
|
|
8256
|
+
startupDate: startupDate.toISOString(),
|
|
8257
|
+
isAnonymousModeAllowed,
|
|
8258
|
+
isApplicationModeAllowed,
|
|
8259
|
+
pipelines: !isApplicationModeAllowed || collection === null
|
|
8260
|
+
? []
|
|
8261
|
+
: await collection.listPipelines(),
|
|
8262
|
+
runningExecutions: runningExecutionTasks.length,
|
|
8263
|
+
paths: [
|
|
8264
|
+
...app._router.stack
|
|
8265
|
+
.map(({ route }) => (route === null || route === void 0 ? void 0 : route.path) || null)
|
|
8266
|
+
.filter((path) => path !== null),
|
|
8267
|
+
'/api-docs',
|
|
8268
|
+
],
|
|
8269
|
+
};
|
|
8270
|
+
response.type('text/html').send(`
|
|
8271
|
+
<!DOCTYPE html>
|
|
8272
|
+
<html lang="en">
|
|
8273
|
+
<head>
|
|
8274
|
+
<meta charset="UTF-8" />
|
|
8275
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8276
|
+
<title>Promptbook Server</title>
|
|
8277
|
+
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
|
|
8278
|
+
</head>
|
|
8279
|
+
<body class="bg-gray-50 text-gray-900">
|
|
8280
|
+
<div id="root"></div>
|
|
8281
|
+
<script>
|
|
8282
|
+
window.__PROMPTBOOK_SERVER_INFO__ = ${JSON.stringify(serverInfo)};
|
|
8283
|
+
// TODO: Hydrate React app here
|
|
8284
|
+
// You will need to bundle and serve a React app for full functionality
|
|
8285
|
+
const info = window.__PROMPTBOOK_SERVER_INFO__;
|
|
8286
|
+
document.getElementById('root').innerHTML = \`
|
|
8287
|
+
<h1 class="text-3xl font-bold mb-4">Promptbook Server Rich UI</h1>
|
|
8288
|
+
<div class="mb-4">
|
|
8289
|
+
<strong>Book language version:</strong> \${info.bookLanguageVersion}<br>
|
|
8290
|
+
<strong>Promptbook engine version:</strong> \${info.promptbookEngineVersion}<br>
|
|
8291
|
+
<strong>Node.js version:</strong> \${info.nodeVersion}<br>
|
|
8292
|
+
<strong>Server port:</strong> \${info.port}<br>
|
|
8293
|
+
<strong>Startup date:</strong> \${info.startupDate}<br>
|
|
8294
|
+
<strong>Anonymous mode:</strong> \${info.isAnonymousModeAllowed ? 'enabled' : 'disabled'}<br>
|
|
8295
|
+
<strong>Application mode:</strong> \${info.isApplicationModeAllowed ? 'enabled' : 'disabled'}<br>
|
|
8296
|
+
<strong>Pipelines in collection:</strong> \${info.pipelines.length ? '<ul>' + info.pipelines.map(p => '<li>' + p + '</li>').join('') + '</ul>' : 'none'}<br>
|
|
8297
|
+
<strong>Running executions:</strong> \${info.runningExecutions}<br>
|
|
8298
|
+
<strong>Paths:</strong> <ul>\${info.paths.map(p => '<li>' + p + '</li>').join('')}</ul>
|
|
8299
|
+
</div>
|
|
8300
|
+
<div class="mt-8">
|
|
8301
|
+
<h2 class="text-xl font-semibold mb-2">Instructions</h2>
|
|
8302
|
+
<ol class="list-decimal ml-6">
|
|
8303
|
+
<li>The client <a href="https://www.npmjs.com/package/@promptbook/remote-client" class="text-blue-600 underline">https://www.npmjs.com/package/@promptbook/remote-client</a></li>
|
|
8304
|
+
<li>OpenAI compatible client <span class="text-gray-500">(Not working yet)</span></li>
|
|
8305
|
+
<li>REST API</li>
|
|
8306
|
+
</ol>
|
|
8307
|
+
<p class="mt-2">For more information look at: <a href="https://github.com/webgptorg/promptbook" class="text-blue-600 underline">https://github.com/webgptorg/promptbook</a></p>
|
|
8308
|
+
</div>
|
|
8309
|
+
\`;
|
|
8310
|
+
</script>
|
|
8311
|
+
</body>
|
|
8312
|
+
</html>
|
|
8313
|
+
`);
|
|
8314
|
+
}
|
|
8315
|
+
else {
|
|
8316
|
+
response.type('text/markdown').send(await spaceTrim$1(async (block) => `
|
|
8317
|
+
# Promptbook
|
|
8251
8318
|
|
|
8252
|
-
|
|
8319
|
+
> ${block(CLAIM)}
|
|
8253
8320
|
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8321
|
+
**Book language version:** ${BOOK_LANGUAGE_VERSION}
|
|
8322
|
+
**Promptbook engine version:** ${PROMPTBOOK_ENGINE_VERSION}
|
|
8323
|
+
**Node.js version:** ${process.version /* <- TODO: [🧠] Is it secure to expose this */}
|
|
8257
8324
|
|
|
8258
|
-
|
|
8325
|
+
---
|
|
8259
8326
|
|
|
8260
|
-
|
|
8327
|
+
## Details
|
|
8261
8328
|
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8329
|
+
**Server port:** ${port}
|
|
8330
|
+
**Startup date:** ${startupDate.toISOString()}
|
|
8331
|
+
**Anonymous mode:** ${isAnonymousModeAllowed ? 'enabled' : 'disabled'}
|
|
8332
|
+
**Application mode:** ${isApplicationModeAllowed ? 'enabled' : 'disabled'}
|
|
8333
|
+
${block(!isApplicationModeAllowed || collection === null
|
|
8334
|
+
? ''
|
|
8335
|
+
: '**Pipelines in collection:**\n' +
|
|
8336
|
+
(await collection.listPipelines())
|
|
8337
|
+
.map((pipelineUrl) => `- ${pipelineUrl}`)
|
|
8338
|
+
.join('\n'))}
|
|
8339
|
+
**Running executions:** ${runningExecutionTasks.length}
|
|
8273
8340
|
|
|
8274
|
-
|
|
8341
|
+
---
|
|
8275
8342
|
|
|
8276
|
-
|
|
8343
|
+
## Paths
|
|
8277
8344
|
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
|
|
8345
|
+
${block([
|
|
8346
|
+
...app._router.stack
|
|
8347
|
+
.map(({ route }) => (route === null || route === void 0 ? void 0 : route.path) || null)
|
|
8348
|
+
.filter((path) => path !== null),
|
|
8349
|
+
'/api-docs',
|
|
8350
|
+
]
|
|
8351
|
+
.map((path) => `- ${path}`)
|
|
8352
|
+
.join('\n'))}
|
|
8286
8353
|
|
|
8287
|
-
|
|
8354
|
+
---
|
|
8288
8355
|
|
|
8289
|
-
|
|
8356
|
+
## Instructions
|
|
8290
8357
|
|
|
8291
|
-
|
|
8358
|
+
To connect to this server use:
|
|
8292
8359
|
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8360
|
+
1) The client https://www.npmjs.com/package/@promptbook/remote-client
|
|
8361
|
+
2) OpenAI compatible client *(Not working yet)*
|
|
8362
|
+
3) REST API
|
|
8296
8363
|
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8364
|
+
For more information look at:
|
|
8365
|
+
https://github.com/webgptorg/promptbook
|
|
8366
|
+
`));
|
|
8367
|
+
}
|
|
8300
8368
|
});
|
|
8301
8369
|
app.post(`/login`, async (request, response) => {
|
|
8302
8370
|
if (!isApplicationModeAllowed || login === null) {
|