@promptbook/remote-server 0.8.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.
Files changed (190) hide show
  1. package/README.md +5 -0
  2. package/esm/index.es.js +160 -0
  3. package/esm/index.es.js.map +1 -0
  4. package/esm/typings/_packages/core.index.d.ts +17 -0
  5. package/esm/typings/_packages/execute-javascript.index.d.ts +3 -0
  6. package/esm/typings/_packages/openai.index.d.ts +3 -0
  7. package/esm/typings/_packages/remote-client.index.d.ts +4 -0
  8. package/esm/typings/_packages/remote-server.index.d.ts +3 -0
  9. package/esm/typings/_packages/types.index.d.ts +20 -0
  10. package/esm/typings/_packages/utils.index.d.ts +6 -0
  11. package/esm/typings/_packages/wizzard.index.d.ts +2 -0
  12. package/esm/typings/classes/PromptTemplatePipeline.d.ts +68 -0
  13. package/esm/typings/classes/PromptTemplatePipelineLibrary.d.ts +55 -0
  14. package/esm/typings/config.d.ts +10 -0
  15. package/esm/typings/conversion/_importPtp.d.ts +12 -0
  16. package/esm/typings/conversion/parseCommand.d.ts +6 -0
  17. package/esm/typings/conversion/parseCommand.test.d.ts +1 -0
  18. package/esm/typings/conversion/promptTemplatePipelineStringToJson.d.ts +12 -0
  19. package/esm/typings/conversion/promptTemplatePipelineStringToJson.test.d.ts +1 -0
  20. package/esm/typings/conversion/validatePromptTemplatePipelineJson.d.ts +26 -0
  21. package/esm/typings/conversion/validatePromptTemplatePipelineJson.test.d.ts +1 -0
  22. package/esm/typings/execution/CommonExecutionToolsOptions.d.ts +6 -0
  23. package/esm/typings/execution/ExecutionTools.d.ts +25 -0
  24. package/esm/typings/execution/NaturalExecutionTools.d.ts +22 -0
  25. package/esm/typings/execution/PromptResult.d.ts +38 -0
  26. package/esm/typings/execution/PtpExecutor.d.ts +19 -0
  27. package/esm/typings/execution/ScriptExecutionTools.d.ts +34 -0
  28. package/esm/typings/execution/UserInterfaceTools.d.ts +30 -0
  29. package/esm/typings/execution/createPtpExecutor.d.ts +18 -0
  30. package/esm/typings/execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools.d.ts +22 -0
  31. package/esm/typings/execution/plugins/natural-execution-tools/mocked/mocked-chat.test.d.ts +4 -0
  32. package/esm/typings/execution/plugins/natural-execution-tools/mocked/mocked-completion.test.d.ts +4 -0
  33. package/esm/typings/execution/plugins/natural-execution-tools/openai/OpenAiExecutionTools.d.ts +27 -0
  34. package/esm/typings/execution/plugins/natural-execution-tools/openai/OpenAiExecutionToolsOptions.d.ts +11 -0
  35. package/esm/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionTools.d.ts +35 -0
  36. package/esm/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionToolsOptions.d.ts +16 -0
  37. package/esm/typings/execution/plugins/natural-execution-tools/remote/createRemoteServer.d.ts +16 -0
  38. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/Ptps_Error.d.ts +3 -0
  39. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/Ptps_Progress.d.ts +4 -0
  40. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/Ptps_Request.d.ts +6 -0
  41. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/Ptps_Response.d.ts +4 -0
  42. package/esm/typings/execution/plugins/natural-execution-tools/remote/interfaces/RemoteServerOptions.d.ts +20 -0
  43. package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptEvalExecutionTools.d.ts +19 -0
  44. package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptEvalExecutionTools.test.d.ts +4 -0
  45. package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionTools.d.ts +20 -0
  46. package/esm/typings/execution/plugins/script-execution-tools/javascript/utils/preserve.d.ts +11 -0
  47. package/esm/typings/execution/plugins/script-execution-tools/postprocessing.test.d.ts +4 -0
  48. package/esm/typings/execution/plugins/script-execution-tools/python/PythonExecutionTools.d.ts +15 -0
  49. package/esm/typings/execution/plugins/script-execution-tools/script-execution-errors.test.d.ts +1 -0
  50. package/esm/typings/execution/plugins/script-execution-tools/script-execution-tools.test.d.ts +1 -0
  51. package/esm/typings/execution/plugins/script-execution-tools/typescript/TypescriptExecutionTools.d.ts +15 -0
  52. package/esm/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools.d.ts +14 -0
  53. package/esm/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions.d.ts +12 -0
  54. package/esm/typings/execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools.d.ts +16 -0
  55. package/esm/typings/execution/plugins/user-interface-execution-tools/user-interface-execution-tools.test.d.ts +1 -0
  56. package/esm/typings/types/Command.d.ts +65 -0
  57. package/esm/typings/types/ExecutionTypes.d.ts +13 -0
  58. package/esm/typings/types/ModelRequirements.d.ts +28 -0
  59. package/esm/typings/types/Parameters.d.ts +14 -0
  60. package/esm/typings/types/Prompt.d.ts +35 -0
  61. package/esm/typings/types/PromptTemplatePipelineJson/PromptTemplateJson.d.ts +82 -0
  62. package/esm/typings/types/PromptTemplatePipelineJson/PromptTemplateParameterJson.d.ts +23 -0
  63. package/esm/typings/types/PromptTemplatePipelineJson/PromptTemplatePipelineJson.d.ts +56 -0
  64. package/esm/typings/types/PromptTemplatePipelineString.d.ts +14 -0
  65. package/esm/typings/types/ScriptLanguage.d.ts +9 -0
  66. package/esm/typings/types/TaskProgress.d.ts +12 -0
  67. package/esm/typings/types/typeAliasEmoji.d.ts +9 -0
  68. package/esm/typings/types/typeAliases.d.ts +477 -0
  69. package/esm/typings/utils/emojis.d.ts +16 -0
  70. package/esm/typings/utils/just.d.ts +10 -0
  71. package/esm/typings/utils/markdown/extractAllListItemsFromMarkdown.d.ts +15 -0
  72. package/esm/typings/utils/markdown/extractAllListItemsFromMarkdown.test.d.ts +1 -0
  73. package/esm/typings/utils/markdown/extractBlocksFromMarkdown.d.ts +13 -0
  74. package/esm/typings/utils/markdown/extractBlocksFromMarkdown.test.d.ts +1 -0
  75. package/esm/typings/utils/markdown/extractOneBlockFromMarkdown.d.ts +16 -0
  76. package/esm/typings/utils/markdown/extractOneBlockFromMarkdown.test.d.ts +1 -0
  77. package/esm/typings/utils/markdown/removeContentComments.d.ts +8 -0
  78. package/esm/typings/utils/markdown/removeContentComments.test.d.ts +1 -0
  79. package/esm/typings/utils/markdown/removeMarkdownFormatting.d.ts +8 -0
  80. package/esm/typings/utils/markdown/removeMarkdownFormatting.test.d.ts +1 -0
  81. package/esm/typings/utils/markdown-json/MarkdownStructure.d.ts +25 -0
  82. package/esm/typings/utils/markdown-json/countMarkdownStructureDeepness.d.ts +7 -0
  83. package/esm/typings/utils/markdown-json/countMarkdownStructureDeepness.test.d.ts +1 -0
  84. package/esm/typings/utils/markdown-json/markdownToMarkdownStructure.d.ts +13 -0
  85. package/esm/typings/utils/markdown-json/markdownToMarkdownStructure.test.d.ts +1 -0
  86. package/esm/typings/utils/removeEmojis.d.ts +7 -0
  87. package/esm/typings/utils/removeEmojis.test.d.ts +1 -0
  88. package/esm/typings/utils/removeQuotes.d.ts +13 -0
  89. package/esm/typings/utils/removeQuotes.test.d.ts +1 -0
  90. package/esm/typings/utils/replaceParameters.d.ts +16 -0
  91. package/esm/typings/utils/replaceParameters.test.d.ts +1 -0
  92. package/esm/typings/utils/unwrapResult.d.ts +13 -0
  93. package/esm/typings/utils/unwrapResult.test.d.ts +1 -0
  94. package/esm/typings/wizzard/Wizzard.d.ts +1 -0
  95. package/esm/typings/wizzard/sample.d.ts +5 -0
  96. package/package.json +46 -0
  97. package/umd/index.umd.js +171 -0
  98. package/umd/index.umd.js.map +1 -0
  99. package/umd/typings/_packages/core.index.d.ts +17 -0
  100. package/umd/typings/_packages/execute-javascript.index.d.ts +3 -0
  101. package/umd/typings/_packages/openai.index.d.ts +3 -0
  102. package/umd/typings/_packages/remote-client.index.d.ts +4 -0
  103. package/umd/typings/_packages/remote-server.index.d.ts +3 -0
  104. package/umd/typings/_packages/types.index.d.ts +20 -0
  105. package/umd/typings/_packages/utils.index.d.ts +6 -0
  106. package/umd/typings/_packages/wizzard.index.d.ts +2 -0
  107. package/umd/typings/classes/PromptTemplatePipeline.d.ts +68 -0
  108. package/umd/typings/classes/PromptTemplatePipelineLibrary.d.ts +55 -0
  109. package/umd/typings/config.d.ts +10 -0
  110. package/umd/typings/conversion/_importPtp.d.ts +12 -0
  111. package/umd/typings/conversion/parseCommand.d.ts +6 -0
  112. package/umd/typings/conversion/parseCommand.test.d.ts +1 -0
  113. package/umd/typings/conversion/promptTemplatePipelineStringToJson.d.ts +12 -0
  114. package/umd/typings/conversion/promptTemplatePipelineStringToJson.test.d.ts +1 -0
  115. package/umd/typings/conversion/validatePromptTemplatePipelineJson.d.ts +26 -0
  116. package/umd/typings/conversion/validatePromptTemplatePipelineJson.test.d.ts +1 -0
  117. package/umd/typings/execution/CommonExecutionToolsOptions.d.ts +6 -0
  118. package/umd/typings/execution/ExecutionTools.d.ts +25 -0
  119. package/umd/typings/execution/NaturalExecutionTools.d.ts +22 -0
  120. package/umd/typings/execution/PromptResult.d.ts +38 -0
  121. package/umd/typings/execution/PtpExecutor.d.ts +19 -0
  122. package/umd/typings/execution/ScriptExecutionTools.d.ts +34 -0
  123. package/umd/typings/execution/UserInterfaceTools.d.ts +30 -0
  124. package/umd/typings/execution/createPtpExecutor.d.ts +18 -0
  125. package/umd/typings/execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools.d.ts +22 -0
  126. package/umd/typings/execution/plugins/natural-execution-tools/mocked/mocked-chat.test.d.ts +4 -0
  127. package/umd/typings/execution/plugins/natural-execution-tools/mocked/mocked-completion.test.d.ts +4 -0
  128. package/umd/typings/execution/plugins/natural-execution-tools/openai/OpenAiExecutionTools.d.ts +27 -0
  129. package/umd/typings/execution/plugins/natural-execution-tools/openai/OpenAiExecutionToolsOptions.d.ts +11 -0
  130. package/umd/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionTools.d.ts +35 -0
  131. package/umd/typings/execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionToolsOptions.d.ts +16 -0
  132. package/umd/typings/execution/plugins/natural-execution-tools/remote/createRemoteServer.d.ts +16 -0
  133. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/Ptps_Error.d.ts +3 -0
  134. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/Ptps_Progress.d.ts +4 -0
  135. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/Ptps_Request.d.ts +6 -0
  136. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/Ptps_Response.d.ts +4 -0
  137. package/umd/typings/execution/plugins/natural-execution-tools/remote/interfaces/RemoteServerOptions.d.ts +20 -0
  138. package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptEvalExecutionTools.d.ts +19 -0
  139. package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptEvalExecutionTools.test.d.ts +4 -0
  140. package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionTools.d.ts +20 -0
  141. package/umd/typings/execution/plugins/script-execution-tools/javascript/utils/preserve.d.ts +11 -0
  142. package/umd/typings/execution/plugins/script-execution-tools/postprocessing.test.d.ts +4 -0
  143. package/umd/typings/execution/plugins/script-execution-tools/python/PythonExecutionTools.d.ts +15 -0
  144. package/umd/typings/execution/plugins/script-execution-tools/script-execution-errors.test.d.ts +1 -0
  145. package/umd/typings/execution/plugins/script-execution-tools/script-execution-tools.test.d.ts +1 -0
  146. package/umd/typings/execution/plugins/script-execution-tools/typescript/TypescriptExecutionTools.d.ts +15 -0
  147. package/umd/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools.d.ts +14 -0
  148. package/umd/typings/execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions.d.ts +12 -0
  149. package/umd/typings/execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools.d.ts +16 -0
  150. package/umd/typings/execution/plugins/user-interface-execution-tools/user-interface-execution-tools.test.d.ts +1 -0
  151. package/umd/typings/types/Command.d.ts +65 -0
  152. package/umd/typings/types/ExecutionTypes.d.ts +13 -0
  153. package/umd/typings/types/ModelRequirements.d.ts +28 -0
  154. package/umd/typings/types/Parameters.d.ts +14 -0
  155. package/umd/typings/types/Prompt.d.ts +35 -0
  156. package/umd/typings/types/PromptTemplatePipelineJson/PromptTemplateJson.d.ts +82 -0
  157. package/umd/typings/types/PromptTemplatePipelineJson/PromptTemplateParameterJson.d.ts +23 -0
  158. package/umd/typings/types/PromptTemplatePipelineJson/PromptTemplatePipelineJson.d.ts +56 -0
  159. package/umd/typings/types/PromptTemplatePipelineString.d.ts +14 -0
  160. package/umd/typings/types/ScriptLanguage.d.ts +9 -0
  161. package/umd/typings/types/TaskProgress.d.ts +12 -0
  162. package/umd/typings/types/typeAliasEmoji.d.ts +9 -0
  163. package/umd/typings/types/typeAliases.d.ts +477 -0
  164. package/umd/typings/utils/emojis.d.ts +16 -0
  165. package/umd/typings/utils/just.d.ts +10 -0
  166. package/umd/typings/utils/markdown/extractAllListItemsFromMarkdown.d.ts +15 -0
  167. package/umd/typings/utils/markdown/extractAllListItemsFromMarkdown.test.d.ts +1 -0
  168. package/umd/typings/utils/markdown/extractBlocksFromMarkdown.d.ts +13 -0
  169. package/umd/typings/utils/markdown/extractBlocksFromMarkdown.test.d.ts +1 -0
  170. package/umd/typings/utils/markdown/extractOneBlockFromMarkdown.d.ts +16 -0
  171. package/umd/typings/utils/markdown/extractOneBlockFromMarkdown.test.d.ts +1 -0
  172. package/umd/typings/utils/markdown/removeContentComments.d.ts +8 -0
  173. package/umd/typings/utils/markdown/removeContentComments.test.d.ts +1 -0
  174. package/umd/typings/utils/markdown/removeMarkdownFormatting.d.ts +8 -0
  175. package/umd/typings/utils/markdown/removeMarkdownFormatting.test.d.ts +1 -0
  176. package/umd/typings/utils/markdown-json/MarkdownStructure.d.ts +25 -0
  177. package/umd/typings/utils/markdown-json/countMarkdownStructureDeepness.d.ts +7 -0
  178. package/umd/typings/utils/markdown-json/countMarkdownStructureDeepness.test.d.ts +1 -0
  179. package/umd/typings/utils/markdown-json/markdownToMarkdownStructure.d.ts +13 -0
  180. package/umd/typings/utils/markdown-json/markdownToMarkdownStructure.test.d.ts +1 -0
  181. package/umd/typings/utils/removeEmojis.d.ts +7 -0
  182. package/umd/typings/utils/removeEmojis.test.d.ts +1 -0
  183. package/umd/typings/utils/removeQuotes.d.ts +13 -0
  184. package/umd/typings/utils/removeQuotes.test.d.ts +1 -0
  185. package/umd/typings/utils/replaceParameters.d.ts +16 -0
  186. package/umd/typings/utils/replaceParameters.test.d.ts +1 -0
  187. package/umd/typings/utils/unwrapResult.d.ts +13 -0
  188. package/umd/typings/utils/unwrapResult.test.d.ts +1 -0
  189. package/umd/typings/wizzard/Wizzard.d.ts +1 -0
  190. package/umd/typings/wizzard/sample.d.ts +5 -0
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Removes quotes and optional introduce text from a string
3
+ *
4
+ * Tip: This is very usefull for post-processing of the result of the LLM model
5
+ * Note: This function trims the text and removes whole introduce sentence if it is present
6
+ * Note: There are two simmilar functions:
7
+ * - `removeQuotes` which removes only bounding quotes
8
+ * - `unwrapResult` which removes whole introduce sentence
9
+ *
10
+ * @param text optionally quoted text
11
+ * @returns text without quotes
12
+ */
13
+ export declare function unwrapResult(text: string): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const Wizzard: any;
@@ -0,0 +1,5 @@
1
+ export {};
2
+ /**
3
+ url, sources nebo folder
4
+ * TODO: [🧠] OpenAi apiKey vs token
5
+ */
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@promptbook/remote-server",
3
+ "version": "0.8.0",
4
+ "description": "Library to supercharge your use of large language models",
5
+ "private": false,
6
+ "sideEffects": false,
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/webgptorg/promptbook"
10
+ },
11
+ "contributors": [
12
+ "Pavol Hejný <me@pavolhejny.com> (https://www.pavolhejny.com/)"
13
+ ],
14
+ "keywords": [
15
+ "autogpt",
16
+ "openai",
17
+ "gpt-3",
18
+ "gpt-4",
19
+ "chatgpt",
20
+ "ai",
21
+ "machine-learning",
22
+ "natural-language-processing",
23
+ "nlp",
24
+ "prompt",
25
+ "template",
26
+ "pipeline",
27
+ "automation",
28
+ "text-generation",
29
+ "language-model"
30
+ ],
31
+ "license": "SEE LICENSE IN LICENSE",
32
+ "bugs": {
33
+ "url": "https://github.com/webgptorg/promptbook/issues"
34
+ },
35
+ "homepage": "https://www.npmjs.com/package/@promptbook/core",
36
+ "dependencies": {
37
+ "socket.io": "4.7.2",
38
+ "spacetrim": "0.9.2"
39
+ },
40
+ "peerDependencies": {
41
+ "@promptbook/core": "0.8.0"
42
+ },
43
+ "main": "./umd/index.umd.js",
44
+ "module": "./esm/index.es.js",
45
+ "typings": "./esm/typings/_packages/remote-server.index.d.ts"
46
+ }
@@ -0,0 +1,171 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('chalk'), require('http'), require('socket.io'), require('spacetrim')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'chalk', 'http', 'socket.io', 'spacetrim'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["ptp-remote-server"] = {}, global.chalk, global.http, global.socket_io, global.spaceTrim));
5
+ })(this, (function (exports, chalk, http, socket_io, spaceTrim) { 'use strict';
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
10
+ var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
11
+ var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
12
+
13
+ /*! *****************************************************************************
14
+ Copyright (c) Microsoft Corporation.
15
+
16
+ Permission to use, copy, modify, and/or distribute this software for any
17
+ purpose with or without fee is hereby granted.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
20
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
21
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
22
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
23
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
24
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
25
+ PERFORMANCE OF THIS SOFTWARE.
26
+ ***************************************************************************** */
27
+
28
+ function __awaiter(thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ }
37
+
38
+ function __generator(thisArg, body) {
39
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
40
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
41
+ function verb(n) { return function (v) { return step([n, v]); }; }
42
+ function step(op) {
43
+ if (f) throw new TypeError("Generator is already executing.");
44
+ while (_) try {
45
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
46
+ if (y = 0, t) op = [op[0] & 2, t.value];
47
+ switch (op[0]) {
48
+ case 0: case 1: t = op; break;
49
+ case 4: _.label++; return { value: op[1], done: false };
50
+ case 5: _.label++; y = op[1]; op = [0]; continue;
51
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
52
+ default:
53
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
54
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
55
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
56
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
57
+ if (t[2]) _.ops.pop();
58
+ _.trys.pop(); continue;
59
+ }
60
+ op = body.call(thisArg, _);
61
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
62
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
68
+ *
69
+ * You can simply use `RemoteExecutionTools` on client-side javascript and connect to your remote server.
70
+ * This is useful to make all logic on browser side but not expose your API keys or no need to use customer's GPU.
71
+ *
72
+ * @see https://github.com/webgptorg/promptbook#remote-server
73
+ */
74
+ function createRemoteServer(options) {
75
+ var _this = this;
76
+ var port = options.port, /* [🎛] ptpLibrary, */ createNaturalExecutionTools = options.createNaturalExecutionTools, isVerbose = options.isVerbose;
77
+ var httpServer = http__default["default"].createServer({}, function (request, response) {
78
+ var _a;
79
+ if ((_a = request.url) === null || _a === void 0 ? void 0 : _a.includes('socket.io')) {
80
+ return;
81
+ }
82
+ response.write(spaceTrim__default["default"]("\n Server for processing PTP requests is running\n\n For more information look at:\n https://github.com/webgptorg/promptbook\n\n "));
83
+ response.end();
84
+ });
85
+ var server = new socket_io.Server(httpServer, {
86
+ path: '/ptp/socket.io',
87
+ transports: [/*'websocket', <- TODO: [🌬] Make websocket transport work */ 'polling'],
88
+ cors: {
89
+ origin: '*',
90
+ methods: ['GET', 'POST'],
91
+ },
92
+ });
93
+ server.on('connection', function (socket) {
94
+ console.log(chalk__default["default"].gray("Client connected"), socket.id);
95
+ socket.on('request', function (request) { return __awaiter(_this, void 0, void 0, function () {
96
+ var prompt, clientId, executionToolsForClient, promptResult, _a, error_1;
97
+ return __generator(this, function (_b) {
98
+ switch (_b.label) {
99
+ case 0:
100
+ prompt = request.prompt, clientId = request.clientId;
101
+ // TODO: !! Validate here clientId (pass validator as dependency)
102
+ if (isVerbose) {
103
+ console.info(chalk__default["default"].bgGray("Prompt:"), chalk__default["default"].gray(JSON.stringify(request, null, 4)));
104
+ }
105
+ _b.label = 1;
106
+ case 1:
107
+ _b.trys.push([1, 8, 9, 10]);
108
+ executionToolsForClient = createNaturalExecutionTools(clientId);
109
+ promptResult = void 0;
110
+ _a = prompt.modelRequirements.variant;
111
+ switch (_a) {
112
+ case 'CHAT': return [3 /*break*/, 2];
113
+ case 'COMPLETION': return [3 /*break*/, 4];
114
+ }
115
+ return [3 /*break*/, 6];
116
+ case 2: return [4 /*yield*/, executionToolsForClient.gptChat(prompt)];
117
+ case 3:
118
+ promptResult = _b.sent();
119
+ return [3 /*break*/, 7];
120
+ case 4: return [4 /*yield*/, executionToolsForClient.gptComplete(prompt)];
121
+ case 5:
122
+ promptResult = _b.sent();
123
+ return [3 /*break*/, 7];
124
+ case 6: throw new Error("Unknown model variant \"".concat(prompt.modelRequirements.variant, "\""));
125
+ case 7:
126
+ if (isVerbose) {
127
+ console.info(chalk__default["default"].bgGreen("PromptResult:"), chalk__default["default"].green(JSON.stringify(promptResult, null, 4)));
128
+ }
129
+ socket.emit('response', { promptResult: promptResult });
130
+ return [3 /*break*/, 10];
131
+ case 8:
132
+ error_1 = _b.sent();
133
+ if (!(error_1 instanceof Error)) {
134
+ throw error_1;
135
+ }
136
+ socket.emit('error', { errorMessage: error_1.message });
137
+ return [3 /*break*/, 10];
138
+ case 9:
139
+ socket.disconnect();
140
+ return [7 /*endfinally*/];
141
+ case 10: return [2 /*return*/];
142
+ }
143
+ });
144
+ }); });
145
+ socket.on('disconnect', function () {
146
+ // TODO: Destroy here executionToolsForClient
147
+ if (isVerbose) {
148
+ console.info(chalk__default["default"].gray("Client disconnected"), socket.id);
149
+ }
150
+ });
151
+ });
152
+ httpServer.listen(port);
153
+ // Note: We want to log this also in non-verbose mode
154
+ console.info(chalk__default["default"].bgGreen("PTP server listening on port ".concat(port)));
155
+ if (isVerbose) {
156
+ console.info(chalk__default["default"].green("Verbose mode is enabled"));
157
+ }
158
+ }
159
+ /**
160
+ * TODO: Handle progress - support streaming
161
+ * TODO: [🤹‍♂️] Do not hang up immediately but wait until client closes OR timeout
162
+ * TODO: [🤹‍♂️] Timeout on chat to free up resources
163
+ * TODO: [🃏] Pass here some security token to prevent DDoS
164
+ */
165
+
166
+ exports.createRemoteServer = createRemoteServer;
167
+
168
+ Object.defineProperty(exports, '__esModule', { value: true });
169
+
170
+ }));
171
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../../../node_modules/tslib/tslib.es6.js","../../../src/execution/plugins/natural-execution-tools/remote/createRemoteServer.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n",null],"names":["http","spaceTrim","Server","chalk"],"mappings":";;;;;;;;;;;;IAAA;IACA;AACA;IACA;IACA;AACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;AAuDA;IACO,SAAS,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,SAAS,EAAE;IAC7D,IAAI,SAAS,KAAK,CAAC,KAAK,EAAE,EAAE,OAAO,KAAK,YAAY,CAAC,GAAG,KAAK,GAAG,IAAI,CAAC,CAAC,UAAU,OAAO,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;IAChH,IAAI,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,EAAE,UAAU,OAAO,EAAE,MAAM,EAAE;IAC/D,QAAQ,SAAS,SAAS,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;IACnG,QAAQ,SAAS,QAAQ,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;IACtG,QAAQ,SAAS,IAAI,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KA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,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,YAAY,cAAA,EAA0B,CAAC,CAAC;;;;4BAElE,IAAI,EAAE,OAAK,YAAY,KAAK,CAAC,EAAE;gCAC3B,MAAM,OAAK,CAAC;6BACf;4BAED,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,OAAK,CAAC,OAAO,EAAuB,CAAC,CAAC;;;4BAE3E,MAAM,CAAC,UAAU,EAAE,CAAC;;;;;iBAE3B,CAAC,CAAC;YAEH,MAAM,CAAC,EAAE,CAAC,YAAY,EAAE;;gBAEpB,IAAI,SAAS,EAAE;oBACX,OAAO,CAAC,IAAI,CAACA,yBAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;iBAC9D;aACJ,CAAC,CAAC;SACN,CAAC,CAAC;QAEH,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;;QAGxB,OAAO,CAAC,IAAI,CAACA,yBAAK,CAAC,OAAO,CAAC,uCAAgC,IAAI,CAAE,CAAC,CAAC,CAAC;QACpE,IAAI,SAAS,EAAE;YACX,OAAO,CAAC,IAAI,CAACA,yBAAK,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;SACxD;IACL,CAAC;IAED;;;;;;;;;;;;;;;"}
@@ -0,0 +1,17 @@
1
+ import { PromptTemplatePipeline } from '../classes/PromptTemplatePipeline';
2
+ import { PromptTemplatePipelineLibrary } from '../classes/PromptTemplatePipelineLibrary';
3
+ import { PTP_VERSION } from '../config';
4
+ import { promptTemplatePipelineStringToJson } from '../conversion/promptTemplatePipelineStringToJson';
5
+ import { validatePromptTemplatePipelineJson } from '../conversion/validatePromptTemplatePipelineJson';
6
+ import { createPtpExecutor } from '../execution/createPtpExecutor';
7
+ import { MockedEchoNaturalExecutionTools } from '../execution/plugins/natural-execution-tools/mocked/MockedEchoNaturalExecutionTools';
8
+ import { CallbackInterfaceTools } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools';
9
+ import { CallbackInterfaceToolsOptions } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions';
10
+ import { SimplePromptInterfaceTools } from '../execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools';
11
+ import { ExecutionTypes } from '../types/ExecutionTypes';
12
+ export { ExecutionTypes, PTP_VERSION, PromptTemplatePipeline, PromptTemplatePipelineLibrary };
13
+ export { SimplePromptInterfaceTools };
14
+ export { promptTemplatePipelineStringToJson, validatePromptTemplatePipelineJson };
15
+ export { MockedEchoNaturalExecutionTools };
16
+ export { createPtpExecutor };
17
+ export { CallbackInterfaceTools, CallbackInterfaceToolsOptions };
@@ -0,0 +1,3 @@
1
+ import { JavascriptEvalExecutionTools } from '../execution/plugins/script-execution-tools/javascript/JavascriptEvalExecutionTools';
2
+ import { JavascriptExecutionTools } from '../execution/plugins/script-execution-tools/javascript/JavascriptExecutionTools';
3
+ export { JavascriptEvalExecutionTools, JavascriptExecutionTools };
@@ -0,0 +1,3 @@
1
+ import { OpenAiExecutionTools } from '../execution/plugins/natural-execution-tools/openai/OpenAiExecutionTools';
2
+ import { OpenAiExecutionToolsOptions } from '../execution/plugins/natural-execution-tools/openai/OpenAiExecutionToolsOptions';
3
+ export { OpenAiExecutionTools, OpenAiExecutionToolsOptions };
@@ -0,0 +1,4 @@
1
+ import { RemoteServerOptions } from '../execution/plugins/natural-execution-tools/remote/interfaces/RemoteServerOptions';
2
+ import { RemoteNaturalExecutionTools } from '../execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionTools';
3
+ import { RemoteNaturalExecutionToolsOptions } from '../execution/plugins/natural-execution-tools/remote/RemoteNaturalExecutionToolsOptions';
4
+ export { RemoteNaturalExecutionTools, RemoteNaturalExecutionToolsOptions, RemoteServerOptions };
@@ -0,0 +1,3 @@
1
+ import { createRemoteServer } from '../execution/plugins/natural-execution-tools/remote/createRemoteServer';
2
+ import { RemoteServerOptions } from '../execution/plugins/natural-execution-tools/remote/interfaces/RemoteServerOptions';
3
+ export { createRemoteServer, RemoteServerOptions };
@@ -0,0 +1,20 @@
1
+ import { CommonExecutionToolsOptions } from '../execution/CommonExecutionToolsOptions';
2
+ import { ExecutionTools } from '../execution/ExecutionTools';
3
+ import { NaturalExecutionTools } from '../execution/NaturalExecutionTools';
4
+ import { PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult } from '../execution/PromptResult';
5
+ import { PtpExecutor } from '../execution/PtpExecutor';
6
+ import { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../execution/ScriptExecutionTools';
7
+ import { UserInterfaceTools, UserInterfaceToolsPromptDialogOptions } from '../execution/UserInterfaceTools';
8
+ import { ExecutionType } from '../types/ExecutionTypes';
9
+ import { ModelRequirements, ModelVariant } from '../types/ModelRequirements';
10
+ import { Parameters } from '../types/Parameters';
11
+ import { Prompt } from '../types/Prompt';
12
+ import { PromptTemplateJson } from '../types/PromptTemplatePipelineJson/PromptTemplateJson';
13
+ import { PromptTemplateParameterJson } from '../types/PromptTemplatePipelineJson/PromptTemplateParameterJson';
14
+ import { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson';
15
+ import { PromptTemplatePipelineString } from '../types/PromptTemplatePipelineString';
16
+ import { ScriptLanguage } from '../types/ScriptLanguage';
17
+ import { DoneTaskProgress, PendingTaskProgress, TaskProgress } from '../types/TaskProgress';
18
+ import { string_char_emoji } from '../types/typeAliasEmoji';
19
+ import { ILicense, IPersonProfile, IRepository, number_bytes, number_days, number_gigabytes, number_hours, number_integer, number_kilobytes, number_likeness, number_megabytes, number_miliseconds, number_minutes, number_months, number_negative, number_percent, number_positive, number_seconds, number_terabytes, number_weeks, number_years, string_attribute, string_attribute_value_scope, string_business_category_name, string_char, string_chat_prompt, string_color, string_completion_prompt, string_css, string_css_class, string_css_cursor, string_css_property, string_css_selector, string_css_value, string_data_url, string_domain, string_email, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_image_prompt, string_javascript, string_javascript_name, string_license, string_license_token, string_markdown, string_markdown_text, string_midjourney_prompt, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_page, string_password, string_person_fullname, string_person_profile, string_pgp_key, string_prompt, string_protocol, string_ptp_url, string_ptp_url_with_hashtemplate, string_script, string_sha256, string_ssh_key, string_svg, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_translate_name, string_translate_name_not_normalized, string_uri, string_uri_part, string_uriid, string_url, string_url_image, string_version, string_version_dependency, string_wallpaper_id, string_xml, uuid, uuid_first_segment } from '../types/typeAliases';
20
+ export { CommonExecutionToolsOptions, DoneTaskProgress, ExecutionTools, ExecutionType, ILicense, IPersonProfile, IRepository, ModelRequirements, ModelVariant, NaturalExecutionTools, Parameters, PendingTaskProgress, Prompt, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptTemplateJson, PromptTemplateParameterJson, PromptTemplatePipelineJson, PromptTemplatePipelineString, PtpExecutor, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptLanguage, TaskProgress, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, number_bytes, number_days, number_gigabytes, number_hours, number_integer, number_kilobytes, number_likeness, number_megabytes, number_miliseconds, number_minutes, number_months, number_negative, number_percent, number_positive, number_seconds, number_terabytes, number_weeks, number_years, string_attribute, string_attribute_value_scope, string_business_category_name, string_char, string_char_emoji, string_chat_prompt, string_color, string_completion_prompt, string_css, string_css_class, string_css_cursor, string_css_property, string_css_selector, string_css_value, string_data_url, string_domain, string_email, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_image_prompt, string_javascript, string_javascript_name, string_license, string_license_token, string_markdown, string_markdown_text, string_midjourney_prompt, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_page, string_password, string_person_fullname, string_person_profile, string_pgp_key, string_prompt, string_protocol, string_ptp_url, string_ptp_url_with_hashtemplate, string_script, string_sha256, string_ssh_key, string_svg, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_translate_name, string_translate_name_not_normalized, string_uri, string_uri_part, string_uriid, string_url, string_url_image, string_version, string_version_dependency, string_wallpaper_id, string_xml, uuid, uuid_first_segment, };
@@ -0,0 +1,6 @@
1
+ import { removeContentComments } from '../utils/markdown/removeContentComments';
2
+ import { removeMarkdownFormatting } from '../utils/markdown/removeMarkdownFormatting';
3
+ import { removeEmojis } from '../utils/removeEmojis';
4
+ import { removeQuotes } from '../utils/removeQuotes';
5
+ import { unwrapResult } from '../utils/unwrapResult';
6
+ export { removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, unwrapResult };
@@ -0,0 +1,2 @@
1
+ import { Wizzard } from '../wizzard/Wizzard';
2
+ export { Wizzard };
@@ -0,0 +1,68 @@
1
+ import { string_name } from '.././types/typeAliases';
2
+ import { PromptTemplateJson } from '../types/PromptTemplatePipelineJson/PromptTemplateJson';
3
+ import { PromptTemplateParameterJson } from '../types/PromptTemplatePipelineJson/PromptTemplateParameterJson';
4
+ import { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson';
5
+ import { PromptTemplatePipelineString } from '../types/PromptTemplatePipelineString';
6
+ /**
7
+ * Prompt template pipeline is the **core concept of this library**.
8
+ * It represents a series of prompt templates chained together to form a pipeline / one big prompt template with input and result parameters.
9
+ *
10
+ * It can have 3 formats:
11
+ * - **.ptp.md file** in custom markdown format described above
12
+ * - **JSON** format, parsed from the .ptp.md file
13
+ * - _(this)_ **Object** which is created from JSON format and bound with tools around (but not the execution logic)
14
+ *
15
+ * @see https://github.com/webgptorg/promptbook#prompt-template-pipeline
16
+ */
17
+ export declare class PromptTemplatePipeline {
18
+ readonly ptpUrl: URL | null;
19
+ readonly parameters: Record<string_name, PromptTemplateParameterJson>;
20
+ readonly promptTemplates: Array<PromptTemplateJson>;
21
+ /**
22
+ * Constructs PromptTemplatePipeline from any source
23
+ *
24
+ * Note: During the construction syntax and logic of source is validated
25
+ *
26
+ * @param source content of .ptp.md or .ptp.json file
27
+ * @returns PromptTemplatePipeline
28
+ */
29
+ static fromSource(ptpSource: PromptTemplatePipelineString | PromptTemplatePipelineJson): PromptTemplatePipeline;
30
+ /**
31
+ * Constructs PromptTemplatePipeline from markdown source
32
+ *
33
+ * Note: During the construction syntax and logic of source is validated
34
+ *
35
+ * @param ptpString content of .ptp.md file
36
+ * @returns PromptTemplatePipeline
37
+ */
38
+ static fromString(ptpString: PromptTemplatePipelineString): PromptTemplatePipeline;
39
+ /**
40
+ * Constructs PromptTemplatePipeline from JSON source
41
+ *
42
+ * Note: During the construction the source is logic validated
43
+ *
44
+ * @param ptpjson content of .ptp.json file parsed into JSON
45
+ * @returns PromptTemplatePipeline
46
+ */
47
+ static fromJson(ptpjson: PromptTemplatePipelineJson): PromptTemplatePipeline;
48
+ private constructor();
49
+ /**
50
+ * Returns the first prompt template in the pipeline
51
+ */
52
+ get entryPromptTemplate(): PromptTemplateJson;
53
+ /**
54
+ * Gets the parameter that is the result of given prompt template
55
+ */
56
+ getResultingParameter(promptTemplateName: string_name): PromptTemplateParameterJson;
57
+ /**
58
+ * Gets the following prompt template in the pipeline or null if there is no following prompt template and this is the last one
59
+ */
60
+ getFollowingPromptTemplate(promptTemplateName: string_name): PromptTemplateJson | null;
61
+ }
62
+ /**
63
+ * TODO: !! [👐][🧠] Split of PromptTemplatePipeline,PromptTemplatePipelineLibrary between interface and class
64
+ * TODO: !! [👐] Make parameters and promptTemplates private WHEN split between interface and class
65
+ * TODO: !! Add generic type for entry and result parameters
66
+ * TODO: Can be Array elegantly typed such as it must have at least one element?
67
+ * TODO: [🧠] Each PromptTemplatePipeline should have its unique hash to be able to compare them and execute on server ONLY the desired ones
68
+ */
@@ -0,0 +1,55 @@
1
+ import { string_name } from '.././types/typeAliases';
2
+ import { ExecutionTools } from '../execution/ExecutionTools';
3
+ import { PtpExecutor } from '../execution/PtpExecutor';
4
+ import { Prompt } from '../types/Prompt';
5
+ import { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson';
6
+ import { PromptTemplatePipelineString } from '../types/PromptTemplatePipelineString';
7
+ import { PromptTemplatePipeline } from './PromptTemplatePipeline';
8
+ /**
9
+ * Library of prompt template pipelines that groups together prompt template pipelines for an application. This is a very thin wrapper around the Array / Set of prompt template pipelines.
10
+ *
11
+ * Prompt Template Pipeline library is a useful helper in execution, it can be shared between execution and consumer parts of the app and make common knowledge about prompt template pipelines.
12
+ *
13
+ * It allows to create executor functions from prompt template pipelines in the library.
14
+ *
15
+ * @see https://github.com/webgptorg/promptbook#prompt-template-pipeline-library
16
+ */
17
+ export declare class PromptTemplatePipelineLibrary {
18
+ readonly promptTemplatePipelines: Record<string_name, PromptTemplatePipeline>;
19
+ /**
20
+ * Constructs PromptTemplatePipeline from any sources
21
+ *
22
+ * Note: During the construction syntax and logic of all sources are validated
23
+ * Note: You can combine .ptp.md and .ptp.json files BUT it is not recommended
24
+ *
25
+ * @param ptpSources contents of .ptp.md or .ptp.json files
26
+ * @returns PromptTemplatePipelineLibrary
27
+ */
28
+ static fromSources(ptpSources: Record<string_name, PromptTemplatePipelineJson | PromptTemplatePipelineString>): PromptTemplatePipelineLibrary;
29
+ private constructor();
30
+ /**
31
+ * Gets prompt template pipeline by name
32
+ */
33
+ getPtp(name: string_name): PromptTemplatePipeline;
34
+ /**
35
+ * Checks whether prompt is in the library
36
+ */
37
+ isPromptInLibrary(prompt: Prompt): boolean;
38
+ /**
39
+ * Gets executor function for given prompt template pipeline
40
+ */
41
+ createExecutor(name: string_name, tools: ExecutionTools): PtpExecutor;
42
+ }
43
+ /**
44
+ * TODO: !! [👐][🧠] Split of PromptTemplatePipeline,PromptTemplatePipelineLibrary between interface and class
45
+ * TODO: !! [👐] Make promptTemplatePipelines private WHEN split between interface and class
46
+ * TODO: [🧠] Maybe isPromptInLibrary should be separate utility function
47
+ * TODO: [🧠] Maybe createExecutor should be separate utility function
48
+ * TODO: Static method fromDirectory
49
+ * TODO: [🤜] Add generic type for entry and result parameters
50
+ * TODO: [🧠] Is it better to ptpLibrary.executePtp('writeXyz',{...}) OR ptpLibrary.createExecutor('writeXyz')({...}) OR createExecutor(ptpLibrary.getPtp('writeXyz'))
51
+ * TODO: [🧠] Formarly (before commit 62229afce7668a5b85077cc18becf798b583bf8d) there were two classes PromptTemplatePipelineLibrary+PtpLibraryExecutor (maybe it was better?)
52
+ * TODO: [🧠] Is it better to pass tools into getExecutor or into constructor
53
+ * Maybe it is not a good idea to cache executors when they are can be created with different tools
54
+ * TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
55
+ */
@@ -0,0 +1,10 @@
1
+ import { ModelRequirements } from './types/ModelRequirements';
2
+ import { string_version } from './types/typeAliases';
3
+ /**
4
+ * The version of the PTP
5
+ */
6
+ export declare const PTP_VERSION: string_version;
7
+ /**
8
+ * Default model requirements for the pipeline
9
+ */
10
+ export declare const DEFAULT_MODEL_REQUIREMENTS: ModelRequirements;
@@ -0,0 +1,12 @@
1
+ import { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson';
2
+ import { PromptTemplatePipelineString } from '../types/PromptTemplatePipelineString';
3
+ /**
4
+ * Import the text file
5
+ *
6
+ * Note: Using here custom import to work in jest tests
7
+ * Note: Using sync version is 💩 in the production code, but it's ok here in tests
8
+ *
9
+ * @private
10
+ */
11
+ export declare function importPtp(path: `${string}.ptp.md`): PromptTemplatePipelineString;
12
+ export declare function importPtp(path: `${string}.ptp.json`): PromptTemplatePipelineJson;
@@ -0,0 +1,6 @@
1
+ import { string_markdown_text } from '.././types/typeAliases';
2
+ import { Command } from '../types/Command';
3
+ /**
4
+ * Parses one line of ul/ol to command
5
+ */
6
+ export declare function parseCommand(listItem: string_markdown_text): Command;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson';
2
+ import { PromptTemplatePipelineString } from '../types/PromptTemplatePipelineString';
3
+ /**
4
+ * Parse prompt template pipeline from string format to JSON format
5
+ *
6
+ * Note: This function does not validate logic of the pipeline only the syntax
7
+ */
8
+ export declare function promptTemplatePipelineStringToJson(promptTemplatePipelineString: PromptTemplatePipelineString): PromptTemplatePipelineJson;
9
+ /**
10
+ * TODO: Report here line/column of error
11
+ * TODO: Use spaceTrim more effectively
12
+ */
@@ -0,0 +1,26 @@
1
+ import { PromptTemplatePipelineJson } from '../types/PromptTemplatePipelineJson/PromptTemplatePipelineJson';
2
+ /**
3
+ * Validates PromptTemplatePipelineJson if it is logically valid.
4
+ *
5
+ * It checks:
6
+ * - if it has correct parameters dependency
7
+ *
8
+ * It does NOT check:
9
+ * - if it is valid json
10
+ * - if it is meaningful
11
+ *
12
+ * @param ptp valid or invalid PromptTemplatePipelineJson
13
+ * @throws {Error} if invalid
14
+ */
15
+ export declare function validatePromptTemplatePipelineJson(ptp: PromptTemplatePipelineJson): void;
16
+ /**
17
+ * TODO: [🧠] Work with ptpVersion
18
+ * TODO: Use here some json-schema, Zod or something similar and change it to:
19
+ * > /**
20
+ * > * Validates PromptTemplatePipelineJson if it is logically valid.
21
+ * > *
22
+ * > * It checks:
23
+ * > * - it has a valid structure
24
+ * > * - ...
25
+ * > ex port function validatePromptTemplatePipelineJson(ptp: unknown): asserts ptp is PromptTemplatePipelineJson {
26
+ */
@@ -0,0 +1,6 @@
1
+ export interface CommonExecutionToolsOptions {
2
+ /**
3
+ * If true, the internal executions will be logged
4
+ */
5
+ readonly isVerbose?: boolean;
6
+ }
@@ -0,0 +1,25 @@
1
+ import { NaturalExecutionTools } from './NaturalExecutionTools';
2
+ import { ScriptExecutionTools } from './ScriptExecutionTools';
3
+ import { UserInterfaceTools } from './UserInterfaceTools';
4
+ /**
5
+ * All the tools needed to execute prompts (template pipelines).
6
+ *
7
+ * @see https://github.com/webgptorg/promptbook#execution-tools
8
+ */
9
+ export interface ExecutionTools {
10
+ /**
11
+ * Tools for executing prompts to large language models like GPT-4
12
+ */
13
+ natural: NaturalExecutionTools;
14
+ /**
15
+ * Tools for executing scripts
16
+ *
17
+ * Note: You can pass multiple ScriptExecutionTools, they will be tried one by one until one of them supports the script
18
+ * If none of them supports the script, an error is thrown
19
+ */
20
+ script: Array<ScriptExecutionTools>;
21
+ /**
22
+ * Tools for interacting with the user
23
+ */
24
+ userInterface: UserInterfaceTools;
25
+ }