@promptbook/openai 0.38.0 → 0.39.0

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.
@@ -1,4 +1,3 @@
1
- import { PromptbookLibrary } from '../classes/PromptbookLibrary';
2
1
  import { promptbookStringToJson } from '../conversion/promptbookStringToJson';
3
2
  import { validatePromptbookJson } from '../conversion/validatePromptbookJson';
4
3
  import { createPromptbookExecutor } from '../execution/createPromptbookExecutor';
@@ -6,9 +5,10 @@ import { MockedEchoNaturalExecutionTools } from '../execution/plugins/natural-ex
6
5
  import { CallbackInterfaceTools } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools';
7
6
  import { CallbackInterfaceToolsOptions } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions';
8
7
  import { SimplePromptInterfaceTools } from '../execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools';
8
+ import { SimplePromptbookLibrary } from '../library/SimplePromptbookLibrary';
9
9
  import { ExecutionTypes } from '../types/ExecutionTypes';
10
10
  import { PROMPTBOOK_VERSION } from '../version';
11
- export { ExecutionTypes, PROMPTBOOK_VERSION, PromptbookLibrary };
11
+ export { ExecutionTypes, PROMPTBOOK_VERSION, SimplePromptbookLibrary };
12
12
  export { SimplePromptInterfaceTools };
13
13
  export { promptbookStringToJson, validatePromptbookJson };
14
14
  export { MockedEchoNaturalExecutionTools };
@@ -5,6 +5,7 @@ import type { PromptChatResult, PromptCommonResult, PromptCompletionResult, Prom
5
5
  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
+ import { PromptbookLibrary } from '../library/PromptbookLibrary';
8
9
  import type { ExecutionType } from '../types/ExecutionTypes';
9
10
  import type { ModelRequirements, ModelVariant } from '../types/ModelRequirements';
10
11
  import type { Parameters } from '../types/Parameters';
@@ -19,7 +20,7 @@ import type { ExecutionReportJson } from '../types/execution-report/ExecutionRep
19
20
  import type { string_char_emoji } from '../types/typeAliasEmoji';
20
21
  import type { client_id, string_char, 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 } from '../types/typeAliases';
21
22
  import { FromtoItems } from '../utils/FromtoItems';
22
- export { CommonExecutionToolsOptions, EXPECTATION_UNITS, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, ExpectationUnit, FromtoItems, ModelRequirements, ModelVariant, NaturalExecutionTools, Parameters, Prompt, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptTemplateJson, PromptTemplateParameterJson, PromptbookExecutor, PromptbookJson, PromptbookString, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptLanguage, TaskProgress, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, 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, };
23
+ export { CommonExecutionToolsOptions, EXPECTATION_UNITS, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, ExpectationUnit, FromtoItems, ModelRequirements, ModelVariant, NaturalExecutionTools, Parameters, Prompt, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptTemplateJson, PromptTemplateParameterJson, PromptbookExecutor, PromptbookJson, PromptbookLibrary, PromptbookString, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptLanguage, TaskProgress, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, 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, };
23
24
  /**
24
25
  * TODO: Delete type aliases that are not exported here
25
26
  */
@@ -1,4 +1,4 @@
1
- import type { PromptbookLibrary } from '../../../../../classes/PromptbookLibrary';
1
+ import type { PromptbookLibrary } from '../../../../../library/PromptbookLibrary';
2
2
  import type { client_id, string_uri } from '../../../../../types/typeAliases';
3
3
  import type { CommonExecutionToolsOptions } from '../../../../CommonExecutionToolsOptions';
4
4
  import type { NaturalExecutionTools } from '../../../../NaturalExecutionTools';
@@ -0,0 +1,24 @@
1
+ import type { Prompt } from '../types/Prompt';
2
+ import type { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
3
+ import type { string_promptbook_url } from '../types/typeAliases';
4
+ /**
5
+ * Library of promptbooks that groups together promptbooks for an application.
6
+ *
7
+ * @see https://github.com/webgptorg/promptbook#promptbook-library
8
+ */
9
+ export type PromptbookLibrary = {
10
+ /**
11
+ * Gets all promptbooks in the library
12
+ */
13
+ listPromptbooks(): Array<string_promptbook_url>;
14
+ /**
15
+ * Gets promptbook by its URL
16
+ *
17
+ * Note: This is not a direct fetching from the URL, but a lookup in the library
18
+ */
19
+ getPromptbookByUrl(url: string_promptbook_url): PromptbookJson;
20
+ /**
21
+ * Checks whether given prompt was defined in any promptbook in the library
22
+ */
23
+ isResponsibleForPrompt(prompt: Prompt): boolean;
24
+ };
@@ -0,0 +1,41 @@
1
+ import { CreatePromptbookExecutorSettings } from '../execution/createPromptbookExecutor';
2
+ import type { Prompt } from '../types/Prompt';
3
+ import type { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
4
+ import type { PromptbookString } from '../types/PromptbookString';
5
+ import type { string_promptbook_url } from '../types/typeAliases';
6
+ import { PromptbookLibrary } from './PromptbookLibrary';
7
+ /**
8
+ * Library of promptbooks that groups together promptbooks for an application.
9
+ * This implementation is a very thin wrapper around the Array / Set of promptbooks.
10
+ *
11
+ * @see https://github.com/webgptorg/promptbook#promptbook-library
12
+ */
13
+ export declare class SimplePromptbookLibrary implements PromptbookLibrary {
14
+ private readonly options;
15
+ /**
16
+ * Constructs Promptbook from any sources
17
+ *
18
+ * Note: During the construction syntax and logic of all sources are validated
19
+ * Note: You can combine .ptbk.md and .ptbk.json files BUT it is not recommended
20
+ *
21
+ * @param promptbookSources contents of .ptbk.md or .ptbk.json files
22
+ * @param settings settings for creating executor functions
23
+ * @returns PromptbookLibrary
24
+ */
25
+ static fromSources(promptbookSources: Record<string_promptbook_url, PromptbookJson | PromptbookString>, settings?: Partial<CreatePromptbookExecutorSettings>): SimplePromptbookLibrary;
26
+ private constructor();
27
+ /**
28
+ * Gets all promptbooks in the library
29
+ */
30
+ listPromptbooks(): Array<string_promptbook_url>;
31
+ /**
32
+ * Gets promptbook by its URL
33
+ *
34
+ * Note: This is not a direct fetching from the URL, but a lookup in the library
35
+ */
36
+ getPromptbookByUrl(url: string_promptbook_url): PromptbookJson;
37
+ /**
38
+ * Checks whether given prompt was defined in any promptbook in the library
39
+ */
40
+ isResponsibleForPrompt(prompt: Prompt): boolean;
41
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/openai",
3
- "version": "0.38.0",
3
+ "version": "0.39.0",
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.38.0"
40
+ "@promptbook/core": "0.39.0"
41
41
  },
42
42
  "main": "./umd/index.umd.js",
43
43
  "module": "./esm/index.es.js",
@@ -1,4 +1,3 @@
1
- import { PromptbookLibrary } from '../classes/PromptbookLibrary';
2
1
  import { promptbookStringToJson } from '../conversion/promptbookStringToJson';
3
2
  import { validatePromptbookJson } from '../conversion/validatePromptbookJson';
4
3
  import { createPromptbookExecutor } from '../execution/createPromptbookExecutor';
@@ -6,9 +5,10 @@ import { MockedEchoNaturalExecutionTools } from '../execution/plugins/natural-ex
6
5
  import { CallbackInterfaceTools } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools';
7
6
  import { CallbackInterfaceToolsOptions } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions';
8
7
  import { SimplePromptInterfaceTools } from '../execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools';
8
+ import { SimplePromptbookLibrary } from '../library/SimplePromptbookLibrary';
9
9
  import { ExecutionTypes } from '../types/ExecutionTypes';
10
10
  import { PROMPTBOOK_VERSION } from '../version';
11
- export { ExecutionTypes, PROMPTBOOK_VERSION, PromptbookLibrary };
11
+ export { ExecutionTypes, PROMPTBOOK_VERSION, SimplePromptbookLibrary };
12
12
  export { SimplePromptInterfaceTools };
13
13
  export { promptbookStringToJson, validatePromptbookJson };
14
14
  export { MockedEchoNaturalExecutionTools };
@@ -5,6 +5,7 @@ import type { PromptChatResult, PromptCommonResult, PromptCompletionResult, Prom
5
5
  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
+ import { PromptbookLibrary } from '../library/PromptbookLibrary';
8
9
  import type { ExecutionType } from '../types/ExecutionTypes';
9
10
  import type { ModelRequirements, ModelVariant } from '../types/ModelRequirements';
10
11
  import type { Parameters } from '../types/Parameters';
@@ -19,7 +20,7 @@ import type { ExecutionReportJson } from '../types/execution-report/ExecutionRep
19
20
  import type { string_char_emoji } from '../types/typeAliasEmoji';
20
21
  import type { client_id, string_char, 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 } from '../types/typeAliases';
21
22
  import { FromtoItems } from '../utils/FromtoItems';
22
- export { CommonExecutionToolsOptions, EXPECTATION_UNITS, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, ExpectationUnit, FromtoItems, ModelRequirements, ModelVariant, NaturalExecutionTools, Parameters, Prompt, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptTemplateJson, PromptTemplateParameterJson, PromptbookExecutor, PromptbookJson, PromptbookString, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptLanguage, TaskProgress, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, 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, };
23
+ export { CommonExecutionToolsOptions, EXPECTATION_UNITS, ExecutionReportJson, ExecutionTools, ExecutionType, ExpectationAmount, ExpectationUnit, FromtoItems, ModelRequirements, ModelVariant, NaturalExecutionTools, Parameters, Prompt, PromptChatResult, PromptCommonResult, PromptCompletionResult, PromptResult, PromptTemplateJson, PromptTemplateParameterJson, PromptbookExecutor, PromptbookJson, PromptbookLibrary, PromptbookString, ScriptExecutionTools, ScriptExecutionToolsExecuteOptions, ScriptLanguage, TaskProgress, UserInterfaceTools, UserInterfaceToolsPromptDialogOptions, client_id, 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, };
23
24
  /**
24
25
  * TODO: Delete type aliases that are not exported here
25
26
  */
@@ -1,4 +1,4 @@
1
- import type { PromptbookLibrary } from '../../../../../classes/PromptbookLibrary';
1
+ import type { PromptbookLibrary } from '../../../../../library/PromptbookLibrary';
2
2
  import type { client_id, string_uri } from '../../../../../types/typeAliases';
3
3
  import type { CommonExecutionToolsOptions } from '../../../../CommonExecutionToolsOptions';
4
4
  import type { NaturalExecutionTools } from '../../../../NaturalExecutionTools';
@@ -0,0 +1,24 @@
1
+ import type { Prompt } from '../types/Prompt';
2
+ import type { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
3
+ import type { string_promptbook_url } from '../types/typeAliases';
4
+ /**
5
+ * Library of promptbooks that groups together promptbooks for an application.
6
+ *
7
+ * @see https://github.com/webgptorg/promptbook#promptbook-library
8
+ */
9
+ export type PromptbookLibrary = {
10
+ /**
11
+ * Gets all promptbooks in the library
12
+ */
13
+ listPromptbooks(): Array<string_promptbook_url>;
14
+ /**
15
+ * Gets promptbook by its URL
16
+ *
17
+ * Note: This is not a direct fetching from the URL, but a lookup in the library
18
+ */
19
+ getPromptbookByUrl(url: string_promptbook_url): PromptbookJson;
20
+ /**
21
+ * Checks whether given prompt was defined in any promptbook in the library
22
+ */
23
+ isResponsibleForPrompt(prompt: Prompt): boolean;
24
+ };
@@ -0,0 +1,41 @@
1
+ import { CreatePromptbookExecutorSettings } from '../execution/createPromptbookExecutor';
2
+ import type { Prompt } from '../types/Prompt';
3
+ import type { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
4
+ import type { PromptbookString } from '../types/PromptbookString';
5
+ import type { string_promptbook_url } from '../types/typeAliases';
6
+ import { PromptbookLibrary } from './PromptbookLibrary';
7
+ /**
8
+ * Library of promptbooks that groups together promptbooks for an application.
9
+ * This implementation is a very thin wrapper around the Array / Set of promptbooks.
10
+ *
11
+ * @see https://github.com/webgptorg/promptbook#promptbook-library
12
+ */
13
+ export declare class SimplePromptbookLibrary implements PromptbookLibrary {
14
+ private readonly options;
15
+ /**
16
+ * Constructs Promptbook from any sources
17
+ *
18
+ * Note: During the construction syntax and logic of all sources are validated
19
+ * Note: You can combine .ptbk.md and .ptbk.json files BUT it is not recommended
20
+ *
21
+ * @param promptbookSources contents of .ptbk.md or .ptbk.json files
22
+ * @param settings settings for creating executor functions
23
+ * @returns PromptbookLibrary
24
+ */
25
+ static fromSources(promptbookSources: Record<string_promptbook_url, PromptbookJson | PromptbookString>, settings?: Partial<CreatePromptbookExecutorSettings>): SimplePromptbookLibrary;
26
+ private constructor();
27
+ /**
28
+ * Gets all promptbooks in the library
29
+ */
30
+ listPromptbooks(): Array<string_promptbook_url>;
31
+ /**
32
+ * Gets promptbook by its URL
33
+ *
34
+ * Note: This is not a direct fetching from the URL, but a lookup in the library
35
+ */
36
+ getPromptbookByUrl(url: string_promptbook_url): PromptbookJson;
37
+ /**
38
+ * Checks whether given prompt was defined in any promptbook in the library
39
+ */
40
+ isResponsibleForPrompt(prompt: Prompt): boolean;
41
+ }
@@ -1,75 +0,0 @@
1
- import { string_name } from '.././types/typeAliases';
2
- import { CreatePromptbookExecutorSettings } from '../execution/createPromptbookExecutor';
3
- import { ExecutionTools } from '../execution/ExecutionTools';
4
- import { PromptbookExecutor } from '../execution/PromptbookExecutor';
5
- import { Prompt } from '../types/Prompt';
6
- import { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
7
- import { PromptbookString } from '../types/PromptbookString';
8
- /**
9
- * Options for PromptbookLibrary
10
- */
11
- type PromptbookLibraryOptions = {
12
- /**
13
- * The library of promptbooks
14
- */
15
- readonly library: Record<string_name, PromptbookJson>;
16
- /**
17
- * Optional settings for creating a PromptbookExecutor
18
- */
19
- readonly settings?: Partial<CreatePromptbookExecutorSettings>;
20
- };
21
- /**
22
- * Library of promptbooks that groups together promptbooks for an application. This is a very thin wrapper around the Array / Set of promptbooks.
23
- *
24
- * Promptbook library is a useful helper in execution, it can be shared between execution and consumer parts of the app and make common knowledge about promptbooks.
25
- *
26
- * It allows to create executor functions from promptbooks in the library.
27
- *
28
- * @see https://github.com/webgptorg/promptbook#prompt-template-pipeline-library
29
- */
30
- export declare class PromptbookLibrary {
31
- readonly options: PromptbookLibraryOptions;
32
- /**
33
- * Constructs Promptbook from any sources
34
- *
35
- * Note: During the construction syntax and logic of all sources are validated
36
- * Note: You can combine .ptbk.md and .ptbk.json files BUT it is not recommended
37
- *
38
- * @param promptbookSources contents of .ptbk.md or .ptbk.json files
39
- * @param settings settings for creating executor functions
40
- * @returns PromptbookLibrary
41
- */
42
- static fromSources(promptbookSources: Record<string_name, PromptbookJson | PromptbookString>, settings?: Partial<CreatePromptbookExecutorSettings>): PromptbookLibrary;
43
- private constructor();
44
- /**
45
- * Gets all promptbooks in the library
46
- */
47
- get promptbookNames(): Array<string_name>;
48
- /**
49
- * Gets promptbook by name
50
- */
51
- getPromptbookByName(name: string_name): PromptbookJson;
52
- /**
53
- * Checks whether prompt is in the library
54
- */
55
- isPromptInLibrary(prompt: Prompt): boolean;
56
- /**
57
- * Gets executor function for given promptbook
58
- */
59
- createExecutor(name: string_name, tools: ExecutionTools): PromptbookExecutor;
60
- }
61
- export {};
62
- /**
63
- * TODO: [🈴] Identify promptbooks by url `promptbookUrls` + `getPromptbookByUrl`
64
- * TODO: !! [👐][🧠] Split of Promptbook,PromptbookLibrary between interface and class
65
- * TODO: !! [👐] Make promptbooks private WHEN split between interface and class
66
- * TODO: [🧠] Maybe isPromptInLibrary should be separate utility function
67
- * TODO: [🧠] Maybe createExecutor should be separate utility function
68
- * TODO: Static method fromDirectory
69
- * TODO: [🤜] Add generic type for entry and result parameters
70
- * TODO: [🧠] Is it better to promptbookLibrary.executePromptbook('writeXyz',{...}) OR promptbookLibrary.createExecutor('writeXyz')({...}) OR createExecutor(promptbookLibrary.getPromptbook('writeXyz'))
71
- * TODO: [🧠] Formarly (before commit 62229afce7668a5b85077cc18becf798b583bf8d) there were two classes PromptbookLibrary+PromptbookLibraryExecutor (maybe it was better?)
72
- * TODO: [🧠] Is it better to pass tools into getExecutor or into constructor
73
- * Maybe it is not a good idea to cache executors when they are can be created with different tools
74
- * TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
75
- */
@@ -1,75 +0,0 @@
1
- import { string_name } from '.././types/typeAliases';
2
- import { CreatePromptbookExecutorSettings } from '../execution/createPromptbookExecutor';
3
- import { ExecutionTools } from '../execution/ExecutionTools';
4
- import { PromptbookExecutor } from '../execution/PromptbookExecutor';
5
- import { Prompt } from '../types/Prompt';
6
- import { PromptbookJson } from '../types/PromptbookJson/PromptbookJson';
7
- import { PromptbookString } from '../types/PromptbookString';
8
- /**
9
- * Options for PromptbookLibrary
10
- */
11
- type PromptbookLibraryOptions = {
12
- /**
13
- * The library of promptbooks
14
- */
15
- readonly library: Record<string_name, PromptbookJson>;
16
- /**
17
- * Optional settings for creating a PromptbookExecutor
18
- */
19
- readonly settings?: Partial<CreatePromptbookExecutorSettings>;
20
- };
21
- /**
22
- * Library of promptbooks that groups together promptbooks for an application. This is a very thin wrapper around the Array / Set of promptbooks.
23
- *
24
- * Promptbook library is a useful helper in execution, it can be shared between execution and consumer parts of the app and make common knowledge about promptbooks.
25
- *
26
- * It allows to create executor functions from promptbooks in the library.
27
- *
28
- * @see https://github.com/webgptorg/promptbook#prompt-template-pipeline-library
29
- */
30
- export declare class PromptbookLibrary {
31
- readonly options: PromptbookLibraryOptions;
32
- /**
33
- * Constructs Promptbook from any sources
34
- *
35
- * Note: During the construction syntax and logic of all sources are validated
36
- * Note: You can combine .ptbk.md and .ptbk.json files BUT it is not recommended
37
- *
38
- * @param promptbookSources contents of .ptbk.md or .ptbk.json files
39
- * @param settings settings for creating executor functions
40
- * @returns PromptbookLibrary
41
- */
42
- static fromSources(promptbookSources: Record<string_name, PromptbookJson | PromptbookString>, settings?: Partial<CreatePromptbookExecutorSettings>): PromptbookLibrary;
43
- private constructor();
44
- /**
45
- * Gets all promptbooks in the library
46
- */
47
- get promptbookNames(): Array<string_name>;
48
- /**
49
- * Gets promptbook by name
50
- */
51
- getPromptbookByName(name: string_name): PromptbookJson;
52
- /**
53
- * Checks whether prompt is in the library
54
- */
55
- isPromptInLibrary(prompt: Prompt): boolean;
56
- /**
57
- * Gets executor function for given promptbook
58
- */
59
- createExecutor(name: string_name, tools: ExecutionTools): PromptbookExecutor;
60
- }
61
- export {};
62
- /**
63
- * TODO: [🈴] Identify promptbooks by url `promptbookUrls` + `getPromptbookByUrl`
64
- * TODO: !! [👐][🧠] Split of Promptbook,PromptbookLibrary between interface and class
65
- * TODO: !! [👐] Make promptbooks private WHEN split between interface and class
66
- * TODO: [🧠] Maybe isPromptInLibrary should be separate utility function
67
- * TODO: [🧠] Maybe createExecutor should be separate utility function
68
- * TODO: Static method fromDirectory
69
- * TODO: [🤜] Add generic type for entry and result parameters
70
- * TODO: [🧠] Is it better to promptbookLibrary.executePromptbook('writeXyz',{...}) OR promptbookLibrary.createExecutor('writeXyz')({...}) OR createExecutor(promptbookLibrary.getPromptbook('writeXyz'))
71
- * TODO: [🧠] Formarly (before commit 62229afce7668a5b85077cc18becf798b583bf8d) there were two classes PromptbookLibrary+PromptbookLibraryExecutor (maybe it was better?)
72
- * TODO: [🧠] Is it better to pass tools into getExecutor or into constructor
73
- * Maybe it is not a good idea to cache executors when they are can be created with different tools
74
- * TODO: [👧] Strongly type the executors to avoid need of remove nullables whtn noUncheckedIndexedAccess in tsconfig.json
75
- */