@promptbook/openai 0.80.0 → 0.81.0-12
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 +8 -1
- package/esm/index.es.js +111 -9
- 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 +6 -0
- package/esm/typings/src/_packages/utils.index.d.ts +12 -2
- package/esm/typings/src/_packages/wizzard.index.d.ts +44 -0
- package/esm/typings/src/config.d.ts +26 -0
- package/esm/typings/src/execution/ExecutionTools.d.ts +7 -0
- package/esm/typings/src/execution/PipelineExecutor.d.ts +2 -2
- 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/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -2
- 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/llm-providers/_common/register/{$provideLlmToolsForCli.d.ts → $provideLlmToolsForWizzardOrCli.d.ts} +2 -2
- package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -0
- package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +2 -0
- package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +1 -0
- package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -0
- package/esm/typings/src/llm-providers/google/register-configuration.d.ts +1 -0
- package/esm/typings/src/llm-providers/google/register-constructor.d.ts +1 -0
- package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +2 -0
- package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +2 -0
- package/esm/typings/src/other/templates/getBookTemplate.d.ts +19 -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 +10 -0
- package/esm/typings/src/scrapers/document/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -0
- package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -0
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -0
- package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -0
- package/esm/typings/src/types/typeAliases.d.ts +8 -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/esm/typings/src/utils/validators/filePath/isPathRoot.d.ts +12 -0
- package/esm/typings/src/utils/validators/filePath/isPathRoot.test.d.ts +4 -0
- package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +3 -0
- package/esm/typings/src/version.d.ts +7 -0
- package/esm/typings/src/wizzard/$getCompiledBook.d.ts +16 -0
- package/esm/typings/src/wizzard/wizzard.d.ts +51 -0
- package/package.json +2 -2
- package/umd/index.umd.js +111 -9
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/scripting/javascript/utils/unknownToString.d.ts +0 -8
- 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
|
@@ -5,6 +5,7 @@ import type { Registration } from '../../utils/$Register';
|
|
|
5
5
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
6
6
|
*
|
|
7
7
|
* @public exported from `@promptbook/pdf`
|
|
8
|
+
* @public exported from `@promptbook/wizzard`
|
|
8
9
|
* @public exported from `@promptbook/cli`
|
|
9
10
|
*/
|
|
10
11
|
export declare const _PdfScraperRegistration: Registration;
|
|
@@ -19,6 +19,7 @@ export declare const pdfScraperMetadata: import("type-fest/source/readonly-deep"
|
|
|
19
19
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
20
20
|
*
|
|
21
21
|
* @public exported from `@promptbook/core`
|
|
22
|
+
* @public exported from `@promptbook/wizzard`
|
|
22
23
|
* @public exported from `@promptbook/cli`
|
|
23
24
|
*/
|
|
24
25
|
export declare const _PdfScraperMetadataRegistration: Registration;
|
|
@@ -5,6 +5,7 @@ import type { Registration } from '../../utils/$Register';
|
|
|
5
5
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
6
6
|
*
|
|
7
7
|
* @public exported from `@promptbook/website-crawler`
|
|
8
|
+
* @public exported from `@promptbook/wizzard`
|
|
8
9
|
* @public exported from `@promptbook/cli`
|
|
9
10
|
*/
|
|
10
11
|
export declare const _WebsiteScraperRegistration: Registration;
|
|
@@ -19,6 +19,7 @@ export declare const websiteScraperMetadata: import("type-fest/source/readonly-d
|
|
|
19
19
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
|
|
20
20
|
*
|
|
21
21
|
* @public exported from `@promptbook/core`
|
|
22
|
+
* @public exported from `@promptbook/wizzard`
|
|
22
23
|
* @public exported from `@promptbook/cli`
|
|
23
24
|
*/
|
|
24
25
|
export declare const _WebsiteScraperMetadataRegistration: Registration;
|
|
@@ -9,5 +9,6 @@ import type { really_any } from '../../../utils/organization/really_any';
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function preserve(func: (...params: ReadonlyArray<really_any>) => unknown): void;
|
|
11
11
|
/**
|
|
12
|
+
* TODO: Probbably remove in favour of `keepImported`
|
|
12
13
|
* TODO: !! [1] This maybe does memory leak
|
|
13
14
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TupleToUnion } from 'type-fest';
|
|
2
2
|
import { RESERVED_PARAMETER_NAMES } from '../constants';
|
|
3
|
+
import type { really_unknown } from '../utils/organization/really_unknown';
|
|
3
4
|
/**
|
|
4
5
|
* Semantic helper
|
|
5
6
|
*/
|
|
@@ -107,6 +108,13 @@ export type string_parameter_value = string;
|
|
|
107
108
|
* @see https://ptbk.io/parameters
|
|
108
109
|
*/
|
|
109
110
|
export type Parameters = Exclude<Record<string_parameter_name, string_parameter_value>, ReservedParameters>;
|
|
111
|
+
/**
|
|
112
|
+
* Parameters to pass to execution of the pipeline
|
|
113
|
+
*
|
|
114
|
+
* Note: [🚉] This should be fully serializable as JSON
|
|
115
|
+
* @see https://ptbk.io/parameters
|
|
116
|
+
*/
|
|
117
|
+
export type InputParameters = Exclude<Record<string_parameter_name, really_unknown>, ReservedParameters>;
|
|
110
118
|
/**
|
|
111
119
|
* Semantic helper
|
|
112
120
|
* Unique identifier of reserved parameter
|
|
@@ -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;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { string_dirname } from '../../../types/typeAliases';
|
|
2
|
+
import type { string_filename } from '../../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Determines if the given path is a root path.
|
|
5
|
+
*
|
|
6
|
+
* Note: This does not check if the file exists only if the path is valid
|
|
7
|
+
* @public exported from `@promptbook/utils`
|
|
8
|
+
*/
|
|
9
|
+
export declare function isPathRoot(value: string_dirname | string_filename): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* TODO: [🍏] Make for MacOS paths
|
|
12
|
+
*/
|
|
@@ -2,15 +2,22 @@ import type { string_semantic_version } from './types/typeAliases';
|
|
|
2
2
|
/**
|
|
3
3
|
* The version of the Book language
|
|
4
4
|
*
|
|
5
|
+
* @generated
|
|
5
6
|
* @see https://github.com/webgptorg/book
|
|
6
7
|
*/
|
|
7
8
|
export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
8
9
|
/**
|
|
9
10
|
* The version of the Promptbook engine
|
|
10
11
|
*
|
|
12
|
+
* @generated
|
|
11
13
|
* @see https://github.com/webgptorg/promptbook
|
|
12
14
|
*/
|
|
13
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
|
+
/**
|
|
17
|
+
* @@@
|
|
18
|
+
*
|
|
19
|
+
* @generated
|
|
20
|
+
*/
|
|
14
21
|
export type string_promptbook_version = string_semantic_version;
|
|
15
22
|
/**
|
|
16
23
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ExecutionTools } from '../execution/ExecutionTools';
|
|
2
|
+
import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
|
|
3
|
+
import type { PipelineString } from '../pipeline/PipelineString';
|
|
4
|
+
import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions';
|
|
5
|
+
import type { string_filename } from '../types/typeAliases';
|
|
6
|
+
import type { string_pipeline_url } from '../types/typeAliases';
|
|
7
|
+
/**
|
|
8
|
+
* @see ./wizzard.ts `getPipeline` method
|
|
9
|
+
*
|
|
10
|
+
* @private usable through `ptbk run` and `@prompbook/wizzard`
|
|
11
|
+
*/
|
|
12
|
+
export declare function $getCompiledBook(tools: Required<Pick<ExecutionTools, 'fs' | 'fetch'>>, pipelineSource: string_filename | string_pipeline_url | PipelineString, options?: PrepareAndScrapeOptions): Promise<PipelineJson>;
|
|
13
|
+
/**
|
|
14
|
+
* TODO: Write unit test
|
|
15
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
16
|
+
*/
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Promisable } from 'type-fest';
|
|
2
|
+
import type { ExecutionTools } from '../execution/ExecutionTools';
|
|
3
|
+
import type { PipelineExecutorResult } from '../execution/PipelineExecutorResult';
|
|
4
|
+
import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
|
|
5
|
+
import type { PipelineString } from '../pipeline/PipelineString';
|
|
6
|
+
import type { TaskProgress } from '../types/TaskProgress';
|
|
7
|
+
import type { InputParameters } from '../types/typeAliases';
|
|
8
|
+
import type { string_filename } from '../types/typeAliases';
|
|
9
|
+
import type { string_pipeline_url } from '../types/typeAliases';
|
|
10
|
+
/**
|
|
11
|
+
* Look at `wizzard` for more details
|
|
12
|
+
*
|
|
13
|
+
* @private just for single instance
|
|
14
|
+
*/
|
|
15
|
+
declare class Wizzard {
|
|
16
|
+
/**
|
|
17
|
+
* @@@!!!!!!
|
|
18
|
+
*/
|
|
19
|
+
execute(book: string_pipeline_url, inputParameters: InputParameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<PipelineExecutorResult>;
|
|
20
|
+
private executionTools;
|
|
21
|
+
/**
|
|
22
|
+
* @@@!!!
|
|
23
|
+
*
|
|
24
|
+
* @param pipelineSource
|
|
25
|
+
*/
|
|
26
|
+
getExecutionTools(): Promise<Required<Pick<ExecutionTools, 'fs' | 'fetch'>>>;
|
|
27
|
+
/**
|
|
28
|
+
* TODO: Make standalone function from this exported from node and used here and in `ptbk run`
|
|
29
|
+
* @@@!!!
|
|
30
|
+
*
|
|
31
|
+
* Strategies:
|
|
32
|
+
* 1) @@@!!!
|
|
33
|
+
* 2) @@@!!!
|
|
34
|
+
*
|
|
35
|
+
* @param pipelineSource
|
|
36
|
+
*/
|
|
37
|
+
getCompiledBook(pipelineSource: string_filename | string_pipeline_url | PipelineString): Promise<PipelineJson>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 🧙♂️ @@@
|
|
41
|
+
*
|
|
42
|
+
* @singleton
|
|
43
|
+
* @public exported from `@promptbook/wizzard`
|
|
44
|
+
*/
|
|
45
|
+
export declare const wizzard: Wizzard;
|
|
46
|
+
export {};
|
|
47
|
+
/**
|
|
48
|
+
* TODO: !!!!!! Mark in jsdoc as non-pure
|
|
49
|
+
* TODO: !!!!!! Add to readmes - one markdown here imported in all packages
|
|
50
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
51
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/openai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.81.0-12",
|
|
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-12"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"colors": "1.4.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -14,15 +14,17 @@
|
|
|
14
14
|
/**
|
|
15
15
|
* The version of the Book language
|
|
16
16
|
*
|
|
17
|
+
* @generated
|
|
17
18
|
* @see https://github.com/webgptorg/book
|
|
18
19
|
*/
|
|
19
20
|
var BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
20
21
|
/**
|
|
21
22
|
* The version of the Promptbook engine
|
|
22
23
|
*
|
|
24
|
+
* @generated
|
|
23
25
|
* @see https://github.com/webgptorg/promptbook
|
|
24
26
|
*/
|
|
25
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
27
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.81.0-11';
|
|
26
28
|
/**
|
|
27
29
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
28
30
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -330,6 +332,26 @@
|
|
|
330
332
|
* @private within the repository - too low-level in comparison with other `MAX_...`
|
|
331
333
|
*/
|
|
332
334
|
var LOOP_LIMIT = 1000;
|
|
335
|
+
/**
|
|
336
|
+
* Strings to represent various values in the context of parameter values
|
|
337
|
+
*
|
|
338
|
+
* @public exported from `@promptbook/utils`
|
|
339
|
+
*/
|
|
340
|
+
var VALUE_STRINGS = {
|
|
341
|
+
empty: '(nothing; empty string)',
|
|
342
|
+
null: '(no value; null)',
|
|
343
|
+
undefined: '(unknown value; undefined)',
|
|
344
|
+
nan: '(not a number; NaN)',
|
|
345
|
+
infinity: '(infinity; ∞)',
|
|
346
|
+
negativeInfinity: '(negative infinity; -∞)',
|
|
347
|
+
unserializable: '(unserializable value)',
|
|
348
|
+
};
|
|
349
|
+
/**
|
|
350
|
+
* Small number limit
|
|
351
|
+
*
|
|
352
|
+
* @public exported from `@promptbook/utils`
|
|
353
|
+
*/
|
|
354
|
+
var SMALL_NUMBER = 0.001;
|
|
333
355
|
// <- TODO: [🧜♂️]
|
|
334
356
|
/**
|
|
335
357
|
* @@@
|
|
@@ -483,7 +505,7 @@
|
|
|
483
505
|
if (!(error instanceof Error)) {
|
|
484
506
|
throw error;
|
|
485
507
|
}
|
|
486
|
-
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.
|
|
508
|
+
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.stack || error.message), "\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
|
|
487
509
|
}
|
|
488
510
|
/*
|
|
489
511
|
TODO: [0] Is there some more elegant way to check circular references?
|
|
@@ -633,16 +655,94 @@
|
|
|
633
655
|
return LimitReachedError;
|
|
634
656
|
}(Error));
|
|
635
657
|
|
|
658
|
+
/**
|
|
659
|
+
* Format either small or big number
|
|
660
|
+
*
|
|
661
|
+
* @public exported from `@promptbook/utils`
|
|
662
|
+
*/
|
|
663
|
+
function numberToString(value) {
|
|
664
|
+
if (value === 0) {
|
|
665
|
+
return '0';
|
|
666
|
+
}
|
|
667
|
+
else if (Number.isNaN(value)) {
|
|
668
|
+
return VALUE_STRINGS.nan;
|
|
669
|
+
}
|
|
670
|
+
else if (value === Infinity) {
|
|
671
|
+
return VALUE_STRINGS.infinity;
|
|
672
|
+
}
|
|
673
|
+
else if (value === -Infinity) {
|
|
674
|
+
return VALUE_STRINGS.negativeInfinity;
|
|
675
|
+
}
|
|
676
|
+
for (var exponent = 0; exponent < 15; exponent++) {
|
|
677
|
+
var factor = Math.pow(10, exponent);
|
|
678
|
+
var valueRounded = Math.round(value * factor) / factor;
|
|
679
|
+
if (Math.abs(value - valueRounded) / value < SMALL_NUMBER) {
|
|
680
|
+
return valueRounded.toFixed(exponent);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return value.toString();
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Function `valueToString` will convert the given value to string
|
|
688
|
+
* This is useful and used in the `templateParameters` function
|
|
689
|
+
*
|
|
690
|
+
* Note: This function is not just calling `toString` method
|
|
691
|
+
* It's more complex and can handle this conversion specifically for LLM models
|
|
692
|
+
* See `VALUE_STRINGS`
|
|
693
|
+
*
|
|
694
|
+
* Note: There are 2 similar functions
|
|
695
|
+
* - `valueToString` converts value to string for LLM models as human-readable string
|
|
696
|
+
* - `asSerializable` converts value to string to preserve full information to be able to convert it back
|
|
697
|
+
*
|
|
698
|
+
* @public exported from `@promptbook/utils`
|
|
699
|
+
*/
|
|
700
|
+
function valueToString(value) {
|
|
701
|
+
try {
|
|
702
|
+
if (value === '') {
|
|
703
|
+
return VALUE_STRINGS.empty;
|
|
704
|
+
}
|
|
705
|
+
else if (value === null) {
|
|
706
|
+
return VALUE_STRINGS.null;
|
|
707
|
+
}
|
|
708
|
+
else if (value === undefined) {
|
|
709
|
+
return VALUE_STRINGS.undefined;
|
|
710
|
+
}
|
|
711
|
+
else if (typeof value === 'string') {
|
|
712
|
+
return value;
|
|
713
|
+
}
|
|
714
|
+
else if (typeof value === 'number') {
|
|
715
|
+
return numberToString(value);
|
|
716
|
+
}
|
|
717
|
+
else if (value instanceof Date) {
|
|
718
|
+
return value.toISOString();
|
|
719
|
+
}
|
|
720
|
+
else {
|
|
721
|
+
return JSON.stringify(value);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
catch (error) {
|
|
725
|
+
if (!(error instanceof Error)) {
|
|
726
|
+
throw error;
|
|
727
|
+
}
|
|
728
|
+
console.error(error);
|
|
729
|
+
return VALUE_STRINGS.unserializable;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
|
|
636
733
|
/**
|
|
637
734
|
* Replaces parameters in template with values from parameters object
|
|
638
735
|
*
|
|
736
|
+
* Note: This function is not places strings into string,
|
|
737
|
+
* It's more complex and can handle this operation specifically for LLM models
|
|
738
|
+
*
|
|
639
739
|
* @param template the template with parameters in {curly} braces
|
|
640
740
|
* @param parameters the object with parameters
|
|
641
741
|
* @returns the template with replaced parameters
|
|
642
742
|
* @throws {PipelineExecutionError} if parameter is not defined, not closed, or not opened
|
|
643
743
|
* @public exported from `@promptbook/utils`
|
|
644
744
|
*/
|
|
645
|
-
function
|
|
745
|
+
function templateParameters(template, parameters) {
|
|
646
746
|
var e_1, _a;
|
|
647
747
|
try {
|
|
648
748
|
for (var _b = __values(Object.entries(parameters)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -668,7 +768,7 @@
|
|
|
668
768
|
var loopLimit = LOOP_LIMIT;
|
|
669
769
|
var _loop_1 = function () {
|
|
670
770
|
if (loopLimit-- < 0) {
|
|
671
|
-
throw new LimitReachedError('Loop limit reached during parameters replacement in `
|
|
771
|
+
throw new LimitReachedError('Loop limit reached during parameters replacement in `templateParameters`');
|
|
672
772
|
}
|
|
673
773
|
var precol = match.groups.precol;
|
|
674
774
|
var parameterName = match.groups.parameterName;
|
|
@@ -685,7 +785,7 @@
|
|
|
685
785
|
if (parameterValue === undefined) {
|
|
686
786
|
throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
|
|
687
787
|
}
|
|
688
|
-
parameterValue = parameterValue
|
|
788
|
+
parameterValue = valueToString(parameterValue);
|
|
689
789
|
if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
|
|
690
790
|
parameterValue = parameterValue
|
|
691
791
|
.split('\n')
|
|
@@ -1669,7 +1769,7 @@
|
|
|
1669
1769
|
type: 'json_object',
|
|
1670
1770
|
};
|
|
1671
1771
|
}
|
|
1672
|
-
rawPromptContent =
|
|
1772
|
+
rawPromptContent = templateParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
|
|
1673
1773
|
rawRequest = __assign(__assign({}, modelSettings), { messages: __spreadArray(__spreadArray([], __read((modelRequirements.systemMessage === undefined
|
|
1674
1774
|
? []
|
|
1675
1775
|
: [
|
|
@@ -1765,7 +1865,7 @@
|
|
|
1765
1865
|
// <- TODO: [🈁] Use `seed` here AND/OR use is `isDeterministic` for entire execution tools
|
|
1766
1866
|
// <- Note: [🧆]
|
|
1767
1867
|
};
|
|
1768
|
-
rawPromptContent =
|
|
1868
|
+
rawPromptContent = templateParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
|
|
1769
1869
|
rawRequest = __assign(__assign({}, modelSettings), { prompt: rawPromptContent, user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString() });
|
|
1770
1870
|
start = $getCurrentDate();
|
|
1771
1871
|
if (this.options.isVerbose) {
|
|
@@ -1837,7 +1937,7 @@
|
|
|
1837
1937
|
throw new PipelineExecutionError('Use embed only for EMBEDDING variant');
|
|
1838
1938
|
}
|
|
1839
1939
|
modelName = modelRequirements.modelName || this.getDefaultEmbeddingModel().modelName;
|
|
1840
|
-
rawPromptContent =
|
|
1940
|
+
rawPromptContent = templateParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
|
|
1841
1941
|
rawRequest = {
|
|
1842
1942
|
input: rawPromptContent,
|
|
1843
1943
|
model: modelName,
|
|
@@ -2007,7 +2107,7 @@
|
|
|
2007
2107
|
}
|
|
2008
2108
|
finally { if (e_1) throw e_1.error; }
|
|
2009
2109
|
}
|
|
2010
|
-
rawPromptContent =
|
|
2110
|
+
rawPromptContent = templateParameters(content, __assign(__assign({}, parameters), { modelName: 'assistant' }));
|
|
2011
2111
|
rawRequest = {
|
|
2012
2112
|
// TODO: [👨👨👧👧] ...modelSettings,
|
|
2013
2113
|
// TODO: [👨👨👧👧][🧠] What about system message for assistants, does it make sence - combination of OpenAI assistants with Promptbook Personas
|
|
@@ -2308,6 +2408,7 @@
|
|
|
2308
2408
|
* Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
|
|
2309
2409
|
*
|
|
2310
2410
|
* @public exported from `@promptbook/openai`
|
|
2411
|
+
* @public exported from `@promptbook/wizzard`
|
|
2311
2412
|
* @public exported from `@promptbook/cli`
|
|
2312
2413
|
*/
|
|
2313
2414
|
var _OpenAiRegistration = $llmToolsRegister.register(createOpenAiExecutionTools);
|
|
@@ -2317,6 +2418,7 @@
|
|
|
2317
2418
|
* Note: [🏐] Configurations registrations are done in @@@ BUT constructor @@@
|
|
2318
2419
|
*
|
|
2319
2420
|
* @public exported from `@promptbook/openai`
|
|
2421
|
+
* @public exported from `@promptbook/wizzard`
|
|
2320
2422
|
* @public exported from `@promptbook/cli`
|
|
2321
2423
|
*/
|
|
2322
2424
|
var _OpenAiAssistantRegistration = $llmToolsRegister.register(createOpenAiAssistantExecutionTools);
|