@promptbook/node 0.89.0-8 → 0.89.0-9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +63 -27
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +4 -0
- package/esm/typings/src/_packages/remote-client.index.d.ts +6 -6
- package/esm/typings/src/_packages/remote-server.index.d.ts +6 -6
- package/esm/typings/src/_packages/types.index.d.ts +10 -18
- package/esm/typings/src/errors/0-index.d.ts +3 -0
- package/esm/typings/src/errors/PromptbookFetchError.d.ts +9 -0
- package/esm/typings/src/llm-providers/_common/register/$provideEnvFilepath.d.ts +12 -0
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +2 -8
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +2 -0
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizzardOrCli.d.ts +5 -3
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -0
- package/esm/typings/src/remote-server/socket-types/_subtypes/{PromptbookServer_Identification.d.ts → Identification.d.ts} +3 -3
- package/esm/typings/src/remote-server/socket-types/listModels/PromptbookServer_ListModels_Request.d.ts +2 -2
- package/esm/typings/src/remote-server/socket-types/prepare/PromptbookServer_PreparePipeline_Request.d.ts +2 -2
- package/esm/typings/src/remote-server/socket-types/prompt/PromptbookServer_Prompt_Request.d.ts +2 -2
- package/esm/typings/src/remote-server/types/RemoteClientOptions.d.ts +2 -2
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +43 -30
- package/esm/typings/src/scrapers/_common/utils/{scraperFetch.d.ts → promptbookFetch.d.ts} +2 -2
- package/package.json +2 -2
- package/umd/index.umd.js +63 -27
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/playground/BrjappConnector.d.ts +0 -67
- package/esm/typings/src/playground/brjapp-api-schema.d.ts +0 -12879
|
@@ -60,6 +60,7 @@ import { ParseError } from '../errors/ParseError';
|
|
|
60
60
|
import { PipelineExecutionError } from '../errors/PipelineExecutionError';
|
|
61
61
|
import { PipelineLogicError } from '../errors/PipelineLogicError';
|
|
62
62
|
import { PipelineUrlError } from '../errors/PipelineUrlError';
|
|
63
|
+
import { PromptbookFetchError } from '../errors/PromptbookFetchError';
|
|
63
64
|
import { UnexpectedError } from '../errors/UnexpectedError';
|
|
64
65
|
import { createPipelineExecutor } from '../execution/createPipelineExecutor/00-createPipelineExecutor';
|
|
65
66
|
import { embeddingVectorToString } from '../execution/embeddingVectorToString';
|
|
@@ -119,6 +120,7 @@ import { prepareKnowledgePieces } from '../scrapers/_common/prepareKnowledgePiec
|
|
|
119
120
|
import { $scrapersMetadataRegister } from '../scrapers/_common/register/$scrapersMetadataRegister';
|
|
120
121
|
import { $scrapersRegister } from '../scrapers/_common/register/$scrapersRegister';
|
|
121
122
|
import { makeKnowledgeSourceHandler } from '../scrapers/_common/utils/makeKnowledgeSourceHandler';
|
|
123
|
+
import { promptbookFetch } from '../scrapers/_common/utils/promptbookFetch';
|
|
122
124
|
import { _LegacyDocumentScraperMetadataRegistration } from '../scrapers/document-legacy/register-metadata';
|
|
123
125
|
import { _DocumentScraperMetadataRegistration } from '../scrapers/document/register-metadata';
|
|
124
126
|
import { _MarkdownScraperMetadataRegistration } from '../scrapers/markdown/register-metadata';
|
|
@@ -194,6 +196,7 @@ export { ParseError };
|
|
|
194
196
|
export { PipelineExecutionError };
|
|
195
197
|
export { PipelineLogicError };
|
|
196
198
|
export { PipelineUrlError };
|
|
199
|
+
export { PromptbookFetchError };
|
|
197
200
|
export { UnexpectedError };
|
|
198
201
|
export { createPipelineExecutor };
|
|
199
202
|
export { embeddingVectorToString };
|
|
@@ -253,6 +256,7 @@ export { prepareKnowledgePieces };
|
|
|
253
256
|
export { $scrapersMetadataRegister };
|
|
254
257
|
export { $scrapersRegister };
|
|
255
258
|
export { makeKnowledgeSourceHandler };
|
|
259
|
+
export { promptbookFetch };
|
|
256
260
|
export { _LegacyDocumentScraperMetadataRegistration };
|
|
257
261
|
export { _DocumentScraperMetadataRegistration };
|
|
258
262
|
export { _MarkdownScraperMetadataRegistration };
|
|
@@ -2,15 +2,15 @@ import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
|
2
2
|
import { compilePipelineOnRemoteServer } from '../conversion/compilePipelineOnRemoteServer';
|
|
3
3
|
import { RemoteLlmExecutionTools } from '../llm-providers/remote/RemoteLlmExecutionTools';
|
|
4
4
|
import { preparePipelineOnRemoteServer } from '../prepare/preparePipelineOnRemoteServer';
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
5
|
+
import type { Identification } from '../remote-server/socket-types/_subtypes/Identification';
|
|
6
|
+
import type { ApplicationModeIdentification } from '../remote-server/socket-types/_subtypes/Identification';
|
|
7
|
+
import type { AnonymousModeIdentification } from '../remote-server/socket-types/_subtypes/Identification';
|
|
8
8
|
import type { RemoteClientOptions } from '../remote-server/types/RemoteClientOptions';
|
|
9
9
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
10
10
|
export { compilePipelineOnRemoteServer };
|
|
11
11
|
export { RemoteLlmExecutionTools };
|
|
12
12
|
export { preparePipelineOnRemoteServer };
|
|
13
|
-
export type {
|
|
14
|
-
export type {
|
|
15
|
-
export type {
|
|
13
|
+
export type { Identification };
|
|
14
|
+
export type { ApplicationModeIdentification };
|
|
15
|
+
export type { AnonymousModeIdentification };
|
|
16
16
|
export type { RemoteClientOptions };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
2
|
+
import type { Identification } from '../remote-server/socket-types/_subtypes/Identification';
|
|
3
|
+
import type { ApplicationModeIdentification } from '../remote-server/socket-types/_subtypes/Identification';
|
|
4
|
+
import type { AnonymousModeIdentification } from '../remote-server/socket-types/_subtypes/Identification';
|
|
5
5
|
import { startRemoteServer } from '../remote-server/startRemoteServer';
|
|
6
6
|
import type { RemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
|
|
7
7
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
8
|
-
export type {
|
|
9
|
-
export type {
|
|
10
|
-
export type {
|
|
8
|
+
export type { Identification };
|
|
9
|
+
export type { ApplicationModeIdentification };
|
|
10
|
+
export type { AnonymousModeIdentification };
|
|
11
11
|
export { startRemoteServer };
|
|
12
12
|
export type { RemoteServerOptions };
|
|
@@ -106,22 +106,18 @@ import type { ScriptTaskJson } from '../pipeline/PipelineJson/ScriptTaskJson';
|
|
|
106
106
|
import type { SimpleTaskJson } from '../pipeline/PipelineJson/SimpleTaskJson';
|
|
107
107
|
import type { TaskJson } from '../pipeline/PipelineJson/TaskJson';
|
|
108
108
|
import type { PipelineString } from '../pipeline/PipelineString';
|
|
109
|
-
import type { paths } from '../playground/brjapp-api-schema';
|
|
110
|
-
import type { webhooks } from '../playground/brjapp-api-schema';
|
|
111
|
-
import type { components } from '../playground/brjapp-api-schema';
|
|
112
|
-
import type { $defs } from '../playground/brjapp-api-schema';
|
|
113
|
-
import type { operations } from '../playground/brjapp-api-schema';
|
|
114
109
|
import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions';
|
|
115
110
|
import type { RemoteServer } from '../remote-server/RemoteServer';
|
|
116
|
-
import type {
|
|
117
|
-
import type {
|
|
118
|
-
import type {
|
|
111
|
+
import type { Identification } from '../remote-server/socket-types/_subtypes/Identification';
|
|
112
|
+
import type { ApplicationModeIdentification } from '../remote-server/socket-types/_subtypes/Identification';
|
|
113
|
+
import type { AnonymousModeIdentification } from '../remote-server/socket-types/_subtypes/Identification';
|
|
119
114
|
import type { RemoteClientOptions } from '../remote-server/types/RemoteClientOptions';
|
|
120
115
|
import type { RemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
|
|
121
116
|
import type { AnonymousRemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
|
|
122
117
|
import type { ApplicationRemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
|
|
123
118
|
import type { ApplicationRemoteServerClientOptions } from '../remote-server/types/RemoteServerOptions';
|
|
124
|
-
import type {
|
|
119
|
+
import type { LoginRequest } from '../remote-server/types/RemoteServerOptions';
|
|
120
|
+
import type { LoginResponse } from '../remote-server/types/RemoteServerOptions';
|
|
125
121
|
import type { Converter } from '../scrapers/_common/Converter';
|
|
126
122
|
import type { ScraperAndConverterMetadata } from '../scrapers/_common/register/ScraperAndConverterMetadata';
|
|
127
123
|
import type { ScraperConstructor } from '../scrapers/_common/register/ScraperConstructor';
|
|
@@ -397,22 +393,18 @@ export type { ScriptTaskJson };
|
|
|
397
393
|
export type { SimpleTaskJson };
|
|
398
394
|
export type { TaskJson };
|
|
399
395
|
export type { PipelineString };
|
|
400
|
-
export type { paths };
|
|
401
|
-
export type { webhooks };
|
|
402
|
-
export type { components };
|
|
403
|
-
export type { $defs };
|
|
404
|
-
export type { operations };
|
|
405
396
|
export type { PrepareAndScrapeOptions };
|
|
406
397
|
export type { RemoteServer };
|
|
407
|
-
export type {
|
|
408
|
-
export type {
|
|
409
|
-
export type {
|
|
398
|
+
export type { Identification };
|
|
399
|
+
export type { ApplicationModeIdentification };
|
|
400
|
+
export type { AnonymousModeIdentification };
|
|
410
401
|
export type { RemoteClientOptions };
|
|
411
402
|
export type { RemoteServerOptions };
|
|
412
403
|
export type { AnonymousRemoteServerOptions };
|
|
413
404
|
export type { ApplicationRemoteServerOptions };
|
|
414
405
|
export type { ApplicationRemoteServerClientOptions };
|
|
415
|
-
export type {
|
|
406
|
+
export type { LoginRequest };
|
|
407
|
+
export type { LoginResponse };
|
|
416
408
|
export type { Converter };
|
|
417
409
|
export type { ScraperAndConverterMetadata };
|
|
418
410
|
export type { ScraperConstructor };
|
|
@@ -13,6 +13,7 @@ import { ParseError } from './ParseError';
|
|
|
13
13
|
import { PipelineExecutionError } from './PipelineExecutionError';
|
|
14
14
|
import { PipelineLogicError } from './PipelineLogicError';
|
|
15
15
|
import { PipelineUrlError } from './PipelineUrlError';
|
|
16
|
+
import { PromptbookFetchError } from './PromptbookFetchError';
|
|
16
17
|
import { UnexpectedError } from './UnexpectedError';
|
|
17
18
|
/**
|
|
18
19
|
* Index of all custom errors
|
|
@@ -51,6 +52,7 @@ export declare const COMMON_JAVASCRIPT_ERRORS: {
|
|
|
51
52
|
readonly URIError: URIErrorConstructor;
|
|
52
53
|
readonly AggregateError: AggregateErrorConstructor;
|
|
53
54
|
readonly AuthenticationError: typeof AuthenticationError;
|
|
55
|
+
readonly PromptbookFetchError: typeof PromptbookFetchError;
|
|
54
56
|
};
|
|
55
57
|
/**
|
|
56
58
|
* Index of all errors
|
|
@@ -67,6 +69,7 @@ export declare const ALL_ERRORS: {
|
|
|
67
69
|
readonly URIError: URIErrorConstructor;
|
|
68
70
|
readonly AggregateError: AggregateErrorConstructor;
|
|
69
71
|
readonly AuthenticationError: typeof AuthenticationError;
|
|
72
|
+
readonly PromptbookFetchError: typeof PromptbookFetchError;
|
|
70
73
|
readonly AbstractFormatError: typeof AbstractFormatError;
|
|
71
74
|
readonly CsvFormatError: typeof CsvFormatError;
|
|
72
75
|
readonly CollectionError: typeof CollectionError;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { string_filename } from '../../../types/typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Provides the path to the `.env` file
|
|
4
|
+
*
|
|
5
|
+
* Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access .env file
|
|
6
|
+
*
|
|
7
|
+
* @private within the repository - for CLI utils
|
|
8
|
+
*/
|
|
9
|
+
export declare function $provideEnvFilepath(): Promise<string_filename | null>;
|
|
10
|
+
/**
|
|
11
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
12
|
+
*/
|
package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
|
|
|
3
3
|
* @@@
|
|
4
4
|
*
|
|
5
5
|
* @@@ .env
|
|
6
|
+
* Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access .env file
|
|
6
7
|
*
|
|
7
8
|
* It looks for environment variables:
|
|
8
9
|
* - `process.env.OPENAI_API_KEY`
|
|
@@ -14,12 +15,5 @@ import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
|
|
|
14
15
|
*/
|
|
15
16
|
export declare function $provideLlmToolsConfigurationFromEnv(): Promise<LlmToolsConfiguration>;
|
|
16
17
|
/**
|
|
17
|
-
* TODO: [🧠][🪁] Maybe do allow to do auto-install if package not registered and not found
|
|
18
|
-
* TODO: Add Azure OpenAI
|
|
19
|
-
* TODO: [🧠][🍛]
|
|
20
|
-
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
21
18
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
22
|
-
|
|
23
|
-
* TODO: This should be maybe not under `_common` but under `utils`
|
|
24
|
-
* TODO: [🧠][⚛] Maybe pass env as argument
|
|
25
|
-
* TODO: [®] DRY Register logic */
|
|
19
|
+
*/
|
|
@@ -12,6 +12,8 @@ type GetLlmToolsForTestingAndScriptsAndPlaygroundOptions = CreateLlmToolsFromCon
|
|
|
12
12
|
/**
|
|
13
13
|
* Returns LLM tools for testing purposes
|
|
14
14
|
*
|
|
15
|
+
* Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access .env file
|
|
16
|
+
*
|
|
15
17
|
* @private within the repository - JUST FOR TESTS, SCRIPTS AND PLAYGROUND
|
|
16
18
|
*/
|
|
17
19
|
export declare function $provideLlmToolsForTestingAndScriptsAndPlayground(options?: GetLlmToolsForTestingAndScriptsAndPlaygroundOptions): Promise<LlmExecutionToolsWithTotalUsage>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Promisable } from 'type-fest';
|
|
2
|
-
import type {
|
|
3
|
-
import type { really_any } from '../../../utils/organization/really_any';
|
|
2
|
+
import type { Identification } from '../../../remote-server/socket-types/_subtypes/Identification';
|
|
4
3
|
import type { string_app_id } from '../../../types/typeAliases';
|
|
5
4
|
import type { string_url } from '../../../types/typeAliases';
|
|
5
|
+
import type { really_any } from '../../../utils/organization/really_any';
|
|
6
6
|
import type { CacheLlmToolsOptions } from '../utils/cache/CacheLlmToolsOptions';
|
|
7
7
|
import type { LlmExecutionToolsWithTotalUsage } from '../utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
|
|
8
8
|
type ProvideLlmToolsForWizzardOrCliOptions = Pick<CacheLlmToolsOptions, 'isCacheReloaded'> & ({
|
|
@@ -30,11 +30,13 @@ type ProvideLlmToolsForWizzardOrCliOptions = Pick<CacheLlmToolsOptions, 'isCache
|
|
|
30
30
|
/**
|
|
31
31
|
*
|
|
32
32
|
*/
|
|
33
|
-
loginPrompt(): Promisable<
|
|
33
|
+
loginPrompt(): Promisable<Identification<really_any>>;
|
|
34
34
|
});
|
|
35
35
|
/**
|
|
36
36
|
* Returns LLM tools for CLI
|
|
37
37
|
*
|
|
38
|
+
* Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access .env file and also writes this .env file
|
|
39
|
+
*
|
|
38
40
|
* @private within the repository - for CLI utils
|
|
39
41
|
*/
|
|
40
42
|
export declare function $provideLlmToolsForWizzardOrCli(options?: ProvideLlmToolsForWizzardOrCliOptions): Promise<LlmExecutionToolsWithTotalUsage>;
|
|
@@ -6,6 +6,7 @@ import type { CreateLlmToolsFromConfigurationOptions } from './createLlmToolsFro
|
|
|
6
6
|
* Note: This function is not cached, every call creates new instance of `MultipleLlmExecutionTools`
|
|
7
7
|
*
|
|
8
8
|
* @@@ .env
|
|
9
|
+
* Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access .env file
|
|
9
10
|
*
|
|
10
11
|
* It looks for environment variables:
|
|
11
12
|
* - `process.env.OPENAI_API_KEY`
|
|
@@ -7,14 +7,14 @@ import type { ApplicationRemoteServerClientOptions } from '../../types/RemoteSer
|
|
|
7
7
|
* @public exported from `@promptbook/remote-server`
|
|
8
8
|
* @public exported from `@promptbook/remote-client`
|
|
9
9
|
*/
|
|
10
|
-
export type
|
|
10
|
+
export type Identification<TCustomOptions> = ApplicationModeIdentification<TCustomOptions> | AnonymousModeIdentification;
|
|
11
11
|
/**
|
|
12
12
|
* Application mode is situation when you run known and well-defined books with your own api keys
|
|
13
13
|
*
|
|
14
14
|
* @public exported from `@promptbook/remote-server`
|
|
15
15
|
* @public exported from `@promptbook/remote-client`
|
|
16
16
|
*/
|
|
17
|
-
export type
|
|
17
|
+
export type ApplicationModeIdentification<TCustomOptions> = ApplicationRemoteServerClientOptions<TCustomOptions> & {
|
|
18
18
|
/**
|
|
19
19
|
* Application mode
|
|
20
20
|
*/
|
|
@@ -29,7 +29,7 @@ export type PromptbookServer_ApplicationIdentification<TCustomOptions> = Applica
|
|
|
29
29
|
* @public exported from `@promptbook/remote-server`
|
|
30
30
|
* @public exported from `@promptbook/remote-client`
|
|
31
31
|
*/
|
|
32
|
-
export type
|
|
32
|
+
export type AnonymousModeIdentification = {
|
|
33
33
|
/**
|
|
34
34
|
* Anonymous mode
|
|
35
35
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Identification } from '../_subtypes/Identification';
|
|
2
2
|
/**
|
|
3
3
|
* List models available in the server
|
|
4
4
|
*
|
|
@@ -10,7 +10,7 @@ export type PromptbookServer_ListModels_Request<TCustomOptions> = {
|
|
|
10
10
|
/**
|
|
11
11
|
* Identifier of the end user or application
|
|
12
12
|
*/
|
|
13
|
-
readonly identification:
|
|
13
|
+
readonly identification: Identification<TCustomOptions>;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
16
|
* TODO: [🧠] Listing models inanonymous mode does not make sence - keeping only to preserve consistency
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PipelineJson } from '../../../pipeline/PipelineJson/PipelineJson';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Identification } from '../_subtypes/Identification';
|
|
3
3
|
/**
|
|
4
4
|
* This is a request from client to server to prepare a pipeline
|
|
5
5
|
*
|
|
@@ -9,7 +9,7 @@ export type PromptbookServer_PreparePipeline_Request<TCustomOptions> = {
|
|
|
9
9
|
/**
|
|
10
10
|
* Identifier of the end user or application
|
|
11
11
|
*/
|
|
12
|
-
readonly identification:
|
|
12
|
+
readonly identification: Identification<TCustomOptions>;
|
|
13
13
|
/**
|
|
14
14
|
* The Pipeline to prepare
|
|
15
15
|
*/
|
package/esm/typings/src/remote-server/socket-types/prompt/PromptbookServer_Prompt_Request.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Prompt } from '../../../types/Prompt';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Identification } from '../_subtypes/Identification';
|
|
3
3
|
/**
|
|
4
4
|
* This is a request from client to server to execute a prompt
|
|
5
5
|
*
|
|
@@ -9,7 +9,7 @@ export type PromptbookServer_Prompt_Request<TCustomOptions> = {
|
|
|
9
9
|
/**
|
|
10
10
|
* Identifier of the end user or application
|
|
11
11
|
*/
|
|
12
|
-
readonly identification:
|
|
12
|
+
readonly identification: Identification<TCustomOptions>;
|
|
13
13
|
/**
|
|
14
14
|
* The Prompt to execute
|
|
15
15
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
|
|
2
2
|
import type { string_base_url } from '../../types/typeAliases';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Identification } from '../socket-types/_subtypes/Identification';
|
|
4
4
|
/**
|
|
5
5
|
* Options for `RemoteLlmExecutionTools`
|
|
6
6
|
*
|
|
@@ -15,7 +15,7 @@ export type RemoteClientOptions<TCustomOptions> = CommonToolsOptions & {
|
|
|
15
15
|
/**
|
|
16
16
|
* Identification of client for Socket.io remote server
|
|
17
17
|
*/
|
|
18
|
-
readonly identification:
|
|
18
|
+
readonly identification: Identification<TCustomOptions>;
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
21
|
* TODO: Pass more options from Socket.io to `RemoteClientOptions` (like `transports`)
|
|
@@ -9,7 +9,7 @@ import type { string_email } from '../../types/typeAliases';
|
|
|
9
9
|
import type { string_password } from '../../types/typeAliases';
|
|
10
10
|
import type { string_uri } from '../../types/typeAliases';
|
|
11
11
|
import type { string_user_id } from '../../types/typeAliases';
|
|
12
|
-
import type {
|
|
12
|
+
import type { Identification } from '../socket-types/_subtypes/Identification';
|
|
13
13
|
/**
|
|
14
14
|
* @@@
|
|
15
15
|
*
|
|
@@ -70,32 +70,7 @@ export type ApplicationRemoteServerOptions<TCustomOptions> = {
|
|
|
70
70
|
* Note: In most cases DO NOT THROW `AuthenticationError` but return `isSuccess: false` with message
|
|
71
71
|
* @throws `AuthenticationError` if the user is not allowed to login for example because of invalid credentials
|
|
72
72
|
*/
|
|
73
|
-
login(
|
|
74
|
-
/**
|
|
75
|
-
* Identifier of the application you are using
|
|
76
|
-
*
|
|
77
|
-
* Note: This is usefull when you use Promptbook remote server for multiple apps/frontends, if its used just for single app, use here just "app" or "your-app-name"
|
|
78
|
-
*/
|
|
79
|
-
readonly appId: string_app_id | null;
|
|
80
|
-
/**
|
|
81
|
-
* Username (for example email) of the user
|
|
82
|
-
*/
|
|
83
|
-
readonly username: string_email | string;
|
|
84
|
-
/**
|
|
85
|
-
* Password of the user
|
|
86
|
-
*/
|
|
87
|
-
readonly password: string_password;
|
|
88
|
-
/**
|
|
89
|
-
* Request object from express if you want to access some request data for example headers, IP address, etc.
|
|
90
|
-
*/
|
|
91
|
-
readonly rawRequest: Request;
|
|
92
|
-
/**
|
|
93
|
-
* Response object from express if you want to add some custom headers.
|
|
94
|
-
*
|
|
95
|
-
* Note: It is not recommended to use this object to send body of the response because it can confuse the client
|
|
96
|
-
*/
|
|
97
|
-
readonly rawResponse: Response;
|
|
98
|
-
}): Promise<ApplicationRemoteServerOptionsLoginResponse<TCustomOptions>>;
|
|
73
|
+
login(loginRequest: LoginRequest): Promise<LoginResponse<TCustomOptions>>;
|
|
99
74
|
/**
|
|
100
75
|
* Creates llm execution tools for each client
|
|
101
76
|
*/
|
|
@@ -127,17 +102,55 @@ export type ApplicationRemoteServerClientOptions<TCustomOptions> = {
|
|
|
127
102
|
*/
|
|
128
103
|
readonly customOptions?: TCustomOptions;
|
|
129
104
|
};
|
|
130
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Login request for the application mode
|
|
107
|
+
*/
|
|
108
|
+
export type LoginRequest = {
|
|
109
|
+
/**
|
|
110
|
+
* Identifier of the application you are using
|
|
111
|
+
*
|
|
112
|
+
* Note: This is usefull when you use Promptbook remote server for multiple apps/frontends, if its used just for single app, use here just "app" or "your-app-name"
|
|
113
|
+
*/
|
|
114
|
+
readonly appId: string_app_id | null;
|
|
115
|
+
/**
|
|
116
|
+
* Username (for example email) of the user
|
|
117
|
+
*/
|
|
118
|
+
readonly username: string_email | string;
|
|
119
|
+
/**
|
|
120
|
+
* Password of the user
|
|
121
|
+
*/
|
|
122
|
+
readonly password: string_password;
|
|
123
|
+
/**
|
|
124
|
+
* Request object from express if you want to access some request data for example headers, IP address, etc.
|
|
125
|
+
*/
|
|
126
|
+
readonly rawRequest: Request;
|
|
127
|
+
/**
|
|
128
|
+
* Response object from express if you want to add some custom headers.
|
|
129
|
+
*
|
|
130
|
+
* Note: It is not recommended to use this object to send body of the response because it can confuse the client
|
|
131
|
+
*/
|
|
132
|
+
readonly rawResponse: Response;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Login response for the application mode
|
|
136
|
+
*/
|
|
137
|
+
export type LoginResponse<TCustomOptions> = {
|
|
131
138
|
/**
|
|
132
139
|
* Was the login successful
|
|
133
140
|
*/
|
|
134
141
|
readonly isSuccess: boolean;
|
|
135
142
|
/**
|
|
136
|
-
*
|
|
143
|
+
* Message to display to the user, this message is always displayed
|
|
137
144
|
*/
|
|
138
145
|
readonly message?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Optional error if the login was not successful
|
|
148
|
+
*/
|
|
139
149
|
readonly error?: AuthenticationError;
|
|
140
|
-
|
|
150
|
+
/**
|
|
151
|
+
* Identification of the user to be used in the future requests
|
|
152
|
+
*/
|
|
153
|
+
readonly identification?: Identification<TCustomOptions>;
|
|
141
154
|
};
|
|
142
155
|
/**
|
|
143
156
|
* TODO: Constrain anonymous mode for specific models / providers
|
|
@@ -2,9 +2,9 @@ import type { PromptbookFetch } from '../../../execution/PromptbookFetch';
|
|
|
2
2
|
/**
|
|
3
3
|
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
5
|
+
* @public exported from `@promptbook/core`
|
|
6
6
|
*/
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const promptbookFetch: PromptbookFetch;
|
|
8
8
|
/**
|
|
9
9
|
* TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
|
|
10
10
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.89.0-
|
|
3
|
+
"version": "0.89.0-9",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"module": "./esm/index.es.js",
|
|
48
48
|
"typings": "./esm/typings/src/_packages/node.index.d.ts",
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@promptbook/core": "0.89.0-
|
|
50
|
+
"@promptbook/core": "0.89.0-9"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* @generated
|
|
47
47
|
* @see https://github.com/webgptorg/promptbook
|
|
48
48
|
*/
|
|
49
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-
|
|
49
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.89.0-9';
|
|
50
50
|
/**
|
|
51
51
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
52
52
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -1814,6 +1814,19 @@
|
|
|
1814
1814
|
}
|
|
1815
1815
|
}
|
|
1816
1816
|
|
|
1817
|
+
/**
|
|
1818
|
+
* Error thrown when a fetch request fails
|
|
1819
|
+
*
|
|
1820
|
+
* @public exported from `@promptbook/core`
|
|
1821
|
+
*/
|
|
1822
|
+
class PromptbookFetchError extends Error {
|
|
1823
|
+
constructor(message) {
|
|
1824
|
+
super(message);
|
|
1825
|
+
this.name = 'PromptbookFetchError';
|
|
1826
|
+
Object.setPrototypeOf(this, PromptbookFetchError.prototype);
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1817
1830
|
/**
|
|
1818
1831
|
* Index of all custom errors
|
|
1819
1832
|
*
|
|
@@ -1852,6 +1865,7 @@
|
|
|
1852
1865
|
URIError,
|
|
1853
1866
|
AggregateError,
|
|
1854
1867
|
AuthenticationError,
|
|
1868
|
+
PromptbookFetchError,
|
|
1855
1869
|
/*
|
|
1856
1870
|
Note: Not widely supported
|
|
1857
1871
|
> InternalError,
|
|
@@ -5063,17 +5077,24 @@
|
|
|
5063
5077
|
/**
|
|
5064
5078
|
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
5065
5079
|
*
|
|
5066
|
-
* @
|
|
5080
|
+
* @public exported from `@promptbook/core`
|
|
5067
5081
|
*/
|
|
5068
|
-
const
|
|
5082
|
+
const promptbookFetch = async (urlOrRequest, init) => {
|
|
5069
5083
|
try {
|
|
5070
|
-
return await fetch(
|
|
5084
|
+
return await fetch(urlOrRequest, init);
|
|
5071
5085
|
}
|
|
5072
5086
|
catch (error) {
|
|
5073
5087
|
if (!(error instanceof Error)) {
|
|
5074
5088
|
throw error;
|
|
5075
5089
|
}
|
|
5076
|
-
|
|
5090
|
+
let url;
|
|
5091
|
+
if (typeof urlOrRequest === 'string') {
|
|
5092
|
+
url = urlOrRequest;
|
|
5093
|
+
}
|
|
5094
|
+
else if (urlOrRequest instanceof Request) {
|
|
5095
|
+
url = urlOrRequest.url;
|
|
5096
|
+
}
|
|
5097
|
+
throw new PromptbookFetchError(spaceTrim__default["default"]((block) => `
|
|
5077
5098
|
Can not fetch "${url}"
|
|
5078
5099
|
|
|
5079
5100
|
Fetch error:
|
|
@@ -5094,7 +5115,7 @@
|
|
|
5094
5115
|
async function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
|
|
5095
5116
|
// console.log('!! makeKnowledgeSourceHandler', knowledgeSource);
|
|
5096
5117
|
var _a;
|
|
5097
|
-
const { fetch =
|
|
5118
|
+
const { fetch = promptbookFetch } = tools;
|
|
5098
5119
|
const { knowledgeSourceContent } = knowledgeSource;
|
|
5099
5120
|
let { name } = knowledgeSource;
|
|
5100
5121
|
const { rootDirname = null,
|
|
@@ -9574,21 +9595,15 @@
|
|
|
9574
9595
|
*/
|
|
9575
9596
|
|
|
9576
9597
|
/**
|
|
9577
|
-
*
|
|
9598
|
+
* Provides the path to the `.env` file
|
|
9578
9599
|
*
|
|
9579
|
-
*
|
|
9600
|
+
* Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access .env file
|
|
9580
9601
|
*
|
|
9581
|
-
*
|
|
9582
|
-
* - `process.env.OPENAI_API_KEY`
|
|
9583
|
-
* - `process.env.ANTHROPIC_CLAUDE_API_KEY`
|
|
9584
|
-
* - ...
|
|
9585
|
-
*
|
|
9586
|
-
* @returns @@@
|
|
9587
|
-
* @public exported from `@promptbook/node`
|
|
9602
|
+
* @private within the repository - for CLI utils
|
|
9588
9603
|
*/
|
|
9589
|
-
async function $
|
|
9604
|
+
async function $provideEnvFilepath() {
|
|
9590
9605
|
if (!$isRunningInNode()) {
|
|
9591
|
-
throw new EnvironmentMismatchError('Function `$
|
|
9606
|
+
throw new EnvironmentMismatchError('Function `$provideEnvFilepath` works only in Node.js environment');
|
|
9592
9607
|
}
|
|
9593
9608
|
const envFilePatterns = [
|
|
9594
9609
|
'.env',
|
|
@@ -9608,8 +9623,7 @@
|
|
|
9608
9623
|
const envFilename = path.join(rootDirname, pattern);
|
|
9609
9624
|
if (await isFileExisting(envFilename, $provideFilesystemForNode())) {
|
|
9610
9625
|
$setUsedEnvFilename(envFilename);
|
|
9611
|
-
|
|
9612
|
-
break up_to_root;
|
|
9626
|
+
return envFilename;
|
|
9613
9627
|
}
|
|
9614
9628
|
}
|
|
9615
9629
|
if (isRootPath(rootDirname)) {
|
|
@@ -9618,6 +9632,34 @@
|
|
|
9618
9632
|
// Note: If the directory does not exist, try the parent directory
|
|
9619
9633
|
rootDirname = path.join(rootDirname, '..');
|
|
9620
9634
|
}
|
|
9635
|
+
return null;
|
|
9636
|
+
}
|
|
9637
|
+
/**
|
|
9638
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
9639
|
+
*/
|
|
9640
|
+
|
|
9641
|
+
/**
|
|
9642
|
+
* @@@
|
|
9643
|
+
*
|
|
9644
|
+
* @@@ .env
|
|
9645
|
+
* Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access .env file
|
|
9646
|
+
*
|
|
9647
|
+
* It looks for environment variables:
|
|
9648
|
+
* - `process.env.OPENAI_API_KEY`
|
|
9649
|
+
* - `process.env.ANTHROPIC_CLAUDE_API_KEY`
|
|
9650
|
+
* - ...
|
|
9651
|
+
*
|
|
9652
|
+
* @returns @@@
|
|
9653
|
+
* @public exported from `@promptbook/node`
|
|
9654
|
+
*/
|
|
9655
|
+
async function $provideLlmToolsConfigurationFromEnv() {
|
|
9656
|
+
if (!$isRunningInNode()) {
|
|
9657
|
+
throw new EnvironmentMismatchError('Function `$provideLlmToolsFromEnv` works only in Node.js environment');
|
|
9658
|
+
}
|
|
9659
|
+
const envFilepath = await $provideEnvFilepath();
|
|
9660
|
+
if (envFilepath !== null) {
|
|
9661
|
+
dotenv__namespace.config({ path: envFilepath });
|
|
9662
|
+
}
|
|
9621
9663
|
const llmToolsConfiguration = $llmToolsMetadataRegister
|
|
9622
9664
|
.list()
|
|
9623
9665
|
.map((metadata) => metadata.createConfigurationFromEnv(process.env))
|
|
@@ -9625,15 +9667,8 @@
|
|
|
9625
9667
|
return llmToolsConfiguration;
|
|
9626
9668
|
}
|
|
9627
9669
|
/**
|
|
9628
|
-
* TODO: [🧠][🪁] Maybe do allow to do auto-install if package not registered and not found
|
|
9629
|
-
* TODO: Add Azure OpenAI
|
|
9630
|
-
* TODO: [🧠][🍛]
|
|
9631
|
-
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
9632
9670
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
9633
|
-
|
|
9634
|
-
* TODO: This should be maybe not under `_common` but under `utils`
|
|
9635
|
-
* TODO: [🧠][⚛] Maybe pass env as argument
|
|
9636
|
-
* TODO: [®] DRY Register logic */
|
|
9671
|
+
*/
|
|
9637
9672
|
|
|
9638
9673
|
/**
|
|
9639
9674
|
* @@@
|
|
@@ -9692,6 +9727,7 @@
|
|
|
9692
9727
|
* Note: This function is not cached, every call creates new instance of `MultipleLlmExecutionTools`
|
|
9693
9728
|
*
|
|
9694
9729
|
* @@@ .env
|
|
9730
|
+
* Note: `$` is used to indicate that this function is not a pure function - it uses filesystem to access .env file
|
|
9695
9731
|
*
|
|
9696
9732
|
* It looks for environment variables:
|
|
9697
9733
|
* - `process.env.OPENAI_API_KEY`
|