@promptbook/openai 0.82.0-0 → 0.82.0-3

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 (35) hide show
  1. package/esm/index.es.js +1 -1
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/core.index.d.ts +2 -0
  4. package/esm/typings/src/_packages/remote-client.index.d.ts +9 -3
  5. package/esm/typings/src/_packages/remote-server.index.d.ts +8 -2
  6. package/esm/typings/src/_packages/types.index.d.ts +16 -26
  7. package/esm/typings/src/collection/PipelineCollection.d.ts +2 -0
  8. package/esm/typings/src/config.d.ts +6 -0
  9. package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +6 -3
  10. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +2 -2
  11. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +3 -7
  12. package/esm/typings/src/other/templates/getBookTemplates.d.ts +5 -3
  13. package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +5 -2
  14. package/esm/typings/src/remote-server/createRemoteClient.d.ts +10 -0
  15. package/esm/typings/src/remote-server/{interfaces → socket-types/_common}/PromptbookServer_Error.d.ts +3 -3
  16. package/esm/typings/src/remote-server/socket-types/_common/PromptbookServer_Progress.d.ts +10 -0
  17. package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts +49 -0
  18. package/esm/typings/src/remote-server/socket-types/listModels/PromptbookServer_ListModels_Request.d.ts +17 -0
  19. package/esm/typings/src/remote-server/{interfaces → socket-types/listModels}/PromptbookServer_ListModels_Response.d.ts +4 -2
  20. package/esm/typings/src/remote-server/socket-types/prepare/PromptbookServer_PreparePipeline_Request.d.ts +17 -0
  21. package/esm/typings/src/remote-server/socket-types/prepare/PromptbookServer_PreparePipeline_Response.d.ts +12 -0
  22. package/esm/typings/src/remote-server/socket-types/prompt/PromptbookServer_Prompt_Request.d.ts +17 -0
  23. package/esm/typings/src/remote-server/{interfaces → socket-types/prompt}/PromptbookServer_Prompt_Response.d.ts +3 -3
  24. package/esm/typings/src/remote-server/startRemoteServer.d.ts +3 -2
  25. package/esm/typings/src/remote-server/types/RemoteClientOptions.d.ts +32 -0
  26. package/esm/typings/src/types/Arrayable.d.ts +1 -0
  27. package/esm/typings/src/types/NonEmptyArray.d.ts +8 -0
  28. package/package.json +2 -2
  29. package/umd/index.umd.js +1 -1
  30. package/umd/index.umd.js.map +1 -1
  31. package/esm/typings/src/remote-server/interfaces/PromptbookServer_ListModels_Request.d.ts +0 -38
  32. package/esm/typings/src/remote-server/interfaces/PromptbookServer_Prompt_Progress.d.ts +0 -12
  33. package/esm/typings/src/remote-server/interfaces/PromptbookServer_Prompt_Request.d.ts +0 -45
  34. package/esm/typings/src/remote-server/interfaces/RemoteLlmExecutionToolsOptions.d.ts +0 -54
  35. /package/esm/typings/src/remote-server/{interfaces → types}/RemoteServerOptions.d.ts +0 -0
@@ -1,12 +1,14 @@
1
+ import { SetRequired } from 'type-fest';
1
2
  import type { string_formfactor_name } from '../../formfactors/_common/string_formfactor_name';
2
3
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
4
+ import type { NonEmptyReadonlyArray } from '../../types/NonEmptyArray';
3
5
  /**
4
6
  * @@@
5
7
  *
6
8
  * @singleton
7
9
  * @private internal cache of `getBookTemplate`
8
10
  */
9
- export declare let pipelines: Array<PipelineJson> | null;
11
+ export declare let pipelines: Array<SetRequired<PipelineJson, 'pipelineUrl'>> | null;
10
12
  /**
11
13
  * Get template for new book
12
14
  *
@@ -14,9 +16,9 @@ export declare let pipelines: Array<PipelineJson> | null;
14
16
  * @returns list of pipelines
15
17
  * @public exported from `@promptbook/templates`
16
18
  */
17
- export declare function getBookTemplates(formfactorName?: string_formfactor_name): ReadonlyArray<PipelineJson>;
19
+ export declare function getBookTemplates(formfactorName?: string_formfactor_name): NonEmptyReadonlyArray<SetRequired<PipelineJson, 'pipelineUrl'>>;
18
20
  /**
19
- * TODO: Unit test
21
+ * TODO: Unit test + test that what we guarantee - always return non-empty array is true for e
20
22
  * TODO: [🧠] Which is the best place for this function
21
23
  * TODO: !!6 For GENERIC template ensure at least one pipeline is present for typescript in `getBookTemplates`
22
24
  */
@@ -1,5 +1,5 @@
1
- import type { RemoteServerOptions } from '../remote-server/interfaces/RemoteServerOptions';
2
1
  import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
2
+ import type { RemoteClientOptions } from '../remote-server/types/RemoteClientOptions';
3
3
  /**
4
4
  * Prepare pipeline on remote server
5
5
  *
@@ -11,4 +11,7 @@ import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
11
11
  *
12
12
  * @public exported from `@promptbook/remote-client`
13
13
  */
14
- export declare function preparePipelineOnRemoteServer<TCustomOptions = undefined>(pipeline: PipelineJson, options: RemoteServerOptions<TCustomOptions>): Promise<PipelineJson>;
14
+ export declare function preparePipelineOnRemoteServer<TCustomOptions = undefined>(pipeline: PipelineJson, options: RemoteClientOptions<TCustomOptions>): Promise<PipelineJson>;
15
+ /**
16
+ * TODO: !!!! Do not return Promise<PipelineJson> But PreparePipelineTask
17
+ */
@@ -0,0 +1,10 @@
1
+ import type { Socket } from 'socket.io-client';
2
+ import type { RemoteClientOptions } from './types/RemoteClientOptions';
3
+ /**
4
+ * Creates a connection to the remote proxy server.
5
+ *
6
+ * Note: This function creates a connection to the remote server and returns a socket but responsibility of closing the connection is on the caller
7
+ *
8
+ * @private internal utility function
9
+ */
10
+ export declare function createRemoteClient<TCustomOptions = undefined>(options: RemoteClientOptions<TCustomOptions>): Promise<Socket>;
@@ -1,7 +1,7 @@
1
- import type { ErrorJson } from '../../errors/utils/ErrorJson';
1
+ import type { ErrorJson } from '../../../errors/utils/ErrorJson';
2
2
  /**
3
- * Socket.io error for remote text generation
4
- *
5
3
  * This is sent from server to client when error occurs and stops the process
4
+ *
5
+ * @private internal type of remote server
6
6
  */
7
7
  export type PromptbookServer_Error = ErrorJson;
@@ -0,0 +1,10 @@
1
+ import type { TaskProgress } from '../../../types/TaskProgress';
2
+ /**
3
+ * This is sent from server to client as indication of prograss arbitrarily and may be sent multiple times
4
+ *
5
+ * @private internal type of remote server
6
+ */
7
+ export type PromptbookServer_Progress = TaskProgress;
8
+ /**
9
+ * TODO: `PromptbookServer_Progress` is unused for now, but it will be used in the future
10
+ */
@@ -0,0 +1,49 @@
1
+ import type { LlmToolsConfiguration } from '../../../llm-providers/_common/register/LlmToolsConfiguration';
2
+ import type { string_user_id } from '../../../types/typeAliases';
3
+ import type { ApplicationRemoteServerClientOptions } from '../../types/RemoteServerOptions';
4
+ /**
5
+ * Identification of client for Socket.io remote server
6
+ *
7
+ * @public exported from `@promptbook/remote-server`
8
+ * @public exported from `@promptbook/remote-client`
9
+ */
10
+ export type PromptbookServer_Identification<TCustomOptions> = PromptbookServer_ApplicationIdentification<TCustomOptions> | PromptbookServer_AnonymousIdentification;
11
+ /**
12
+ * Application mode is @@@!!!
13
+ *
14
+ * @public exported from `@promptbook/remote-server`
15
+ * @public exported from `@promptbook/remote-client`
16
+ */
17
+ export type PromptbookServer_ApplicationIdentification<TCustomOptions> = ApplicationRemoteServerClientOptions<TCustomOptions> & {
18
+ /**
19
+ * Application mode
20
+ */
21
+ readonly isAnonymous: false;
22
+ };
23
+ /**
24
+ * Anonymous mode is @@@!!!
25
+ *
26
+ * @public exported from `@promptbook/remote-server`
27
+ * @public exported from `@promptbook/remote-client`
28
+ */
29
+ export type PromptbookServer_AnonymousIdentification = {
30
+ /**
31
+ * Anonymous mode
32
+ */
33
+ readonly isAnonymous: true;
34
+ /**
35
+ * Identifier of the end user
36
+ *
37
+ * Note: this is passed to the certain model providers to identify misuse
38
+ * Note: In anonymous mode, there is no need to identify yourself, nor does it change the actual configuration of LLM Tools (unlike in application mode)
39
+ */
40
+ readonly userId?: string_user_id;
41
+ /**
42
+ * Configuration for the LLM tools
43
+ */
44
+ readonly llmToolsConfiguration: LlmToolsConfiguration;
45
+ };
46
+ /**
47
+ * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
48
+ * TODO: [🧠][🤺] Maybe allow overriding of `userId` for each prompt - Pass `userId` in `PromptbookServer_ListModels_Request`
49
+ */
@@ -0,0 +1,17 @@
1
+ import type { PromptbookServer_Identification } from '../_subtypes/PromptbookServer_Identification';
2
+ /**
3
+ * List models available in the server
4
+ *
5
+ * This is a request from client to server
6
+ *
7
+ * @private internal type of remote server
8
+ */
9
+ export type PromptbookServer_ListModels_Request<TCustomOptions> = {
10
+ /**
11
+ * Identifier of the end user or application
12
+ */
13
+ readonly identification: PromptbookServer_Identification<TCustomOptions>;
14
+ };
15
+ /**
16
+ * TODO: [🧠] Listing models inanonymous mode does not make sence - keeping only to preserve consistency
17
+ */
@@ -1,8 +1,10 @@
1
- import type { AvailableModel } from '../../execution/AvailableModel';
1
+ import type { AvailableModel } from '../../../execution/AvailableModel';
2
2
  /**
3
- * Socket.io error for remote text generation
3
+ * Models available for use in the server
4
4
  *
5
5
  * This is sent from server to client when models are listed
6
+ *
7
+ * @private internal type of remote server
6
8
  */
7
9
  export type PromptbookServer_ListModels_Response = {
8
10
  /**
@@ -0,0 +1,17 @@
1
+ import type { PipelineJson } from '../../../pipeline/PipelineJson/PipelineJson';
2
+ import type { PromptbookServer_Identification } from '../_subtypes/PromptbookServer_Identification';
3
+ /**
4
+ * This is a request from client to server to prepare a pipeline
5
+ *
6
+ * @private internal type of remote server
7
+ */
8
+ export type PromptbookServer_PreparePipeline_Request<TCustomOptions> = {
9
+ /**
10
+ * Identifier of the end user or application
11
+ */
12
+ readonly identification: PromptbookServer_Identification<TCustomOptions>;
13
+ /**
14
+ * The Pipeline to prepare
15
+ */
16
+ readonly pipeline: PipelineJson;
17
+ };
@@ -0,0 +1,12 @@
1
+ import type { PipelineJson } from '../../../pipeline/PipelineJson/PipelineJson';
2
+ /**
3
+ * This is sent from server to client when the pipeline is prepared
4
+ *
5
+ * @private internal type of remote server
6
+ */
7
+ export type PromptbookServer_PreparePipeline_Response = {
8
+ /**
9
+ * Prepared pipeline
10
+ */
11
+ readonly preparedPipeline: PipelineJson;
12
+ };
@@ -0,0 +1,17 @@
1
+ import type { Prompt } from '../../../types/Prompt';
2
+ import type { PromptbookServer_Identification } from '../_subtypes/PromptbookServer_Identification';
3
+ /**
4
+ * This is a request from client to server to execute a prompt
5
+ *
6
+ * @private internal type of remote server
7
+ */
8
+ export type PromptbookServer_Prompt_Request<TCustomOptions> = {
9
+ /**
10
+ * Identifier of the end user or application
11
+ */
12
+ readonly identification: PromptbookServer_Identification<TCustomOptions>;
13
+ /**
14
+ * The Prompt to execute
15
+ */
16
+ readonly prompt: Prompt;
17
+ };
@@ -1,8 +1,8 @@
1
- import type { PromptResult } from '../../execution/PromptResult';
1
+ import type { PromptResult } from '../../../execution/PromptResult';
2
2
  /**
3
- * Socket.io error for remote text generation
4
- *
5
3
  * This is sent from server to client when the generated text is completed
4
+ *
5
+ * @private internal type of remote server
6
6
  */
7
7
  export type PromptbookServer_Prompt_Response = {
8
8
  /**
@@ -1,5 +1,5 @@
1
1
  import type { IDestroyable } from 'destroyable';
2
- import type { RemoteServerOptions } from './interfaces/RemoteServerOptions';
2
+ import type { RemoteServerOptions } from './types/RemoteServerOptions';
3
3
  /**
4
4
  * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
5
5
  *
@@ -11,6 +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: Split this file into multiple functions - handler for each request
14
15
  * TODO: Maybe use `$exportJson`
15
16
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
16
17
  * TODO: [⚖] Expose the collection to be able to connect to same collection via createCollectionFromUrl
@@ -19,5 +20,5 @@ export declare function startRemoteServer<TCustomOptions = undefined>(options: R
19
20
  * TODO: [🗯] Timeout on chat to free up resources
20
21
  * TODO: [🃏] Pass here some security token to prevent malitious usage and/or DDoS
21
22
  * TODO: [0] Set unavailable models as undefined in `RemoteLlmExecutionTools` NOT throw error here
22
- * TODO: Constrain anonymous mode for specific models / providers
23
+ * TODO: Allow to constrain anonymous mode for specific models / providers
23
24
  */
@@ -0,0 +1,32 @@
1
+ import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
2
+ import type { string_base_url } from '../../types/typeAliases';
3
+ import type { string_uri } from '../../types/typeAliases';
4
+ import type { PromptbookServer_Identification } from '../socket-types/_subtypes/PromptbookServer_Identification';
5
+ /**
6
+ * Options for `RemoteLlmExecutionTools`
7
+ *
8
+ * @public exported from `@promptbook/remote-client`
9
+ */
10
+ export type RemoteClientOptions<TCustomOptions> = CommonToolsOptions & {
11
+ /**
12
+ * URL of the remote server
13
+ * On this server will be connected to the socket.io server
14
+ */
15
+ readonly remoteUrl: string_base_url;
16
+ /**
17
+ * Path for the Socket.io server to listen
18
+ *
19
+ * @default '/socket.io'
20
+ * @example '/promptbook/socket.io'
21
+ */
22
+ readonly path: string_uri;
23
+ /**
24
+ * Identification of client for Socket.io remote server
25
+ */
26
+ readonly identification: PromptbookServer_Identification<TCustomOptions>;
27
+ };
28
+ /**
29
+ * TODO: Pass more options from Socket.io to `RemoteClientOptions` (like `transports`)
30
+ * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
31
+ * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
32
+ */
@@ -5,6 +5,7 @@
5
5
  * 2) Undefined represents empty array
6
6
  * 3) Array represents itself
7
7
  *
8
+ * @deprecated Use `Arrayable` from `type-fest` instead
8
9
  * @private internal type
9
10
  */
10
11
  export type Arrayable<TItem> = TItem | ReadonlyArray<TItem> | undefined;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Represents an array that is guaranteed to have at least one element
3
+ */
4
+ export type NonEmptyArray<TItem> = [TItem, ...TItem[]];
5
+ /**
6
+ * Represents an array that is guaranteed to have at least one element and is readonly
7
+ */
8
+ export type NonEmptyReadonlyArray<TItem> = ReadonlyArray<TItem> & NonEmptyArray<TItem>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/openai",
3
- "version": "0.82.0-0",
3
+ "version": "0.82.0-3",
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/openai.index.d.ts",
56
56
  "peerDependencies": {
57
- "@promptbook/core": "0.82.0-0"
57
+ "@promptbook/core": "0.82.0-3"
58
58
  },
59
59
  "dependencies": {
60
60
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -24,7 +24,7 @@
24
24
  * @generated
25
25
  * @see https://github.com/webgptorg/promptbook
26
26
  */
27
- var PROMPTBOOK_ENGINE_VERSION = '0.81.0-23';
27
+ var PROMPTBOOK_ENGINE_VERSION = '0.82.0-2';
28
28
  /**
29
29
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
30
30
  * Note: [💞] Ignore a discrepancy between file name and entity name