@promptbook/openai 0.52.0-3 โ†’ 0.52.0-30

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 (50) hide show
  1. package/README.md +104 -4
  2. package/esm/index.es.js +1 -1
  3. package/esm/typings/_packages/core.index.d.ts +15 -6
  4. package/esm/typings/_packages/utils.index.d.ts +5 -8
  5. package/esm/typings/execution/ExecutionTools.d.ts +5 -3
  6. package/esm/typings/execution/plugins/llm-execution-tools/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +0 -1
  7. package/esm/typings/execution/plugins/llm-execution-tools/azure-openai/AzureOpenAiExecutionTools.d.ts +0 -1
  8. package/esm/typings/execution/plugins/llm-execution-tools/langtail/LangtailExecutionTools.d.ts +0 -3
  9. package/esm/typings/execution/plugins/llm-execution-tools/openai/OpenAiExecutionTools.d.ts +1 -1
  10. package/esm/typings/execution/plugins/llm-execution-tools/remote/RemoteLlmExecutionTools.d.ts +1 -1
  11. package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptEvalExecutionTools.d.ts +1 -1
  12. package/esm/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionTools.d.ts +4 -17
  13. package/esm/typings/execution/utils/forEachAsync.d.ts +18 -0
  14. package/esm/typings/library/constructors/createPromptbookLibraryFromDirectory.d.ts +36 -4
  15. package/esm/typings/library/constructors/createPromptbookLibraryFromDirectory.test.d.ts +1 -0
  16. package/esm/typings/library/constructors/createPromptbookLibraryFromPromise.d.ts +2 -2
  17. package/esm/typings/library/constructors/createPromptbookLibraryFromPromise.test.d.ts +1 -0
  18. package/esm/typings/library/constructors/createPromptbookLibraryFromSources.test.d.ts +1 -0
  19. package/esm/typings/library/constructors/createPromptbookLibraryFromUrl.d.ts +21 -5
  20. package/esm/typings/library/constructors/justTestFsImport.d.ts +7 -0
  21. package/esm/typings/types/Prompt.d.ts +1 -1
  22. package/esm/typings/types/typeAliases.d.ts +2 -2
  23. package/package.json +2 -2
  24. package/umd/index.umd.js +1 -1
  25. package/umd/typings/_packages/core.index.d.ts +15 -6
  26. package/umd/typings/_packages/utils.index.d.ts +5 -8
  27. package/umd/typings/execution/ExecutionTools.d.ts +5 -3
  28. package/umd/typings/execution/plugins/llm-execution-tools/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +0 -1
  29. package/umd/typings/execution/plugins/llm-execution-tools/azure-openai/AzureOpenAiExecutionTools.d.ts +0 -1
  30. package/umd/typings/execution/plugins/llm-execution-tools/langtail/LangtailExecutionTools.d.ts +0 -3
  31. package/umd/typings/execution/plugins/llm-execution-tools/openai/OpenAiExecutionTools.d.ts +1 -1
  32. package/umd/typings/execution/plugins/llm-execution-tools/remote/RemoteLlmExecutionTools.d.ts +1 -1
  33. package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptEvalExecutionTools.d.ts +1 -1
  34. package/umd/typings/execution/plugins/script-execution-tools/javascript/JavascriptExecutionTools.d.ts +4 -17
  35. package/umd/typings/execution/utils/forEachAsync.d.ts +18 -0
  36. package/umd/typings/library/constructors/createPromptbookLibraryFromDirectory.d.ts +36 -4
  37. package/umd/typings/library/constructors/createPromptbookLibraryFromDirectory.test.d.ts +1 -0
  38. package/umd/typings/library/constructors/createPromptbookLibraryFromPromise.d.ts +2 -2
  39. package/umd/typings/library/constructors/createPromptbookLibraryFromPromise.test.d.ts +1 -0
  40. package/umd/typings/library/constructors/createPromptbookLibraryFromSources.test.d.ts +1 -0
  41. package/umd/typings/library/constructors/createPromptbookLibraryFromUrl.d.ts +21 -5
  42. package/umd/typings/library/constructors/justTestFsImport.d.ts +7 -0
  43. package/umd/typings/types/Prompt.d.ts +1 -1
  44. package/umd/typings/types/typeAliases.d.ts +2 -2
  45. package/esm/typings/_packages/wizzard.index.d.ts +0 -5
  46. package/esm/typings/wizzard/Wizzard.d.ts +0 -4
  47. package/esm/typings/wizzard/sample.d.ts +0 -6
  48. package/umd/typings/_packages/wizzard.index.d.ts +0 -5
  49. package/umd/typings/wizzard/Wizzard.d.ts +0 -4
  50. package/umd/typings/wizzard/sample.d.ts +0 -6
package/README.md CHANGED
@@ -30,9 +30,111 @@ npm i ptbk
30
30
  npm i @promptbook/openai
31
31
  ```
32
32
 
33
- Wrapper around [OpenAI's SDK](https://www.npmjs.com/package/openai) to make it easier to use inside Promptbooks.
33
+ `@promptbook/openai` integrates [OpenAI's API](https://openai.com/) with [Promptbook](https://github.com/webgptorg/promptbook). It allows to execute Promptbooks with OpenAI GPT models.
34
34
 
35
+ ## ๐Ÿงก Usage
35
36
 
37
+ ```typescript
38
+ import {
39
+ createPromptbookExecutor,
40
+ createPromptbookLibraryFromDirectory,
41
+ assertsExecutionSuccessful,
42
+ } from '@promptbook/core';
43
+ import { JavascriptExecutionTools } from '@promptbook/execute-javascript';
44
+ import { OpenAiExecutionTools } from '@promptbook/openai';
45
+
46
+ // โ–ถ Create whole Promptbook library
47
+ const library = await createPromptbookLibraryFromDirectory('./promptbook-library');
48
+
49
+ // โ–ถ Get one Promptbook
50
+ const promptbook = await library.getPromptbookByUrl(`https://promptbook.studio/my-library/write-article.ptbk.md`);
51
+
52
+ // โ–ถ Prepare tools
53
+ const tools = {
54
+ llm: new OpenAiExecutionTools({
55
+ apiKey: process.env.OPENAI_API_KEY,
56
+ }),
57
+ script: [new JavascriptExecutionTools()],
58
+ };
59
+
60
+ // โ–ถ Create executor - the function that will execute the Promptbook
61
+ const promptbookExecutor = createPromptbookExecutor({ promptbook, tools });
62
+
63
+ // โ–ถ Prepare input parameters
64
+ const inputParameters = { word: 'cat' };
65
+
66
+ // ๐Ÿš€โ–ถ Execute the Promptbook
67
+ const result = await promptbookExecutor(inputParameters);
68
+
69
+ // โ–ถ Fail if the execution was not successful
70
+ assertsExecutionSuccessful(result);
71
+
72
+ // โ–ถ Handle the result
73
+ const { isSuccessful, errors, outputParameters, executionReport } = result;
74
+ console.info(outputParameters);
75
+ ```
76
+
77
+ ## ๐Ÿ’• Usage of multiple LLM providers
78
+
79
+ You can use multiple LLM providers in one Promptbook execution. The best model will be chosen automatically according to the prompt and the model's capabilities.
80
+
81
+ ```typescript
82
+ import {
83
+ createPromptbookExecutor,
84
+ createPromptbookLibraryFromDirectory,
85
+ assertsExecutionSuccessful,
86
+ } from '@promptbook/core';
87
+ import { JavascriptExecutionTools } from '@promptbook/execute-javascript';
88
+ import { OpenAiExecutionTools } from '@promptbook/openai';
89
+
90
+ // โ–ถ Create whole Promptbook library
91
+ const library = await createPromptbookLibraryFromDirectory('./promptbook-library');
92
+
93
+ // โ–ถ Get one Promptbook
94
+ const promptbook = await library.getPromptbookByUrl(`https://promptbook.studio/my-library/write-article.ptbk.md`);
95
+
96
+ // โ–ถ Prepare tools
97
+ const tools = new MultipleLlmExecutionTools(
98
+ // Note: You can use multiple LLM providers in one Promptbook execution. The best model will be chosen automatically according to the prompt and the model's capabilities.
99
+ new OpenAiExecutionTools({
100
+ isVerbose: true,
101
+ apiKey: process.env.OPENAI_API_KEY,
102
+ }),
103
+ new AnthropicClaudeExecutionTools({
104
+ isVerbose: true,
105
+ apiKey: process.env.ANTHROPIC_CLAUDE_API_KEY,
106
+ }),
107
+ new AzureOpenAiExecutionTools({
108
+ isVerbose: true,
109
+ resourceName: process.env.AZUREOPENAI_RESOURCE_NAME,
110
+ deploymentName: process.env.AZUREOPENAI_DEPLOYMENT_NAME,
111
+ apiKey: process.env.AZUREOPENAI_API_KEY,
112
+ }),
113
+ );
114
+
115
+ // โ–ถ Create executor - the function that will execute the Promptbook
116
+ const promptbookExecutor = createPromptbookExecutor({ promptbook, tools });
117
+
118
+ // โ–ถ Prepare input parameters
119
+ const inputParameters = { word: 'cat' };
120
+
121
+ // ๐Ÿš€โ–ถ Execute the Promptbook
122
+ const result = await promptbookExecutor(inputParameters);
123
+
124
+ // โ–ถ Fail if the execution was not successful
125
+ assertsExecutionSuccessful(result);
126
+
127
+ // โ–ถ Handle the result
128
+ const { isSuccessful, errors, outputParameters, executionReport } = result;
129
+ console.info(outputParameters);
130
+ ```
131
+
132
+ ## ๐Ÿ’™ Integration with other models
133
+
134
+ See the other models available in the Promptbook package:
135
+
136
+ - [Azure OpenAI](https://www.npmjs.com/package/@promptbook/azure-openai)
137
+ - [Anthropic Claude](https://www.npmjs.com/package/@promptbook/anthropic-claude)
36
138
 
37
139
 
38
140
 
@@ -96,7 +198,7 @@ File `write-website-content.ptbk.md`:
96
198
  >
97
199
  > Instructions for creating web page content.
98
200
  >
99
- > - PROMPTBOOK URL https://promptbook.webgpt.com/en/write-website-content.ptbk.md@v0.1.0
201
+ > - PROMPTBOOK URL https://promptbook.webgpt.com/en/write-website-content.ptbk.md
100
202
  > - PROMPTBOOK VERSION 0.0.1
101
203
  > - INPUTโ€ฏโ€ฏPARAM `{rawTitle}` Automatically suggested a site name or empty text
102
204
  > - INPUTโ€ฏโ€ฏPARAM `{rawAssigment}` Automatically generated site entry from image recognition
@@ -555,8 +657,6 @@ _Note: LLMs work with tokens, not characters, but in Promptbooks we want to use
555
657
  ```markdown
556
658
  # โœจ Sample: Expectations
557
659
 
558
- - PROMPTBOOK URL https://promptbook.example.com/samples/postprocessing-2.ptbk.md@v1
559
- - PROMPTBOOK VERSION 1.0.0
560
660
  - INPUTโ€ฏโ€ฏPARAMETER {yourName} Name of the hero
561
661
 
562
662
  ## ๐Ÿ’ฌ Question
package/esm/index.es.js CHANGED
@@ -675,7 +675,7 @@ var OpenAiExecutionTools = /** @class */ (function () {
675
675
  return OpenAiExecutionTools;
676
676
  }());
677
677
  /**
678
- * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
678
+ * TODO: [๐Ÿง ][๐Ÿง™โ€โ™‚๏ธ] Maybe there can be some wizzard for thoose who want to use just OpenAI
679
679
  * TODO: Maybe Create some common util for gptChat and gptComplete
680
680
  * TODO: Maybe make custom OpenaiError
681
681
  */
@@ -1,20 +1,29 @@
1
- import { promptbookStringToJson } from '../conversion/promptbookStringToJson';
1
+ import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptbookString';
2
2
  import { promptbookJsonToString } from '../conversion/promptbookJsonToString';
3
+ import { promptbookStringToJson } from '../conversion/promptbookStringToJson';
3
4
  import { validatePromptbookJson } from '../conversion/validation/validatePromptbookJson';
5
+ import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
4
6
  import { createPromptbookExecutor } from '../execution/createPromptbookExecutor';
7
+ import { MultipleLlmExecutionTools } from '../execution/plugins/llm-execution-tools/multiple/MultipleLlmExecutionTools';
5
8
  import { CallbackInterfaceTools } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools';
6
9
  import { CallbackInterfaceToolsOptions } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions';
7
10
  import { SimplePromptInterfaceTools } from '../execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools';
8
- import { SimplePromptbookLibrary } from '../library/SimplePromptbookLibrary';
9
- import { createPromptbookLibraryFromPromise } from '../library/constructors/createPromptbookLibraryFromPromise';
11
+ import { checkExpectations, isPassingExpectations } from '../execution/utils/checkExpectations';
12
+ import { createPromptbookLibraryFromDirectory } from '../library/constructors/createPromptbookLibraryFromDirectory';
10
13
  import { createPromptbookLibraryFromSources } from '../library/constructors/createPromptbookLibraryFromSources';
14
+ import { createPromptbookLibraryFromUrl } from '../library/constructors/createPromptbookLibraryFromUrl';
11
15
  import { createPromptbookSublibrary } from '../library/constructors/createPromptbookSublibrary';
16
+ import { justTestFsImport } from '../library/constructors/justTestFsImport';
17
+ import { SimplePromptbookLibrary } from '../library/SimplePromptbookLibrary';
18
+ import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
19
+ import { ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults } from '../types/execution-report/ExecutionReportStringOptions';
12
20
  import { ExecutionTypes } from '../types/ExecutionTypes';
13
21
  import { PROMPTBOOK_VERSION } from '../version';
14
- import { MultipleLlmExecutionTools } from '../execution/plugins/llm-execution-tools/multiple/MultipleLlmExecutionTools';
22
+ export { justTestFsImport };
15
23
  export { ExecutionTypes, PROMPTBOOK_VERSION };
16
- export { createPromptbookLibraryFromPromise, createPromptbookLibraryFromSources, createPromptbookSublibrary, SimplePromptbookLibrary, };
24
+ export { assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, isPassingExpectations, prettifyPromptbookString, };
25
+ export { createPromptbookLibraryFromDirectory, createPromptbookLibraryFromSources, createPromptbookLibraryFromUrl, createPromptbookSublibrary, SimplePromptbookLibrary, };
17
26
  export { SimplePromptInterfaceTools };
18
- export { promptbookStringToJson, promptbookJsonToString, validatePromptbookJson };
27
+ export { promptbookJsonToString, promptbookStringToJson, validatePromptbookJson };
19
28
  export { createPromptbookExecutor, MultipleLlmExecutionTools };
20
29
  export { CallbackInterfaceTools, CallbackInterfaceToolsOptions };
@@ -1,16 +1,12 @@
1
1
  import { spaceTrim } from 'spacetrim';
2
- import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptbookString';
3
2
  import { renderPromptbookMermaid } from '../conversion/prettify/renderPromptbookMermaid';
4
3
  import { extractParametersFromPromptTemplate } from '../conversion/utils/extractParametersFromPromptTemplate';
5
4
  import { extractVariables } from '../conversion/utils/extractVariables';
6
5
  import { parseNumber } from '../conversion/utils/parseNumber';
7
6
  import { renameParameter } from '../conversion/utils/renameParameter';
8
7
  import { titleToName } from '../conversion/utils/titleToName';
9
- import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
10
- import { checkExpectations, isPassingExpectations } from '../execution/utils/checkExpectations';
8
+ import { forEachAsync } from '../execution/utils/forEachAsync';
11
9
  import { replaceParameters } from '../execution/utils/replaceParameters';
12
- import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
13
- import { ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults } from '../types/execution-report/ExecutionReportStringOptions';
14
10
  import { CountUtils } from '../utils/expectation-counters';
15
11
  import { countCharacters } from '../utils/expectation-counters/countCharacters';
16
12
  import { countLines } from '../utils/expectation-counters/countLines';
@@ -51,10 +47,11 @@ import { union } from '../utils/sets/union';
51
47
  import { trimCodeBlock } from '../utils/trimCodeBlock';
52
48
  import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
53
49
  import { unwrapResult } from '../utils/unwrapResult';
54
- export { assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [๐ŸŒป]
50
+ export { forEachAsync };
51
+ export { extractAllBlocksFromMarkdown, // <- [๐ŸŒป]
55
52
  extractAllListItemsFromMarkdown, extractBlock, // <- [๐ŸŒป]
56
- extractOneBlockFromMarkdown, extractParameters, extractVariables, isPassingExpectations, isValidJsonString, parseNumber, // <- [๐ŸŒป]
57
- prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, spaceTrim, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
53
+ extractOneBlockFromMarkdown, extractParameters, extractVariables, isValidJsonString, parseNumber, // <- [๐ŸŒป]
54
+ removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, spaceTrim, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
58
55
  export { countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords };
59
56
  export { splitIntoSentences };
60
57
  export declare const normalizeTo: {
@@ -9,6 +9,9 @@ import type { UserInterfaceTools } from './UserInterfaceTools';
9
9
  export type ExecutionTools = {
10
10
  /**
11
11
  * Tools for executing prompts to large language models like GPT-4
12
+ *
13
+ * Tip: Combine multiple LLM execution tools with `MultipleLlmExecutionTools`
14
+ * @see https://github.com/webgptorg/promptbook/?tab=readme-ov-file#llm-execution-tools
12
15
  */
13
16
  llm: LlmExecutionTools;
14
17
  /**
@@ -16,15 +19,14 @@ export type ExecutionTools = {
16
19
  *
17
20
  * Note: You can pass multiple ScriptExecutionTools, they will be tried one by one until one of them supports the script
18
21
  * If none of them supports the script, an error is thrown
22
+ * @see https://github.com/webgptorg/promptbook/?tab=readme-ov-file#script-execution-tools
19
23
  */
20
24
  script: Array<ScriptExecutionTools>;
21
25
  /**
22
26
  * Tools for interacting with the user
23
27
  *
24
28
  * Note: When undefined, the user interface is disabled and promptbook which requires user interaction will fail
29
+ * @see https://github.com/webgptorg/promptbook/?tab=readme-ov-file#user-interface-tools
25
30
  */
26
31
  userInterface?: UserInterfaceTools;
27
32
  };
28
- /**
29
- * TODO: [๐Ÿ“] !!!! Allow to have more LlmExecutionTools
30
- */
@@ -36,7 +36,6 @@ export declare class AnthropicClaudeExecutionTools implements LlmExecutionTools
36
36
  }
37
37
  /**
38
38
  * TODO: [๐Ÿง ] Maybe handle errors via transformAnthropicError (like transformAzureError)
39
- * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
40
39
  * TODO: Maybe Create some common util for gptChat and gptComplete
41
40
  * TODO: Maybe make custom OpenaiError
42
41
  */
@@ -35,7 +35,6 @@ export declare class AzureOpenAiExecutionTools implements LlmExecutionTools {
35
35
  listModels(): Promise<Array<AvailableModel>>;
36
36
  }
37
37
  /**
38
- * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
39
38
  * TODO: Maybe Create some common util for gptChat and gptComplete
40
39
  * TODO: Maybe make custom AzureOpenaiError
41
40
  */
@@ -5,6 +5,3 @@ import { OpenAiExecutionTools } from '../openai/OpenAiExecutionTools';
5
5
  */
6
6
  export declare class LangtailExecutionTools extends OpenAiExecutionTools implements LlmExecutionTools {
7
7
  }
8
- /**
9
- * TODO: [๐Ÿ“][โ™] Allow to list the available prompts in Langtail
10
- */
@@ -39,7 +39,7 @@ export declare class OpenAiExecutionTools implements LlmExecutionTools {
39
39
  listModels(): Array<AvailableModel>;
40
40
  }
41
41
  /**
42
- * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
42
+ * TODO: [๐Ÿง ][๐Ÿง™โ€โ™‚๏ธ] Maybe there can be some wizzard for thoose who want to use just OpenAI
43
43
  * TODO: Maybe Create some common util for gptChat and gptComplete
44
44
  * TODO: Maybe make custom OpenaiError
45
45
  */
@@ -35,6 +35,6 @@ export declare class RemoteLlmExecutionTools implements LlmExecutionTools {
35
35
  listModels(): Promise<Array<AvailableModel>>;
36
36
  }
37
37
  /**
38
- * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
38
+ * TODO: [๐Ÿ“] Allow to list compatible models with each variant
39
39
  * TODO: [๐Ÿคนโ€โ™‚๏ธ] RemoteLlmExecutionTools should extend Destroyable and implement IDestroyable
40
40
  */
@@ -8,7 +8,7 @@ import { JavascriptExecutionToolsOptions } from './JavascriptExecutionToolsOptio
8
8
  */
9
9
  export declare class JavascriptEvalExecutionTools implements ScriptExecutionTools {
10
10
  private readonly options;
11
- constructor(options: JavascriptExecutionToolsOptions);
11
+ constructor(options?: JavascriptExecutionToolsOptions);
12
12
  /**
13
13
  * Executes a JavaScript
14
14
  */
@@ -1,20 +1,7 @@
1
- import { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../../../ScriptExecutionTools';
2
- import { JavascriptExecutionToolsOptions } from './JavascriptExecutionToolsOptions';
1
+ import { JavascriptEvalExecutionTools } from './JavascriptEvalExecutionTools';
3
2
  /**
4
- * ScriptExecutionTools for JavaScript implemented via vm2
3
+ * Placeholder for better implementation of JavascriptExecutionTools - some propper sandboxing
5
4
  *
6
- * Warning: This is not implemented yet
7
- */
8
- export declare class JavascriptExecutionTools implements ScriptExecutionTools {
9
- private readonly options;
10
- constructor(options: JavascriptExecutionToolsOptions);
11
- /**
12
- * Executes a JavaScript
13
- */
14
- execute(options: ScriptExecutionToolsExecuteOptions): Promise<string>;
15
- }
16
- /**
17
- * TODO: !! Pass isVerbose to constructor and use it
18
- * TODO: !! Probbably make some common util createStatementToEvaluate
19
- * TODO: !! Implement via vm2
5
+ * @alias JavascriptExecutionTools
20
6
  */
7
+ export declare const JavascriptExecutionTools: typeof JavascriptEvalExecutionTools;
@@ -0,0 +1,18 @@
1
+ import type { Promisable } from 'type-fest';
2
+ type ForEachAsyncOptions = {
3
+ /**
4
+ * Maximum number of tasks running in parallel
5
+ *
6
+ * @default Infinity
7
+ */
8
+ inParallelCount?: number;
9
+ };
10
+ /**
11
+ * Async version of Array.forEach
12
+ *
13
+ * @param array - Array to iterate over
14
+ * @param options - Options for the function
15
+ * @param callbackfunction - Function to call for each item
16
+ */
17
+ export declare function forEachAsync<TItem>(array: Array<TItem>, options: ForEachAsyncOptions, callbackfunction: (value: TItem, index: number, array: Array<TItem>) => Promisable<void>): Promise<void>;
18
+ export {};
@@ -1,14 +1,46 @@
1
+ import { string_folder_path } from '../../types/typeAliases';
1
2
  import { PromptbookLibrary } from '../PromptbookLibrary';
3
+ /**
4
+ * Options for `createPromptbookLibraryFromDirectory` function
5
+ */
6
+ type CreatePromptbookLibraryFromDirectoryOptions = {
7
+ /**
8
+ * If true, the directory is searched recursively for promptbooks
9
+ *
10
+ * @default true
11
+ */
12
+ isRecursive?: boolean;
13
+ /**
14
+ * If true, the library creation outputs information about each file it reads
15
+ *
16
+ * @default false
17
+ */
18
+ isVerbose?: boolean;
19
+ /**
20
+ * If true, directory will be scanned only when needed not during the construction
21
+ *
22
+ * @default false
23
+ */
24
+ isLazyLoaded?: boolean;
25
+ };
2
26
  /**
3
27
  * Constructs Promptbook from given directory
4
28
  *
5
29
  * Note: Works only in Node.js environment because it reads the file system
6
- * Note: The function does NOT return promise it returns the library directly which dynamically loads promptbooks when needed
7
- * SO during the construction syntax and logic sources IS NOT validated
8
30
  *
31
+ * @param path - path to the directory with promptbooks
32
+ * @param options - Misc options for the library
9
33
  * @returns PromptbookLibrary
10
34
  */
11
- export declare function createPromptbookLibraryFromDirectory(): PromptbookLibrary;
35
+ export declare function createPromptbookLibraryFromDirectory(path: string_folder_path, options?: CreatePromptbookLibraryFromDirectoryOptions): Promise<PromptbookLibrary>;
36
+ export {};
12
37
  /***
13
- * TODO: [๐Ÿ“][๐Ÿšฏ] !!! Add to README and samples + maybe make `@promptbook/library` package
38
+ * TODO: [๐Ÿง ] Maybe do not do hacks like [1] and just create package @promptbook/node
39
+ * [๐Ÿ“][๐Ÿšฏ] maybe make `@promptbook/library` package
40
+ * TODO: Fix the dynamic import issue in Webpack (! Not working !)
41
+ * > ./node_modules/@promptbook/core/esm/index.es.js
42
+ * > Critical dependency: the request of a dependency is an expression
43
+ *
44
+ * Note: [1] Using require(just('fs/promises')) to allow
45
+ * the `@promptbook/core` work for both Node.js and browser environments
14
46
  */
@@ -14,11 +14,11 @@ import { PromptbookLibrary } from '../PromptbookLibrary';
14
14
  * Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
15
15
  * when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
16
16
  *
17
+ * Note: Consider using `createPromptbookLibraryFromDirectory` or `createPromptbookLibraryFromUrl`
17
18
  *
18
19
  * @param promptbookSourcesPromiseOrFactory
19
20
  * @returns PromptbookLibrary
20
- *
21
- * @deprecated Consider using `createPromptbookLibraryFromUrl` or `createPromptbookLibraryFromDirectory`
21
+ * @private Just internal tool for other constructor functions
22
22
  */
23
23
  export declare function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory: Promise<Array<PromptbookJson | PromptbookString>> | (() => Promise<Array<PromptbookJson | PromptbookString>>)): PromptbookLibrary;
24
24
  /***
@@ -1,13 +1,29 @@
1
+ import { string_url } from '../../types/typeAliases';
1
2
  import { PromptbookLibrary } from '../PromptbookLibrary';
3
+ /**
4
+ * Options for `createPromptbookLibraryFromDirectory` function
5
+ */
6
+ type CreatePromptbookLibraryFromUrlyOptions = {
7
+ /**
8
+ * If true, the library creation outputs information about each file it reads
9
+ *
10
+ * @default false
11
+ */
12
+ isVerbose?: boolean;
13
+ /**
14
+ * If true, directory will be scanned only when needed not during the construction
15
+ *
16
+ * @default false
17
+ */
18
+ isLazyLoaded?: boolean;
19
+ };
2
20
  /**
3
21
  * Constructs Promptbook from remote Promptbase URL
4
- *
5
- * Note: The function does NOT return promise it returns the library directly which dynamically loads promptbooks when needed
6
- * SO during the construction syntax and logic sources IS NOT validated
7
- *
22
+
8
23
  * @returns PromptbookLibrary
9
24
  */
10
- export declare function createPromptbookLibraryFromUrl(): PromptbookLibrary;
25
+ export declare function createPromptbookLibraryFromUrl(url: string_url | URL, options: CreatePromptbookLibraryFromUrlyOptions): Promise<PromptbookLibrary>;
26
+ export {};
11
27
  /***
12
28
  * TODO: [๐Ÿ“][๐Ÿšฏ] !!! Add to README and samples + maybe make `@promptbook/library` package
13
29
  */
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Just testing imports and compatibility
3
+ */
4
+ export declare function justTestFsImport(): Promise<void>;
5
+ /**
6
+ * TODO: !!! Remove this file
7
+ */
@@ -39,7 +39,7 @@ export type Prompt = {
39
39
  /**
40
40
  * Unique identifier of the promptbook with specific template name as hash
41
41
  *
42
- * @example https://promptbook.webgpt.com/cs/write-website-content.ptbk.md@v2.4.15#keywords
42
+ * @example https://promptbook.webgpt.com/cs/write-website-content.ptbk.md#keywords
43
43
  */
44
44
  readonly promptbookUrl: string_promptbook_url_with_hashtemplate;
45
45
  /**
@@ -179,13 +179,13 @@ export type string_url = string;
179
179
  /**
180
180
  * Semantic helper
181
181
  *
182
- * For example `"https://promptbook.webgpt.com/cs/write-website-content.ptbk.md@v2.4.15"`
182
+ * For example `"https://promptbook.webgpt.com/cs/write-website-content.ptbk.md"`
183
183
  */
184
184
  export type string_promptbook_url = string;
185
185
  /**
186
186
  * Semantic helper
187
187
  *
188
- * For example `"https://promptbook.webgpt.com/cs/write-website-content.ptbk.md@v2.4.15#keywords"`
188
+ * For example `"https://promptbook.webgpt.com/cs/write-website-content.ptbk.md#keywords"`
189
189
  */
190
190
  export type string_promptbook_url_with_hashtemplate = string;
191
191
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/openai",
3
- "version": "0.52.0-3",
3
+ "version": "0.52.0-30",
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.52.0-3"
51
+ "@promptbook/core": "0.52.0-30"
52
52
  },
53
53
  "main": "./umd/index.umd.js",
54
54
  "module": "./esm/index.es.js",
package/umd/index.umd.js CHANGED
@@ -683,7 +683,7 @@
683
683
  return OpenAiExecutionTools;
684
684
  }());
685
685
  /**
686
- * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
686
+ * TODO: [๐Ÿง ][๐Ÿง™โ€โ™‚๏ธ] Maybe there can be some wizzard for thoose who want to use just OpenAI
687
687
  * TODO: Maybe Create some common util for gptChat and gptComplete
688
688
  * TODO: Maybe make custom OpenaiError
689
689
  */
@@ -1,20 +1,29 @@
1
- import { promptbookStringToJson } from '../conversion/promptbookStringToJson';
1
+ import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptbookString';
2
2
  import { promptbookJsonToString } from '../conversion/promptbookJsonToString';
3
+ import { promptbookStringToJson } from '../conversion/promptbookStringToJson';
3
4
  import { validatePromptbookJson } from '../conversion/validation/validatePromptbookJson';
5
+ import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
4
6
  import { createPromptbookExecutor } from '../execution/createPromptbookExecutor';
7
+ import { MultipleLlmExecutionTools } from '../execution/plugins/llm-execution-tools/multiple/MultipleLlmExecutionTools';
5
8
  import { CallbackInterfaceTools } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceTools';
6
9
  import { CallbackInterfaceToolsOptions } from '../execution/plugins/user-interface-execution-tools/callback/CallbackInterfaceToolsOptions';
7
10
  import { SimplePromptInterfaceTools } from '../execution/plugins/user-interface-execution-tools/simple-prompt/SimplePromptInterfaceTools';
8
- import { SimplePromptbookLibrary } from '../library/SimplePromptbookLibrary';
9
- import { createPromptbookLibraryFromPromise } from '../library/constructors/createPromptbookLibraryFromPromise';
11
+ import { checkExpectations, isPassingExpectations } from '../execution/utils/checkExpectations';
12
+ import { createPromptbookLibraryFromDirectory } from '../library/constructors/createPromptbookLibraryFromDirectory';
10
13
  import { createPromptbookLibraryFromSources } from '../library/constructors/createPromptbookLibraryFromSources';
14
+ import { createPromptbookLibraryFromUrl } from '../library/constructors/createPromptbookLibraryFromUrl';
11
15
  import { createPromptbookSublibrary } from '../library/constructors/createPromptbookSublibrary';
16
+ import { justTestFsImport } from '../library/constructors/justTestFsImport';
17
+ import { SimplePromptbookLibrary } from '../library/SimplePromptbookLibrary';
18
+ import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
19
+ import { ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults } from '../types/execution-report/ExecutionReportStringOptions';
12
20
  import { ExecutionTypes } from '../types/ExecutionTypes';
13
21
  import { PROMPTBOOK_VERSION } from '../version';
14
- import { MultipleLlmExecutionTools } from '../execution/plugins/llm-execution-tools/multiple/MultipleLlmExecutionTools';
22
+ export { justTestFsImport };
15
23
  export { ExecutionTypes, PROMPTBOOK_VERSION };
16
- export { createPromptbookLibraryFromPromise, createPromptbookLibraryFromSources, createPromptbookSublibrary, SimplePromptbookLibrary, };
24
+ export { assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, isPassingExpectations, prettifyPromptbookString, };
25
+ export { createPromptbookLibraryFromDirectory, createPromptbookLibraryFromSources, createPromptbookLibraryFromUrl, createPromptbookSublibrary, SimplePromptbookLibrary, };
17
26
  export { SimplePromptInterfaceTools };
18
- export { promptbookStringToJson, promptbookJsonToString, validatePromptbookJson };
27
+ export { promptbookJsonToString, promptbookStringToJson, validatePromptbookJson };
19
28
  export { createPromptbookExecutor, MultipleLlmExecutionTools };
20
29
  export { CallbackInterfaceTools, CallbackInterfaceToolsOptions };
@@ -1,16 +1,12 @@
1
1
  import { spaceTrim } from 'spacetrim';
2
- import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptbookString';
3
2
  import { renderPromptbookMermaid } from '../conversion/prettify/renderPromptbookMermaid';
4
3
  import { extractParametersFromPromptTemplate } from '../conversion/utils/extractParametersFromPromptTemplate';
5
4
  import { extractVariables } from '../conversion/utils/extractVariables';
6
5
  import { parseNumber } from '../conversion/utils/parseNumber';
7
6
  import { renameParameter } from '../conversion/utils/renameParameter';
8
7
  import { titleToName } from '../conversion/utils/titleToName';
9
- import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
10
- import { checkExpectations, isPassingExpectations } from '../execution/utils/checkExpectations';
8
+ import { forEachAsync } from '../execution/utils/forEachAsync';
11
9
  import { replaceParameters } from '../execution/utils/replaceParameters';
12
- import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
13
- import { ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults } from '../types/execution-report/ExecutionReportStringOptions';
14
10
  import { CountUtils } from '../utils/expectation-counters';
15
11
  import { countCharacters } from '../utils/expectation-counters/countCharacters';
16
12
  import { countLines } from '../utils/expectation-counters/countLines';
@@ -51,10 +47,11 @@ import { union } from '../utils/sets/union';
51
47
  import { trimCodeBlock } from '../utils/trimCodeBlock';
52
48
  import { trimEndOfCodeBlock } from '../utils/trimEndOfCodeBlock';
53
49
  import { unwrapResult } from '../utils/unwrapResult';
54
- export { assertsExecutionSuccessful, checkExpectations, executionReportJsonToString, ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults, extractAllBlocksFromMarkdown, // <- [๐ŸŒป]
50
+ export { forEachAsync };
51
+ export { extractAllBlocksFromMarkdown, // <- [๐ŸŒป]
55
52
  extractAllListItemsFromMarkdown, extractBlock, // <- [๐ŸŒป]
56
- extractOneBlockFromMarkdown, extractParameters, extractVariables, isPassingExpectations, isValidJsonString, parseNumber, // <- [๐ŸŒป]
57
- prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, spaceTrim, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
53
+ extractOneBlockFromMarkdown, extractParameters, extractVariables, isValidJsonString, parseNumber, // <- [๐ŸŒป]
54
+ removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, spaceTrim, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
58
55
  export { countCharacters, countLines, countPages, countParagraphs, countSentences, CountUtils, countWords };
59
56
  export { splitIntoSentences };
60
57
  export declare const normalizeTo: {
@@ -9,6 +9,9 @@ import type { UserInterfaceTools } from './UserInterfaceTools';
9
9
  export type ExecutionTools = {
10
10
  /**
11
11
  * Tools for executing prompts to large language models like GPT-4
12
+ *
13
+ * Tip: Combine multiple LLM execution tools with `MultipleLlmExecutionTools`
14
+ * @see https://github.com/webgptorg/promptbook/?tab=readme-ov-file#llm-execution-tools
12
15
  */
13
16
  llm: LlmExecutionTools;
14
17
  /**
@@ -16,15 +19,14 @@ export type ExecutionTools = {
16
19
  *
17
20
  * Note: You can pass multiple ScriptExecutionTools, they will be tried one by one until one of them supports the script
18
21
  * If none of them supports the script, an error is thrown
22
+ * @see https://github.com/webgptorg/promptbook/?tab=readme-ov-file#script-execution-tools
19
23
  */
20
24
  script: Array<ScriptExecutionTools>;
21
25
  /**
22
26
  * Tools for interacting with the user
23
27
  *
24
28
  * Note: When undefined, the user interface is disabled and promptbook which requires user interaction will fail
29
+ * @see https://github.com/webgptorg/promptbook/?tab=readme-ov-file#user-interface-tools
25
30
  */
26
31
  userInterface?: UserInterfaceTools;
27
32
  };
28
- /**
29
- * TODO: [๐Ÿ“] !!!! Allow to have more LlmExecutionTools
30
- */
@@ -36,7 +36,6 @@ export declare class AnthropicClaudeExecutionTools implements LlmExecutionTools
36
36
  }
37
37
  /**
38
38
  * TODO: [๐Ÿง ] Maybe handle errors via transformAnthropicError (like transformAzureError)
39
- * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
40
39
  * TODO: Maybe Create some common util for gptChat and gptComplete
41
40
  * TODO: Maybe make custom OpenaiError
42
41
  */
@@ -35,7 +35,6 @@ export declare class AzureOpenAiExecutionTools implements LlmExecutionTools {
35
35
  listModels(): Promise<Array<AvailableModel>>;
36
36
  }
37
37
  /**
38
- * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
39
38
  * TODO: Maybe Create some common util for gptChat and gptComplete
40
39
  * TODO: Maybe make custom AzureOpenaiError
41
40
  */
@@ -5,6 +5,3 @@ import { OpenAiExecutionTools } from '../openai/OpenAiExecutionTools';
5
5
  */
6
6
  export declare class LangtailExecutionTools extends OpenAiExecutionTools implements LlmExecutionTools {
7
7
  }
8
- /**
9
- * TODO: [๐Ÿ“][โ™] Allow to list the available prompts in Langtail
10
- */
@@ -39,7 +39,7 @@ export declare class OpenAiExecutionTools implements LlmExecutionTools {
39
39
  listModels(): Array<AvailableModel>;
40
40
  }
41
41
  /**
42
- * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
42
+ * TODO: [๐Ÿง ][๐Ÿง™โ€โ™‚๏ธ] Maybe there can be some wizzard for thoose who want to use just OpenAI
43
43
  * TODO: Maybe Create some common util for gptChat and gptComplete
44
44
  * TODO: Maybe make custom OpenaiError
45
45
  */
@@ -35,6 +35,6 @@ export declare class RemoteLlmExecutionTools implements LlmExecutionTools {
35
35
  listModels(): Promise<Array<AvailableModel>>;
36
36
  }
37
37
  /**
38
- * TODO: [๐Ÿ“][โ™] Allow to list compatible models with each variant
38
+ * TODO: [๐Ÿ“] Allow to list compatible models with each variant
39
39
  * TODO: [๐Ÿคนโ€โ™‚๏ธ] RemoteLlmExecutionTools should extend Destroyable and implement IDestroyable
40
40
  */
@@ -8,7 +8,7 @@ import { JavascriptExecutionToolsOptions } from './JavascriptExecutionToolsOptio
8
8
  */
9
9
  export declare class JavascriptEvalExecutionTools implements ScriptExecutionTools {
10
10
  private readonly options;
11
- constructor(options: JavascriptExecutionToolsOptions);
11
+ constructor(options?: JavascriptExecutionToolsOptions);
12
12
  /**
13
13
  * Executes a JavaScript
14
14
  */
@@ -1,20 +1,7 @@
1
- import { ScriptExecutionTools, ScriptExecutionToolsExecuteOptions } from '../../../ScriptExecutionTools';
2
- import { JavascriptExecutionToolsOptions } from './JavascriptExecutionToolsOptions';
1
+ import { JavascriptEvalExecutionTools } from './JavascriptEvalExecutionTools';
3
2
  /**
4
- * ScriptExecutionTools for JavaScript implemented via vm2
3
+ * Placeholder for better implementation of JavascriptExecutionTools - some propper sandboxing
5
4
  *
6
- * Warning: This is not implemented yet
7
- */
8
- export declare class JavascriptExecutionTools implements ScriptExecutionTools {
9
- private readonly options;
10
- constructor(options: JavascriptExecutionToolsOptions);
11
- /**
12
- * Executes a JavaScript
13
- */
14
- execute(options: ScriptExecutionToolsExecuteOptions): Promise<string>;
15
- }
16
- /**
17
- * TODO: !! Pass isVerbose to constructor and use it
18
- * TODO: !! Probbably make some common util createStatementToEvaluate
19
- * TODO: !! Implement via vm2
5
+ * @alias JavascriptExecutionTools
20
6
  */
7
+ export declare const JavascriptExecutionTools: typeof JavascriptEvalExecutionTools;
@@ -0,0 +1,18 @@
1
+ import type { Promisable } from 'type-fest';
2
+ type ForEachAsyncOptions = {
3
+ /**
4
+ * Maximum number of tasks running in parallel
5
+ *
6
+ * @default Infinity
7
+ */
8
+ inParallelCount?: number;
9
+ };
10
+ /**
11
+ * Async version of Array.forEach
12
+ *
13
+ * @param array - Array to iterate over
14
+ * @param options - Options for the function
15
+ * @param callbackfunction - Function to call for each item
16
+ */
17
+ export declare function forEachAsync<TItem>(array: Array<TItem>, options: ForEachAsyncOptions, callbackfunction: (value: TItem, index: number, array: Array<TItem>) => Promisable<void>): Promise<void>;
18
+ export {};
@@ -1,14 +1,46 @@
1
+ import { string_folder_path } from '../../types/typeAliases';
1
2
  import { PromptbookLibrary } from '../PromptbookLibrary';
3
+ /**
4
+ * Options for `createPromptbookLibraryFromDirectory` function
5
+ */
6
+ type CreatePromptbookLibraryFromDirectoryOptions = {
7
+ /**
8
+ * If true, the directory is searched recursively for promptbooks
9
+ *
10
+ * @default true
11
+ */
12
+ isRecursive?: boolean;
13
+ /**
14
+ * If true, the library creation outputs information about each file it reads
15
+ *
16
+ * @default false
17
+ */
18
+ isVerbose?: boolean;
19
+ /**
20
+ * If true, directory will be scanned only when needed not during the construction
21
+ *
22
+ * @default false
23
+ */
24
+ isLazyLoaded?: boolean;
25
+ };
2
26
  /**
3
27
  * Constructs Promptbook from given directory
4
28
  *
5
29
  * Note: Works only in Node.js environment because it reads the file system
6
- * Note: The function does NOT return promise it returns the library directly which dynamically loads promptbooks when needed
7
- * SO during the construction syntax and logic sources IS NOT validated
8
30
  *
31
+ * @param path - path to the directory with promptbooks
32
+ * @param options - Misc options for the library
9
33
  * @returns PromptbookLibrary
10
34
  */
11
- export declare function createPromptbookLibraryFromDirectory(): PromptbookLibrary;
35
+ export declare function createPromptbookLibraryFromDirectory(path: string_folder_path, options?: CreatePromptbookLibraryFromDirectoryOptions): Promise<PromptbookLibrary>;
36
+ export {};
12
37
  /***
13
- * TODO: [๐Ÿ“][๐Ÿšฏ] !!! Add to README and samples + maybe make `@promptbook/library` package
38
+ * TODO: [๐Ÿง ] Maybe do not do hacks like [1] and just create package @promptbook/node
39
+ * [๐Ÿ“][๐Ÿšฏ] maybe make `@promptbook/library` package
40
+ * TODO: Fix the dynamic import issue in Webpack (! Not working !)
41
+ * > ./node_modules/@promptbook/core/esm/index.es.js
42
+ * > Critical dependency: the request of a dependency is an expression
43
+ *
44
+ * Note: [1] Using require(just('fs/promises')) to allow
45
+ * the `@promptbook/core` work for both Node.js and browser environments
14
46
  */
@@ -14,11 +14,11 @@ import { PromptbookLibrary } from '../PromptbookLibrary';
14
14
  * Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
15
15
  * when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
16
16
  *
17
+ * Note: Consider using `createPromptbookLibraryFromDirectory` or `createPromptbookLibraryFromUrl`
17
18
  *
18
19
  * @param promptbookSourcesPromiseOrFactory
19
20
  * @returns PromptbookLibrary
20
- *
21
- * @deprecated Consider using `createPromptbookLibraryFromUrl` or `createPromptbookLibraryFromDirectory`
21
+ * @private Just internal tool for other constructor functions
22
22
  */
23
23
  export declare function createPromptbookLibraryFromPromise(promptbookSourcesPromiseOrFactory: Promise<Array<PromptbookJson | PromptbookString>> | (() => Promise<Array<PromptbookJson | PromptbookString>>)): PromptbookLibrary;
24
24
  /***
@@ -1,13 +1,29 @@
1
+ import { string_url } from '../../types/typeAliases';
1
2
  import { PromptbookLibrary } from '../PromptbookLibrary';
3
+ /**
4
+ * Options for `createPromptbookLibraryFromDirectory` function
5
+ */
6
+ type CreatePromptbookLibraryFromUrlyOptions = {
7
+ /**
8
+ * If true, the library creation outputs information about each file it reads
9
+ *
10
+ * @default false
11
+ */
12
+ isVerbose?: boolean;
13
+ /**
14
+ * If true, directory will be scanned only when needed not during the construction
15
+ *
16
+ * @default false
17
+ */
18
+ isLazyLoaded?: boolean;
19
+ };
2
20
  /**
3
21
  * Constructs Promptbook from remote Promptbase URL
4
- *
5
- * Note: The function does NOT return promise it returns the library directly which dynamically loads promptbooks when needed
6
- * SO during the construction syntax and logic sources IS NOT validated
7
- *
22
+
8
23
  * @returns PromptbookLibrary
9
24
  */
10
- export declare function createPromptbookLibraryFromUrl(): PromptbookLibrary;
25
+ export declare function createPromptbookLibraryFromUrl(url: string_url | URL, options: CreatePromptbookLibraryFromUrlyOptions): Promise<PromptbookLibrary>;
26
+ export {};
11
27
  /***
12
28
  * TODO: [๐Ÿ“][๐Ÿšฏ] !!! Add to README and samples + maybe make `@promptbook/library` package
13
29
  */
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Just testing imports and compatibility
3
+ */
4
+ export declare function justTestFsImport(): Promise<void>;
5
+ /**
6
+ * TODO: !!! Remove this file
7
+ */
@@ -39,7 +39,7 @@ export type Prompt = {
39
39
  /**
40
40
  * Unique identifier of the promptbook with specific template name as hash
41
41
  *
42
- * @example https://promptbook.webgpt.com/cs/write-website-content.ptbk.md@v2.4.15#keywords
42
+ * @example https://promptbook.webgpt.com/cs/write-website-content.ptbk.md#keywords
43
43
  */
44
44
  readonly promptbookUrl: string_promptbook_url_with_hashtemplate;
45
45
  /**
@@ -179,13 +179,13 @@ export type string_url = string;
179
179
  /**
180
180
  * Semantic helper
181
181
  *
182
- * For example `"https://promptbook.webgpt.com/cs/write-website-content.ptbk.md@v2.4.15"`
182
+ * For example `"https://promptbook.webgpt.com/cs/write-website-content.ptbk.md"`
183
183
  */
184
184
  export type string_promptbook_url = string;
185
185
  /**
186
186
  * Semantic helper
187
187
  *
188
- * For example `"https://promptbook.webgpt.com/cs/write-website-content.ptbk.md@v2.4.15#keywords"`
188
+ * For example `"https://promptbook.webgpt.com/cs/write-website-content.ptbk.md#keywords"`
189
189
  */
190
190
  export type string_promptbook_url_with_hashtemplate = string;
191
191
  /**
@@ -1,5 +0,0 @@
1
- import { Wizzard } from '../wizzard/Wizzard';
2
- export { Wizzard };
3
- /**
4
- * TODO: [๐Ÿง™โ€โ™‚๏ธ]
5
- */
@@ -1,4 +0,0 @@
1
- export declare const Wizzard: any;
2
- /**
3
- * TODO: [๐Ÿง™โ€โ™‚๏ธ]
4
- */
@@ -1,6 +0,0 @@
1
- export {};
2
- /**
3
- * TODO: [๐Ÿง™โ€โ™‚๏ธ]
4
- url, sources nebo folder
5
- * TODO: [๐Ÿง ] OpenAi apiKey vs token
6
- */
@@ -1,5 +0,0 @@
1
- import { Wizzard } from '../wizzard/Wizzard';
2
- export { Wizzard };
3
- /**
4
- * TODO: [๐Ÿง™โ€โ™‚๏ธ]
5
- */
@@ -1,4 +0,0 @@
1
- export declare const Wizzard: any;
2
- /**
3
- * TODO: [๐Ÿง™โ€โ™‚๏ธ]
4
- */
@@ -1,6 +0,0 @@
1
- export {};
2
- /**
3
- * TODO: [๐Ÿง™โ€โ™‚๏ธ]
4
- url, sources nebo folder
5
- * TODO: [๐Ÿง ] OpenAi apiKey vs token
6
- */