@promptbook/remote-server 0.81.0 → 0.82.0-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/esm/index.es.js +6136 -807
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/remote-client.index.d.ts +14 -4
- package/esm/typings/src/_packages/remote-server.index.d.ts +9 -3
- package/esm/typings/src/_packages/types.index.d.ts +20 -30
- package/esm/typings/src/collection/PipelineCollection.d.ts +2 -0
- package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +21 -0
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +2 -2
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +3 -7
- package/esm/typings/src/other/templates/getBookTemplates.d.ts +5 -3
- package/esm/typings/src/prepare/preparePipeline.d.ts +2 -2
- package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +17 -0
- package/esm/typings/src/remote-server/createRemoteClient.d.ts +10 -0
- package/esm/typings/src/{llm-providers/remote/interfaces → remote-server/socket-types/_common}/PromptbookServer_Error.d.ts +2 -2
- package/esm/typings/src/remote-server/socket-types/_common/PromptbookServer_Progress.d.ts +10 -0
- package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts +49 -0
- package/esm/typings/src/remote-server/socket-types/listModels/PromptbookServer_ListModels_Request.d.ts +17 -0
- package/esm/typings/src/{llm-providers/remote/interfaces → remote-server/socket-types/listModels}/PromptbookServer_ListModels_Response.d.ts +3 -1
- package/esm/typings/src/remote-server/socket-types/prepare/PromptbookServer_PreparePipeline_Request.d.ts +17 -0
- package/esm/typings/src/remote-server/socket-types/prepare/PromptbookServer_PreparePipeline_Response.d.ts +12 -0
- package/esm/typings/src/remote-server/socket-types/prompt/PromptbookServer_Prompt_Request.d.ts +17 -0
- package/esm/typings/src/{llm-providers/remote/interfaces → remote-server/socket-types/prompt}/PromptbookServer_Prompt_Response.d.ts +2 -2
- package/esm/typings/src/{llm-providers/remote → remote-server}/startRemoteServer.d.ts +3 -2
- package/esm/typings/src/remote-server/types/RemoteClientOptions.d.ts +32 -0
- package/esm/typings/src/{llm-providers/remote/interfaces → remote-server/types}/RemoteServerOptions.d.ts +10 -10
- package/esm/typings/src/types/Arrayable.d.ts +1 -0
- package/esm/typings/src/types/NonEmptyArray.d.ts +8 -0
- package/package.json +8 -3
- package/umd/index.umd.js +6131 -811
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Request.d.ts +0 -38
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Progress.d.ts +0 -12
- package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Request.d.ts +0 -45
- package/esm/typings/src/llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions.d.ts +0 -54
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
2
|
-
import
|
|
3
|
-
import type { RemoteServerOptions } from '../llm-providers/remote/interfaces/RemoteServerOptions';
|
|
2
|
+
import { compilePipelineOnRemoteServer } from '../conversion/compilePipelineOnRemoteServer';
|
|
4
3
|
import { RemoteLlmExecutionTools } from '../llm-providers/remote/RemoteLlmExecutionTools';
|
|
4
|
+
import { preparePipelineOnRemoteServer } from '../prepare/preparePipelineOnRemoteServer';
|
|
5
|
+
import type { PromptbookServer_Identification } from '../remote-server/socket-types/_subtypes/PromptbookServer_Identification';
|
|
6
|
+
import type { PromptbookServer_ApplicationIdentification } from '../remote-server/socket-types/_subtypes/PromptbookServer_Identification';
|
|
7
|
+
import type { PromptbookServer_AnonymousIdentification } from '../remote-server/socket-types/_subtypes/PromptbookServer_Identification';
|
|
8
|
+
import type { RemoteClientOptions } from '../remote-server/types/RemoteClientOptions';
|
|
9
|
+
import type { RemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
|
|
5
10
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
6
|
-
export
|
|
7
|
-
export type { RemoteServerOptions };
|
|
11
|
+
export { compilePipelineOnRemoteServer };
|
|
8
12
|
export { RemoteLlmExecutionTools };
|
|
13
|
+
export { preparePipelineOnRemoteServer };
|
|
14
|
+
export type { PromptbookServer_Identification };
|
|
15
|
+
export type { PromptbookServer_ApplicationIdentification };
|
|
16
|
+
export type { PromptbookServer_AnonymousIdentification };
|
|
17
|
+
export type { RemoteClientOptions };
|
|
18
|
+
export type { RemoteServerOptions };
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
2
|
+
import type { PromptbookServer_Identification } from '../remote-server/socket-types/_subtypes/PromptbookServer_Identification';
|
|
3
|
+
import type { PromptbookServer_ApplicationIdentification } from '../remote-server/socket-types/_subtypes/PromptbookServer_Identification';
|
|
4
|
+
import type { PromptbookServer_AnonymousIdentification } from '../remote-server/socket-types/_subtypes/PromptbookServer_Identification';
|
|
5
|
+
import { startRemoteServer } from '../remote-server/startRemoteServer';
|
|
6
|
+
import type { RemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
|
|
4
7
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
5
|
-
export type {
|
|
8
|
+
export type { PromptbookServer_Identification };
|
|
9
|
+
export type { PromptbookServer_ApplicationIdentification };
|
|
10
|
+
export type { PromptbookServer_AnonymousIdentification };
|
|
6
11
|
export { startRemoteServer };
|
|
12
|
+
export type { RemoteServerOptions };
|
|
@@ -60,21 +60,6 @@ import type { AzureOpenAiExecutionToolsOptions } from '../llm-providers/azure-op
|
|
|
60
60
|
import type { GoogleExecutionToolsOptions } from '../llm-providers/google/GoogleExecutionToolsOptions';
|
|
61
61
|
import type { OpenAiAssistantExecutionToolsOptions } from '../llm-providers/openai/OpenAiAssistantExecutionToolsOptions';
|
|
62
62
|
import type { OpenAiExecutionToolsOptions } from '../llm-providers/openai/OpenAiExecutionToolsOptions';
|
|
63
|
-
import type { PromptbookServer_Error } from '../llm-providers/remote/interfaces/PromptbookServer_Error';
|
|
64
|
-
import type { PromptbookServer_ListModels_Request } from '../llm-providers/remote/interfaces/PromptbookServer_ListModels_Request';
|
|
65
|
-
import type { PromptbookServer_ListModels_CollectionRequest } from '../llm-providers/remote/interfaces/PromptbookServer_ListModels_Request';
|
|
66
|
-
import type { PromptbookServer_ListModels_AnonymousRequest } from '../llm-providers/remote/interfaces/PromptbookServer_ListModels_Request';
|
|
67
|
-
import type { PromptbookServer_ListModels_Response } from '../llm-providers/remote/interfaces/PromptbookServer_ListModels_Response';
|
|
68
|
-
import type { PromptbookServer_Prompt_Progress } from '../llm-providers/remote/interfaces/PromptbookServer_Prompt_Progress';
|
|
69
|
-
import type { PromptbookServer_Prompt_Request } from '../llm-providers/remote/interfaces/PromptbookServer_Prompt_Request';
|
|
70
|
-
import type { PromptbookServer_Prompt_CollectionRequest } from '../llm-providers/remote/interfaces/PromptbookServer_Prompt_Request';
|
|
71
|
-
import type { PromptbookServer_Prompt_AnonymousRequest } from '../llm-providers/remote/interfaces/PromptbookServer_Prompt_Request';
|
|
72
|
-
import type { PromptbookServer_Prompt_Response } from '../llm-providers/remote/interfaces/PromptbookServer_Prompt_Response';
|
|
73
|
-
import type { RemoteLlmExecutionToolsOptions } from '../llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions';
|
|
74
|
-
import type { RemoteServerOptions } from '../llm-providers/remote/interfaces/RemoteServerOptions';
|
|
75
|
-
import type { AnonymousRemoteServerOptions } from '../llm-providers/remote/interfaces/RemoteServerOptions';
|
|
76
|
-
import type { CollectionRemoteServerOptions } from '../llm-providers/remote/interfaces/RemoteServerOptions';
|
|
77
|
-
import type { CollectionRemoteServerClientOptions } from '../llm-providers/remote/interfaces/RemoteServerOptions';
|
|
78
63
|
import type { VercelExecutionToolsOptions } from '../llm-providers/vercel/VercelExecutionToolsOptions';
|
|
79
64
|
import type { VercelProvider } from '../llm-providers/vercel/VercelProvider';
|
|
80
65
|
import type { IsPipelineImplementingInterfaceOptions } from '../pipeline/PipelineInterface/isPipelineImplementingInterface';
|
|
@@ -102,6 +87,14 @@ import type { SimpleTaskJson } from '../pipeline/PipelineJson/SimpleTaskJson';
|
|
|
102
87
|
import type { TaskJson } from '../pipeline/PipelineJson/TaskJson';
|
|
103
88
|
import type { PipelineString } from '../pipeline/PipelineString';
|
|
104
89
|
import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions';
|
|
90
|
+
import type { PromptbookServer_Identification } from '../remote-server/socket-types/_subtypes/PromptbookServer_Identification';
|
|
91
|
+
import type { PromptbookServer_ApplicationIdentification } from '../remote-server/socket-types/_subtypes/PromptbookServer_Identification';
|
|
92
|
+
import type { PromptbookServer_AnonymousIdentification } from '../remote-server/socket-types/_subtypes/PromptbookServer_Identification';
|
|
93
|
+
import type { RemoteClientOptions } from '../remote-server/types/RemoteClientOptions';
|
|
94
|
+
import type { RemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
|
|
95
|
+
import type { AnonymousRemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
|
|
96
|
+
import type { ApplicationRemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
|
|
97
|
+
import type { ApplicationRemoteServerClientOptions } from '../remote-server/types/RemoteServerOptions';
|
|
105
98
|
import type { Converter } from '../scrapers/_common/Converter';
|
|
106
99
|
import type { ScraperAndConverterMetadata } from '../scrapers/_common/register/ScraperAndConverterMetadata';
|
|
107
100
|
import type { ScraperConstructor } from '../scrapers/_common/register/ScraperConstructor';
|
|
@@ -118,6 +111,8 @@ import type { CompletionModelRequirements } from '../types/ModelRequirements';
|
|
|
118
111
|
import type { ChatModelRequirements } from '../types/ModelRequirements';
|
|
119
112
|
import type { EmbeddingModelRequirements } from '../types/ModelRequirements';
|
|
120
113
|
import type { ModelVariant } from '../types/ModelVariant';
|
|
114
|
+
import type { NonEmptyArray } from '../types/NonEmptyArray';
|
|
115
|
+
import type { NonEmptyReadonlyArray } from '../types/NonEmptyArray';
|
|
121
116
|
import type { Prompt } from '../types/Prompt';
|
|
122
117
|
import type { CompletionPrompt } from '../types/Prompt';
|
|
123
118
|
import type { ChatPrompt } from '../types/Prompt';
|
|
@@ -326,21 +321,6 @@ export type { AzureOpenAiExecutionToolsOptions };
|
|
|
326
321
|
export type { GoogleExecutionToolsOptions };
|
|
327
322
|
export type { OpenAiAssistantExecutionToolsOptions };
|
|
328
323
|
export type { OpenAiExecutionToolsOptions };
|
|
329
|
-
export type { PromptbookServer_Error };
|
|
330
|
-
export type { PromptbookServer_ListModels_Request };
|
|
331
|
-
export type { PromptbookServer_ListModels_CollectionRequest };
|
|
332
|
-
export type { PromptbookServer_ListModels_AnonymousRequest };
|
|
333
|
-
export type { PromptbookServer_ListModels_Response };
|
|
334
|
-
export type { PromptbookServer_Prompt_Progress };
|
|
335
|
-
export type { PromptbookServer_Prompt_Request };
|
|
336
|
-
export type { PromptbookServer_Prompt_CollectionRequest };
|
|
337
|
-
export type { PromptbookServer_Prompt_AnonymousRequest };
|
|
338
|
-
export type { PromptbookServer_Prompt_Response };
|
|
339
|
-
export type { RemoteLlmExecutionToolsOptions };
|
|
340
|
-
export type { RemoteServerOptions };
|
|
341
|
-
export type { AnonymousRemoteServerOptions };
|
|
342
|
-
export type { CollectionRemoteServerOptions };
|
|
343
|
-
export type { CollectionRemoteServerClientOptions };
|
|
344
324
|
export type { VercelExecutionToolsOptions };
|
|
345
325
|
export type { VercelProvider };
|
|
346
326
|
export type { IsPipelineImplementingInterfaceOptions };
|
|
@@ -368,6 +348,14 @@ export type { SimpleTaskJson };
|
|
|
368
348
|
export type { TaskJson };
|
|
369
349
|
export type { PipelineString };
|
|
370
350
|
export type { PrepareAndScrapeOptions };
|
|
351
|
+
export type { PromptbookServer_Identification };
|
|
352
|
+
export type { PromptbookServer_ApplicationIdentification };
|
|
353
|
+
export type { PromptbookServer_AnonymousIdentification };
|
|
354
|
+
export type { RemoteClientOptions };
|
|
355
|
+
export type { RemoteServerOptions };
|
|
356
|
+
export type { AnonymousRemoteServerOptions };
|
|
357
|
+
export type { ApplicationRemoteServerOptions };
|
|
358
|
+
export type { ApplicationRemoteServerClientOptions };
|
|
371
359
|
export type { Converter };
|
|
372
360
|
export type { ScraperAndConverterMetadata };
|
|
373
361
|
export type { ScraperConstructor };
|
|
@@ -384,6 +372,8 @@ export type { CompletionModelRequirements };
|
|
|
384
372
|
export type { ChatModelRequirements };
|
|
385
373
|
export type { EmbeddingModelRequirements };
|
|
386
374
|
export type { ModelVariant };
|
|
375
|
+
export type { NonEmptyArray };
|
|
376
|
+
export type { NonEmptyReadonlyArray };
|
|
387
377
|
export type { Prompt };
|
|
388
378
|
export type { CompletionPrompt };
|
|
389
379
|
export type { ChatPrompt };
|
|
@@ -20,6 +20,8 @@ export type PipelineCollection = {
|
|
|
20
20
|
getPipelineByUrl(url: string_pipeline_url): Promisable<PipelineJson>;
|
|
21
21
|
/**
|
|
22
22
|
* Checks whether given prompt was defined in any pipeline in the collection
|
|
23
|
+
*
|
|
24
|
+
* @deprecated Make better mechanism for skimming the remote server
|
|
23
25
|
*/
|
|
24
26
|
isResponsibleForPrompt(prompt: Prompt): Promisable<boolean>;
|
|
25
27
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
|
|
2
|
+
import type { PipelineString } from '../pipeline/PipelineString';
|
|
3
|
+
import type { RemoteClientOptions } from '../remote-server/types/RemoteClientOptions';
|
|
4
|
+
/**
|
|
5
|
+
* Compile pipeline from string (markdown) format to JSON format
|
|
6
|
+
*
|
|
7
|
+
* @see https://github.com/webgptorg/promptbook/discussions/196
|
|
8
|
+
*
|
|
9
|
+
* Note: This function does not validate logic of the pipeline only the parsing
|
|
10
|
+
* Note: This function acts as compilation process
|
|
11
|
+
*
|
|
12
|
+
* @param pipelineString {Promptbook} in string markdown format (.book.md)
|
|
13
|
+
* @param options - Configuration of the remote server
|
|
14
|
+
* @returns {Promptbook} compiled in JSON format (.book.json)
|
|
15
|
+
* @throws {ParseError} if the promptbook string is not valid
|
|
16
|
+
* @public exported from `@promptbook/remote-client`
|
|
17
|
+
*/
|
|
18
|
+
export declare function compilePipelineOnRemoteServer<TCustomOptions = undefined>(pipelineString: PipelineString, options: RemoteClientOptions<TCustomOptions>): Promise<PipelineJson>;
|
|
19
|
+
/**
|
|
20
|
+
* TODO: !!!! Do not return Promise<PipelineJson> But PreparePipelineTask
|
|
21
|
+
*/
|
package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ClientOptions } from '@anthropic-ai/sdk';
|
|
2
2
|
import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
|
|
3
|
-
import type {
|
|
3
|
+
import type { RemoteClientOptions } from '../../remote-server/types/RemoteClientOptions';
|
|
4
4
|
/**
|
|
5
5
|
* Options for `AnthropicClaudeExecutionTools`
|
|
6
6
|
*
|
|
@@ -25,7 +25,7 @@ export type AnthropicClaudeExecutionToolsDirectOptions = CommonToolsOptions & Cl
|
|
|
25
25
|
*/
|
|
26
26
|
export type AnthropicClaudeExecutionToolsProxiedOptions = CommonToolsOptions & ClientOptions & {
|
|
27
27
|
isProxied: true;
|
|
28
|
-
} & Pick<
|
|
28
|
+
} & Pick<RemoteClientOptions<undefined>, 'remoteUrl' | 'path'>;
|
|
29
29
|
/**
|
|
30
30
|
* TODO: [🧠][🤺] Pass `userId`
|
|
31
31
|
*/
|
|
@@ -3,13 +3,13 @@ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
|
3
3
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
4
4
|
import type { CompletionPromptResult } from '../../execution/PromptResult';
|
|
5
5
|
import type { EmbeddingPromptResult } from '../../execution/PromptResult';
|
|
6
|
+
import type { RemoteClientOptions } from '../../remote-server/types/RemoteClientOptions';
|
|
6
7
|
import type { ChatPrompt } from '../../types/Prompt';
|
|
7
8
|
import type { CompletionPrompt } from '../../types/Prompt';
|
|
8
9
|
import type { EmbeddingPrompt } from '../../types/Prompt';
|
|
9
10
|
import type { string_markdown } from '../../types/typeAliases';
|
|
10
11
|
import type { string_markdown_text } from '../../types/typeAliases';
|
|
11
12
|
import type { string_title } from '../../types/typeAliases';
|
|
12
|
-
import type { RemoteLlmExecutionToolsOptions } from './interfaces/RemoteLlmExecutionToolsOptions';
|
|
13
13
|
/**
|
|
14
14
|
* Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
|
|
15
15
|
*
|
|
@@ -20,8 +20,8 @@ import type { RemoteLlmExecutionToolsOptions } from './interfaces/RemoteLlmExecu
|
|
|
20
20
|
* @public exported from `@promptbook/remote-client`
|
|
21
21
|
*/
|
|
22
22
|
export declare class RemoteLlmExecutionTools<TCustomOptions = undefined> implements LlmExecutionTools {
|
|
23
|
-
protected readonly options:
|
|
24
|
-
constructor(options:
|
|
23
|
+
protected readonly options: RemoteClientOptions<TCustomOptions>;
|
|
24
|
+
constructor(options: RemoteClientOptions<TCustomOptions>);
|
|
25
25
|
get title(): string_title & string_markdown_text;
|
|
26
26
|
get description(): string_markdown;
|
|
27
27
|
/**
|
|
@@ -32,10 +32,6 @@ export declare class RemoteLlmExecutionTools<TCustomOptions = undefined> impleme
|
|
|
32
32
|
* List all available models that can be used
|
|
33
33
|
*/
|
|
34
34
|
listModels(): Promise<ReadonlyArray<AvailableModel>>;
|
|
35
|
-
/**
|
|
36
|
-
* Creates a connection to the remote proxy server.
|
|
37
|
-
*/
|
|
38
|
-
private makeConnection;
|
|
39
35
|
/**
|
|
40
36
|
* Calls remote proxy server to use a chat model
|
|
41
37
|
*/
|
|
@@ -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
|
|
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):
|
|
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
|
*/
|
|
@@ -2,7 +2,7 @@ import type { ExecutionTools } from '../execution/ExecutionTools';
|
|
|
2
2
|
import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
|
|
3
3
|
import type { PrepareAndScrapeOptions } from './PrepareAndScrapeOptions';
|
|
4
4
|
/**
|
|
5
|
-
* Prepare pipeline
|
|
5
|
+
* Prepare pipeline locally
|
|
6
6
|
*
|
|
7
7
|
* @see https://github.com/webgptorg/promptbook/discussions/196
|
|
8
8
|
*
|
|
@@ -13,7 +13,7 @@ import type { PrepareAndScrapeOptions } from './PrepareAndScrapeOptions';
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function preparePipeline(pipeline: PipelineJson, tools: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>, options: PrepareAndScrapeOptions): Promise<PipelineJson>;
|
|
15
15
|
/**
|
|
16
|
-
* TODO: Write tests for `preparePipeline`
|
|
16
|
+
* TODO: Write tests for `preparePipeline` and `preparePipelineOnRemoteServer`
|
|
17
17
|
* TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
|
|
18
18
|
* TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
|
|
19
19
|
* TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
|
|
2
|
+
import type { RemoteClientOptions } from '../remote-server/types/RemoteClientOptions';
|
|
3
|
+
/**
|
|
4
|
+
* Prepare pipeline on remote server
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/webgptorg/promptbook/discussions/196
|
|
7
|
+
*
|
|
8
|
+
* Note: This function does not validate logic of the pipeline
|
|
9
|
+
* Note: This function acts as part of compilation process
|
|
10
|
+
* Note: When the pipeline is already prepared, it returns the same pipeline
|
|
11
|
+
*
|
|
12
|
+
* @public exported from `@promptbook/remote-client`
|
|
13
|
+
*/
|
|
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
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
|
+
*/
|
package/esm/typings/src/remote-server/socket-types/_subtypes/PromptbookServer_Identification.d.ts
ADDED
|
@@ -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
1
|
import type { AvailableModel } from '../../../execution/AvailableModel';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
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
|
+
};
|
package/esm/typings/src/remote-server/socket-types/prompt/PromptbookServer_Prompt_Request.d.ts
ADDED
|
@@ -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
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 './
|
|
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:
|
|
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
|
+
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Promisable } from 'type-fest';
|
|
2
|
-
import type { PipelineCollection } from '
|
|
3
|
-
import type { CommonToolsOptions } from '
|
|
4
|
-
import type { LlmExecutionTools } from '
|
|
5
|
-
import type { string_app_id } from '
|
|
6
|
-
import type { string_uri } from '
|
|
7
|
-
import type { string_user_id } from '
|
|
2
|
+
import type { PipelineCollection } from '../../collection/PipelineCollection';
|
|
3
|
+
import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
|
|
4
|
+
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
5
|
+
import type { string_app_id } from '../../types/typeAliases';
|
|
6
|
+
import type { string_uri } from '../../types/typeAliases';
|
|
7
|
+
import type { string_user_id } from '../../types/typeAliases';
|
|
8
8
|
/**
|
|
9
9
|
* @@@
|
|
10
10
|
*
|
|
@@ -31,14 +31,14 @@ export type RemoteServerOptions<TCustomOptions> = CommonToolsOptions & {
|
|
|
31
31
|
* @example '/promptbook/socket.io'
|
|
32
32
|
*/
|
|
33
33
|
readonly path: string_uri;
|
|
34
|
-
} & (AnonymousRemoteServerOptions |
|
|
34
|
+
} & (AnonymousRemoteServerOptions | ApplicationRemoteServerOptions<TCustomOptions> | (AnonymousRemoteServerOptions & ApplicationRemoteServerOptions<TCustomOptions>));
|
|
35
35
|
export type AnonymousRemoteServerOptions = {
|
|
36
36
|
/**
|
|
37
37
|
* Enable anonymous mode
|
|
38
38
|
*/
|
|
39
39
|
readonly isAnonymousModeAllowed: true;
|
|
40
40
|
};
|
|
41
|
-
export type
|
|
41
|
+
export type ApplicationRemoteServerOptions<TCustomOptions> = {
|
|
42
42
|
/**
|
|
43
43
|
* Enable application mode
|
|
44
44
|
*/
|
|
@@ -52,9 +52,9 @@ export type CollectionRemoteServerOptions<TCustomOptions> = {
|
|
|
52
52
|
/**
|
|
53
53
|
* Creates llm execution tools for each client
|
|
54
54
|
*/
|
|
55
|
-
createLlmExecutionTools(options:
|
|
55
|
+
createLlmExecutionTools(options: ApplicationRemoteServerClientOptions<TCustomOptions>): Promisable<LlmExecutionTools>;
|
|
56
56
|
};
|
|
57
|
-
export type
|
|
57
|
+
export type ApplicationRemoteServerClientOptions<TCustomOptions> = {
|
|
58
58
|
/**
|
|
59
59
|
* @@@
|
|
60
60
|
*/
|
|
@@ -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/remote-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.82.0-2",
|
|
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,11 +54,16 @@
|
|
|
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.
|
|
57
|
+
"@promptbook/core": "0.82.0-2"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"colors": "1.4.0",
|
|
61
|
+
"crypto-js": "4.2.0",
|
|
62
|
+
"papaparse": "5.4.1",
|
|
63
|
+
"prettier": "2.8.1",
|
|
61
64
|
"socket.io": "4.8.1",
|
|
62
|
-
"spacetrim": "0.11.59"
|
|
65
|
+
"spacetrim": "0.11.59",
|
|
66
|
+
"userhome": "1.0.1",
|
|
67
|
+
"waitasecond": "1.11.83"
|
|
63
68
|
}
|
|
64
69
|
}
|