@promptbook/openai 0.40.0-3 → 0.40.0-5

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.
@@ -6,9 +6,13 @@ import { CallbackInterfaceTools } from '../execution/plugins/user-interface-exec
6
6
  import { CallbackInterfaceToolsOptions } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions';
7
7
  import { SimplePromptInterfaceTools } from '../execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools';
8
8
  import { SimplePromptbookLibrary } from '../library/SimplePromptbookLibrary';
9
+ import { createPromptbookLibraryFromPromise } from '../library/constructors/createPromptbookLibraryFromPromise';
10
+ import { createPromptbookLibraryFromSources } from '../library/constructors/createPromptbookLibraryFromSources';
11
+ import { createPromptbookSublibrary } from '../library/constructors/createPromptbookSublibrary';
9
12
  import { ExecutionTypes } from '../types/ExecutionTypes';
10
13
  import { PROMPTBOOK_VERSION } from '../version';
11
- export { ExecutionTypes, PROMPTBOOK_VERSION, SimplePromptbookLibrary };
14
+ export { ExecutionTypes, PROMPTBOOK_VERSION };
15
+ export { SimplePromptbookLibrary, createPromptbookLibraryFromPromise, createPromptbookLibraryFromSources, createPromptbookSublibrary, };
12
16
  export { SimplePromptInterfaceTools };
13
17
  export { promptbookStringToJson, validatePromptbookJson };
14
18
  export { MockedEchoNaturalExecutionTools };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This error indicates errors in referencing promptbooks between each other
3
+ */
4
+ export declare class PromptbookReferenceError extends Error {
5
+ readonly name = "PromptbookReferenceError";
6
+ constructor(message: string);
7
+ }
@@ -21,5 +21,5 @@ export type PromptbookLibrary = {
21
21
  /**
22
22
  * Checks whether given prompt was defined in any promptbook in the library
23
23
  */
24
- isResponsibleForPrompt(prompt: Prompt): boolean;
24
+ isResponsibleForPrompt(prompt: Prompt): Promisable<boolean>;
25
25
  };
@@ -1,28 +1,23 @@
1
1
  import type { Prompt } from '../types/Prompt';
2
2
  import type { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
3
- import type { PromptbookString } from '../types/PromptbookString';
4
3
  import type { string_promptbook_url } from '../types/typeAliases';
5
4
  import { PromptbookLibrary } from './PromptbookLibrary';
6
5
  /**
7
6
  * Library of promptbooks that groups together promptbooks for an application.
8
- * This implementation is a very thin wrapper around the Array / Set of promptbooks.
7
+ * This implementation is a very thin wrapper around the Array / Map of promptbooks.
9
8
  *
10
9
  * @see https://github.com/webgptorg/promptbook#promptbook-library
11
10
  */
12
11
  export declare class SimplePromptbookLibrary implements PromptbookLibrary {
13
- private readonly library;
14
- /**
15
- * Constructs Promptbook from any sources
12
+ private library;
13
+ /**!!!
16
14
  *
17
- * Note: During the construction syntax and logic of all sources are validated
18
- * Note: You can combine .ptbk.md and .ptbk.json files BUT it is not recommended
15
+ * @param promptbooks !!!
19
16
  *
20
- * @param promptbookSources contents of .ptbk.md or .ptbk.json files
21
- * @param settings settings for creating executor functions
22
- * @returns PromptbookLibrary
17
+ * Note: During the construction logic of all promptbooks are validated
18
+ * Note: It is not recommended to use this constructor directly, use `createPromptbookLibraryFromSources` *(or other variant)* instead
23
19
  */
24
- static fromSources(...promptbookSources: Array<PromptbookJson | PromptbookString>): SimplePromptbookLibrary;
25
- private constructor();
20
+ constructor(...promptbooks: Array<PromptbookJson>);
26
21
  /**
27
22
  * Gets all promptbooks in the library
28
23
  */
@@ -0,0 +1,7 @@
1
+ import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
2
+ import { PromptbookString } from '../../types/PromptbookString';
3
+ import { PromptbookLibrary } from '../PromptbookLibrary';
4
+ export declare function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory: Promise<Array<PromptbookJson | PromptbookString>> | (() => Promise<Array<PromptbookJson | PromptbookString>>)): PromptbookLibrary;
5
+ /***
6
+ * TODO: !!! Annotate all + all to README and samples
7
+ */
@@ -0,0 +1,16 @@
1
+ import { PromptbookJson, PromptbookString } from '../../_packages/types.index';
2
+ import { SimplePromptbookLibrary } from '../SimplePromptbookLibrary';
3
+ export declare function createPromptbookLibraryFromSources(...promptbookSources: Array<PromptbookJson | PromptbookString>): SimplePromptbookLibrary;
4
+ /**
5
+ * Constructs Promptbook from any sources
6
+ *
7
+ * Note: During the construction syntax and logic of all sources are validated
8
+ * Note: You can combine .ptbk.md and .ptbk.json files BUT it is not recommended
9
+ *
10
+ * @param promptbookSources contents of .ptbk.md or .ptbk.json files
11
+ * @param settings settings for creating executor functions
12
+ * @returns PromptbookLibrary
13
+ */
14
+ /***
15
+ * TODO: !!! Annotate all + all to README and samples
16
+ */
@@ -0,0 +1,6 @@
1
+ import type { string_promptbook_url } from '../../types/typeAliases';
2
+ import { PromptbookLibrary } from '../PromptbookLibrary';
3
+ export declare function createPromptbookSublibrary(library: PromptbookLibrary, predicate: (url: string_promptbook_url) => boolean): PromptbookLibrary;
4
+ /***
5
+ * TODO: !!! Annotate all + all to README and samples
6
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/openai",
3
- "version": "0.40.0-3",
3
+ "version": "0.40.0-5",
4
4
  "description": "Library to supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -37,7 +37,7 @@
37
37
  "openai": "4.2.0"
38
38
  },
39
39
  "peerDependencies": {
40
- "@promptbook/core": "0.40.0-3"
40
+ "@promptbook/core": "0.40.0-5"
41
41
  },
42
42
  "main": "./umd/index.umd.js",
43
43
  "module": "./esm/index.es.js",
@@ -6,9 +6,13 @@ import { CallbackInterfaceTools } from '../execution/plugins/user-interface-exec
6
6
  import { CallbackInterfaceToolsOptions } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions';
7
7
  import { SimplePromptInterfaceTools } from '../execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools';
8
8
  import { SimplePromptbookLibrary } from '../library/SimplePromptbookLibrary';
9
+ import { createPromptbookLibraryFromPromise } from '../library/constructors/createPromptbookLibraryFromPromise';
10
+ import { createPromptbookLibraryFromSources } from '../library/constructors/createPromptbookLibraryFromSources';
11
+ import { createPromptbookSublibrary } from '../library/constructors/createPromptbookSublibrary';
9
12
  import { ExecutionTypes } from '../types/ExecutionTypes';
10
13
  import { PROMPTBOOK_VERSION } from '../version';
11
- export { ExecutionTypes, PROMPTBOOK_VERSION, SimplePromptbookLibrary };
14
+ export { ExecutionTypes, PROMPTBOOK_VERSION };
15
+ export { SimplePromptbookLibrary, createPromptbookLibraryFromPromise, createPromptbookLibraryFromSources, createPromptbookSublibrary, };
12
16
  export { SimplePromptInterfaceTools };
13
17
  export { promptbookStringToJson, validatePromptbookJson };
14
18
  export { MockedEchoNaturalExecutionTools };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This error indicates errors in referencing promptbooks between each other
3
+ */
4
+ export declare class PromptbookReferenceError extends Error {
5
+ readonly name = "PromptbookReferenceError";
6
+ constructor(message: string);
7
+ }
@@ -21,5 +21,5 @@ export type PromptbookLibrary = {
21
21
  /**
22
22
  * Checks whether given prompt was defined in any promptbook in the library
23
23
  */
24
- isResponsibleForPrompt(prompt: Prompt): boolean;
24
+ isResponsibleForPrompt(prompt: Prompt): Promisable<boolean>;
25
25
  };
@@ -1,28 +1,23 @@
1
1
  import type { Prompt } from '../types/Prompt';
2
2
  import type { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
3
- import type { PromptbookString } from '../types/PromptbookString';
4
3
  import type { string_promptbook_url } from '../types/typeAliases';
5
4
  import { PromptbookLibrary } from './PromptbookLibrary';
6
5
  /**
7
6
  * Library of promptbooks that groups together promptbooks for an application.
8
- * This implementation is a very thin wrapper around the Array / Set of promptbooks.
7
+ * This implementation is a very thin wrapper around the Array / Map of promptbooks.
9
8
  *
10
9
  * @see https://github.com/webgptorg/promptbook#promptbook-library
11
10
  */
12
11
  export declare class SimplePromptbookLibrary implements PromptbookLibrary {
13
- private readonly library;
14
- /**
15
- * Constructs Promptbook from any sources
12
+ private library;
13
+ /**!!!
16
14
  *
17
- * Note: During the construction syntax and logic of all sources are validated
18
- * Note: You can combine .ptbk.md and .ptbk.json files BUT it is not recommended
15
+ * @param promptbooks !!!
19
16
  *
20
- * @param promptbookSources contents of .ptbk.md or .ptbk.json files
21
- * @param settings settings for creating executor functions
22
- * @returns PromptbookLibrary
17
+ * Note: During the construction logic of all promptbooks are validated
18
+ * Note: It is not recommended to use this constructor directly, use `createPromptbookLibraryFromSources` *(or other variant)* instead
23
19
  */
24
- static fromSources(...promptbookSources: Array<PromptbookJson | PromptbookString>): SimplePromptbookLibrary;
25
- private constructor();
20
+ constructor(...promptbooks: Array<PromptbookJson>);
26
21
  /**
27
22
  * Gets all promptbooks in the library
28
23
  */
@@ -0,0 +1,7 @@
1
+ import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
2
+ import { PromptbookString } from '../../types/PromptbookString';
3
+ import { PromptbookLibrary } from '../PromptbookLibrary';
4
+ export declare function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory: Promise<Array<PromptbookJson | PromptbookString>> | (() => Promise<Array<PromptbookJson | PromptbookString>>)): PromptbookLibrary;
5
+ /***
6
+ * TODO: !!! Annotate all + all to README and samples
7
+ */
@@ -0,0 +1,16 @@
1
+ import { PromptbookJson, PromptbookString } from '../../_packages/types.index';
2
+ import { SimplePromptbookLibrary } from '../SimplePromptbookLibrary';
3
+ export declare function createPromptbookLibraryFromSources(...promptbookSources: Array<PromptbookJson | PromptbookString>): SimplePromptbookLibrary;
4
+ /**
5
+ * Constructs Promptbook from any sources
6
+ *
7
+ * Note: During the construction syntax and logic of all sources are validated
8
+ * Note: You can combine .ptbk.md and .ptbk.json files BUT it is not recommended
9
+ *
10
+ * @param promptbookSources contents of .ptbk.md or .ptbk.json files
11
+ * @param settings settings for creating executor functions
12
+ * @returns PromptbookLibrary
13
+ */
14
+ /***
15
+ * TODO: !!! Annotate all + all to README and samples
16
+ */
@@ -0,0 +1,6 @@
1
+ import type { string_promptbook_url } from '../../types/typeAliases';
2
+ import { PromptbookLibrary } from '../PromptbookLibrary';
3
+ export declare function createPromptbookSublibrary(library: PromptbookLibrary, predicate: (url: string_promptbook_url) => boolean): PromptbookLibrary;
4
+ /***
5
+ * TODO: !!! Annotate all + all to README and samples
6
+ */