@promptbook/node 0.92.0-11 → 0.92.0-13

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 (24) hide show
  1. package/esm/index.es.js +256 -233
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/browser.index.d.ts +2 -0
  4. package/esm/typings/src/_packages/core.index.d.ts +6 -4
  5. package/esm/typings/src/_packages/types.index.d.ts +2 -2
  6. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +3 -1
  7. package/esm/typings/src/execution/createPipelineExecutor/computeCosineSimilarity.d.ts +13 -0
  8. package/esm/typings/src/execution/utils/checkExpectations.d.ts +1 -1
  9. package/esm/typings/src/formats/_common/{FormatDefinition.d.ts → FormatParser.d.ts} +3 -3
  10. package/esm/typings/src/formats/_common/{FormatSubvalueDefinition.d.ts → FormatSubvalueParser.d.ts} +1 -1
  11. package/esm/typings/src/formats/csv/CsvFormatParser.d.ts +17 -0
  12. package/esm/typings/src/formats/index.d.ts +2 -2
  13. package/esm/typings/src/formats/json/{JsonFormatDefinition.d.ts → JsonFormatParser.d.ts} +6 -6
  14. package/esm/typings/src/formats/text/{TextFormatDefinition.d.ts → TextFormatParser.d.ts} +7 -7
  15. package/esm/typings/src/formats/xml/XmlFormatParser.d.ts +19 -0
  16. package/esm/typings/src/postprocessing/utils/extractJsonBlock.d.ts +1 -1
  17. package/esm/typings/src/storage/local-storage/getIndexedDbStorage.d.ts +10 -0
  18. package/esm/typings/src/storage/local-storage/utils/makePromptbookStorageFromIndexedDb.d.ts +7 -0
  19. package/esm/typings/src/utils/expectation-counters/index.d.ts +1 -1
  20. package/package.json +2 -2
  21. package/umd/index.umd.js +259 -236
  22. package/umd/index.umd.js.map +1 -1
  23. package/esm/typings/src/formats/csv/CsvFormatDefinition.d.ts +0 -17
  24. package/esm/typings/src/formats/xml/XmlFormatDefinition.d.ts +0 -19
@@ -1,10 +1,12 @@
1
1
  import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
2
2
  import { SimplePromptInterfaceTools } from '../dialogs/simple-prompt/SimplePromptInterfaceTools';
3
3
  import { $provideScrapersForBrowser } from '../scrapers/_common/register/$provideScrapersForBrowser';
4
+ import { getIndexedDbStorage } from '../storage/local-storage/getIndexedDbStorage';
4
5
  import { getLocalStorage } from '../storage/local-storage/getLocalStorage';
5
6
  import { getSessionStorage } from '../storage/local-storage/getSessionStorage';
6
7
  export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
7
8
  export { SimplePromptInterfaceTools };
8
9
  export { $provideScrapersForBrowser };
10
+ export { getIndexedDbStorage };
9
11
  export { getLocalStorage };
10
12
  export { getSessionStorage };
@@ -62,6 +62,7 @@ import { PromptbookFetchError } from '../errors/PromptbookFetchError';
62
62
  import { UnexpectedError } from '../errors/UnexpectedError';
63
63
  import { WrappedError } from '../errors/WrappedError';
64
64
  import { createPipelineExecutor } from '../execution/createPipelineExecutor/00-createPipelineExecutor';
65
+ import { computeCosineSimilarity } from '../execution/createPipelineExecutor/computeCosineSimilarity';
65
66
  import { embeddingVectorToString } from '../execution/embeddingVectorToString';
66
67
  import { executionReportJsonToString } from '../execution/execution-report/executionReportJsonToString';
67
68
  import type { ExecutionReportStringOptions } from '../execution/execution-report/ExecutionReportStringOptions';
@@ -74,10 +75,10 @@ import { ZERO_USAGE } from '../execution/utils/usage-constants';
74
75
  import { UNCERTAIN_USAGE } from '../execution/utils/usage-constants';
75
76
  import { usageToHuman } from '../execution/utils/usageToHuman';
76
77
  import { usageToWorktime } from '../execution/utils/usageToWorktime';
77
- import { CsvFormatDefinition } from '../formats/csv/CsvFormatDefinition';
78
78
  import { CsvFormatError } from '../formats/csv/CsvFormatError';
79
+ import { CsvFormatParser } from '../formats/csv/CsvFormatParser';
79
80
  import { MANDATORY_CSV_SETTINGS } from '../formats/csv/CsvSettings';
80
- import { TextFormatDefinition } from '../formats/text/TextFormatDefinition';
81
+ import { TextFormatParser } from '../formats/text/TextFormatParser';
81
82
  import { BoilerplateFormfactorDefinition } from '../formfactors/_boilerplate/BoilerplateFormfactorDefinition';
82
83
  import { ChatbotFormfactorDefinition } from '../formfactors/chatbot/ChatbotFormfactorDefinition';
83
84
  import { GeneratorFormfactorDefinition } from '../formfactors/generator/GeneratorFormfactorDefinition';
@@ -203,6 +204,7 @@ export { PromptbookFetchError };
203
204
  export { UnexpectedError };
204
205
  export { WrappedError };
205
206
  export { createPipelineExecutor };
207
+ export { computeCosineSimilarity };
206
208
  export { embeddingVectorToString };
207
209
  export { executionReportJsonToString };
208
210
  export type { ExecutionReportStringOptions };
@@ -215,10 +217,10 @@ export { ZERO_USAGE };
215
217
  export { UNCERTAIN_USAGE };
216
218
  export { usageToHuman };
217
219
  export { usageToWorktime };
218
- export { CsvFormatDefinition };
219
220
  export { CsvFormatError };
221
+ export { CsvFormatParser };
220
222
  export { MANDATORY_CSV_SETTINGS };
221
- export { TextFormatDefinition };
223
+ export { TextFormatParser };
222
224
  export { BoilerplateFormfactorDefinition };
223
225
  export { ChatbotFormfactorDefinition };
224
226
  export { GeneratorFormfactorDefinition };
@@ -61,7 +61,7 @@ import type { Usage } from '../execution/Usage';
61
61
  import type { UsageCounts } from '../execution/Usage';
62
62
  import type { UserInterfaceTools } from '../execution/UserInterfaceTools';
63
63
  import type { UserInterfaceToolsPromptDialogOptions } from '../execution/UserInterfaceTools';
64
- import type { FormatSubvalueDefinition } from '../formats/_common/FormatSubvalueDefinition';
64
+ import type { FormatSubvalueParser } from '../formats/_common/FormatSubvalueParser';
65
65
  import type { CsvSettings } from '../formats/csv/CsvSettings';
66
66
  import type { AbstractFormfactorDefinition } from '../formfactors/_common/AbstractFormfactorDefinition';
67
67
  import type { FormfactorDefinition } from '../formfactors/_common/FormfactorDefinition';
@@ -357,7 +357,7 @@ export type { Usage };
357
357
  export type { UsageCounts };
358
358
  export type { UserInterfaceTools };
359
359
  export type { UserInterfaceToolsPromptDialogOptions };
360
- export type { FormatSubvalueDefinition };
360
+ export type { FormatSubvalueParser };
361
361
  export type { CsvSettings };
362
362
  export type { AbstractFormfactorDefinition };
363
363
  export type { FormfactorDefinition };
@@ -22,8 +22,10 @@ export type PipelineExecutorResult = AbstractTaskResult & {
22
22
  readonly usage: ReadonlyDeep<Usage>;
23
23
  /**
24
24
  * The report of the execution with all details
25
+ *
26
+ * Note: If the execution fails unexpectedly, this will be `null`
25
27
  */
26
- readonly executionReport: ReadonlyDeep<ExecutionReportJson>;
28
+ readonly executionReport: ReadonlyDeep<ExecutionReportJson> | null;
27
29
  /**
28
30
  * The prepared pipeline that was used for the execution
29
31
  *
@@ -0,0 +1,13 @@
1
+ import type { EmbeddingVector } from '../EmbeddingVector';
2
+ /**
3
+ * Computes the cosine similarity between two embedding vectors
4
+ *
5
+ * Note: This is helping function for RAG (retrieval-augmented generation)
6
+ *
7
+ * @param embeddingVector1
8
+ * @param embeddingVector2
9
+ * @returns Cosine similarity between the two vectors
10
+ *
11
+ * @public exported from `@promptbook/core`
12
+ */
13
+ export declare function computeCosineSimilarity(embeddingVector1: EmbeddingVector, embeddingVector2: EmbeddingVector): number;
@@ -24,6 +24,6 @@ export declare function checkExpectations(expectations: Expectations, value: str
24
24
  export declare function isPassingExpectations(expectations: Expectations, value: string): boolean;
25
25
  /**
26
26
  * TODO: [💝] Unite object for expecting amount and format
27
- * TODO: [🧠][🤠] This should be part of `TextFormatDefinition`
27
+ * TODO: [🧠][🤠] This should be part of `TextFormatParser`
28
28
  * Note: [💝] and [🤠] are interconnected together
29
29
  */
@@ -2,7 +2,7 @@ import type { string_mime_type } from '../../types/typeAliases';
2
2
  import type { string_name } from '../../types/typeAliases';
3
3
  import type { string_SCREAMING_CASE } from '../../utils/normalization/normalizeTo_SCREAMING_CASE';
4
4
  import type { empty_object } from '../../utils/organization/empty_object';
5
- import type { FormatSubvalueDefinition } from './FormatSubvalueDefinition';
5
+ import type { FormatSubvalueParser } from './FormatSubvalueParser';
6
6
  /**
7
7
  * A format definition is a set of functions that define how to validate, heal and convert response from LLM
8
8
  *
@@ -11,7 +11,7 @@ import type { FormatSubvalueDefinition } from './FormatSubvalueDefinition';
11
11
  * @see https://github.com/webgptorg/promptbook/discussions/36
12
12
  * @private still in development [🏢]
13
13
  */
14
- export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends string, TSettings extends empty_object, TSchema extends empty_object> = {
14
+ export type FormatParser<TValue extends TPartialValue, TPartialValue extends string, TSettings extends empty_object, TSchema extends empty_object> = {
15
15
  /**
16
16
  * The name of the format used in .book.md files
17
17
  *
@@ -58,7 +58,7 @@ export type FormatDefinition<TValue extends TPartialValue, TPartialValue extends
58
58
  /**
59
59
  * @@@
60
60
  */
61
- readonly subvalueDefinitions: ReadonlyArray<FormatSubvalueDefinition<TValue, TSettings>>;
61
+ readonly subvalueParsers: ReadonlyArray<FormatSubvalueParser<TValue, TSettings>>;
62
62
  };
63
63
  /**
64
64
  * TODO: [♏] Add some prepare hook to modify prompt according to the format
@@ -7,7 +7,7 @@ import type { empty_object } from '../../utils/organization/empty_object';
7
7
  /**
8
8
  * @@@
9
9
  */
10
- export type FormatSubvalueDefinition<TValue extends string, TSettings extends empty_object> = {
10
+ export type FormatSubvalueParser<TValue extends string, TSettings extends empty_object> = {
11
11
  /**
12
12
  * The name of the format used in .book.md files
13
13
  *
@@ -0,0 +1,17 @@
1
+ import type { TODO_any } from '../../utils/organization/TODO_any';
2
+ import type { FormatParser } from '../_common/FormatParser';
3
+ import type { CsvSettings } from './CsvSettings';
4
+ /**
5
+ * Definition for CSV spreadsheet
6
+ *
7
+ * @public exported from `@promptbook/core`
8
+ * <- TODO: [🏢] Export from package `@promptbook/csv`
9
+ */
10
+ export declare const CsvFormatParser: FormatParser<string, string, CsvSettings, TODO_any>;
11
+ /**
12
+ * TODO: [🍓] In `CsvFormatParser` implement simple `isValid`
13
+ * TODO: [🍓] In `CsvFormatParser` implement partial `canBeValid`
14
+ * TODO: [🍓] In `CsvFormatParser` implement `heal
15
+ * TODO: [🍓] In `CsvFormatParser` implement `subvalueParsers`
16
+ * TODO: [🏢] Allow to expect something inside CSV objects and other formats
17
+ */
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @private internal index of `...` <- TODO [🏢]
5
5
  */
6
- export declare const FORMAT_DEFINITIONS: readonly [import("./_common/FormatDefinition").FormatDefinition<string, string, any, any>, import("./_common/FormatDefinition").FormatDefinition<string, string, any, any>, import("./_common/FormatDefinition").FormatDefinition<string, string, any, any>, import("./_common/FormatDefinition").FormatDefinition<string, string, import("./csv/CsvSettings").CsvSettings, any>];
6
+ export declare const FORMAT_DEFINITIONS: readonly [import("./_common/FormatParser").FormatParser<string, string, any, any>, import("./_common/FormatParser").FormatParser<string, string, any, any>, import("./_common/FormatParser").FormatParser<string, string, any, any>, import("./_common/FormatParser").FormatParser<string, string, import("./csv/CsvSettings").CsvSettings, any>];
7
7
  /**
8
8
  * Note: [💞] Ignore a discrepancy between file name and entity name
9
- */
9
+ */
@@ -1,19 +1,19 @@
1
1
  import type { TODO_any } from '../../utils/organization/TODO_any';
2
- import type { FormatDefinition } from '../_common/FormatDefinition';
2
+ import type { FormatParser } from '../_common/FormatParser';
3
3
  /**
4
4
  * Definition for JSON format
5
5
  *
6
6
  * @private still in development [🏢]
7
7
  */
8
- export declare const JsonFormatDefinition: FormatDefinition<string, string, TODO_any, TODO_any>;
8
+ export declare const JsonFormatParser: FormatParser<string, string, TODO_any, TODO_any>;
9
9
  /**
10
10
  * TODO: [🧠] Maybe propper instance of object
11
11
  * TODO: [0] Make string_serialized_json
12
12
  * TODO: [1] Make type for JSON Settings and Schema
13
13
  * TODO: [🧠] What to use for validating JSONs - JSON Schema, ZoD, typescript types/interfaces,...?
14
- * TODO: [🍓] In `JsonFormatDefinition` implement simple `isValid`
15
- * TODO: [🍓] In `JsonFormatDefinition` implement partial `canBeValid`
16
- * TODO: [🍓] In `JsonFormatDefinition` implement `heal
17
- * TODO: [🍓] In `JsonFormatDefinition` implement `subvalueDefinitions`
14
+ * TODO: [🍓] In `JsonFormatParser` implement simple `isValid`
15
+ * TODO: [🍓] In `JsonFormatParser` implement partial `canBeValid`
16
+ * TODO: [🍓] In `JsonFormatParser` implement `heal
17
+ * TODO: [🍓] In `JsonFormatParser` implement `subvalueParsers`
18
18
  * TODO: [🏢] Allow to expect something inside JSON objects and other formats
19
19
  */
@@ -1,19 +1,19 @@
1
1
  import type { TODO_any } from '../../utils/organization/TODO_any';
2
- import type { FormatDefinition } from '../_common/FormatDefinition';
2
+ import type { FormatParser } from '../_common/FormatParser';
3
3
  /**
4
4
  * Definition for any text - this will be always valid
5
5
  *
6
- * Note: This is not useful for validation, but for splitting and mapping with `subvalueDefinitions`
6
+ * Note: This is not useful for validation, but for splitting and mapping with `subvalueParsers`
7
7
  *
8
8
  * @public exported from `@promptbook/core`
9
9
  */
10
- export declare const TextFormatDefinition: FormatDefinition<string, string, TODO_any, TODO_any>;
10
+ export declare const TextFormatParser: FormatParser<string, string, TODO_any, TODO_any>;
11
11
  /**
12
12
  * TODO: [1] Make type for XML Text and Schema
13
13
  * TODO: [🧠][🤠] Here should be all words, characters, lines, paragraphs, pages available as subvalues
14
- * TODO: [🍓] In `TextFormatDefinition` implement simple `isValid`
15
- * TODO: [🍓] In `TextFormatDefinition` implement partial `canBeValid`
16
- * TODO: [🍓] In `TextFormatDefinition` implement `heal
17
- * TODO: [🍓] In `TextFormatDefinition` implement `subvalueDefinitions`
14
+ * TODO: [🍓] In `TextFormatParser` implement simple `isValid`
15
+ * TODO: [🍓] In `TextFormatParser` implement partial `canBeValid`
16
+ * TODO: [🍓] In `TextFormatParser` implement `heal
17
+ * TODO: [🍓] In `TextFormatParser` implement `subvalueParsers`
18
18
  * TODO: [🏢] Allow to expect something inside each item of list and other formats
19
19
  */
@@ -0,0 +1,19 @@
1
+ import type { TODO_any } from '../../utils/organization/TODO_any';
2
+ import type { FormatParser } from '../_common/FormatParser';
3
+ /**
4
+ * Definition for XML format
5
+ *
6
+ * @private still in development [🏢]
7
+ */
8
+ export declare const XmlFormatParser: FormatParser<string, string, TODO_any, TODO_any>;
9
+ /**
10
+ * TODO: [🧠] Maybe propper instance of object
11
+ * TODO: [0] Make string_serialized_xml
12
+ * TODO: [1] Make type for XML Settings and Schema
13
+ * TODO: [🧠] What to use for validating XMLs - XSD,...
14
+ * TODO: [🍓] In `XmlFormatParser` implement simple `isValid`
15
+ * TODO: [🍓] In `XmlFormatParser` implement partial `canBeValid`
16
+ * TODO: [🍓] In `XmlFormatParser` implement `heal
17
+ * TODO: [🍓] In `XmlFormatParser` implement `subvalueParsers`
18
+ * TODO: [🏢] Allow to expect something inside XML and other formats
19
+ */
@@ -21,5 +21,5 @@ import type { really_unknown } from '../../utils/organization/really_unknown';
21
21
  export declare function extractJsonBlock(markdown: string_markdown): string_json<really_unknown>;
22
22
  /**
23
23
  * TODO: Add some auto-healing logic + extract YAML, JSON5, TOML, etc.
24
- * TODO: [🏢] Make this logic part of `JsonFormatDefinition` or `isValidJsonString`
24
+ * TODO: [🏢] Make this logic part of `JsonFormatParser` or `isValidJsonString`
25
25
  */
@@ -0,0 +1,10 @@
1
+ import type { PromptbookStorage } from '../_common/PromptbookStorage';
2
+ /**
3
+ * Gets wrapper around IndexedDB which can be used as PromptbookStorage
4
+ *
5
+ * @public exported from `@promptbook/browser`
6
+ */
7
+ export declare function getIndexedDbStorage<TItem>(): PromptbookStorage<TItem>;
8
+ /**
9
+ * Note: [🔵] Code in this file should never be published outside of `@promptbook/browser`
10
+ */
@@ -0,0 +1,7 @@
1
+ import type { PromptbookStorage } from '../../_common/PromptbookStorage';
2
+ /**
3
+ * Creates a PromptbookStorage backed by IndexedDB.
4
+ * Uses a single object store named 'promptbook'.
5
+ * @private for `getIndexedDbStorage`
6
+ */
7
+ export declare function makePromptbookStorageFromIndexedDb<TValue>(dbName?: string, storeName?: string): PromptbookStorage<TValue>;
@@ -7,6 +7,6 @@ import type { ExpectationUnit } from '../../pipeline/PipelineJson/Expectations';
7
7
  */
8
8
  export declare const CountUtils: Record<ExpectationUnit, (text: string) => ExpectationAmount>;
9
9
  /**
10
- * TODO: [🧠][🤠] This should be probbably as part of `TextFormatDefinition`
10
+ * TODO: [🧠][🤠] This should be probbably as part of `TextFormatParser`
11
11
  * Note: [💞] Ignore a discrepancy between file name and entity name
12
12
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/node",
3
- "version": "0.92.0-11",
3
+ "version": "0.92.0-13",
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/node.index.d.ts",
53
53
  "peerDependencies": {
54
- "@promptbook/core": "0.92.0-11"
54
+ "@promptbook/core": "0.92.0-13"
55
55
  },
56
56
  "dependencies": {
57
57
  "colors": "1.4.0",