@promptbook/openai 0.89.0-2 → 0.89.0-20
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 +10 -6
- package/esm/index.es.js +66 -10
- package/esm/index.es.js.map +1 -1
- package/esm/typings/servers.d.ts +40 -0
- package/esm/typings/src/_packages/core.index.d.ts +20 -8
- package/esm/typings/src/_packages/remote-client.index.d.ts +6 -8
- package/esm/typings/src/_packages/remote-server.index.d.ts +6 -6
- package/esm/typings/src/_packages/types.index.d.ts +18 -16
- package/esm/typings/src/cli/cli-commands/login.d.ts +0 -1
- package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +7 -0
- package/esm/typings/src/cli/common/$provideLlmToolsForCli.d.ts +28 -0
- package/esm/typings/src/cli/test/ptbk.d.ts +1 -1
- package/esm/typings/src/commands/EXPECT/expectCommandParser.d.ts +2 -0
- package/esm/typings/src/config.d.ts +24 -26
- package/esm/typings/src/errors/0-index.d.ts +9 -0
- package/esm/typings/src/errors/AuthenticationError.d.ts +9 -0
- package/esm/typings/src/errors/PipelineExecutionError.d.ts +1 -1
- package/esm/typings/src/errors/PromptbookFetchError.d.ts +9 -0
- package/esm/typings/src/errors/WrappedError.d.ts +10 -0
- package/esm/typings/src/errors/assertsError.d.ts +11 -0
- package/esm/typings/src/execution/PromptbookFetch.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideEnvFilename.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 +45 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -0
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -1
- package/esm/typings/src/remote-server/RemoteServer.d.ts +23 -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/_subtypes/identificationToPromptbookToken.d.ts +11 -0
- package/esm/typings/src/remote-server/socket-types/_subtypes/promptbookTokenToIdentification.d.ts +10 -0
- 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/startRemoteServer.d.ts +2 -3
- package/esm/typings/src/remote-server/types/RemoteClientOptions.d.ts +4 -12
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +89 -4
- package/esm/typings/src/scrapers/_common/utils/{scraperFetch.d.ts → promptbookFetch.d.ts} +2 -2
- package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +40 -0
- package/esm/typings/src/types/typeAliases.d.ts +19 -0
- package/esm/typings/src/utils/organization/TODO_narrow.d.ts +6 -0
- package/package.json +7 -3
- package/umd/index.umd.js +66 -10
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/cli/test/ptbk2.d.ts +0 -5
- package/esm/typings/src/playground/BrjappConnector.d.ts +0 -67
- package/esm/typings/src/playground/brjapp-api-schema.d.ts +0 -12879
|
@@ -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,20 +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
|
-
import type {
|
|
116
|
-
import type {
|
|
117
|
-
import type {
|
|
110
|
+
import type { RemoteServer } from '../remote-server/RemoteServer';
|
|
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';
|
|
118
114
|
import type { RemoteClientOptions } from '../remote-server/types/RemoteClientOptions';
|
|
119
115
|
import type { RemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
|
|
120
116
|
import type { AnonymousRemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
|
|
121
117
|
import type { ApplicationRemoteServerOptions } from '../remote-server/types/RemoteServerOptions';
|
|
122
118
|
import type { ApplicationRemoteServerClientOptions } from '../remote-server/types/RemoteServerOptions';
|
|
119
|
+
import type { LoginRequest } from '../remote-server/types/RemoteServerOptions';
|
|
120
|
+
import type { LoginResponse } from '../remote-server/types/RemoteServerOptions';
|
|
123
121
|
import type { Converter } from '../scrapers/_common/Converter';
|
|
124
122
|
import type { ScraperAndConverterMetadata } from '../scrapers/_common/register/ScraperAndConverterMetadata';
|
|
125
123
|
import type { ScraperConstructor } from '../scrapers/_common/register/ScraperConstructor';
|
|
@@ -192,6 +190,7 @@ import type { string_css_property } from '../types/typeAliases';
|
|
|
192
190
|
import type { string_css_value } from '../types/typeAliases';
|
|
193
191
|
import type { string_css_selector } from '../types/typeAliases';
|
|
194
192
|
import type { string_url } from '../types/typeAliases';
|
|
193
|
+
import type { string_promptbook_server_url } from '../types/typeAliases';
|
|
195
194
|
import type { string_base_url } from '../types/typeAliases';
|
|
196
195
|
import type { string_pipeline_root_url } from '../types/typeAliases';
|
|
197
196
|
import type { string_pipeline_url } from '../types/typeAliases';
|
|
@@ -224,6 +223,7 @@ import type { string_dirname } from '../types/typeAliases';
|
|
|
224
223
|
import type { string_person_fullname } from '../types/typeAliases';
|
|
225
224
|
import type { string_person_profile } from '../types/typeAliases';
|
|
226
225
|
import type { string_license } from '../types/typeAliases';
|
|
226
|
+
import type { string_legal_entity } from '../types/typeAliases';
|
|
227
227
|
import type { string_attribute } from '../types/typeAliases';
|
|
228
228
|
import type { string_attribute_value_scope } from '../types/typeAliases';
|
|
229
229
|
import type { string_color } from '../types/typeAliases';
|
|
@@ -235,6 +235,7 @@ import type { string_postprocessing_function_name } from '../types/typeAliases';
|
|
|
235
235
|
import type { id } from '../types/typeAliases';
|
|
236
236
|
import type { task_id } from '../types/typeAliases';
|
|
237
237
|
import type { string_token } from '../types/typeAliases';
|
|
238
|
+
import type { string_promptbook_token } from '../types/typeAliases';
|
|
238
239
|
import type { string_license_token } from '../types/typeAliases';
|
|
239
240
|
import type { string_password } from '../types/typeAliases';
|
|
240
241
|
import type { string_ssh_key } from '../types/typeAliases';
|
|
@@ -395,20 +396,18 @@ export type { ScriptTaskJson };
|
|
|
395
396
|
export type { SimpleTaskJson };
|
|
396
397
|
export type { TaskJson };
|
|
397
398
|
export type { PipelineString };
|
|
398
|
-
export type { paths };
|
|
399
|
-
export type { webhooks };
|
|
400
|
-
export type { components };
|
|
401
|
-
export type { $defs };
|
|
402
|
-
export type { operations };
|
|
403
399
|
export type { PrepareAndScrapeOptions };
|
|
404
|
-
export type {
|
|
405
|
-
export type {
|
|
406
|
-
export type {
|
|
400
|
+
export type { RemoteServer };
|
|
401
|
+
export type { Identification };
|
|
402
|
+
export type { ApplicationModeIdentification };
|
|
403
|
+
export type { AnonymousModeIdentification };
|
|
407
404
|
export type { RemoteClientOptions };
|
|
408
405
|
export type { RemoteServerOptions };
|
|
409
406
|
export type { AnonymousRemoteServerOptions };
|
|
410
407
|
export type { ApplicationRemoteServerOptions };
|
|
411
408
|
export type { ApplicationRemoteServerClientOptions };
|
|
409
|
+
export type { LoginRequest };
|
|
410
|
+
export type { LoginResponse };
|
|
412
411
|
export type { Converter };
|
|
413
412
|
export type { ScraperAndConverterMetadata };
|
|
414
413
|
export type { ScraperConstructor };
|
|
@@ -481,6 +480,7 @@ export type { string_css_property };
|
|
|
481
480
|
export type { string_css_value };
|
|
482
481
|
export type { string_css_selector };
|
|
483
482
|
export type { string_url };
|
|
483
|
+
export type { string_promptbook_server_url };
|
|
484
484
|
export type { string_base_url };
|
|
485
485
|
export type { string_pipeline_root_url };
|
|
486
486
|
export type { string_pipeline_url };
|
|
@@ -513,6 +513,7 @@ export type { string_dirname };
|
|
|
513
513
|
export type { string_person_fullname };
|
|
514
514
|
export type { string_person_profile };
|
|
515
515
|
export type { string_license };
|
|
516
|
+
export type { string_legal_entity };
|
|
516
517
|
export type { string_attribute };
|
|
517
518
|
export type { string_attribute_value_scope };
|
|
518
519
|
export type { string_color };
|
|
@@ -524,6 +525,7 @@ export type { string_postprocessing_function_name };
|
|
|
524
525
|
export type { id };
|
|
525
526
|
export type { task_id };
|
|
526
527
|
export type { string_token };
|
|
528
|
+
export type { string_promptbook_token };
|
|
527
529
|
export type { string_license_token };
|
|
528
530
|
export type { string_password };
|
|
529
531
|
export type { string_ssh_key };
|
|
@@ -8,7 +8,6 @@ import type { Command as Program } from 'commander';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function $initializeLoginCommand(program: Program): void;
|
|
10
10
|
/**
|
|
11
|
-
* TODO: Pass remote server URL (and path)
|
|
12
11
|
* TODO: Implement non-interactive login
|
|
13
12
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
14
13
|
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Note: `$` is used to indicate that this function is not a pure function - it registers an option in the CLI
|
|
4
|
+
*
|
|
5
|
+
* @private utility of CLI
|
|
6
|
+
*/
|
|
7
|
+
export declare function $addGlobalOptionsToCommand(command: Command): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { LlmExecutionToolsWithTotalUsage } from '../../llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
|
|
2
|
+
import type { CacheLlmToolsOptions } from '../../llm-providers/_common/utils/cache/CacheLlmToolsOptions';
|
|
3
|
+
import type { string_promptbook_server_url } from '../../types/typeAliases';
|
|
4
|
+
type ProvideLlmToolsForCliOptions = Pick<CacheLlmToolsOptions, 'isCacheReloaded'> & {
|
|
5
|
+
/**
|
|
6
|
+
* If true, user will be always prompted for login
|
|
7
|
+
*
|
|
8
|
+
* Note: This is used in `ptbk login` command
|
|
9
|
+
*/
|
|
10
|
+
isLoginloaded?: true;
|
|
11
|
+
/**
|
|
12
|
+
* CLI options
|
|
13
|
+
*/
|
|
14
|
+
cliOptions: {
|
|
15
|
+
verbose: boolean;
|
|
16
|
+
interactive: boolean;
|
|
17
|
+
provider: 'BYOK' | 'BRING_YOUR_OWN_KEYS' | 'REMOTE_SERVER' | 'RS' | string;
|
|
18
|
+
remoteServerUrl: string_promptbook_server_url;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* @private utility of CLI
|
|
23
|
+
*/
|
|
24
|
+
export declare function $provideLlmToolsForCli(options: ProvideLlmToolsForCliOptions): Promise<{
|
|
25
|
+
strategy: 'BRING_YOUR_OWN_KEYS' | 'REMOTE_SERVER';
|
|
26
|
+
llm: LlmExecutionToolsWithTotalUsage;
|
|
27
|
+
}>;
|
|
28
|
+
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { PipelineTaskCommandParser } from '../_common/types/CommandParser';
|
|
2
2
|
import type { ExpectCommand } from './ExpectCommand';
|
|
3
3
|
/**
|
|
4
|
+
import { WrappedError } from '../../errors/WrappedError';
|
|
5
|
+
import { assertsError } from '../../errors/assertsError';
|
|
4
6
|
* Parses the expect command
|
|
5
7
|
*
|
|
6
8
|
* @see `documentationUrl` for more details
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { CsvSettings } from './formats/csv/CsvSettings';
|
|
2
2
|
import type { IntermediateFilesStrategy } from './types/IntermediateFilesStrategy';
|
|
3
|
+
import type { string_app_id } from './types/typeAliases';
|
|
3
4
|
import type { string_email } from './types/typeAliases';
|
|
4
5
|
import type { string_name } from './types/typeAliases';
|
|
5
|
-
import type {
|
|
6
|
+
import type { string_promptbook_server_url } from './types/typeAliases';
|
|
6
7
|
/**
|
|
7
8
|
* Warning message for the generated sections and files files
|
|
8
9
|
*
|
|
@@ -37,22 +38,6 @@ export declare const ADMIN_GITHUB_NAME: string_name;
|
|
|
37
38
|
* @public exported from `@promptbook/core`
|
|
38
39
|
*/
|
|
39
40
|
export declare const CLAIM = "It's time for a paradigm shift. The future of software in plain English, French or Latin";
|
|
40
|
-
/**
|
|
41
|
-
* Logo for the light theme
|
|
42
|
-
*
|
|
43
|
-
* TODO: [🗽] Unite branding and make single place for it
|
|
44
|
-
*
|
|
45
|
-
* @public exported from `@promptbook/core`
|
|
46
|
-
*/
|
|
47
|
-
export declare const LOGO_LIGHT_SRC: string_url_image;
|
|
48
|
-
/**
|
|
49
|
-
* Logo for the dark theme
|
|
50
|
-
*
|
|
51
|
-
* TODO: [🗽] Unite branding and make single place for it
|
|
52
|
-
*
|
|
53
|
-
* @public exported from `@promptbook/core`
|
|
54
|
-
*/
|
|
55
|
-
export declare const LOGO_DARK_SRC: string_url_image;
|
|
56
41
|
/**
|
|
57
42
|
* When the title is not provided, the default title is used
|
|
58
43
|
*
|
|
@@ -89,6 +74,12 @@ export declare const DEFAULT_MAX_FILE_SIZE: number;
|
|
|
89
74
|
* @private within the repository
|
|
90
75
|
*/
|
|
91
76
|
export declare const GENERATOR_WARNING_BY_PROMPTBOOK_CLI = "\u26A0\uFE0F WARNING: This code has been generated by `@promptbook/cli` so that any manual changes will be overwritten";
|
|
77
|
+
/**
|
|
78
|
+
* Warning message for the automatically generated sections of `.env` files
|
|
79
|
+
*
|
|
80
|
+
* @private within the repository
|
|
81
|
+
*/
|
|
82
|
+
export declare const GENERATOR_WARNING_IN_ENV = "Note: Added by Promptbook";
|
|
92
83
|
/**
|
|
93
84
|
* The maximum number of iterations for a loops
|
|
94
85
|
*
|
|
@@ -114,6 +105,7 @@ export declare const VALUE_STRINGS: {
|
|
|
114
105
|
readonly infinity: "(infinity; ∞)";
|
|
115
106
|
readonly negativeInfinity: "(negative infinity; -∞)";
|
|
116
107
|
readonly unserializable: "(unserializable value)";
|
|
108
|
+
readonly circular: "(circular JSON)";
|
|
117
109
|
};
|
|
118
110
|
/**
|
|
119
111
|
* Small number limit
|
|
@@ -208,6 +200,18 @@ export declare const DEFAULT_EXECUTION_CACHE_DIRNAME = "./.promptbook/execution-
|
|
|
208
200
|
* @public exported from `@promptbook/core`
|
|
209
201
|
*/
|
|
210
202
|
export declare const DEFAULT_SCRAPE_CACHE_DIRNAME = "./.promptbook/scrape-cache";
|
|
203
|
+
/**
|
|
204
|
+
* Id of application for the CLI when using remote server
|
|
205
|
+
*
|
|
206
|
+
* @public exported from `@promptbook/core`
|
|
207
|
+
*/
|
|
208
|
+
export declare const CLI_APP_ID: string_app_id;
|
|
209
|
+
/**
|
|
210
|
+
* Id of application for the playground
|
|
211
|
+
*
|
|
212
|
+
* @public exported from `@promptbook/core`
|
|
213
|
+
*/
|
|
214
|
+
export declare const PLAYGROUND_APP_ID: string_app_id;
|
|
211
215
|
/**
|
|
212
216
|
* The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createCollectionFromDirectory`
|
|
213
217
|
*
|
|
@@ -224,17 +228,11 @@ export declare const MOMENT_ARG_THRESHOLDS: {
|
|
|
224
228
|
readonly ss: 3;
|
|
225
229
|
};
|
|
226
230
|
/**
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
* @public exported from `@promptbook/core`
|
|
230
|
-
*/
|
|
231
|
-
export declare const DEFAULT_REMOTE_URL = "https://api.pavolhejny.com/";
|
|
232
|
-
/**
|
|
233
|
-
* @@@
|
|
231
|
+
* Default remote server URL for the Promptbook
|
|
234
232
|
*
|
|
235
233
|
* @public exported from `@promptbook/core`
|
|
236
234
|
*/
|
|
237
|
-
export declare const
|
|
235
|
+
export declare const DEFAULT_REMOTE_SERVER_URL: string_promptbook_server_url;
|
|
238
236
|
/**
|
|
239
237
|
* @@@
|
|
240
238
|
*
|
|
@@ -281,5 +279,5 @@ export declare const IS_PIPELINE_LOGIC_VALIDATED: boolean;
|
|
|
281
279
|
export declare const IS_COST_PREVENTED: boolean;
|
|
282
280
|
/**
|
|
283
281
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
284
|
-
* TODO: [🧠][🧜♂️] Maybe join
|
|
282
|
+
* TODO: [🧠][🧜♂️] Maybe join remoteServerUrl and path into single value
|
|
285
283
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CsvFormatError } from '../formats/csv/CsvFormatError';
|
|
2
2
|
import { AbstractFormatError } from './AbstractFormatError';
|
|
3
|
+
import { AuthenticationError } from './AuthenticationError';
|
|
3
4
|
import { CollectionError } from './CollectionError';
|
|
4
5
|
import { EnvironmentMismatchError } from './EnvironmentMismatchError';
|
|
5
6
|
import { ExpectError } from './ExpectError';
|
|
@@ -12,7 +13,9 @@ import { ParseError } from './ParseError';
|
|
|
12
13
|
import { PipelineExecutionError } from './PipelineExecutionError';
|
|
13
14
|
import { PipelineLogicError } from './PipelineLogicError';
|
|
14
15
|
import { PipelineUrlError } from './PipelineUrlError';
|
|
16
|
+
import { PromptbookFetchError } from './PromptbookFetchError';
|
|
15
17
|
import { UnexpectedError } from './UnexpectedError';
|
|
18
|
+
import { WrappedError } from './WrappedError';
|
|
16
19
|
/**
|
|
17
20
|
* Index of all custom errors
|
|
18
21
|
*
|
|
@@ -33,7 +36,10 @@ export declare const PROMPTBOOK_ERRORS: {
|
|
|
33
36
|
readonly PipelineExecutionError: typeof PipelineExecutionError;
|
|
34
37
|
readonly PipelineLogicError: typeof PipelineLogicError;
|
|
35
38
|
readonly PipelineUrlError: typeof PipelineUrlError;
|
|
39
|
+
readonly AuthenticationError: typeof AuthenticationError;
|
|
40
|
+
readonly PromptbookFetchError: typeof PromptbookFetchError;
|
|
36
41
|
readonly UnexpectedError: typeof UnexpectedError;
|
|
42
|
+
readonly WrappedError: typeof WrappedError;
|
|
37
43
|
};
|
|
38
44
|
/**
|
|
39
45
|
* Index of all javascript errors
|
|
@@ -78,7 +84,10 @@ export declare const ALL_ERRORS: {
|
|
|
78
84
|
readonly PipelineExecutionError: typeof PipelineExecutionError;
|
|
79
85
|
readonly PipelineLogicError: typeof PipelineLogicError;
|
|
80
86
|
readonly PipelineUrlError: typeof PipelineUrlError;
|
|
87
|
+
readonly AuthenticationError: typeof AuthenticationError;
|
|
88
|
+
readonly PromptbookFetchError: typeof PromptbookFetchError;
|
|
81
89
|
readonly UnexpectedError: typeof UnexpectedError;
|
|
90
|
+
readonly WrappedError: typeof WrappedError;
|
|
82
91
|
};
|
|
83
92
|
/**
|
|
84
93
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthenticationError is thrown from login function which is dependency of remote server
|
|
3
|
+
*
|
|
4
|
+
* @public exported from `@promptbook/core`
|
|
5
|
+
*/
|
|
6
|
+
export declare class AuthenticationError extends Error {
|
|
7
|
+
readonly name = "AuthenticationError";
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { really_any } from '../utils/organization/really_any';
|
|
2
|
+
/**
|
|
3
|
+
* This error type indicates that somewhere in the code non-Error object was thrown and it was wrapped into the `WrappedError`
|
|
4
|
+
*
|
|
5
|
+
* @public exported from `@promptbook/core`
|
|
6
|
+
*/
|
|
7
|
+
export declare class WrappedError extends Error {
|
|
8
|
+
readonly name = "WrappedError";
|
|
9
|
+
constructor(whatWasThrown: really_any);
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { really_unknown } from '../utils/organization/really_unknown';
|
|
2
|
+
/**
|
|
3
|
+
* Helper used in catch blocks to assert that the error is an instance of `Error`
|
|
4
|
+
*
|
|
5
|
+
* @param whatWasThrown Any object that was thrown
|
|
6
|
+
* @returns Nothing if the error is an instance of `Error`
|
|
7
|
+
* @throws `WrappedError` or `UnexpectedError` if the error is not standard
|
|
8
|
+
*
|
|
9
|
+
* @private within the repository
|
|
10
|
+
*/
|
|
11
|
+
export declare function assertsError(whatWasThrown: really_unknown): asserts whatWasThrown is Error;
|
|
@@ -7,6 +7,6 @@ import type { string_url } from '../types/typeAliases';
|
|
|
7
7
|
*
|
|
8
8
|
* It is used in theese places:
|
|
9
9
|
* - Fetching knowledge sources
|
|
10
|
-
* - Callbacks from remote server
|
|
10
|
+
* - Callbacks from remote server
|
|
11
11
|
*/
|
|
12
12
|
export type PromptbookFetch = (url: string_url, init?: RequestInit) => Promise<Response>;
|
|
@@ -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 $provideEnvFilename(): 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,11 +1,55 @@
|
|
|
1
|
+
import { Promisable } from 'type-fest';
|
|
2
|
+
import type { Identification } from '../../../remote-server/socket-types/_subtypes/Identification';
|
|
3
|
+
import type { string_app_id } from '../../../types/typeAliases';
|
|
4
|
+
import type { string_url } from '../../../types/typeAliases';
|
|
5
|
+
import type { really_any } from '../../../utils/organization/really_any';
|
|
1
6
|
import type { CacheLlmToolsOptions } from '../utils/cache/CacheLlmToolsOptions';
|
|
2
7
|
import type { LlmExecutionToolsWithTotalUsage } from '../utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
|
|
8
|
+
type ProvideLlmToolsForWizzardOrCliOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* If true, user will be always prompted for login
|
|
11
|
+
*
|
|
12
|
+
* Note: This is used in `ptbk login` command
|
|
13
|
+
*/
|
|
14
|
+
isLoginloaded?: true;
|
|
15
|
+
} & Pick<CacheLlmToolsOptions, 'isCacheReloaded'> & ({
|
|
16
|
+
/**
|
|
17
|
+
* Use local keys and execute LLMs directly
|
|
18
|
+
*/
|
|
19
|
+
readonly strategy: 'BRING_YOUR_OWN_KEYS';
|
|
20
|
+
} | {
|
|
21
|
+
/**
|
|
22
|
+
* Do not use local keys but login to Promptbook server and execute LLMs there
|
|
23
|
+
*/
|
|
24
|
+
readonly strategy: 'REMOTE_SERVER';
|
|
25
|
+
/**
|
|
26
|
+
* URL of the remote server
|
|
27
|
+
*
|
|
28
|
+
* @default `DEFAULT_REMOTE_SERVER_URL`
|
|
29
|
+
*/
|
|
30
|
+
readonly remoteServerUrl?: string_url;
|
|
31
|
+
/**
|
|
32
|
+
* Identifier of the application which will be passed to the remote server identification
|
|
33
|
+
*
|
|
34
|
+
* Note: This can be some id or some semantic name like "email-agent"
|
|
35
|
+
*/
|
|
36
|
+
readonly appId: string_app_id;
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
*
|
|
40
|
+
* Note: When login prompt fails, `process.exit(1)` is called
|
|
41
|
+
*/
|
|
42
|
+
loginPrompt(): Promisable<Identification<really_any>>;
|
|
43
|
+
});
|
|
3
44
|
/**
|
|
4
45
|
* Returns LLM tools for CLI
|
|
5
46
|
*
|
|
47
|
+
* 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
|
|
48
|
+
*
|
|
6
49
|
* @private within the repository - for CLI utils
|
|
7
50
|
*/
|
|
8
|
-
export declare function $provideLlmToolsForWizzardOrCli(options?:
|
|
51
|
+
export declare function $provideLlmToolsForWizzardOrCli(options?: ProvideLlmToolsForWizzardOrCliOptions): Promise<LlmExecutionToolsWithTotalUsage>;
|
|
52
|
+
export {};
|
|
9
53
|
/**
|
|
10
54
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
11
55
|
* TODO: [👷♂️] @@@ Manual about construction of llmTools
|
|
@@ -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`
|
package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export type AnthropicClaudeExecutionToolsDirectOptions = CommonToolsOptions & Cl
|
|
|
25
25
|
*/
|
|
26
26
|
export type AnthropicClaudeExecutionToolsProxiedOptions = CommonToolsOptions & ClientOptions & {
|
|
27
27
|
isProxied: true;
|
|
28
|
-
} & Pick<RemoteClientOptions<undefined>, '
|
|
28
|
+
} & Pick<RemoteClientOptions<undefined>, 'remoteServerUrl'>;
|
|
29
29
|
/**
|
|
30
30
|
* TODO: [🧠][🤺] Pass `userId`
|
|
31
31
|
*/
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { IDestroyable } from 'destroyable';
|
|
3
|
+
import express from 'express';
|
|
4
|
+
import http from 'http';
|
|
5
|
+
import { DefaultEventsMap, Server } from 'socket.io';
|
|
6
|
+
import type { TODO_any } from '../utils/organization/TODO_any';
|
|
7
|
+
import type { TODO_narrow } from '../utils/organization/TODO_narrow';
|
|
8
|
+
export type RemoteServer = IDestroyable & {
|
|
9
|
+
/**
|
|
10
|
+
* HTTP server instance
|
|
11
|
+
*/
|
|
12
|
+
readonly httpServer: http.Server<TODO_any>;
|
|
13
|
+
/**
|
|
14
|
+
* Express application instance
|
|
15
|
+
*
|
|
16
|
+
* Note: This is useful for adding custom routes
|
|
17
|
+
*/
|
|
18
|
+
readonly expressApp: express.Express;
|
|
19
|
+
/**
|
|
20
|
+
* Socket.io server instance
|
|
21
|
+
*/
|
|
22
|
+
readonly socketIoServer: Server<TODO_narrow<DefaultEventsMap>, TODO_narrow<DefaultEventsMap>, TODO_narrow<DefaultEventsMap>, TODO_any>;
|
|
23
|
+
};
|
|
@@ -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
|
*/
|
package/esm/typings/src/remote-server/socket-types/_subtypes/identificationToPromptbookToken.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { string_promptbook_token } from '../../../types/typeAliases';
|
|
2
|
+
import type { really_unknown } from '../../../utils/organization/really_unknown';
|
|
3
|
+
import type { ApplicationModeIdentification } from './Identification';
|
|
4
|
+
/**
|
|
5
|
+
* Convert identification to Promptbook token
|
|
6
|
+
*
|
|
7
|
+
* @param identification
|
|
8
|
+
*
|
|
9
|
+
* @public exported from `@promptbook/core`
|
|
10
|
+
*/
|
|
11
|
+
export declare function identificationToPromptbookToken(identification: ApplicationModeIdentification<really_unknown>): string_promptbook_token;
|
package/esm/typings/src/remote-server/socket-types/_subtypes/promptbookTokenToIdentification.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { string_promptbook_token } from '../../../types/typeAliases';
|
|
2
|
+
import type { ApplicationModeIdentification } from './Identification';
|
|
3
|
+
/**
|
|
4
|
+
* Convert Promptbook token to identification
|
|
5
|
+
*
|
|
6
|
+
* @param promptbookToken
|
|
7
|
+
*
|
|
8
|
+
* @public exported from `@promptbook/core`
|
|
9
|
+
*/
|
|
10
|
+
export declare function promptbookTokenToIdentification(promptbookToken: string_promptbook_token): ApplicationModeIdentification<undefined>;
|
|
@@ -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
|
*/
|