@promptbook/remote-server 0.78.4 → 0.80.0-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 (36) hide show
  1. package/README.md +4 -0
  2. package/esm/index.es.js +5 -6
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/books/index.d.ts +6 -6
  5. package/esm/typings/src/_packages/core.index.d.ts +4 -2
  6. package/esm/typings/src/_packages/types.index.d.ts +10 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +4 -0
  8. package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +32 -0
  9. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +5 -2
  10. package/esm/typings/src/config.d.ts +0 -25
  11. package/esm/typings/src/constants.d.ts +35 -0
  12. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -0
  13. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +1 -0
  14. package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +6 -1
  15. package/esm/typings/src/formfactors/index.d.ts +12 -2
  16. package/esm/typings/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +6 -1
  17. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +20 -0
  18. package/esm/typings/src/high-level-abstractions/implicit-formfactor/ImplicitFormfactorHla.d.ts +10 -0
  19. package/esm/typings/src/high-level-abstractions/index.d.ts +44 -0
  20. package/esm/typings/src/high-level-abstractions/quick-chatbot/QuickChatbotHla.d.ts +10 -0
  21. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
  22. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  23. package/esm/typings/src/prepare/prepareTasks.d.ts +1 -0
  24. package/esm/typings/src/types/typeAliases.d.ts +1 -1
  25. package/esm/typings/src/utils/normalization/orderJson.d.ts +21 -0
  26. package/esm/typings/src/utils/normalization/orderJson.test.d.ts +4 -0
  27. package/esm/typings/src/utils/organization/keepTypeImported.d.ts +9 -0
  28. package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +1 -1
  29. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +20 -2
  30. package/esm/typings/src/utils/serialization/deepClone.test.d.ts +1 -0
  31. package/esm/typings/src/utils/serialization/exportJson.d.ts +29 -0
  32. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +2 -1
  33. package/package.json +2 -2
  34. package/umd/index.umd.js +5 -6
  35. package/umd/index.umd.js.map +1 -1
  36. package/esm/typings/src/utils/serialization/$asDeeplyFrozenSerializableJson.d.ts +0 -17
@@ -18,6 +18,7 @@ import type { PipelineString } from '../pipeline/PipelineString';
18
18
  */
19
19
  export declare function pipelineStringToJsonSync(pipelineString: PipelineString): PipelineJson;
20
20
  /**
21
+ * TODO: [🧠] Maybe more things here can be refactored as high-level abstractions
21
22
  * TODO: [main] !!!! Warn if used only sync version
22
23
  * TODO: [🚞] Report here line/column of error
23
24
  * TODO: Use spaceTrim more effectively
@@ -8,7 +8,12 @@ export declare const GeneratorFormfactorDefinition: {
8
8
  readonly description: "@@@";
9
9
  readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184";
10
10
  readonly pipelineInterface: {
11
- readonly inputParameters: readonly [];
11
+ readonly inputParameters: readonly [{
12
+ readonly name: "nonce";
13
+ readonly description: "Just to prevent GENERATOR to be set as implicit formfactor";
14
+ readonly isInput: true;
15
+ readonly isOutput: false;
16
+ }];
12
17
  readonly outputParameters: readonly [];
13
18
  };
14
19
  };
@@ -96,7 +96,12 @@ export declare const FORMFACTOR_DEFINITIONS: readonly [{
96
96
  readonly description: "@@@";
97
97
  readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177";
98
98
  readonly pipelineInterface: {
99
- readonly inputParameters: readonly [];
99
+ readonly inputParameters: readonly [{
100
+ readonly name: "nonce";
101
+ readonly description: "Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor";
102
+ readonly isInput: true;
103
+ readonly isOutput: false;
104
+ }];
100
105
  readonly outputParameters: readonly [];
101
106
  };
102
107
  }, {
@@ -104,7 +109,12 @@ export declare const FORMFACTOR_DEFINITIONS: readonly [{
104
109
  readonly description: "@@@";
105
110
  readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/184";
106
111
  readonly pipelineInterface: {
107
- readonly inputParameters: readonly [];
112
+ readonly inputParameters: readonly [{
113
+ readonly name: "nonce";
114
+ readonly description: "Just to prevent GENERATOR to be set as implicit formfactor";
115
+ readonly isInput: true;
116
+ readonly isOutput: false;
117
+ }];
108
118
  readonly outputParameters: readonly [];
109
119
  };
110
120
  }];
@@ -8,7 +8,12 @@ export declare const MatcherFormfactorDefinition: {
8
8
  readonly description: "@@@";
9
9
  readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/177";
10
10
  readonly pipelineInterface: {
11
- readonly inputParameters: readonly [];
11
+ readonly inputParameters: readonly [{
12
+ readonly name: "nonce";
13
+ readonly description: "Just to prevent EXPERIMENTAL_MATCHER to be set as implicit formfactor";
14
+ readonly isInput: true;
15
+ readonly isOutput: false;
16
+ }];
12
17
  readonly outputParameters: readonly [];
13
18
  };
14
19
  };
@@ -0,0 +1,20 @@
1
+ import type { $PipelineJson } from '../../commands/_common/types/CommandParser';
2
+ /**
3
+ * Used in `pipelineStringToJsonSync`
4
+ *
5
+ * @private
6
+ */
7
+ export type SyncHighLevelAbstraction = {
8
+ type: 'SYNC';
9
+ /**
10
+ * Apply the abstraction to the `pipelineJson`
11
+ *
12
+ * Note: `$` is used to indicate that this function mutates given `pipelineJson`
13
+ */
14
+ $applyToPipelineJson($pipelineJson: $PipelineJson): void;
15
+ };
16
+ /**
17
+ * TODO: [♓️] Add order here
18
+ * TODO: [🧠][🍱] Maybe make some common abstraction between `HighLevelAbstraction` and `CommandParser`
19
+ * Note: [💞] Ignore a discrepancy between file name and entity name
20
+ */
@@ -0,0 +1,10 @@
1
+ import type { $PipelineJson } from '../../commands/_common/types/CommandParser';
2
+ /**
3
+ * Set formfactor based on the pipeline interface e
4
+ *
5
+ * @private
6
+ */
7
+ export declare const ImplicitFormfactorHla: {
8
+ type: "SYNC";
9
+ $applyToPipelineJson($pipelineJson: $PipelineJson): void;
10
+ };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * All high-level abstractions
3
+ *
4
+ * @private internal index of `pipelineStringToJsonSync` (= used for sync) and `preparePipeline` (= used for async)
5
+ */
6
+ export declare const HIGH_LEVEL_ABSTRACTIONS: readonly [{
7
+ type: "SYNC";
8
+ $applyToPipelineJson($pipelineJson: import("type-fest/source/writable-deep").WritableObjectDeep<{
9
+ readonly pipelineUrl?: string | undefined;
10
+ readonly sourceFile?: string | undefined;
11
+ readonly title: string;
12
+ readonly bookVersion?: string | undefined;
13
+ readonly description?: string | undefined;
14
+ readonly parameters: import("../_packages/types.index").ParameterJson[];
15
+ readonly defaultModelRequirements?: Partial<import("../types/ModelRequirements").ModelRequirements> | undefined;
16
+ readonly tasks: import("../_packages/types.index").TaskJson[];
17
+ readonly knowledgeSources: (import("../_packages/types.index").KnowledgeSourceJson | import("../_packages/types.index").KnowledgeSourcePreparedJson)[];
18
+ readonly knowledgePieces: import("../_packages/types.index").KnowledgePiecePreparedJson[];
19
+ readonly personas: (import("../_packages/types.index").PersonaJson | import("../_packages/types.index").PersonaPreparedJson)[];
20
+ readonly preparations: import("../_packages/types.index").PreparationJson[];
21
+ readonly formfactorName?: "CHATBOT" | "GENERATOR" | "GENERIC" | "EXPERIMENTAL_MATCHER" | "SHEETS" | "TRANSLATOR" | undefined;
22
+ }>): void;
23
+ }, {
24
+ type: "SYNC";
25
+ $applyToPipelineJson($pipelineJson: import("type-fest/source/writable-deep").WritableObjectDeep<{
26
+ readonly pipelineUrl?: string | undefined;
27
+ readonly sourceFile?: string | undefined;
28
+ readonly title: string;
29
+ readonly bookVersion?: string | undefined;
30
+ readonly description?: string | undefined;
31
+ readonly parameters: import("../_packages/types.index").ParameterJson[];
32
+ readonly defaultModelRequirements?: Partial<import("../types/ModelRequirements").ModelRequirements> | undefined;
33
+ readonly tasks: import("../_packages/types.index").TaskJson[];
34
+ readonly knowledgeSources: (import("../_packages/types.index").KnowledgeSourceJson | import("../_packages/types.index").KnowledgeSourcePreparedJson)[];
35
+ readonly knowledgePieces: import("../_packages/types.index").KnowledgePiecePreparedJson[];
36
+ readonly personas: (import("../_packages/types.index").PersonaJson | import("../_packages/types.index").PersonaPreparedJson)[];
37
+ readonly preparations: import("../_packages/types.index").PreparationJson[];
38
+ readonly formfactorName?: "CHATBOT" | "GENERATOR" | "GENERIC" | "EXPERIMENTAL_MATCHER" | "SHEETS" | "TRANSLATOR" | undefined;
39
+ }>): void;
40
+ }];
41
+ /**
42
+ * TODO: Test that all sync high-level abstractions are before async high-level abstractions
43
+ * Note: [💞] Ignore a discrepancy between file name and entity name
44
+ */
@@ -0,0 +1,10 @@
1
+ import type { $PipelineJson } from '../../commands/_common/types/CommandParser';
2
+ /**
3
+ * Allow to define chatbot with no need to write full interface
4
+ *
5
+ * @private
6
+ */
7
+ export declare const QuickChatbotHla: {
8
+ type: "SYNC";
9
+ $applyToPipelineJson($pipelineJson: $PipelineJson): void;
10
+ };
@@ -54,7 +54,7 @@ export declare class RemoteLlmExecutionTools<TCustomOptions = undefined> impleme
54
54
  private callCommonModel;
55
55
  }
56
56
  /**
57
- * TODO: Maybe use `$asDeeplyFrozenSerializableJson`
57
+ * TODO: Maybe use `$exportJson`
58
58
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
59
59
  * TODO: [🍓] Allow to list compatible models with each variant
60
60
  * TODO: [🗯] RemoteLlmExecutionTools should extend Destroyable and implement IDestroyable
@@ -11,7 +11,7 @@ import type { RemoteServerOptions } from './interfaces/RemoteServerOptions';
11
11
  */
12
12
  export declare function startRemoteServer<TCustomOptions = undefined>(options: RemoteServerOptions<TCustomOptions>): IDestroyable;
13
13
  /**
14
- * TODO: Maybe use `$asDeeplyFrozenSerializableJson`
14
+ * TODO: Maybe use `$exportJson`
15
15
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
16
16
  * TODO: [⚖] Expose the collection to be able to connect to same collection via createCollectionFromUrl
17
17
  * TODO: Handle progress - support streaming
@@ -22,6 +22,7 @@ type PreparedTasks = {
22
22
  export declare function prepareTasks(pipeline: PrepareTaskInput, tools: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>, options: PrepareAndScrapeOptions): Promise<PreparedTasks>;
23
23
  export {};
24
24
  /**
25
+ * TODO: [😂] Adding knowledge should be convert to async high-level abstractions, simmilar thing with expectations to sync high-level abstractions
25
26
  * TODO: [🧠] Add context to each task (if missing)
26
27
  * TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
27
28
  * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
@@ -1,5 +1,5 @@
1
1
  import type { TupleToUnion } from 'type-fest';
2
- import { RESERVED_PARAMETER_NAMES } from '../config';
2
+ import { RESERVED_PARAMETER_NAMES } from '../constants';
3
3
  /**
4
4
  * Semantic helper
5
5
  */
@@ -0,0 +1,21 @@
1
+ import type { JsonArray, JsonObject } from 'type-fest';
2
+ /**
3
+ * Options for the `orderJson` function
4
+ */
5
+ export type OrderJsonOptions<TObject extends JsonObject | JsonArray> = {
6
+ /**
7
+ * Value to checked, ordered and deeply frozen
8
+ */
9
+ value: TObject;
10
+ /**
11
+ * Order of the object properties
12
+ */
13
+ order: Array<keyof TObject>;
14
+ };
15
+ /**
16
+ * Orders JSON object by keys
17
+ *
18
+ * @returns The same type of object as the input re-ordered
19
+ * @public exported from `@promptbook/utils`
20
+ */
21
+ export declare function orderJson<TObject extends JsonObject | JsonArray>(options: OrderJsonOptions<TObject>): TObject;
@@ -0,0 +1,4 @@
1
+ export {};
2
+ /**
3
+ * TODO: [🧠] Is there a way how to test order of value better way than via `JSON.stringify`
4
+ */
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Just says that the type is used but `organize-imports-cli` does not recognize it.
3
+ * [🤛] This is a workaround for the issue.
4
+ *
5
+ * @param value any values
6
+ * @returns void
7
+ * @private within the repository
8
+ */
9
+ export declare function keepTypeImported<TTypeToKeep>(): void;
@@ -1,6 +1,6 @@
1
1
  import type { ReadonlyDeep } from 'type-fest';
2
2
  /**
3
- * @@@
3
+ * Freezes the given object and all its nested objects recursively
4
4
  *
5
5
  * Note: `$` is used to indicate that this function is not a pure function - it mutates given object
6
6
  * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
@@ -1,4 +1,22 @@
1
1
  import type { string_name } from '../../types/typeAliases';
2
+ import type { really_unknown } from '../organization/really_unknown';
3
+ /**
4
+ * Options for the `checkSerializableAsJson` function
5
+ */
6
+ export type CheckSerializableAsJsonOptions = {
7
+ /**
8
+ * Value to be checked
9
+ */
10
+ value: really_unknown;
11
+ /**
12
+ * Semantic name of the value for debugging purposes
13
+ */
14
+ name?: string_name;
15
+ /**
16
+ * Message alongside the value for debugging purposes
17
+ */
18
+ message?: string;
19
+ };
2
20
  /**
3
21
  * Checks if the value is [🚉] serializable as JSON
4
22
  * If not, throws an UnexpectedError with a rich error message and tracking
@@ -19,9 +37,9 @@ import type { string_name } from '../../types/typeAliases';
19
37
  * @throws UnexpectedError if the value is not serializable as JSON
20
38
  * @public exported from `@promptbook/utils`
21
39
  */
22
- export declare function checkSerializableAsJson(name: string_name, value: unknown): void;
40
+ export declare function checkSerializableAsJson(options: CheckSerializableAsJsonOptions): void;
23
41
  /**
24
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
42
+ * TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
25
43
  * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
26
44
  * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
27
45
  */
@@ -0,0 +1,29 @@
1
+ import type { JsonArray, JsonObject } from 'type-fest';
2
+ import type { OrderJsonOptions } from '../normalization/orderJson';
3
+ import type { CheckSerializableAsJsonOptions } from './checkSerializableAsJson';
4
+ /**
5
+ * Options for the `$exportJson` function
6
+ */
7
+ export type ExportJsonOptions<TObject> = CheckSerializableAsJsonOptions & Partial<Pick<OrderJsonOptions<TObject & (JsonObject | JsonArray)>, 'order'>> & {
8
+ /**
9
+ * Value to be checked, ordered and deeply frozen
10
+ */
11
+ value: TObject;
12
+ };
13
+ /**
14
+ * Utility to export a JSON object from a function
15
+ *
16
+ * 1) Checks if the value is serializable as JSON
17
+ * 2) Makes a deep clone of the object
18
+ * 2) Orders the object properties
19
+ * 2) Deeply freezes the cloned object
20
+ *
21
+ * Note: This function does not mutates the given object
22
+ *
23
+ * @returns The same type of object as the input but read-only and re-ordered
24
+ * @public exported from `@promptbook/utils`
25
+ */
26
+ export declare function exportJson<TObject>(options: ExportJsonOptions<TObject>): TObject;
27
+ /**
28
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
29
+ */
@@ -1,3 +1,4 @@
1
+ import { JsonValue } from 'type-fest';
1
2
  /**
2
3
  * Tests if the value is [🚉] serializable as JSON
3
4
  *
@@ -17,7 +18,7 @@
17
18
  *
18
19
  * @public exported from `@promptbook/utils`
19
20
  */
20
- export declare function isSerializableAsJson(value: unknown): boolean;
21
+ export declare function isSerializableAsJson(value: unknown): value is JsonValue;
21
22
  /**
22
23
  * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
23
24
  * TODO: [🧠][💺] Can be done this on type-level?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/remote-server",
3
- "version": "0.78.4",
3
+ "version": "0.80.0-0",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "--note-0": " <- [🐊]",
6
6
  "private": false,
@@ -54,7 +54,7 @@
54
54
  "module": "./esm/index.es.js",
55
55
  "typings": "./esm/typings/src/_packages/remote-server.index.d.ts",
56
56
  "peerDependencies": {
57
- "@promptbook/core": "0.78.4"
57
+ "@promptbook/core": "0.80.0-0"
58
58
  },
59
59
  "dependencies": {
60
60
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -22,7 +22,7 @@
22
22
  *
23
23
  * @see https://github.com/webgptorg/promptbook
24
24
  */
25
- var PROMPTBOOK_ENGINE_VERSION = '0.78.3';
25
+ var PROMPTBOOK_ENGINE_VERSION = '0.79.0';
26
26
  /**
27
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
28
28
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -206,7 +206,6 @@
206
206
  */
207
207
  var DEFAULT_IS_VERBOSE = false;
208
208
  /**
209
- * TODO: Extract `constants.ts` from `config.ts`
210
209
  * Note: [💞] Ignore a discrepancy between file name and entity name
211
210
  * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
212
211
  */
@@ -1346,14 +1345,14 @@
1346
1345
  if (isVerbose) {
1347
1346
  console.info(colors__default["default"].bgGreen("PromptResult:"), colors__default["default"].green(JSON.stringify(promptResult, null, 4)));
1348
1347
  }
1349
- socket.emit('prompt-response', { promptResult: promptResult } /* <- TODO: [🤛] */);
1348
+ socket.emit('prompt-response', { promptResult: promptResult } /* <- Note: [🤛] */);
1350
1349
  return [3 /*break*/, 17];
1351
1350
  case 15:
1352
1351
  error_1 = _c.sent();
1353
1352
  if (!(error_1 instanceof Error)) {
1354
1353
  throw error_1;
1355
1354
  }
1356
- socket.emit('error', serializeError(error_1) /* <- TODO: [🤛] */);
1355
+ socket.emit('error', serializeError(error_1) /* <- Note: [🤛] */);
1357
1356
  return [3 /*break*/, 17];
1358
1357
  case 16:
1359
1358
  socket.disconnect();
@@ -1400,7 +1399,7 @@
1400
1399
  case 4: return [4 /*yield*/, llmExecutionTools.listModels()];
1401
1400
  case 5:
1402
1401
  models = _b.sent();
1403
- socket.emit('listModels-response', { models: models } /* <- TODO: [🤛] */);
1402
+ socket.emit('listModels-response', { models: models } /* <- Note: [🤛] */);
1404
1403
  return [3 /*break*/, 8];
1405
1404
  case 6:
1406
1405
  error_2 = _b.sent();
@@ -1445,7 +1444,7 @@
1445
1444
  };
1446
1445
  }
1447
1446
  /**
1448
- * TODO: Maybe use `$asDeeplyFrozenSerializableJson`
1447
+ * TODO: Maybe use `$exportJson`
1449
1448
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
1450
1449
  * TODO: [⚖] Expose the collection to be able to connect to same collection via createCollectionFromUrl
1451
1450
  * TODO: Handle progress - support streaming