@promptbook/openai 0.92.0-22 → 0.92.0-24

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.
Files changed (35) hide show
  1. package/esm/index.es.js +20 -6
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/core.index.d.ts +6 -0
  4. package/esm/typings/src/collection/PipelineCollection.d.ts +0 -2
  5. package/esm/typings/src/collection/SimplePipelineCollection.d.ts +1 -1
  6. package/esm/typings/src/commands/FOREACH/ForeachJson.d.ts +6 -6
  7. package/esm/typings/src/commands/FORMFACTOR/formfactorCommandParser.d.ts +1 -1
  8. package/esm/typings/src/config.d.ts +33 -11
  9. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +12 -9
  10. package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +11 -8
  11. package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +8 -3
  12. package/esm/typings/src/execution/createPipelineExecutor/getReservedParametersForTask.d.ts +10 -8
  13. package/esm/typings/src/formats/_common/FormatParser.d.ts +5 -3
  14. package/esm/typings/src/formats/_common/FormatSubvalueParser.d.ts +31 -6
  15. package/esm/typings/src/formats/csv/utils/isValidCsvString.d.ts +1 -1
  16. package/esm/typings/src/formats/json/utils/isValidJsonString.d.ts +1 -1
  17. package/esm/typings/src/formats/xml/utils/isValidXmlString.d.ts +1 -1
  18. package/esm/typings/src/formfactors/_boilerplate/BoilerplateFormfactorDefinition.d.ts +3 -2
  19. package/esm/typings/src/formfactors/_common/string_formfactor_name.d.ts +2 -1
  20. package/esm/typings/src/formfactors/index.d.ts +1 -1
  21. package/esm/typings/src/formfactors/sheets/SheetsFormfactorDefinition.d.ts +3 -2
  22. package/esm/typings/src/llm-providers/_common/register/LlmToolsOptions.d.ts +4 -1
  23. package/esm/typings/src/llm-providers/_common/utils/cache/cacheLlmTools.d.ts +3 -3
  24. package/esm/typings/src/scrapers/_common/register/$scrapersMetadataRegister.d.ts +3 -3
  25. package/esm/typings/src/types/typeAliases.d.ts +9 -7
  26. package/esm/typings/src/utils/$Register.d.ts +8 -7
  27. package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -1
  28. package/esm/typings/src/utils/parameters/mapAvailableToExpectedParameters.d.ts +7 -7
  29. package/esm/typings/src/utils/serialization/clonePipeline.d.ts +4 -3
  30. package/esm/typings/src/utils/serialization/deepClone.d.ts +5 -1
  31. package/esm/typings/src/utils/validators/javascriptName/isValidJavascriptName.d.ts +3 -3
  32. package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +5 -4
  33. package/package.json +2 -2
  34. package/umd/index.umd.js +20 -6
  35. package/umd/index.umd.js.map +1 -1
@@ -3,18 +3,23 @@ import type { TODO_any } from '../../utils/organization/TODO_any';
3
3
  import type { PipelineExecutorResult } from '../PipelineExecutorResult';
4
4
  import type { ExecuteAttemptsOptions } from './40-executeAttempts';
5
5
  /**
6
- * @@@
6
+ * Options for executing a pipeline task that involves formatting subvalues (e.g., iterating over CSV rows).
7
+ * Extends ExecuteAttemptsOptions with a progress callback.
7
8
  *
8
9
  * @private internal type of `executeFormatSubvalues`
9
10
  */
10
11
  type ExecuteFormatCellsOptions = ExecuteAttemptsOptions & {
11
12
  /**
12
- * @@@
13
+ * Callback invoked with partial results as the execution progresses.
13
14
  */
14
15
  readonly onProgress: (newOngoingResult: PartialDeep<PipelineExecutorResult>) => Promisable<void>;
15
16
  };
16
17
  /**
17
- * @@@
18
+ * Executes a pipeline task that requires mapping or iterating over subvalues of a parameter (such as rows in a CSV).
19
+ * Handles format and subformat resolution, error handling, and progress reporting.
20
+ *
21
+ * @param options - Options for execution, including task details and progress callback.
22
+ * @returns The result of the subvalue mapping or execution attempts.
18
23
  *
19
24
  * @private internal utility of `createPipelineExecutor`
20
25
  */
@@ -5,7 +5,7 @@ import type { Parameters } from '../../types/typeAliases';
5
5
  import type { ReservedParameters } from '../../types/typeAliases';
6
6
  import type { ExecutionTools } from '../ExecutionTools';
7
7
  /**
8
- * @@@
8
+ * Options for retrieving reserved parameters for a pipeline task, including context, pipeline, and identification.
9
9
  *
10
10
  * @private internal type of `getReservedParametersForTask`
11
11
  */
@@ -15,26 +15,28 @@ type GetReservedParametersForTaskOptions = {
15
15
  */
16
16
  readonly tools: ExecutionTools;
17
17
  /**
18
- * @@@
18
+ * The prepared and validated pipeline in which the task resides.
19
19
  */
20
20
  readonly preparedPipeline: ReadonlyDeep<PipelineJson>;
21
21
  /**
22
- * @@@
22
+ * The task for which reserved parameters are being retrieved.
23
23
  */
24
24
  readonly task: ReadonlyDeep<TaskJson>;
25
25
  /**
26
- * @@@
27
- *
28
- * Parameters to complete the content of the task for embedding
26
+ * Parameters to complete the content of the task for embedding and context.
29
27
  */
30
28
  readonly parameters: Readonly<Parameters>;
31
29
  /**
32
- * @@@
30
+ * String identifier for the pipeline, used in error messages and reporting.
33
31
  */
34
32
  readonly pipelineIdentification: string;
35
33
  };
36
34
  /**
37
- * @@@
35
+ * Retrieves all reserved parameters for a given pipeline task, including context, knowledge, examples, and metadata.
36
+ * Ensures all reserved parameters are defined and throws if any are missing.
37
+ *
38
+ * @param options - Options including tools, pipeline, task, and context.
39
+ * @returns An object containing all reserved parameters for the task.
38
40
  *
39
41
  * @private internal utility of `createPipelineExecutor`
40
42
  */
@@ -4,9 +4,11 @@ import type { string_SCREAMING_CASE } from '../../utils/normalization/normalizeT
4
4
  import type { empty_object } from '../../utils/organization/empty_object';
5
5
  import type { FormatSubvalueParser } from './FormatSubvalueParser';
6
6
  /**
7
- * A format definition is a set of functions that define how to validate, heal and convert response from LLM
7
+ * A format definition is a set of functions that define how to validate, heal and convert response from LLM.
8
8
  *
9
- * @@@ Describe setting vs schema
9
+ * @remarks
10
+ * - "settings" are runtime options that affect parsing (e.g., delimiter for CSV).
11
+ * - "schema" is a structural definition or contract for the data (e.g., expected fields in JSON).
10
12
  *
11
13
  * @see https://github.com/webgptorg/promptbook/discussions/36
12
14
  * @private still in development [🏢]
@@ -56,7 +58,7 @@ export type FormatParser<TValue extends TPartialValue, TPartialValue extends str
56
58
  */
57
59
  heal(value: string, settings?: TSettings, scheme?: TSchema): TValue;
58
60
  /**
59
- * @@@
61
+ * Parsers for extracting or mapping subvalues from the main value (e.g., rows from CSV, items from JSON array).
60
62
  */
61
63
  readonly subvalueParsers: ReadonlyArray<FormatSubvalueParser<TValue, TSettings>>;
62
64
  };
@@ -5,7 +5,8 @@ import type { string_parameter_name } from '../../types/typeAliases';
5
5
  import type { string_SCREAMING_CASE } from '../../utils/normalization/normalizeTo_SCREAMING_CASE';
6
6
  import type { empty_object } from '../../utils/organization/empty_object';
7
7
  /**
8
- * @@@
8
+ * Defines how to extract or map subvalues from a main value in a specific format (e.g., cells from CSV, items from JSON array).
9
+ * Used for iterating or transforming structured data in pipeline tasks.
9
10
  */
10
11
  export type FormatSubvalueParser<TValue extends string, TSettings extends empty_object> = {
11
12
  /**
@@ -19,21 +20,45 @@ export type FormatSubvalueParser<TValue extends string, TSettings extends empty_
19
20
  */
20
21
  readonly aliases?: ReadonlyArray<string_name & string_SCREAMING_CASE>;
21
22
  /**
22
- * Maps values
23
+ * Maps or transforms subvalues from the main value. For example, iterates over all CSV cells or JSON array items.
23
24
  *
24
- * For example, if you have a JSON object and you want to map all values to uppercase
25
- * Or iterate over all CSV cells @@@
25
+ * @param options - Options for mapping, including callbacks for progress and value transformation.
26
+ * @returns The final mapped string result.
26
27
  */
27
28
  mapValues(options: FormatSubvalueParserMapValuesOptions<TValue, TSettings>): Promise<string>;
28
29
  };
29
30
  /**
30
- * @@@
31
+ * Options for mapping or extracting subvalues from a main value using a FormatSubvalueParser.
31
32
  */
32
33
  export type FormatSubvalueParserMapValuesOptions<TValue extends string, TSettings extends empty_object> = {
34
+ /**
35
+ * The input string value to parse for subvalues
36
+ */
33
37
  readonly value: TValue;
38
+ /**
39
+ * The name of the output parameter where the processed value will be stored
40
+ */
34
41
  readonly outputParameterName: string_parameter_name;
42
+ /**
43
+ * Format-specific settings that control how subvalues are parsed or processed
44
+ */
35
45
  readonly settings: TSettings;
36
- mapCallback: (subvalues: Parameters, index: number) => Promisable<TValue>;
46
+ /**
47
+ * Callback function that processes each subvalue and returns the transformed value
48
+ *
49
+ * @param subvalues Object containing the extracted subvalues
50
+ * @param index Current index of the subvalue which is being mapped
51
+ * @param length Full length of the subvalues
52
+ * @param number Total number of subvalues to process
53
+ * @returns Transformed value after processing
54
+ */
55
+ mapCallback(subvalues: Parameters, index: number, length: number): Promisable<TValue>;
56
+ /**
57
+ * Progress callback that receives partial results during processing
58
+ *
59
+ * @param partialResultString The current partial result as processing progresses
60
+ * @returns Promise or void to continue execution
61
+ */
37
62
  onProgress(partialResultString: TValue): Promisable<void>;
38
63
  };
39
64
  /**
@@ -2,7 +2,7 @@
2
2
  * Function to check if a string is valid CSV
3
3
  *
4
4
  * @param value The string to check
5
- * @returns True if the string is a valid CSV string, false otherwise
5
+ * @returns `true` if the string is a valid CSV string, false otherwise
6
6
  *
7
7
  * @public exported from `@promptbook/utils`
8
8
  */
@@ -2,7 +2,7 @@
2
2
  * Function isValidJsonString will tell you if the string is valid JSON or not
3
3
  *
4
4
  * @param value The string to check
5
- * @returns True if the string is a valid JSON string, false otherwise
5
+ * @returns `true` if the string is a valid JSON string, false otherwise
6
6
  *
7
7
  * @public exported from `@promptbook/utils`
8
8
  */
@@ -2,7 +2,7 @@
2
2
  * Function to check if a string is valid XML
3
3
  *
4
4
  * @param value
5
- * @returns True if the string is a valid XML string, false otherwise
5
+ * @returns `true` if the string is a valid XML string, false otherwise
6
6
  *
7
7
  * @public exported from `@promptbook/utils`
8
8
  */
@@ -1,11 +1,12 @@
1
1
  /**
2
- * Boilerplate is form of app that @@@
2
+ * Boilerplate is form of app that serves as a template structure for creating other formfactors
3
+ * and should not be used directly in production.
3
4
  *
4
5
  * @public exported from `@promptbook/core`
5
6
  */
6
7
  export declare const BoilerplateFormfactorDefinition: {
7
8
  readonly name: "BOILERPLATE";
8
- readonly description: "@@@";
9
+ readonly description: "A template structure for creating new formfactors, providing the base architecture and interfaces that should be implemented.";
9
10
  readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@";
10
11
  readonly pipelineInterface: {
11
12
  readonly inputParameters: readonly [];
@@ -1,5 +1,6 @@
1
1
  import type { FormfactorDefinition } from './FormfactorDefinition';
2
2
  /**
3
- * @@@
3
+ * A type alias representing the name of a formfactor, used for type checking and validation
4
+ * in the formfactor registry and selection processes
4
5
  */
5
6
  export type string_formfactor_name = FormfactorDefinition['name'];
@@ -71,7 +71,7 @@ export declare const FORMFACTOR_DEFINITIONS: readonly [{
71
71
  }, {
72
72
  readonly name: "SHEETS";
73
73
  readonly aliasNames: readonly ["SHEETS", "SHEET"];
74
- readonly description: "@@@";
74
+ readonly description: "A formfactor for processing spreadsheet-like data in CSV format, enabling AI transformations on tabular data";
75
75
  readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/176";
76
76
  readonly pipelineInterface: {
77
77
  readonly inputParameters: readonly [{
@@ -1,12 +1,13 @@
1
1
  /**
2
- * Sheets is form of app that @@@
2
+ * Sheets is form of app that processes tabular data in CSV format, allowing transformation
3
+ * and analysis of structured data through AI-powered operations
3
4
  *
4
5
  * @public exported from `@promptbook/core`
5
6
  */
6
7
  export declare const SheetsFormfactorDefinition: {
7
8
  readonly name: "SHEETS";
8
9
  readonly aliasNames: readonly ["SHEETS", "SHEET"];
9
- readonly description: "@@@";
10
+ readonly description: "A formfactor for processing spreadsheet-like data in CSV format, enabling AI transformations on tabular data";
10
11
  readonly documentationUrl: "https://github.com/webgptorg/promptbook/discussions/176";
11
12
  readonly pipelineInterface: {
12
13
  readonly inputParameters: readonly [{
@@ -1,6 +1,9 @@
1
1
  import type { TODO_object } from '../../../utils/organization/TODO_object';
2
2
  /**
3
- * @@@
3
+ * Options for configuring LLM (Large Language Model) tools.
4
+ *
5
+ * This type is used to pass provider-specific options to LLM execution tools.
6
+ *
4
7
  *
5
8
  * @@@ `LlmToolsMetadata` vs `LlmToolsConfiguration` vs `LlmToolsOptions` (vs `Registered`)
6
9
  */
@@ -13,7 +13,7 @@ export declare function cacheLlmTools<TLlmTools extends LlmExecutionTools>(llmTo
13
13
  /**
14
14
  * TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
15
15
  * TODO: [🧠] Is there some meaningfull way how to test this util
16
- * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
17
- * @@@ write discussion about this and storages
18
- * @@@ write how to combine multiple interceptors
16
+ * TODO: [👷‍♂️] Comprehensive manual about construction of llmTools
17
+ * Detailed explanation about caching strategies and appropriate storage selection for different use cases
18
+ * Examples of how to combine multiple interceptors for advanced caching, logging, and usage tracking
19
19
  */
@@ -1,10 +1,10 @@
1
1
  import { $Register } from '../../../utils/$Register';
2
2
  import type { ScraperAndConverterMetadata } from './ScraperAndConverterMetadata';
3
3
  /**
4
- * @@@
4
+ * Global registry for storing metadata about all available scrapers and converters.
5
5
  *
6
- * Note: `$` is used to indicate that this interacts with the global scope
7
- * @singleton Only one instance of each register is created per build, but thare can be more @@@
6
+ * Note: `$` is used to indicate that this interacts with the global scope.
7
+ * @singleton Only one instance of each register is created per build, but there can be more in different contexts (e.g., tests).
8
8
  * @public exported from `@promptbook/core`
9
9
  */
10
10
  export declare const $scrapersMetadataRegister: $Register<ScraperAndConverterMetadata>;
@@ -123,7 +123,8 @@ export type InputParameters = Exclude<Record<string_parameter_name, really_unkno
123
123
  */
124
124
  export type string_reserved_parameter_name = TupleToUnion<typeof RESERVED_PARAMETER_NAMES>;
125
125
  /**
126
- * @@@
126
+ * Represents a mapping of reserved parameter names to their values.
127
+ * Reserved parameters are used internally by the pipeline and should not be set by users.
127
128
  *
128
129
  * Note: [🚉] This is fully serializable as JSON
129
130
  */
@@ -233,7 +234,9 @@ export type string_markdown_text = string;
233
234
  */
234
235
  export type string_markdown_codeblock_language = 'book' | 'markdown' | 'text' | 'javascript' | 'css' | 'json';
235
236
  /**
236
- * @@@
237
+ * A URL pointing to Promptbook documentation or a specific discussion.
238
+ *
239
+ * For example: `https://github.com/webgptorg/promptbook/discussions/123`
237
240
  */
238
241
  export type string_promptbook_documentation_url = `https://github.com/webgptorg/promptbook/discussions/${number | `@@${string}`}`;
239
242
  /**
@@ -448,15 +451,14 @@ export type string_uuid = string & {
448
451
  readonly _type: 'uuid';
449
452
  };
450
453
  /**
451
- * Application identifier
454
+ * Application identifier, used to distinguish different apps or clients.
452
455
  *
453
- * @@@
456
+ * For example: 'cli', 'playground', or a custom app id.
454
457
  */
455
458
  export type string_app_id = id | 'app';
456
459
  /**
457
- * End user identifier
458
- *
459
- * @@@
460
+ * End user identifier, can be a user id or email address.
461
+ * Used for tracking and abuse prevention.
460
462
  */
461
463
  export type string_user_id = id | string_email;
462
464
  /**
@@ -2,33 +2,34 @@ import { type IDestroyable } from 'destroyable';
2
2
  import type { string_name } from '../types/typeAliases';
3
3
  import type { TODO_string } from './organization/TODO_string';
4
4
  /**
5
- * @@@
5
+ * Represents an entity in a global registry.
6
+ * Contains identifying information about the package and class.
6
7
  */
7
8
  export type Registered = {
8
9
  /**
9
- * @@@
10
+ * The name of the package where the registered entity is defined.
10
11
  */
11
12
  readonly packageName: TODO_string;
12
13
  /**
13
- * @@@
14
+ * The name of the class being registered.
14
15
  */
15
16
  readonly className: TODO_string;
16
17
  };
17
18
  /**
18
- * @@@
19
+ * Represents a registration record, including destroyable interface and registry name.
19
20
  */
20
21
  export type Registration = Registered & IDestroyable & {
21
22
  /**
22
- * @@@
23
+ * The name of the register this entity is registered in.
23
24
  */
24
25
  readonly registerName: string_name;
25
26
  };
26
27
  /**
27
- * Register is @@@
28
+ * Global registry for storing and managing registered entities of a given type.
28
29
  *
29
30
  * Note: `$` is used to indicate that this function is not a pure function - it accesses and adds variables in global scope.
30
31
  *
31
- * @private internal utility, exported are only signleton instances of this class
32
+ * @private internal utility, exported are only singleton instances of this class
32
33
  */
33
34
  export declare class $Register<TRegistered extends Registered> {
34
35
  private readonly registerName;
@@ -1,6 +1,7 @@
1
1
  import type { really_any } from '../organization/really_any';
2
2
  /**
3
- * @@@
3
+ * Safely retrieves the global scope object (window in browser, global in Node.js)
4
+ * regardless of the JavaScript environment in which the code is running
4
5
  *
5
6
  * Note: `$` is used to indicate that this function is not a pure function - it access global scope
6
7
  *
@@ -1,26 +1,26 @@
1
1
  import type { string_parameter_name } from '../../types/typeAliases';
2
2
  import type { string_parameter_value } from '../../types/typeAliases';
3
3
  /**
4
- * @@@
4
+ * Options for mapping available parameters to expected parameters in a pipeline task.
5
5
  */
6
6
  type MakeapAvailableToExpectedParametersOptions = {
7
7
  /**
8
- * @@@
8
+ * The set of expected parameter names (keys) for the task, all values are null.
9
9
  */
10
10
  readonly expectedParameters: Readonly<Record<string_parameter_name, null>>;
11
11
  /**
12
- * @@@
12
+ * The set of available parameters (name-value pairs) to map to the expected parameters.
13
13
  */
14
14
  readonly availableParameters: Readonly<Record<string_parameter_name, string_parameter_value>>;
15
15
  };
16
16
  /**
17
- * Maps available parameters to expected parameters
17
+ * Maps available parameters to expected parameters for a pipeline task.
18
18
  *
19
19
  * The strategy is:
20
- * 1) @@@
21
- * 2) @@@
20
+ * 1) First, match parameters by name where both available and expected.
21
+ * 2) Then, if there are unmatched expected and available parameters, map them by order.
22
22
  *
23
- * @throws {PipelineExecutionError} @@@
23
+ * @throws {PipelineExecutionError} If the number of unmatched expected and available parameters does not match, or mapping is ambiguous.
24
24
  * @private within the repository used in `createPipelineExecutor`
25
25
  */
26
26
  export declare function mapAvailableToExpectedParameters(options: MakeapAvailableToExpectedParametersOptions): Readonly<Record<string_parameter_name, string_parameter_value>>;
@@ -1,10 +1,11 @@
1
1
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
2
2
  /**
3
- * @@@
3
+ * Creates a deep clone of a PipelineJson object, copying all properties explicitly.
4
4
  *
5
- * Note: It is usefull @@@
5
+ * Note: It is useful for ensuring that modifications to the returned pipeline do not affect the original.
6
6
  *
7
- * @param pipeline
7
+ * @param pipeline The pipeline to clone.
8
+ * @returns A new PipelineJson object with the same properties as the input.
8
9
  * @public exported from `@promptbook/utils`
9
10
  */
10
11
  export declare function clonePipeline(pipeline: PipelineJson): PipelineJson;
@@ -1,7 +1,11 @@
1
1
  import type { WritableDeep } from 'type-fest';
2
2
  /**
3
- * @@@
3
+ * Creates a deep clone of the given object
4
4
  *
5
+ * Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
6
+ *
7
+ * @param objectValue The object to clone.
8
+ * @returns A deep, writable clone of the input object.
5
9
  * @public exported from `@promptbook/utils`
6
10
  */
7
11
  export declare function deepClone<TObject>(objectValue: TObject): WritableDeep<TObject>;
@@ -1,10 +1,10 @@
1
1
  import type { string_javascript_name } from '../../../types/typeAliases';
2
2
  import type { really_unknown } from '../../organization/really_unknown';
3
3
  /**
4
- * @@@
4
+ * Checks if the given value is a valid JavaScript identifier name.
5
5
  *
6
- * @param javascriptName @@@
7
- * @returns @@@
6
+ * @param javascriptName The value to check for JavaScript identifier validity.
7
+ * @returns `true` if the value is a valid JavaScript name, false otherwise.
8
8
  * @public exported from `@promptbook/utils`
9
9
  */
10
10
  export declare function isValidJavascriptName(javascriptName: really_unknown): javascriptName is string_javascript_name;
@@ -1,10 +1,11 @@
1
1
  import type { string_parameter_name } from '../../../types/typeAliases';
2
2
  /**
3
- * Function `validateParameterName` will @@@
3
+ * Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
4
+ * It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
4
5
  *
5
- * @param parameterName @@@
6
- * @returns @@@
7
- * @throws {ParseError} @@@
6
+ * @param parameterName The parameter name to validate and normalize.
7
+ * @returns The validated and normalized parameter name.
8
+ * @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
8
9
  * @private within the repository
9
10
  */
10
11
  export declare function validateParameterName(parameterName: string): string_parameter_name;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/openai",
3
- "version": "0.92.0-22",
3
+ "version": "0.92.0-24",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -51,7 +51,7 @@
51
51
  "module": "./esm/index.es.js",
52
52
  "typings": "./esm/typings/src/_packages/openai.index.d.ts",
53
53
  "peerDependencies": {
54
- "@promptbook/core": "0.92.0-22"
54
+ "@promptbook/core": "0.92.0-24"
55
55
  },
56
56
  "dependencies": {
57
57
  "bottleneck": "^2.19.5",
package/umd/index.umd.js CHANGED
@@ -25,7 +25,7 @@
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- const PROMPTBOOK_ENGINE_VERSION = '0.92.0-22';
28
+ const PROMPTBOOK_ENGINE_VERSION = '0.92.0-24';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -285,7 +285,7 @@
285
285
  const SMALL_NUMBER = 0.001;
286
286
  // <- TODO: [🧜‍♂️]
287
287
  /**
288
- * @@@
288
+ * Default settings for parsing and generating CSV files in Promptbook.
289
289
  *
290
290
  * @public exported from `@promptbook/core`
291
291
  */
@@ -578,8 +578,12 @@
578
578
  */
579
579
 
580
580
  /**
581
- * @@@
581
+ * Creates a deep clone of the given object
582
+ *
583
+ * Note: This method only works for objects that are fully serializable to JSON and do not contain functions, Dates, or special types.
582
584
  *
585
+ * @param objectValue The object to clone.
586
+ * @returns A deep, writable clone of the input object.
583
587
  * @public exported from `@promptbook/utils`
584
588
  */
585
589
  function deepClone(objectValue) {
@@ -1740,14 +1744,23 @@
1740
1744
  resultContent, rawResponse) {
1741
1745
  var _a, _b;
1742
1746
  if (rawResponse.usage === undefined) {
1747
+ console.log('!!! computeOpenAiUsage', 'The usage is not defined in the response from OpenAI');
1743
1748
  throw new PipelineExecutionError('The usage is not defined in the response from OpenAI');
1744
1749
  }
1745
1750
  if (((_a = rawResponse.usage) === null || _a === void 0 ? void 0 : _a.prompt_tokens) === undefined) {
1751
+ console.log('!!! computeOpenAiUsage', 'In OpenAI response `usage.prompt_tokens` not defined');
1746
1752
  throw new PipelineExecutionError('In OpenAI response `usage.prompt_tokens` not defined');
1747
1753
  }
1748
1754
  const inputTokens = rawResponse.usage.prompt_tokens;
1749
1755
  const outputTokens = ((_b = rawResponse.usage) === null || _b === void 0 ? void 0 : _b.completion_tokens) || 0;
1750
1756
  const modelInfo = OPENAI_MODELS.find((model) => model.modelName === rawResponse.model);
1757
+ console.log('!!! computeOpenAiUsage', {
1758
+ inputTokens,
1759
+ outputTokens,
1760
+ rawResponse,
1761
+ resultContent,
1762
+ modelInfo,
1763
+ });
1751
1764
  let price;
1752
1765
  if (modelInfo === undefined || modelInfo.pricing === undefined) {
1753
1766
  price = uncertainNumber();
@@ -2332,7 +2345,8 @@
2332
2345
  */
2333
2346
 
2334
2347
  /**
2335
- * @@@
2348
+ * Safely retrieves the global scope object (window in browser, global in Node.js)
2349
+ * regardless of the JavaScript environment in which the code is running
2336
2350
  *
2337
2351
  * Note: `$` is used to indicate that this function is not a pure function - it access global scope
2338
2352
  *
@@ -2411,11 +2425,11 @@
2411
2425
  }
2412
2426
 
2413
2427
  /**
2414
- * Register is @@@
2428
+ * Global registry for storing and managing registered entities of a given type.
2415
2429
  *
2416
2430
  * Note: `$` is used to indicate that this function is not a pure function - it accesses and adds variables in global scope.
2417
2431
  *
2418
- * @private internal utility, exported are only signleton instances of this class
2432
+ * @private internal utility, exported are only singleton instances of this class
2419
2433
  */
2420
2434
  class $Register {
2421
2435
  constructor(registerName) {