@promptbook/openai 0.80.0 → 0.81.0-6
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 +6 -0
- package/esm/index.es.js +106 -8
- package/esm/index.es.js.map +1 -1
- package/esm/typings/books/index.d.ts +15 -0
- package/esm/typings/src/_packages/core.index.d.ts +2 -6
- package/esm/typings/src/_packages/editable.index.d.ts +10 -0
- package/esm/typings/src/_packages/templates.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +4 -0
- package/esm/typings/src/_packages/utils.index.d.ts +10 -2
- package/esm/typings/src/config.d.ts +26 -0
- package/esm/typings/src/execution/ExecutionTools.d.ts +7 -0
- package/esm/typings/src/execution/PromptbookFetch.d.ts +5 -0
- package/esm/typings/src/execution/PromptbookFetch.test-type.d.ts +5 -0
- package/esm/typings/src/expectations/drafts/isDomainNameFree.d.ts +2 -1
- package/esm/typings/src/expectations/drafts/isGithubNameFree.d.ts +2 -1
- package/esm/typings/src/high-level-abstractions/index.d.ts +10 -0
- package/esm/typings/src/other/templates/getBookTemplate.d.ts +12 -0
- package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +10 -0
- package/esm/typings/src/pipeline/PipelineJson/PipelineJson.d.ts +10 -0
- package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
- package/esm/typings/src/scrapers/_common/utils/scraperFetch.d.ts +7 -0
- package/esm/typings/src/utils/editable/types/PipelineEditableSerialized.d.ts +27 -0
- package/esm/typings/src/{conversion → utils/editable}/utils/removePipelineCommand.d.ts +3 -3
- package/esm/typings/src/{conversion → utils/editable}/utils/renamePipelineParameter.d.ts +3 -3
- package/esm/typings/src/{conversion → utils/editable}/utils/stringifyPipelineJson.d.ts +2 -2
- package/esm/typings/src/utils/parameters/numberToString.d.ts +7 -0
- package/esm/typings/src/utils/parameters/{replaceParameters.d.ts → templateParameters.d.ts} +6 -2
- package/esm/typings/src/utils/parameters/valueToString.d.ts +17 -0
- package/esm/typings/src/utils/parameters/valueToString.test.d.ts +1 -0
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +4 -0
- package/package.json +2 -2
- package/umd/index.umd.js +106 -8
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/utils/formatNumber.d.ts +0 -6
- /package/esm/typings/src/{conversion → utils/editable}/utils/removePipelineCommand.test.d.ts +0 -0
- /package/esm/typings/src/{conversion → utils/editable}/utils/renamePipelineParameter.test.d.ts +0 -0
- /package/esm/typings/src/{conversion → utils/editable}/utils/stringifyPipelineJson.test.d.ts +0 -0
- /package/esm/typings/src/utils/{formatNumber.test.d.ts → parameters/numberToString.test.d.ts} +0 -0
- /package/esm/typings/src/utils/parameters/{replaceParameters.test.d.ts → templateParameters.test.d.ts} +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
2
|
+
import type { PipelineEditableSerialized } from '../utils/editable/types/PipelineEditableSerialized';
|
|
3
|
+
import { removePipelineCommand } from '../utils/editable/utils/removePipelineCommand';
|
|
4
|
+
import { renamePipelineParameter } from '../utils/editable/utils/renamePipelineParameter';
|
|
5
|
+
import { stringifyPipelineJson } from '../utils/editable/utils/stringifyPipelineJson';
|
|
6
|
+
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
7
|
+
export type { PipelineEditableSerialized };
|
|
8
|
+
export { removePipelineCommand };
|
|
9
|
+
export { renamePipelineParameter };
|
|
10
|
+
export { stringifyPipelineJson };
|
|
@@ -30,6 +30,7 @@ import type { LlmExecutionTools } from '../execution/LlmExecutionTools';
|
|
|
30
30
|
import type { LlmExecutionToolsConstructor } from '../execution/LlmExecutionToolsConstructor';
|
|
31
31
|
import type { PipelineExecutor } from '../execution/PipelineExecutor';
|
|
32
32
|
import type { PipelineExecutorResult } from '../execution/PipelineExecutorResult';
|
|
33
|
+
import type { PromptbookFetch } from '../execution/PromptbookFetch';
|
|
33
34
|
import type { PromptResult } from '../execution/PromptResult';
|
|
34
35
|
import type { CompletionPromptResult } from '../execution/PromptResult';
|
|
35
36
|
import type { ChatPromptResult } from '../execution/PromptResult';
|
|
@@ -241,6 +242,7 @@ import type { number_gigabytes } from '../types/typeAliases';
|
|
|
241
242
|
import type { number_terabytes } from '../types/typeAliases';
|
|
242
243
|
import type { Registered } from '../utils/$Register';
|
|
243
244
|
import type { Registration } from '../utils/$Register';
|
|
245
|
+
import type { PipelineEditableSerialized } from '../utils/editable/types/PipelineEditableSerialized';
|
|
244
246
|
import type { ExecCommandOptions } from '../utils/execCommand/ExecCommandOptions';
|
|
245
247
|
import type { ExecCommandOptionsAdvanced } from '../utils/execCommand/ExecCommandOptions';
|
|
246
248
|
import type { FromtoItems } from '../utils/FromtoItems';
|
|
@@ -292,6 +294,7 @@ export type { LlmExecutionTools };
|
|
|
292
294
|
export type { LlmExecutionToolsConstructor };
|
|
293
295
|
export type { PipelineExecutor };
|
|
294
296
|
export type { PipelineExecutorResult };
|
|
297
|
+
export type { PromptbookFetch };
|
|
295
298
|
export type { PromptResult };
|
|
296
299
|
export type { CompletionPromptResult };
|
|
297
300
|
export type { ChatPromptResult };
|
|
@@ -503,6 +506,7 @@ export type { number_gigabytes };
|
|
|
503
506
|
export type { number_terabytes };
|
|
504
507
|
export type { Registered };
|
|
505
508
|
export type { Registration };
|
|
509
|
+
export type { PipelineEditableSerialized };
|
|
506
510
|
export type { ExecCommandOptions };
|
|
507
511
|
export type { ExecCommandOptionsAdvanced };
|
|
508
512
|
export type { FromtoItems };
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
2
|
+
import { VALUE_STRINGS } from '../config';
|
|
3
|
+
import { SMALL_NUMBER } from '../config';
|
|
2
4
|
import { renderPromptbookMermaid } from '../conversion/prettify/renderPipelineMermaidOptions';
|
|
3
5
|
import { extractVariablesFromScript } from '../conversion/utils/extractVariablesFromScript';
|
|
4
6
|
import { deserializeError } from '../errors/utils/deserializeError';
|
|
@@ -46,7 +48,9 @@ import { searchKeywords } from '../utils/normalization/searchKeywords';
|
|
|
46
48
|
import { titleToName } from '../utils/normalization/titleToName';
|
|
47
49
|
import { spaceTrim } from '../utils/organization/spaceTrim';
|
|
48
50
|
import { extractParameterNames } from '../utils/parameters/extractParameterNames';
|
|
49
|
-
import {
|
|
51
|
+
import { numberToString } from '../utils/parameters/numberToString';
|
|
52
|
+
import { templateParameters } from '../utils/parameters/templateParameters';
|
|
53
|
+
import { valueToString } from '../utils/parameters/valueToString';
|
|
50
54
|
import { parseNumber } from '../utils/parseNumber';
|
|
51
55
|
import { $randomSeed } from '../utils/random/$randomSeed';
|
|
52
56
|
import { removeEmojis } from '../utils/removeEmojis';
|
|
@@ -74,6 +78,8 @@ import { isValidPipelineUrl } from '../utils/validators/url/isValidPipelineUrl';
|
|
|
74
78
|
import { isValidUrl } from '../utils/validators/url/isValidUrl';
|
|
75
79
|
import { isValidUuid } from '../utils/validators/uuid/isValidUuid';
|
|
76
80
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
81
|
+
export { VALUE_STRINGS };
|
|
82
|
+
export { SMALL_NUMBER };
|
|
77
83
|
export { renderPromptbookMermaid };
|
|
78
84
|
export { extractVariablesFromScript };
|
|
79
85
|
export { deserializeError };
|
|
@@ -121,7 +127,9 @@ export { searchKeywords };
|
|
|
121
127
|
export { titleToName };
|
|
122
128
|
export { spaceTrim };
|
|
123
129
|
export { extractParameterNames };
|
|
124
|
-
export {
|
|
130
|
+
export { numberToString };
|
|
131
|
+
export { templateParameters };
|
|
132
|
+
export { valueToString };
|
|
125
133
|
export { parseNumber };
|
|
126
134
|
export { $randomSeed };
|
|
127
135
|
export { removeEmojis };
|
|
@@ -77,6 +77,26 @@ export declare const LOOP_LIMIT = 1000;
|
|
|
77
77
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
78
78
|
*/
|
|
79
79
|
export declare const CHARACTER_LOOP_LIMIT = 100000;
|
|
80
|
+
/**
|
|
81
|
+
* Strings to represent various values in the context of parameter values
|
|
82
|
+
*
|
|
83
|
+
* @public exported from `@promptbook/utils`
|
|
84
|
+
*/
|
|
85
|
+
export declare const VALUE_STRINGS: {
|
|
86
|
+
readonly empty: "(nothing; empty string)";
|
|
87
|
+
readonly null: "(no value; null)";
|
|
88
|
+
readonly undefined: "(unknown value; undefined)";
|
|
89
|
+
readonly nan: "(not a number; NaN)";
|
|
90
|
+
readonly infinity: "(infinity; ∞)";
|
|
91
|
+
readonly negativeInfinity: "(negative infinity; -∞)";
|
|
92
|
+
readonly unserializable: "(unserializable value)";
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Small number limit
|
|
96
|
+
*
|
|
97
|
+
* @public exported from `@promptbook/utils`
|
|
98
|
+
*/
|
|
99
|
+
export declare const SMALL_NUMBER = 0.001;
|
|
80
100
|
/**
|
|
81
101
|
* Timeout for the connections in milliseconds
|
|
82
102
|
*
|
|
@@ -209,6 +229,12 @@ export declare function SET_IS_VERBOSE(isVerbose: boolean): void;
|
|
|
209
229
|
* @public exported from `@promptbook/core`
|
|
210
230
|
*/
|
|
211
231
|
export declare const DEFAULT_IS_AUTO_INSTALLED = false;
|
|
232
|
+
/**
|
|
233
|
+
* Function name for generated function via `ptbk make` to get the pipeline collection
|
|
234
|
+
*
|
|
235
|
+
* @public exported from `@promptbook/core`
|
|
236
|
+
*/
|
|
237
|
+
export declare const DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME = "getPipelineCollection";
|
|
212
238
|
/**
|
|
213
239
|
* @@@
|
|
214
240
|
*
|
|
@@ -3,6 +3,7 @@ import type { Arrayable } from '../types/Arrayable';
|
|
|
3
3
|
import type { Executables } from './Executables';
|
|
4
4
|
import type { FilesystemTools } from './FilesystemTools';
|
|
5
5
|
import type { LlmExecutionTools } from './LlmExecutionTools';
|
|
6
|
+
import type { PromptbookFetch } from './PromptbookFetch';
|
|
6
7
|
import type { ScriptExecutionTools } from './ScriptExecutionTools';
|
|
7
8
|
import type { UserInterfaceTools } from './UserInterfaceTools';
|
|
8
9
|
/**
|
|
@@ -27,6 +28,12 @@ export type ExecutionTools = {
|
|
|
27
28
|
* @default undefined - If not provided, no filesystem operations will be possible
|
|
28
29
|
*/
|
|
29
30
|
readonly fs?: FilesystemTools;
|
|
31
|
+
/**
|
|
32
|
+
* Fetch function for fetching resources
|
|
33
|
+
*
|
|
34
|
+
* @default `fetch` - If not provided, the built-in `fetch' function is used with a lightweight error handling wrapper.
|
|
35
|
+
*/
|
|
36
|
+
readonly fetch?: PromptbookFetch;
|
|
30
37
|
/**
|
|
31
38
|
* Scrapers for extracting knowledge from external sources
|
|
32
39
|
*
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { PromptbookFetch } from '../../execution/PromptbookFetch';
|
|
1
2
|
import type { string_name } from '../../types/typeAliases';
|
|
2
3
|
/**
|
|
3
4
|
* @private still in development
|
|
4
5
|
*/
|
|
5
|
-
export declare function isDomainNameFree(name: string_name): Promise<boolean>;
|
|
6
|
+
export declare function isDomainNameFree(name: string_name, fetch: PromptbookFetch): Promise<boolean>;
|
|
6
7
|
/**
|
|
7
8
|
* TODO: [🍓][🧠] Test and implement `isDomainNameFree`
|
|
8
9
|
* TODO: Export via some (and probably new) NPM package
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { PromptbookFetch } from '../../execution/PromptbookFetch';
|
|
1
2
|
import type { string_name } from '../../types/typeAliases';
|
|
2
3
|
/**
|
|
3
4
|
* @private still in development
|
|
4
5
|
*/
|
|
5
|
-
export declare function isGithubNameFree(name: string_name): Promise<boolean>;
|
|
6
|
+
export declare function isGithubNameFree(name: string_name, fetch: PromptbookFetch): Promise<boolean>;
|
|
6
7
|
/**
|
|
7
8
|
* TODO: [🍓][🧠] Test and implement `isGithubNameFree`
|
|
8
9
|
* TODO: Export via some (and probably new) NPM package
|
|
@@ -18,6 +18,11 @@ export declare const HIGH_LEVEL_ABSTRACTIONS: readonly [{
|
|
|
18
18
|
readonly knowledgePieces: import("../_packages/types.index").KnowledgePiecePreparedJson[];
|
|
19
19
|
readonly personas: (import("../_packages/types.index").PersonaJson | import("../_packages/types.index").PersonaPreparedJson)[];
|
|
20
20
|
readonly preparations: import("../_packages/types.index").PreparationJson[];
|
|
21
|
+
readonly sources: readonly {
|
|
22
|
+
type: "BOOK";
|
|
23
|
+
path: string | null;
|
|
24
|
+
content: import("../pipeline/PipelineString").PipelineString;
|
|
25
|
+
}[];
|
|
21
26
|
readonly formfactorName?: "CHATBOT" | "GENERATOR" | "GENERIC" | "EXPERIMENTAL_MATCHER" | "SHEETS" | "TRANSLATOR" | undefined;
|
|
22
27
|
}>): void;
|
|
23
28
|
}, {
|
|
@@ -35,6 +40,11 @@ export declare const HIGH_LEVEL_ABSTRACTIONS: readonly [{
|
|
|
35
40
|
readonly knowledgePieces: import("../_packages/types.index").KnowledgePiecePreparedJson[];
|
|
36
41
|
readonly personas: (import("../_packages/types.index").PersonaJson | import("../_packages/types.index").PersonaPreparedJson)[];
|
|
37
42
|
readonly preparations: import("../_packages/types.index").PreparationJson[];
|
|
43
|
+
readonly sources: readonly {
|
|
44
|
+
type: "BOOK";
|
|
45
|
+
path: string | null;
|
|
46
|
+
content: import("../pipeline/PipelineString").PipelineString;
|
|
47
|
+
}[];
|
|
38
48
|
readonly formfactorName?: "CHATBOT" | "GENERATOR" | "GENERIC" | "EXPERIMENTAL_MATCHER" | "SHEETS" | "TRANSLATOR" | undefined;
|
|
39
49
|
}>): void;
|
|
40
50
|
}];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { string_formfactor_name } from '../../formfactors/_common/string_formfactor_name';
|
|
2
|
+
import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
|
|
3
|
+
/**
|
|
4
|
+
* Get template for new book
|
|
5
|
+
*
|
|
6
|
+
* @public exported from `@promptbook/templates`
|
|
7
|
+
*/
|
|
8
|
+
export declare function getBookTemplate(formfactorName: string_formfactor_name): Promise<PipelineJson | null>;
|
|
9
|
+
/**
|
|
10
|
+
* TODO: [🧠] Which is the best place for this function
|
|
11
|
+
* TODO: !!!!!! `book string template notation
|
|
12
|
+
*/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PipelineCollection } from '../../collection/PipelineCollection';
|
|
2
|
+
/**
|
|
3
|
+
* Get pipeline collection for Untitled Promptbook project
|
|
4
|
+
*
|
|
5
|
+
* ⚠️ WARNING: This code has been generated by `@promptbook/cli` so that any manual changes will be overwritten
|
|
6
|
+
*
|
|
7
|
+
* @generated
|
|
8
|
+
* @returns {PipelineCollection} Library of promptbooks for Untitled Promptbook project
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTemplatesPipelineCollection(): PipelineCollection;
|
|
@@ -3,7 +3,9 @@ import type { ModelRequirements } from '../../types/ModelRequirements';
|
|
|
3
3
|
import type { string_filename } from '../../types/typeAliases';
|
|
4
4
|
import type { string_markdown_text } from '../../types/typeAliases';
|
|
5
5
|
import type { string_pipeline_url } from '../../types/typeAliases';
|
|
6
|
+
import type { string_relative_filename } from '../../types/typeAliases';
|
|
6
7
|
import type { string_semantic_version } from '../../types/typeAliases';
|
|
8
|
+
import type { PipelineString } from '../PipelineString';
|
|
7
9
|
import type { KnowledgePiecePreparedJson } from './KnowledgePieceJson';
|
|
8
10
|
import type { KnowledgeSourceJson } from './KnowledgeSourceJson';
|
|
9
11
|
import type { KnowledgeSourcePreparedJson } from './KnowledgeSourceJson';
|
|
@@ -91,6 +93,14 @@ export type PipelineJson = {
|
|
|
91
93
|
* @see https://github.com/webgptorg/promptbook/discussions/78
|
|
92
94
|
*/
|
|
93
95
|
readonly preparations: Array<PreparationJson>;
|
|
96
|
+
/**
|
|
97
|
+
* Backup of the original book source
|
|
98
|
+
*/
|
|
99
|
+
readonly sources: ReadonlyArray<{
|
|
100
|
+
type: 'BOOK';
|
|
101
|
+
path: string_relative_filename | null;
|
|
102
|
+
content: PipelineString;
|
|
103
|
+
}>;
|
|
94
104
|
};
|
|
95
105
|
/**
|
|
96
106
|
* TODO: [🛳] Default PERSONA for the pipeline `defaultPersonaName` (same as `defaultModelRequirements`)
|
|
@@ -8,4 +8,4 @@ import type { ScraperSourceHandler } from '../Scraper';
|
|
|
8
8
|
*
|
|
9
9
|
* @public exported from `@promptbook/core`
|
|
10
10
|
*/
|
|
11
|
-
export declare function makeKnowledgeSourceHandler(knowledgeSource: SetOptional<KnowledgeSourceJson, 'name'>, tools: Pick<ExecutionTools, 'fs'>, options?: Pick<PrepareAndScrapeOptions, 'rootDirname' | 'isVerbose'>): Promise<ScraperSourceHandler>;
|
|
11
|
+
export declare function makeKnowledgeSourceHandler(knowledgeSource: SetOptional<KnowledgeSourceJson, 'name'>, tools: Pick<ExecutionTools, 'fs' | 'fetch'>, options?: Pick<PrepareAndScrapeOptions, 'rootDirname' | 'isVerbose'>): Promise<ScraperSourceHandler>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PromptbookFetch } from '../../../execution/PromptbookFetch';
|
|
2
|
+
/**
|
|
3
|
+
* The built-in `fetch' function with a lightweight error handling wrapper as default fetch function used in Promptbook scrapers
|
|
4
|
+
*
|
|
5
|
+
* @private as default `fetch` function used in Promptbook scrapers
|
|
6
|
+
*/
|
|
7
|
+
export declare const scraperFetch: PromptbookFetch;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ErrorJson } from '../../../errors/utils/ErrorJson';
|
|
2
|
+
import type { PipelineJson } from '../../../pipeline/PipelineJson/PipelineJson';
|
|
3
|
+
import type { string_date_iso8601 } from '../../../types/typeAliases';
|
|
4
|
+
/**
|
|
5
|
+
* Represents a single pipeline in PromptbookStudio
|
|
6
|
+
*
|
|
7
|
+
* This is simple extension of PipelineJson with additional metadata
|
|
8
|
+
* Note: There are two similar entities:
|
|
9
|
+
* 1) Type (interface) `PipelineEditableSerialized` which represents just data in database
|
|
10
|
+
* 2) Class `PipelineEditable` which implements `PipelineEditableSerialized` and adds error handling and editing capabilities
|
|
11
|
+
*
|
|
12
|
+
* @public exported from `@promptbook/editable`
|
|
13
|
+
*/
|
|
14
|
+
export type PipelineEditableSerialized = PipelineJson & {
|
|
15
|
+
/**
|
|
16
|
+
* When was the pipeline created
|
|
17
|
+
*/
|
|
18
|
+
readonly createdAt: string_date_iso8601;
|
|
19
|
+
/**
|
|
20
|
+
* When was the pipeline last modified
|
|
21
|
+
*/
|
|
22
|
+
readonly updatedAt: string_date_iso8601 | null;
|
|
23
|
+
/**
|
|
24
|
+
* Known errors to transfer to new PipelineEditable
|
|
25
|
+
*/
|
|
26
|
+
readonly knownErrors: Array<ErrorJson>;
|
|
27
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CommandType } from '
|
|
2
|
-
import type { PipelineString } from '
|
|
1
|
+
import type { CommandType } from '../../../commands/_common/types/CommandType';
|
|
2
|
+
import type { PipelineString } from '../../../pipeline/PipelineString';
|
|
3
3
|
/**
|
|
4
4
|
* Options for `removePipelineCommand`
|
|
5
5
|
*/
|
|
@@ -16,7 +16,7 @@ type RemovePipelineCommandOptions = {
|
|
|
16
16
|
/**
|
|
17
17
|
* Function `removePipelineCommand` will remove one command from pipeline string
|
|
18
18
|
*
|
|
19
|
-
* @public exported from `@promptbook/
|
|
19
|
+
* @public exported from `@promptbook/editable`
|
|
20
20
|
*/
|
|
21
21
|
export declare function removePipelineCommand(options: RemovePipelineCommandOptions): PipelineString;
|
|
22
22
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PipelineJson } from '
|
|
2
|
-
import type { string_name } from '
|
|
1
|
+
import type { PipelineJson } from '../../../pipeline/PipelineJson/PipelineJson';
|
|
2
|
+
import type { string_name } from '../../../types/typeAliases';
|
|
3
3
|
type RenameParameterOptions = {
|
|
4
4
|
/**
|
|
5
5
|
* Pipeline to search and replace for parameters
|
|
@@ -20,7 +20,7 @@ type RenameParameterOptions = {
|
|
|
20
20
|
* In other words, it will find all parameters that are not used in the task itseld and all its dependencies
|
|
21
21
|
*
|
|
22
22
|
* @throws {PipelineLogicError} If the new parameter name is already used in the pipeline
|
|
23
|
-
* @public exported from `@promptbook/
|
|
23
|
+
* @public exported from `@promptbook/editable`
|
|
24
24
|
*/
|
|
25
25
|
export declare function renamePipelineParameter(options: RenameParameterOptions): PipelineJson;
|
|
26
26
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { string_json } from '
|
|
1
|
+
import type { string_json } from '../../../types/typeAliases';
|
|
2
2
|
/**
|
|
3
3
|
* Stringify the PipelineJson with proper formatting
|
|
4
4
|
*
|
|
5
5
|
* Note: [0] It can be used for more JSON types like whole collection of pipelines, single knowledge piece, etc.
|
|
6
6
|
* Note: In contrast to JSON.stringify, this function ensures that **embedding index** is on single line
|
|
7
7
|
*
|
|
8
|
-
* @public exported from `@promptbook/
|
|
8
|
+
* @public exported from `@promptbook/editable`
|
|
9
9
|
*/
|
|
10
10
|
export declare function stringifyPipelineJson<TType>(pipeline: TType): string_json<TType>;
|
|
11
11
|
/**
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { string_parameter_name } from '../../types/typeAliases';
|
|
2
2
|
import type { string_template } from '../../types/typeAliases';
|
|
3
|
+
import type { really_unknown } from '../organization/really_unknown';
|
|
3
4
|
/**
|
|
4
5
|
* Replaces parameters in template with values from parameters object
|
|
5
6
|
*
|
|
7
|
+
* Note: This function is not places strings into string,
|
|
8
|
+
* It's more complex and can handle this operation specifically for LLM models
|
|
9
|
+
*
|
|
6
10
|
* @param template the template with parameters in {curly} braces
|
|
7
11
|
* @param parameters the object with parameters
|
|
8
12
|
* @returns the template with replaced parameters
|
|
9
13
|
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
10
14
|
* @public exported from `@promptbook/utils`
|
|
11
15
|
*/
|
|
12
|
-
export declare function
|
|
16
|
+
export declare function templateParameters(template: string_template, parameters: Record<string_parameter_name, really_unknown>): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { string_parameter_value } from '../../types/typeAliases';
|
|
2
|
+
import type { really_unknown } from '../organization/really_unknown';
|
|
3
|
+
/**
|
|
4
|
+
* Function `valueToString` will convert the given value to string
|
|
5
|
+
* This is useful and used in the `templateParameters` function
|
|
6
|
+
*
|
|
7
|
+
* Note: This function is not just calling `toString` method
|
|
8
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
9
|
+
* See `VALUE_STRINGS`
|
|
10
|
+
*
|
|
11
|
+
* Note: There are 2 similar functions
|
|
12
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
13
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
14
|
+
*
|
|
15
|
+
* @public exported from `@promptbook/utils`
|
|
16
|
+
*/
|
|
17
|
+
export declare function valueToString(value: really_unknown): string_parameter_value;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,6 +6,10 @@ import type { really_any } from '../organization/really_any';
|
|
|
6
6
|
* For example:
|
|
7
7
|
* - `Date` objects will be converted to string
|
|
8
8
|
*
|
|
9
|
+
* Note: There are 2 similar functions
|
|
10
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
11
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
12
|
+
*
|
|
9
13
|
* @private Internal helper function
|
|
10
14
|
*/
|
|
11
15
|
export declare function asSerializable(value: really_any): really_any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/openai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.81.0-6",
|
|
4
4
|
"description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
|
|
5
5
|
"--note-0": " <- [🐊]",
|
|
6
6
|
"private": false,
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"module": "./esm/index.es.js",
|
|
55
55
|
"typings": "./esm/typings/src/_packages/openai.index.d.ts",
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@promptbook/core": "0.
|
|
57
|
+
"@promptbook/core": "0.81.0-6"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*
|
|
23
23
|
* @see https://github.com/webgptorg/promptbook
|
|
24
24
|
*/
|
|
25
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
25
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-5';
|
|
26
26
|
/**
|
|
27
27
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
28
28
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -330,6 +330,26 @@
|
|
|
330
330
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
331
331
|
*/
|
|
332
332
|
var LOOP_LIMIT = 1000;
|
|
333
|
+
/**
|
|
334
|
+
* Strings to represent various values in the context of parameter values
|
|
335
|
+
*
|
|
336
|
+
* @public exported from `@promptbook/utils`
|
|
337
|
+
*/
|
|
338
|
+
var VALUE_STRINGS = {
|
|
339
|
+
empty: '(nothing; empty string)',
|
|
340
|
+
null: '(no value; null)',
|
|
341
|
+
undefined: '(unknown value; undefined)',
|
|
342
|
+
nan: '(not a number; NaN)',
|
|
343
|
+
infinity: '(infinity; ∞)',
|
|
344
|
+
negativeInfinity: '(negative infinity; -∞)',
|
|
345
|
+
unserializable: '(unserializable value)',
|
|
346
|
+
};
|
|
347
|
+
/**
|
|
348
|
+
* Small number limit
|
|
349
|
+
*
|
|
350
|
+
* @public exported from `@promptbook/utils`
|
|
351
|
+
*/
|
|
352
|
+
var SMALL_NUMBER = 0.001;
|
|
333
353
|
// <- TODO: [🧜♂️]
|
|
334
354
|
/**
|
|
335
355
|
* @@@
|
|
@@ -633,16 +653,94 @@
|
|
|
633
653
|
return LimitReachedError;
|
|
634
654
|
}(Error));
|
|
635
655
|
|
|
656
|
+
/**
|
|
657
|
+
* Format either small or big number
|
|
658
|
+
*
|
|
659
|
+
* @public exported from `@promptbook/utils`
|
|
660
|
+
*/
|
|
661
|
+
function numberToString(value) {
|
|
662
|
+
if (value === 0) {
|
|
663
|
+
return '0';
|
|
664
|
+
}
|
|
665
|
+
else if (Number.isNaN(value)) {
|
|
666
|
+
return VALUE_STRINGS.nan;
|
|
667
|
+
}
|
|
668
|
+
else if (value === Infinity) {
|
|
669
|
+
return VALUE_STRINGS.infinity;
|
|
670
|
+
}
|
|
671
|
+
else if (value === -Infinity) {
|
|
672
|
+
return VALUE_STRINGS.negativeInfinity;
|
|
673
|
+
}
|
|
674
|
+
for (var exponent = 0; exponent < 15; exponent++) {
|
|
675
|
+
var factor = Math.pow(10, exponent);
|
|
676
|
+
var valueRounded = Math.round(value * factor) / factor;
|
|
677
|
+
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
678
|
+
return valueRounded.toFixed(exponent);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
return value.toString();
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Function `valueToString` will convert the given value to string
|
|
686
|
+
* This is useful and used in the `templateParameters` function
|
|
687
|
+
*
|
|
688
|
+
* Note: This function is not just calling `toString` method
|
|
689
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
690
|
+
* See `VALUE_STRINGS`
|
|
691
|
+
*
|
|
692
|
+
* Note: There are 2 similar functions
|
|
693
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
694
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
695
|
+
*
|
|
696
|
+
* @public exported from `@promptbook/utils`
|
|
697
|
+
*/
|
|
698
|
+
function valueToString(value) {
|
|
699
|
+
try {
|
|
700
|
+
if (value === '') {
|
|
701
|
+
return VALUE_STRINGS.empty;
|
|
702
|
+
}
|
|
703
|
+
else if (value === null) {
|
|
704
|
+
return VALUE_STRINGS.null;
|
|
705
|
+
}
|
|
706
|
+
else if (value === undefined) {
|
|
707
|
+
return VALUE_STRINGS.undefined;
|
|
708
|
+
}
|
|
709
|
+
else if (typeof value === 'string') {
|
|
710
|
+
return value;
|
|
711
|
+
}
|
|
712
|
+
else if (typeof value === 'number') {
|
|
713
|
+
return numberToString(value);
|
|
714
|
+
}
|
|
715
|
+
else if (value instanceof Date) {
|
|
716
|
+
return value.toISOString();
|
|
717
|
+
}
|
|
718
|
+
else {
|
|
719
|
+
return JSON.stringify(value);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
catch (error) {
|
|
723
|
+
if (!(error instanceof Error)) {
|
|
724
|
+
throw error;
|
|
725
|
+
}
|
|
726
|
+
console.error(error);
|
|
727
|
+
return VALUE_STRINGS.unserializable;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
|
|
636
731
|
/**
|
|
637
732
|
* Replaces parameters in template with values from parameters object
|
|
638
733
|
*
|
|
734
|
+
* Note: This function is not places strings into string,
|
|
735
|
+
* It's more complex and can handle this operation specifically for LLM models
|
|
736
|
+
*
|
|
639
737
|
* @param template the template with parameters in {curly} braces
|
|
640
738
|
* @param parameters the object with parameters
|
|
641
739
|
* @returns the template with replaced parameters
|
|
642
740
|
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
643
741
|
* @public exported from `@promptbook/utils`
|
|
644
742
|
*/
|
|
645
|
-
function
|
|
743
|
+
function templateParameters(template, parameters) {
|
|
646
744
|
var e_1, _a;
|
|
647
745
|
try {
|
|
648
746
|
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -668,7 +766,7 @@
|
|
|
668
766
|
var loopLimit = LOOP_LIMIT;
|
|
669
767
|
var _loop_1 = function () {
|
|
670
768
|
if (loopLimit-- < 0) {
|
|
671
|
-
throw new LimitReachedError('Loop limit reached during parameters replacement in `
|
|
769
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `templateParameters`');
|
|
672
770
|
}
|
|
673
771
|
var precol = match.groups.precol;
|
|
674
772
|
var parameterName = match.groups.parameterName;
|
|
@@ -685,7 +783,7 @@
|
|
|
685
783
|
if (parameterValue === undefined) {
|
|
686
784
|
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
687
785
|
}
|
|
688
|
-
parameterValue = parameterValue
|
|
786
|
+
parameterValue = valueToString(parameterValue);
|
|
689
787
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
690
788
|
parameterValue = parameterValue
|
|
691
789
|
.split('\n')
|
|
@@ -1669,7 +1767,7 @@
|
|
|
1669
1767
|
type: 'json_object',
|
|
1670
1768
|
};
|
|
1671
1769
|
}
|
|
1672
|
-
rawPromptContent =
|
|
1770
|
+
rawPromptContent = templateParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
|
|
1673
1771
|
rawRequest = __assign(__assign({}, modelSettings), { messages: __spreadArray(__spreadArray([], __read((modelRequirements.systemMessage === undefined
|
|
1674
1772
|
? []
|
|
1675
1773
|
: [
|
|
@@ -1765,7 +1863,7 @@
|
|
|
1765
1863
|
// <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
|
|
1766
1864
|
// <- Note: [🧆]
|
|
1767
1865
|
};
|
|
1768
|
-
rawPromptContent =
|
|
1866
|
+
rawPromptContent = templateParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
|
|
1769
1867
|
rawRequest = __assign(__assign({}, modelSettings), { prompt: rawPromptContent, user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString() });
|
|
1770
1868
|
start = $getCurrentDate();
|
|
1771
1869
|
if (this.options.isVerbose) {
|
|
@@ -1837,7 +1935,7 @@
|
|
|
1837
1935
|
throw new PipelineExecutionError('Use embed only for EMBEDDING variant');
|
|
1838
1936
|
}
|
|
1839
1937
|
modelName = modelRequirements.modelName || this.getDefaultEmbeddingModel().modelName;
|
|
1840
|
-
rawPromptContent =
|
|
1938
|
+
rawPromptContent = templateParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
|
|
1841
1939
|
rawRequest = {
|
|
1842
1940
|
input: rawPromptContent,
|
|
1843
1941
|
model: modelName,
|
|
@@ -2007,7 +2105,7 @@
|
|
|
2007
2105
|
}
|
|
2008
2106
|
finally { if (e_1) throw e_1.error; }
|
|
2009
2107
|
}
|
|
2010
|
-
rawPromptContent =
|
|
2108
|
+
rawPromptContent = templateParameters(content, __assign(__assign({}, parameters), { modelName: 'assistant' }));
|
|
2011
2109
|
rawRequest = {
|
|
2012
2110
|
// TODO: [👨👨👧👧] ...modelSettings,
|
|
2013
2111
|
// TODO: [👨👨👧👧][🧠] What about system message for assistants, does it make sence - combination of OpenAI assistants with Promptbook Personas
|