@promptbook/openai 0.59.0-21 → 0.59.0-23

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 (46) hide show
  1. package/README.md +4 -4
  2. package/esm/index.es.js +1 -1
  3. package/esm/typings/src/_packages/cli.index.d.ts +2 -2
  4. package/esm/typings/src/_packages/core.index.d.ts +6 -6
  5. package/esm/typings/src/_packages/node.index.d.ts +2 -2
  6. package/esm/typings/src/_packages/types.index.d.ts +2 -1
  7. package/esm/typings/src/cli/actions/hello.d.ts +7 -0
  8. package/esm/typings/src/cli/actions/make.d.ts +7 -0
  9. package/esm/typings/src/cli/actions/prettify.d.ts +7 -0
  10. package/esm/typings/src/{conversion/prettify/prettifyPromptbookStringCli.d.ts → cli/promptbookCli.d.ts} +2 -2
  11. package/esm/typings/src/library/SimplePromptbookLibrary.d.ts +3 -1
  12. package/{umd/typings/src/library/constructors/createPromptbookLibraryFromDirectory.d.ts → esm/typings/src/library/constructors/createLibraryFromDirectory.d.ts} +2 -2
  13. package/esm/typings/src/library/constructors/createLibraryFromJson.d.ts +12 -0
  14. package/{umd/typings/src/library/constructors/createPromptbookLibraryFromPromise.d.ts → esm/typings/src/library/constructors/createLibraryFromPromise.d.ts} +3 -7
  15. package/{umd/typings/src/library/constructors/createPromptbookLibraryFromUrl.d.ts → esm/typings/src/library/constructors/createLibraryFromUrl.d.ts} +2 -2
  16. package/esm/typings/src/library/constructors/{createPromptbookSublibrary.d.ts → createSublibrary.d.ts} +1 -1
  17. package/esm/typings/src/library/libraryToJson.d.ts +8 -0
  18. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  19. package/package.json +2 -2
  20. package/umd/index.umd.js +1 -1
  21. package/umd/typings/src/_packages/cli.index.d.ts +2 -2
  22. package/umd/typings/src/_packages/core.index.d.ts +6 -6
  23. package/umd/typings/src/_packages/node.index.d.ts +2 -2
  24. package/umd/typings/src/_packages/types.index.d.ts +2 -1
  25. package/umd/typings/src/cli/actions/hello.d.ts +7 -0
  26. package/umd/typings/src/cli/actions/make.d.ts +7 -0
  27. package/umd/typings/src/cli/actions/prettify.d.ts +7 -0
  28. package/umd/typings/src/{conversion/prettify/prettifyPromptbookStringCli.d.ts → cli/promptbookCli.d.ts} +2 -2
  29. package/umd/typings/src/library/SimplePromptbookLibrary.d.ts +3 -1
  30. package/{esm/typings/src/library/constructors/createPromptbookLibraryFromDirectory.d.ts → umd/typings/src/library/constructors/createLibraryFromDirectory.d.ts} +2 -2
  31. package/umd/typings/src/library/constructors/createLibraryFromJson.d.ts +12 -0
  32. package/{esm/typings/src/library/constructors/createPromptbookLibraryFromPromise.d.ts → umd/typings/src/library/constructors/createLibraryFromPromise.d.ts} +3 -7
  33. package/umd/typings/src/library/constructors/createLibraryFromPromise.test.d.ts +1 -0
  34. package/{esm/typings/src/library/constructors/createPromptbookLibraryFromUrl.d.ts → umd/typings/src/library/constructors/createLibraryFromUrl.d.ts} +2 -2
  35. package/umd/typings/src/library/constructors/{createPromptbookSublibrary.d.ts → createSublibrary.d.ts} +1 -1
  36. package/umd/typings/src/library/libraryToJson.d.ts +8 -0
  37. package/umd/typings/src/library/libraryToJson.test.d.ts +1 -0
  38. package/umd/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  39. package/esm/typings/src/library/constructors/createPromptbookLibraryFromSources.d.ts +0 -16
  40. package/umd/typings/src/library/constructors/createPromptbookLibraryFromSources.d.ts +0 -16
  41. /package/esm/typings/src/library/constructors/{createPromptbookLibraryFromDirectory.test.d.ts → createLibraryFromDirectory.test.d.ts} +0 -0
  42. /package/esm/typings/src/library/constructors/{createPromptbookLibraryFromPromise.test.d.ts → createLibraryFromJson.test.d.ts} +0 -0
  43. /package/esm/typings/src/library/constructors/{createPromptbookLibraryFromSources.test.d.ts → createLibraryFromPromise.test.d.ts} +0 -0
  44. /package/{umd/typings/src/library/constructors/createPromptbookLibraryFromDirectory.test.d.ts → esm/typings/src/library/libraryToJson.test.d.ts} +0 -0
  45. /package/umd/typings/src/library/constructors/{createPromptbookLibraryFromPromise.test.d.ts → createLibraryFromDirectory.test.d.ts} +0 -0
  46. /package/umd/typings/src/library/constructors/{createPromptbookLibraryFromSources.test.d.ts → createLibraryFromJson.test.d.ts} +0 -0
package/README.md CHANGED
@@ -35,12 +35,12 @@ npm i @promptbook/openai
35
35
 
36
36
  ```typescript
37
37
  import { createPromptbookExecutor, assertsExecutionSuccessful } from '@promptbook/core';
38
- import { createPromptbookLibraryFromDirectory } from '@promptbook/node';
38
+ import { createLibraryFromDirectory } from '@promptbook/node';
39
39
  import { JavascriptExecutionTools } from '@promptbook/execute-javascript';
40
40
  import { OpenAiExecutionTools } from '@promptbook/openai';
41
41
 
42
42
  // ▶ Create whole Promptbook library
43
- const library = await createPromptbookLibraryFromDirectory('./promptbook-library');
43
+ const library = await createLibraryFromDirectory('./promptbook-library');
44
44
 
45
45
  // ▶ Get one Promptbook
46
46
  const promptbook = await library.getPromptbookByUrl(`https://promptbook.studio/my-library/write-article.ptbk.md`);
@@ -77,12 +77,12 @@ You can use multiple LLM providers in one Promptbook execution. The best model w
77
77
 
78
78
  ```typescript
79
79
  import { createPromptbookExecutor, assertsExecutionSuccessful } from '@promptbook/core';
80
- import { createPromptbookLibraryFromDirectory } from '@promptbook/node';
80
+ import { createLibraryFromDirectory } from '@promptbook/node';
81
81
  import { JavascriptExecutionTools } from '@promptbook/execute-javascript';
82
82
  import { OpenAiExecutionTools } from '@promptbook/openai';
83
83
 
84
84
  // ▶ Create whole Promptbook library
85
- const library = await createPromptbookLibraryFromDirectory('./promptbook-library');
85
+ const library = await createLibraryFromDirectory('./promptbook-library');
86
86
 
87
87
  // ▶ Get one Promptbook
88
88
  const promptbook = await library.getPromptbookByUrl(`https://promptbook.studio/my-library/write-article.ptbk.md`);
package/esm/index.es.js CHANGED
@@ -1035,7 +1035,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
1035
1035
  /**
1036
1036
  * The version of the Promptbook library
1037
1037
  */
1038
- var PROMPTBOOK_VERSION = '0.59.0-20';
1038
+ var PROMPTBOOK_VERSION = '0.59.0-21';
1039
1039
 
1040
1040
  export { OPENAI_MODELS, OpenAiExecutionTools, PROMPTBOOK_VERSION };
1041
1041
  //# sourceMappingURL=index.es.js.map
@@ -1,10 +1,10 @@
1
- import { prettifyPromptbookStringCli } from '../conversion/prettify/prettifyPromptbookStringCli';
1
+ import { promptbookCli } from '../cli/promptbookCli';
2
2
  import { PROMPTBOOK_VERSION } from '../version';
3
3
  export { PROMPTBOOK_VERSION };
4
4
  /**
5
5
  * Hidden utilities which should not be used by external consumers.
6
6
  */
7
7
  declare const __: {
8
- prettifyPromptbookStringCli: typeof prettifyPromptbookStringCli;
8
+ promptbookCli: typeof promptbookCli;
9
9
  };
10
10
  export { __ };
@@ -20,11 +20,11 @@ import { CallbackInterfaceTools } from '../knowledge/dialogs/callback/CallbackIn
20
20
  import type { CallbackInterfaceToolsOptions } from '../knowledge/dialogs/callback/CallbackInterfaceToolsOptions';
21
21
  import { SimplePromptInterfaceTools } from '../knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools';
22
22
  import { prepareKnowledgeFromMarkdown } from '../knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown';
23
- import { createPromptbookLibraryFromPromise } from '../library/constructors/createPromptbookLibraryFromPromise';
24
- import { createPromptbookLibraryFromSources } from '../library/constructors/createPromptbookLibraryFromSources';
25
- import { createPromptbookLibraryFromUrl } from '../library/constructors/createPromptbookLibraryFromUrl';
26
- import { createPromptbookSublibrary } from '../library/constructors/createPromptbookSublibrary';
27
- import { SimplePromptbookLibrary } from '../library/SimplePromptbookLibrary';
23
+ import { createLibraryFromJson } from '../library/constructors/createLibraryFromJson';
24
+ import { createLibraryFromPromise } from '../library/constructors/createLibraryFromPromise';
25
+ import { createLibraryFromUrl } from '../library/constructors/createLibraryFromUrl';
26
+ import { createSublibrary } from '../library/constructors/createSublibrary';
27
+ import { libraryToJson } from '../library/libraryToJson';
28
28
  import { MultipleLlmExecutionTools } from '../llm-providers/multiple/MultipleLlmExecutionTools';
29
29
  import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
30
30
  import type { ExecutionReportStringOptions } from '../types/execution-report/ExecutionReportStringOptions';
@@ -34,7 +34,7 @@ import { PROMPTBOOK_VERSION } from '../version';
34
34
  export { PROMPTBOOK_VERSION };
35
35
  export { ExecutionTypes };
36
36
  export { addUsage, assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, isPassingExpectations, prepareKnowledgeFromMarkdown, prettifyPromptbookString, usageToWorktime, };
37
- export { createPromptbookLibraryFromPromise, createPromptbookLibraryFromSources, createPromptbookLibraryFromUrl, createPromptbookSublibrary, SimplePromptbookLibrary, };
37
+ export { createLibraryFromJson, createLibraryFromPromise, createLibraryFromUrl, createSublibrary, libraryToJson };
38
38
  export { SimplePromptInterfaceTools };
39
39
  export { promptbookJsonToString, promptbookStringToJson, validatePromptbookJson };
40
40
  export { createPromptbookExecutor, MultipleLlmExecutionTools };
@@ -1,4 +1,4 @@
1
- import { createPromptbookLibraryFromDirectory } from '../library/constructors/createPromptbookLibraryFromDirectory';
1
+ import { createLibraryFromDirectory } from '../library/constructors/createLibraryFromDirectory';
2
2
  import { PROMPTBOOK_VERSION } from '../version';
3
3
  export { PROMPTBOOK_VERSION };
4
- export { createPromptbookLibraryFromDirectory };
4
+ export { createLibraryFromDirectory };
@@ -6,6 +6,7 @@ import type { PromptbookExecutor } from '../execution/PromptbookExecutor';
6
6
  import type { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../execution/ScriptExecutionTools';
7
7
  import type { UserInterfaceTools, UserInterfaceToolsPromptDialogOptions } from '../execution/UserInterfaceTools';
8
8
  import type { PromptbookLibrary } from '../library/PromptbookLibrary';
9
+ import type { SimplePromptbookLibrary } from '../library/SimplePromptbookLibrary';
9
10
  import type { ExecutionType } from '../types/ExecutionTypes';
10
11
  import type { ModelRequirements, ModelVariant } from '../types/ModelRequirements';
11
12
  import type { Parameters } from '../types/Parameters';
@@ -26,7 +27,7 @@ import type { FromtoItems } from '../utils/FromtoItems';
26
27
  import { PROMPTBOOK_VERSION } from '../version';
27
28
  export { PROMPTBOOK_VERSION };
28
29
  export { EXPECTATION_UNITS };
29
- export type { AvailableModel, client_id, CommonExecutionToolsOptions, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, Expectations, ExpectationUnit, FromtoItems, KnowledgeJson, LlmExecutionTools, LlmTemplateJson, MaterialKnowledgePieceJson, ModelRequirements, ModelVariant, Parameters, Prompt, PromptbookExecutor, PromptbookJson, PromptbookLibrary, PromptbookString, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptDialogJson, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_person_fullname, string_prompt, string_promptbook_url, string_promptbook_url_with_hashtemplate, string_script, string_sha256, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_version, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, };
30
+ export type { AvailableModel, client_id, CommonExecutionToolsOptions, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, Expectations, ExpectationUnit, FromtoItems, KnowledgeJson, LlmExecutionTools, LlmTemplateJson, MaterialKnowledgePieceJson, ModelRequirements, ModelVariant, Parameters, Prompt, PromptbookExecutor, PromptbookJson, PromptbookLibrary, PromptbookString, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptDialogJson, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimplePromptbookLibrary, SimpleTemplateJson, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_person_fullname, string_prompt, string_promptbook_url, string_promptbook_url_with_hashtemplate, string_script, string_sha256, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_version, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, };
30
31
  /**
31
32
  * TODO: Delete type aliases (from ../types/typeAliases) that are not exported here
32
33
  */
@@ -0,0 +1,7 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * Initializes testing `hello` command for Promptbook CLI utilities
4
+ *
5
+ * @private part of `promptbookCli`
6
+ */
7
+ export declare function initializeHello(program: Command): void;
@@ -0,0 +1,7 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * Initializes `make` command for Promptbook CLI utilities
4
+ *
5
+ * @private part of `promptbookCli`
6
+ */
7
+ export declare function initializeMake(program: Command): void;
@@ -0,0 +1,7 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * Initializes `prettify` command for Promptbook CLI utilities
4
+ *
5
+ * @private part of `promptbookCli`
6
+ */
7
+ export declare function initializePrettify(program: Command): void;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Runs CLI script for prettifying promptbooks
2
+ * Runs CLI utilities of Promptbook package
3
3
  */
4
- export declare function prettifyPromptbookStringCli(): Promise<void>;
4
+ export declare function promptbookCli(): Promise<void>;
5
5
  /**
6
6
  * TODO: [🥠] Do not export to utils directly, its just for CLI script
7
7
  * TODO: [🕌] When more functionalities, rename
@@ -6,6 +6,7 @@ import type { PromptbookLibrary } from './PromptbookLibrary';
6
6
  * Library of promptbooks that groups together promptbooks for an application.
7
7
  * This implementation is a very thin wrapper around the Array / Map of promptbooks.
8
8
  *
9
+ * @private use `createLibraryFromJson` instead
9
10
  * @see https://github.com/webgptorg/promptbook#promptbook-library
10
11
  */
11
12
  export declare class SimplePromptbookLibrary implements PromptbookLibrary {
@@ -15,8 +16,9 @@ export declare class SimplePromptbookLibrary implements PromptbookLibrary {
15
16
  *
16
17
  * @param promptbooks !!!
17
18
  *
19
+ * @private Use instead `createLibraryFromJson`
18
20
  * Note: During the construction logic of all promptbooks are validated
19
- * Note: It is not recommended to use this constructor directly, use `createPromptbookLibraryFromSources` *(or other variant)* instead
21
+ * Note: It is not recommended to use this constructor directly, use `createLibraryFromJson` *(or other variant)* instead
20
22
  */
21
23
  constructor(...promptbooks: Array<PromptbookJson>);
22
24
  /**
@@ -1,7 +1,7 @@
1
1
  import type { string_folder_path } from '../../types/typeAliases';
2
2
  import type { PromptbookLibrary } from '../PromptbookLibrary';
3
3
  /**
4
- * Options for `createPromptbookLibraryFromDirectory` function
4
+ * Options for `createLibraryFromDirectory` function
5
5
  */
6
6
  type CreatePromptbookLibraryFromDirectoryOptions = {
7
7
  /**
@@ -39,7 +39,7 @@ type CreatePromptbookLibraryFromDirectoryOptions = {
39
39
  * @param options - Misc options for the library
40
40
  * @returns PromptbookLibrary
41
41
  */
42
- export declare function createPromptbookLibraryFromDirectory(path: string_folder_path, options?: CreatePromptbookLibraryFromDirectoryOptions): Promise<PromptbookLibrary>;
42
+ export declare function createLibraryFromDirectory(path: string_folder_path, options?: CreatePromptbookLibraryFromDirectoryOptions): Promise<PromptbookLibrary>;
43
43
  export {};
44
44
  /**
45
45
  * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
@@ -0,0 +1,12 @@
1
+ import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
2
+ import { SimplePromptbookLibrary } from '../SimplePromptbookLibrary';
3
+ /**
4
+ * Creates PromptbookLibrary from array of PromptbookJson or PromptbookString
5
+ *
6
+ * Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
7
+ * Note: During the construction syntax and logic of all sources are validated
8
+ *
9
+ * @param promptbookSources
10
+ * @returns PromptbookLibrary
11
+ */
12
+ export declare function createLibraryFromJson(...promptbooks: Array<PromptbookJson>): Promise<SimplePromptbookLibrary>;
@@ -1,5 +1,4 @@
1
1
  import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
2
- import type { PromptbookString } from '../../types/PromptbookString';
3
2
  import type { PromptbookLibrary } from '../PromptbookLibrary';
4
3
  /**
5
4
  * Constructs Promptbook from async sources
@@ -8,19 +7,16 @@ import type { PromptbookLibrary } from '../PromptbookLibrary';
8
7
  * - Factory function that returns Promise of array of PromptbookJson or PromptbookString
9
8
  *
10
9
  * Note: This is useful as internal tool for other constructor functions like
11
- * `createPromptbookLibraryFromUrl` or `createPromptbookLibraryFromDirectory`
10
+ * `createLibraryFromUrl` or `createLibraryFromDirectory`
12
11
  * Consider using those functions instead of this one
13
12
  *
14
13
  * Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
15
14
  * when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
16
15
  *
17
- * Note: Consider using `createPromptbookLibraryFromDirectory` or `createPromptbookLibraryFromUrl`
16
+ * Note: Consider using `createLibraryFromDirectory` or `createLibraryFromUrl`
18
17
  *
19
18
  * @param promptbookSourcesPromiseOrFactory
20
19
  * @returns PromptbookLibrary
21
20
  * @deprecated Do not use, it will became internal tool for other constructor functions
22
21
  */
23
- export declare function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory: Promise<Array<PromptbookJson | PromptbookString>> | (() => Promise<Array<PromptbookJson | PromptbookString>>)): PromptbookLibrary;
24
- /**
25
- * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
26
- */
22
+ export declare function createLibraryFromPromise(promptbookSourcesPromiseOrFactory: Promise<Array<PromptbookJson>> | (() => Promise<Array<PromptbookJson>>)): PromptbookLibrary;
@@ -1,7 +1,7 @@
1
1
  import type { string_url } from '../../types/typeAliases';
2
2
  import type { PromptbookLibrary } from '../PromptbookLibrary';
3
3
  /**
4
- * Options for `createPromptbookLibraryFromDirectory` function
4
+ * Options for `createLibraryFromDirectory` function
5
5
  */
6
6
  type CreatePromptbookLibraryFromUrlyOptions = {
7
7
  /**
@@ -22,7 +22,7 @@ type CreatePromptbookLibraryFromUrlyOptions = {
22
22
 
23
23
  * @returns PromptbookLibrary
24
24
  */
25
- export declare function createPromptbookLibraryFromUrl(url: string_url | URL, options: CreatePromptbookLibraryFromUrlyOptions): Promise<PromptbookLibrary>;
25
+ export declare function createLibraryFromUrl(url: string_url | URL, options: CreatePromptbookLibraryFromUrlyOptions): Promise<PromptbookLibrary>;
26
26
  export {};
27
27
  /**
28
28
  * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
@@ -9,4 +9,4 @@ import type { PromptbookLibrary } from '../PromptbookLibrary';
9
9
  * @param promptbookSources
10
10
  * @returns PromptbookLibrary
11
11
  */
12
- export declare function createPromptbookSublibrary(library: PromptbookLibrary, predicate: (url: string_promptbook_url) => boolean): PromptbookLibrary;
12
+ export declare function createSublibrary(library: PromptbookLibrary, predicate: (url: string_promptbook_url) => boolean): PromptbookLibrary;
@@ -0,0 +1,8 @@
1
+ import type { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
2
+ import type { PromptbookLibrary } from './PromptbookLibrary';
3
+ /**
4
+ * Converts PromptbookLibrary to serialized JSON
5
+ *
6
+ * Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
7
+ */
8
+ export declare function libraryToJson(library: PromptbookLibrary): Promise<Array<PromptbookJson>>;
@@ -10,7 +10,7 @@ import type { RemoteServerOptions } from './interfaces/RemoteServerOptions';
10
10
  */
11
11
  export declare function startRemoteServer(options: RemoteServerOptions): IDestroyable;
12
12
  /**
13
- * TODO: [⚖] Expose the library to be able to connect to same library via createPromptbookLibraryFromUrl
13
+ * TODO: [⚖] Expose the library to be able to connect to same library via createLibraryFromUrl
14
14
  * TODO: Handle progress - support streaming
15
15
  * TODO: [🤹‍♂️] Do not hang up immediately but wait until client closes OR timeout
16
16
  * TODO: [🤹‍♂️] Timeout on chat to free up resources
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/openai",
3
- "version": "0.59.0-21",
3
+ "version": "0.59.0-23",
4
4
  "description": "Library to supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -48,7 +48,7 @@
48
48
  }
49
49
  ],
50
50
  "peerDependencies": {
51
- "@promptbook/core": "0.59.0-21"
51
+ "@promptbook/core": "0.59.0-23"
52
52
  },
53
53
  "main": "./umd/index.umd.js",
54
54
  "module": "./esm/index.es.js",
package/umd/index.umd.js CHANGED
@@ -1043,7 +1043,7 @@
1043
1043
  /**
1044
1044
  * The version of the Promptbook library
1045
1045
  */
1046
- var PROMPTBOOK_VERSION = '0.59.0-20';
1046
+ var PROMPTBOOK_VERSION = '0.59.0-21';
1047
1047
 
1048
1048
  exports.OPENAI_MODELS = OPENAI_MODELS;
1049
1049
  exports.OpenAiExecutionTools = OpenAiExecutionTools;
@@ -1,10 +1,10 @@
1
- import { prettifyPromptbookStringCli } from '../conversion/prettify/prettifyPromptbookStringCli';
1
+ import { promptbookCli } from '../cli/promptbookCli';
2
2
  import { PROMPTBOOK_VERSION } from '../version';
3
3
  export { PROMPTBOOK_VERSION };
4
4
  /**
5
5
  * Hidden utilities which should not be used by external consumers.
6
6
  */
7
7
  declare const __: {
8
- prettifyPromptbookStringCli: typeof prettifyPromptbookStringCli;
8
+ promptbookCli: typeof promptbookCli;
9
9
  };
10
10
  export { __ };
@@ -20,11 +20,11 @@ import { CallbackInterfaceTools } from '../knowledge/dialogs/callback/CallbackIn
20
20
  import type { CallbackInterfaceToolsOptions } from '../knowledge/dialogs/callback/CallbackInterfaceToolsOptions';
21
21
  import { SimplePromptInterfaceTools } from '../knowledge/dialogs/simple-prompt/SimplePromptInterfaceTools';
22
22
  import { prepareKnowledgeFromMarkdown } from '../knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown';
23
- import { createPromptbookLibraryFromPromise } from '../library/constructors/createPromptbookLibraryFromPromise';
24
- import { createPromptbookLibraryFromSources } from '../library/constructors/createPromptbookLibraryFromSources';
25
- import { createPromptbookLibraryFromUrl } from '../library/constructors/createPromptbookLibraryFromUrl';
26
- import { createPromptbookSublibrary } from '../library/constructors/createPromptbookSublibrary';
27
- import { SimplePromptbookLibrary } from '../library/SimplePromptbookLibrary';
23
+ import { createLibraryFromJson } from '../library/constructors/createLibraryFromJson';
24
+ import { createLibraryFromPromise } from '../library/constructors/createLibraryFromPromise';
25
+ import { createLibraryFromUrl } from '../library/constructors/createLibraryFromUrl';
26
+ import { createSublibrary } from '../library/constructors/createSublibrary';
27
+ import { libraryToJson } from '../library/libraryToJson';
28
28
  import { MultipleLlmExecutionTools } from '../llm-providers/multiple/MultipleLlmExecutionTools';
29
29
  import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
30
30
  import type { ExecutionReportStringOptions } from '../types/execution-report/ExecutionReportStringOptions';
@@ -34,7 +34,7 @@ import { PROMPTBOOK_VERSION } from '../version';
34
34
  export { PROMPTBOOK_VERSION };
35
35
  export { ExecutionTypes };
36
36
  export { addUsage, assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, isPassingExpectations, prepareKnowledgeFromMarkdown, prettifyPromptbookString, usageToWorktime, };
37
- export { createPromptbookLibraryFromPromise, createPromptbookLibraryFromSources, createPromptbookLibraryFromUrl, createPromptbookSublibrary, SimplePromptbookLibrary, };
37
+ export { createLibraryFromJson, createLibraryFromPromise, createLibraryFromUrl, createSublibrary, libraryToJson };
38
38
  export { SimplePromptInterfaceTools };
39
39
  export { promptbookJsonToString, promptbookStringToJson, validatePromptbookJson };
40
40
  export { createPromptbookExecutor, MultipleLlmExecutionTools };
@@ -1,4 +1,4 @@
1
- import { createPromptbookLibraryFromDirectory } from '../library/constructors/createPromptbookLibraryFromDirectory';
1
+ import { createLibraryFromDirectory } from '../library/constructors/createLibraryFromDirectory';
2
2
  import { PROMPTBOOK_VERSION } from '../version';
3
3
  export { PROMPTBOOK_VERSION };
4
- export { createPromptbookLibraryFromDirectory };
4
+ export { createLibraryFromDirectory };
@@ -6,6 +6,7 @@ import type { PromptbookExecutor } from '../execution/PromptbookExecutor';
6
6
  import type { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../execution/ScriptExecutionTools';
7
7
  import type { UserInterfaceTools, UserInterfaceToolsPromptDialogOptions } from '../execution/UserInterfaceTools';
8
8
  import type { PromptbookLibrary } from '../library/PromptbookLibrary';
9
+ import type { SimplePromptbookLibrary } from '../library/SimplePromptbookLibrary';
9
10
  import type { ExecutionType } from '../types/ExecutionTypes';
10
11
  import type { ModelRequirements, ModelVariant } from '../types/ModelRequirements';
11
12
  import type { Parameters } from '../types/Parameters';
@@ -26,7 +27,7 @@ import type { FromtoItems } from '../utils/FromtoItems';
26
27
  import { PROMPTBOOK_VERSION } from '../version';
27
28
  export { PROMPTBOOK_VERSION };
28
29
  export { EXPECTATION_UNITS };
29
- export type { AvailableModel, client_id, CommonExecutionToolsOptions, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, Expectations, ExpectationUnit, FromtoItems, KnowledgeJson, LlmExecutionTools, LlmTemplateJson, MaterialKnowledgePieceJson, ModelRequirements, ModelVariant, Parameters, Prompt, PromptbookExecutor, PromptbookJson, PromptbookLibrary, PromptbookString, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptDialogJson, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimpleTemplateJson, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_person_fullname, string_prompt, string_promptbook_url, string_promptbook_url_with_hashtemplate, string_script, string_sha256, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_version, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, };
30
+ export type { AvailableModel, client_id, CommonExecutionToolsOptions, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, Expectations, ExpectationUnit, FromtoItems, KnowledgeJson, LlmExecutionTools, LlmTemplateJson, MaterialKnowledgePieceJson, ModelRequirements, ModelVariant, Parameters, Prompt, PromptbookExecutor, PromptbookJson, PromptbookLibrary, PromptbookString, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptDialogJson, PromptResult, PromptResultUsage, PromptResultUsageCounts, PromptTemplateJson, PromptTemplateParameterJson, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptJson, ScriptLanguage, SimplePromptbookLibrary, SimpleTemplateJson, string_char, string_char_emoji, string_chat_prompt, string_completion_prompt, string_data_url, string_domain, string_email, string_file_absolute_path, string_file_extension, string_file_path, string_file_relative_path, string_filename, string_folder_absolute_path, string_folder_path, string_folder_relative_path, string_host, string_hostname, string_href, string_html, string_javascript, string_javascript_name, string_license, string_markdown, string_markdown_text, string_mime_type, string_mime_type_with_wildcard, string_model_name, string_name, string_person_fullname, string_prompt, string_promptbook_url, string_promptbook_url_with_hashtemplate, string_script, string_sha256, string_tdl, string_template, string_text_prompt, string_title, string_token, string_translate_language, string_uri, string_uri_part, string_url, string_url_image, string_version, TaskProgress, UncertainNumber, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, };
30
31
  /**
31
32
  * TODO: Delete type aliases (from ../types/typeAliases) that are not exported here
32
33
  */
@@ -0,0 +1,7 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * Initializes testing `hello` command for Promptbook CLI utilities
4
+ *
5
+ * @private part of `promptbookCli`
6
+ */
7
+ export declare function initializeHello(program: Command): void;
@@ -0,0 +1,7 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * Initializes `make` command for Promptbook CLI utilities
4
+ *
5
+ * @private part of `promptbookCli`
6
+ */
7
+ export declare function initializeMake(program: Command): void;
@@ -0,0 +1,7 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * Initializes `prettify` command for Promptbook CLI utilities
4
+ *
5
+ * @private part of `promptbookCli`
6
+ */
7
+ export declare function initializePrettify(program: Command): void;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Runs CLI script for prettifying promptbooks
2
+ * Runs CLI utilities of Promptbook package
3
3
  */
4
- export declare function prettifyPromptbookStringCli(): Promise<void>;
4
+ export declare function promptbookCli(): Promise<void>;
5
5
  /**
6
6
  * TODO: [🥠] Do not export to utils directly, its just for CLI script
7
7
  * TODO: [🕌] When more functionalities, rename
@@ -6,6 +6,7 @@ import type { PromptbookLibrary } from './PromptbookLibrary';
6
6
  * Library of promptbooks that groups together promptbooks for an application.
7
7
  * This implementation is a very thin wrapper around the Array / Map of promptbooks.
8
8
  *
9
+ * @private use `createLibraryFromJson` instead
9
10
  * @see https://github.com/webgptorg/promptbook#promptbook-library
10
11
  */
11
12
  export declare class SimplePromptbookLibrary implements PromptbookLibrary {
@@ -15,8 +16,9 @@ export declare class SimplePromptbookLibrary implements PromptbookLibrary {
15
16
  *
16
17
  * @param promptbooks !!!
17
18
  *
19
+ * @private Use instead `createLibraryFromJson`
18
20
  * Note: During the construction logic of all promptbooks are validated
19
- * Note: It is not recommended to use this constructor directly, use `createPromptbookLibraryFromSources` *(or other variant)* instead
21
+ * Note: It is not recommended to use this constructor directly, use `createLibraryFromJson` *(or other variant)* instead
20
22
  */
21
23
  constructor(...promptbooks: Array<PromptbookJson>);
22
24
  /**
@@ -1,7 +1,7 @@
1
1
  import type { string_folder_path } from '../../types/typeAliases';
2
2
  import type { PromptbookLibrary } from '../PromptbookLibrary';
3
3
  /**
4
- * Options for `createPromptbookLibraryFromDirectory` function
4
+ * Options for `createLibraryFromDirectory` function
5
5
  */
6
6
  type CreatePromptbookLibraryFromDirectoryOptions = {
7
7
  /**
@@ -39,7 +39,7 @@ type CreatePromptbookLibraryFromDirectoryOptions = {
39
39
  * @param options - Misc options for the library
40
40
  * @returns PromptbookLibrary
41
41
  */
42
- export declare function createPromptbookLibraryFromDirectory(path: string_folder_path, options?: CreatePromptbookLibraryFromDirectoryOptions): Promise<PromptbookLibrary>;
42
+ export declare function createLibraryFromDirectory(path: string_folder_path, options?: CreatePromptbookLibraryFromDirectoryOptions): Promise<PromptbookLibrary>;
43
43
  export {};
44
44
  /**
45
45
  * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
@@ -0,0 +1,12 @@
1
+ import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
2
+ import { SimplePromptbookLibrary } from '../SimplePromptbookLibrary';
3
+ /**
4
+ * Creates PromptbookLibrary from array of PromptbookJson or PromptbookString
5
+ *
6
+ * Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
7
+ * Note: During the construction syntax and logic of all sources are validated
8
+ *
9
+ * @param promptbookSources
10
+ * @returns PromptbookLibrary
11
+ */
12
+ export declare function createLibraryFromJson(...promptbooks: Array<PromptbookJson>): Promise<SimplePromptbookLibrary>;
@@ -1,5 +1,4 @@
1
1
  import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
2
- import type { PromptbookString } from '../../types/PromptbookString';
3
2
  import type { PromptbookLibrary } from '../PromptbookLibrary';
4
3
  /**
5
4
  * Constructs Promptbook from async sources
@@ -8,19 +7,16 @@ import type { PromptbookLibrary } from '../PromptbookLibrary';
8
7
  * - Factory function that returns Promise of array of PromptbookJson or PromptbookString
9
8
  *
10
9
  * Note: This is useful as internal tool for other constructor functions like
11
- * `createPromptbookLibraryFromUrl` or `createPromptbookLibraryFromDirectory`
10
+ * `createLibraryFromUrl` or `createLibraryFromDirectory`
12
11
  * Consider using those functions instead of this one
13
12
  *
14
13
  * Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
15
14
  * when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
16
15
  *
17
- * Note: Consider using `createPromptbookLibraryFromDirectory` or `createPromptbookLibraryFromUrl`
16
+ * Note: Consider using `createLibraryFromDirectory` or `createLibraryFromUrl`
18
17
  *
19
18
  * @param promptbookSourcesPromiseOrFactory
20
19
  * @returns PromptbookLibrary
21
20
  * @deprecated Do not use, it will became internal tool for other constructor functions
22
21
  */
23
- export declare function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory: Promise<Array<PromptbookJson | PromptbookString>> | (() => Promise<Array<PromptbookJson | PromptbookString>>)): PromptbookLibrary;
24
- /**
25
- * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
26
- */
22
+ export declare function createLibraryFromPromise(promptbookSourcesPromiseOrFactory: Promise<Array<PromptbookJson>> | (() => Promise<Array<PromptbookJson>>)): PromptbookLibrary;
@@ -1,7 +1,7 @@
1
1
  import type { string_url } from '../../types/typeAliases';
2
2
  import type { PromptbookLibrary } from '../PromptbookLibrary';
3
3
  /**
4
- * Options for `createPromptbookLibraryFromDirectory` function
4
+ * Options for `createLibraryFromDirectory` function
5
5
  */
6
6
  type CreatePromptbookLibraryFromUrlyOptions = {
7
7
  /**
@@ -22,7 +22,7 @@ type CreatePromptbookLibraryFromUrlyOptions = {
22
22
 
23
23
  * @returns PromptbookLibrary
24
24
  */
25
- export declare function createPromptbookLibraryFromUrl(url: string_url | URL, options: CreatePromptbookLibraryFromUrlyOptions): Promise<PromptbookLibrary>;
25
+ export declare function createLibraryFromUrl(url: string_url | URL, options: CreatePromptbookLibraryFromUrlyOptions): Promise<PromptbookLibrary>;
26
26
  export {};
27
27
  /**
28
28
  * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
@@ -9,4 +9,4 @@ import type { PromptbookLibrary } from '../PromptbookLibrary';
9
9
  * @param promptbookSources
10
10
  * @returns PromptbookLibrary
11
11
  */
12
- export declare function createPromptbookSublibrary(library: PromptbookLibrary, predicate: (url: string_promptbook_url) => boolean): PromptbookLibrary;
12
+ export declare function createSublibrary(library: PromptbookLibrary, predicate: (url: string_promptbook_url) => boolean): PromptbookLibrary;
@@ -0,0 +1,8 @@
1
+ import type { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
2
+ import type { PromptbookLibrary } from './PromptbookLibrary';
3
+ /**
4
+ * Converts PromptbookLibrary to serialized JSON
5
+ *
6
+ * Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
7
+ */
8
+ export declare function libraryToJson(library: PromptbookLibrary): Promise<Array<PromptbookJson>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -10,7 +10,7 @@ import type { RemoteServerOptions } from './interfaces/RemoteServerOptions';
10
10
  */
11
11
  export declare function startRemoteServer(options: RemoteServerOptions): IDestroyable;
12
12
  /**
13
- * TODO: [⚖] Expose the library to be able to connect to same library via createPromptbookLibraryFromUrl
13
+ * TODO: [⚖] Expose the library to be able to connect to same library via createLibraryFromUrl
14
14
  * TODO: Handle progress - support streaming
15
15
  * TODO: [🤹‍♂️] Do not hang up immediately but wait until client closes OR timeout
16
16
  * TODO: [🤹‍♂️] Timeout on chat to free up resources
@@ -1,16 +0,0 @@
1
- import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
2
- import type { PromptbookString } from '../../types/PromptbookString';
3
- import { SimplePromptbookLibrary } from '../SimplePromptbookLibrary';
4
- /**
5
- * Creates PromptbookLibrary from array of PromptbookJson or PromptbookString
6
- *
7
- * Note: You can combine `PromptbookString` (`.ptbk.md`) with `PromptbookJson` BUT it is not recommended
8
- * Note: During the construction syntax and logic of all sources are validated
9
- *
10
- * @param promptbookSources
11
- * @returns PromptbookLibrary
12
- */
13
- export declare function createPromptbookLibraryFromSources(...promptbookSources: Array<PromptbookJson | PromptbookString>): Promise<SimplePromptbookLibrary>;
14
- /**
15
- * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
16
- */
@@ -1,16 +0,0 @@
1
- import type { PromptbookJson } from '../../types/PromptbookJson/PromptbookJson';
2
- import type { PromptbookString } from '../../types/PromptbookString';
3
- import { SimplePromptbookLibrary } from '../SimplePromptbookLibrary';
4
- /**
5
- * Creates PromptbookLibrary from array of PromptbookJson or PromptbookString
6
- *
7
- * Note: You can combine `PromptbookString` (`.ptbk.md`) with `PromptbookJson` BUT it is not recommended
8
- * Note: During the construction syntax and logic of all sources are validated
9
- *
10
- * @param promptbookSources
11
- * @returns PromptbookLibrary
12
- */
13
- export declare function createPromptbookLibraryFromSources(...promptbookSources: Array<PromptbookJson | PromptbookString>): Promise<SimplePromptbookLibrary>;
14
- /**
15
- * TODO: !!!! [🧠] Library precompilation and do not mix markdown and json promptbooks
16
- */