@promptbook/openai 0.81.0-8 → 0.82.0-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.
Files changed (110) hide show
  1. package/README.md +54 -7
  2. package/esm/index.es.js +12 -9
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/books/index.d.ts +38 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +12 -4
  6. package/esm/typings/src/_packages/markdown-utils.index.d.ts +2 -2
  7. package/esm/typings/src/_packages/node.index.d.ts +0 -2
  8. package/esm/typings/src/_packages/remote-client.index.d.ts +7 -3
  9. package/esm/typings/src/_packages/remote-server.index.d.ts +2 -2
  10. package/esm/typings/src/_packages/templates.index.d.ts +2 -2
  11. package/esm/typings/src/_packages/types.index.d.ts +34 -30
  12. package/esm/typings/src/_packages/utils.index.d.ts +2 -0
  13. package/esm/typings/src/_packages/wizzard.index.d.ts +44 -0
  14. package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
  15. package/esm/typings/src/cli/cli-commands/run.d.ts +2 -2
  16. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +11 -0
  17. package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
  18. package/esm/typings/src/commands/index.d.ts +1 -1
  19. package/esm/typings/src/config.d.ts +3 -3
  20. package/esm/typings/src/conversion/compilePipeline.d.ts +1 -4
  21. package/esm/typings/src/conversion/compilePipelineOnRemoteServer.d.ts +18 -0
  22. package/esm/typings/src/conversion/{precompilePipeline.d.ts → parsePipeline.d.ts} +3 -3
  23. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -3
  24. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +7 -7
  25. package/esm/typings/src/errors/utils/getErrorReportUrl.d.ts +1 -1
  26. package/esm/typings/src/execution/PipelineExecutor.d.ts +2 -2
  27. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -2
  28. package/esm/typings/src/formfactors/generator/GeneratorFormfactorDefinition.d.ts +9 -4
  29. package/esm/typings/src/formfactors/image-generator/ImageGeneratorFormfactorDefinition.d.ts +24 -0
  30. package/esm/typings/src/formfactors/index.d.ts +31 -9
  31. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +1 -1
  32. package/esm/typings/src/high-level-abstractions/index.d.ts +3 -3
  33. package/esm/typings/src/high-level-abstractions/quick-chatbot/QuickChatbotHla.d.ts +3 -0
  34. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
  35. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
  36. package/esm/typings/src/llm-providers/_common/register/{$provideLlmToolsForCli.d.ts → $provideLlmToolsForWizzardOrCli.d.ts} +2 -2
  37. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsFromEnv.d.ts +1 -1
  38. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +1 -1
  39. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  40. package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts +2 -2
  41. package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +2 -2
  42. package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -0
  43. package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +2 -0
  44. package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +1 -0
  45. package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -0
  46. package/esm/typings/src/llm-providers/google/register-configuration.d.ts +1 -0
  47. package/esm/typings/src/llm-providers/google/register-constructor.d.ts +1 -0
  48. package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +1 -1
  49. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +2 -0
  50. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +2 -0
  51. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
  52. package/esm/typings/src/llm-providers/vercel/playground/playground.d.ts +1 -1
  53. package/esm/typings/src/other/templates/getBookTemplates.d.ts +22 -0
  54. package/esm/typings/src/personas/preparePersona.d.ts +4 -4
  55. package/esm/typings/src/pipeline/PipelineString.d.ts +0 -3
  56. package/esm/typings/src/pipeline/book-notation.d.ts +14 -0
  57. package/esm/typings/src/pipeline/isValidPipelineString.d.ts +13 -0
  58. package/esm/typings/src/pipeline/isValidPipelineString.test.d.ts +4 -0
  59. package/esm/typings/src/pipeline/validatePipelineString.d.ts +14 -0
  60. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +3 -1
  61. package/esm/typings/src/prepare/preparePipeline.d.ts +4 -2
  62. package/esm/typings/src/prepare/preparePipelineOnRemoteServer.d.ts +14 -0
  63. package/esm/typings/src/prepare/prepareTasks.d.ts +1 -1
  64. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/PromptbookServer_Error.d.ts +1 -1
  65. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/PromptbookServer_ListModels_Request.d.ts +4 -4
  66. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/PromptbookServer_ListModels_Response.d.ts +1 -1
  67. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/PromptbookServer_Prompt_Progress.d.ts +1 -1
  68. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/PromptbookServer_Prompt_Request.d.ts +5 -5
  69. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/PromptbookServer_Prompt_Response.d.ts +1 -1
  70. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/RemoteLlmExecutionToolsOptions.d.ts +7 -7
  71. package/esm/typings/src/{llm-providers/remote → remote-server}/interfaces/RemoteServerOptions.d.ts +10 -10
  72. package/esm/typings/src/scrapers/_common/Converter.d.ts +1 -0
  73. package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -1
  74. package/esm/typings/src/scrapers/_common/ScraperIntermediateSource.d.ts +3 -0
  75. package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +2 -0
  76. package/esm/typings/src/scrapers/_common/utils/scraperFetch.d.ts +3 -0
  77. package/esm/typings/src/scrapers/document/register-constructor.d.ts +1 -0
  78. package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -0
  79. package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -0
  80. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -0
  81. package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -0
  82. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -0
  83. package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +1 -0
  84. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -1
  85. package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -0
  86. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +2 -1
  87. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +3 -1
  88. package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -0
  89. package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -0
  90. package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.test.d.ts +1 -1
  91. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +2 -1
  92. package/esm/typings/src/types/typeAliases.d.ts +16 -2
  93. package/esm/typings/src/utils/markdown/flattenMarkdown.d.ts +1 -1
  94. package/esm/typings/src/utils/markdown/{removeContentComments.d.ts → removeMarkdownComments.d.ts} +2 -2
  95. package/esm/typings/src/utils/organization/$sideEffect.d.ts +9 -0
  96. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +1 -1
  97. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +2 -2
  98. package/esm/typings/src/utils/validators/filePath/isRootPath.d.ts +12 -0
  99. package/esm/typings/src/utils/validators/filePath/isRootPath.test.d.ts +4 -0
  100. package/esm/typings/src/utils/validators/filePath/isValidFilePath.d.ts +3 -0
  101. package/esm/typings/src/wizzard/$getCompiledBook.d.ts +16 -0
  102. package/esm/typings/src/wizzard/wizzard.d.ts +52 -8
  103. package/package.json +2 -2
  104. package/umd/index.umd.js +12 -9
  105. package/umd/index.umd.js.map +1 -1
  106. package/esm/typings/src/other/templates/getBookTemplate.d.ts +0 -21
  107. package/esm/typings/src/scripting/javascript/utils/unknownToString.d.ts +0 -8
  108. /package/esm/typings/src/conversion/{precompilePipeline.test.d.ts → parsePipeline.test.d.ts} +0 -0
  109. /package/esm/typings/src/{llm-providers/remote → remote-server}/startRemoteServer.d.ts +0 -0
  110. /package/esm/typings/src/utils/markdown/{removeContentComments.test.d.ts → removeMarkdownComments.test.d.ts} +0 -0
@@ -1,10 +1,10 @@
1
1
  import type { Promisable } from 'type-fest';
2
- import type { PipelineCollection } from '../../../collection/PipelineCollection';
3
- import type { CommonToolsOptions } from '../../../execution/CommonToolsOptions';
4
- import type { LlmExecutionTools } from '../../../execution/LlmExecutionTools';
5
- import type { string_app_id } from '../../../types/typeAliases';
6
- import type { string_uri } from '../../../types/typeAliases';
7
- import type { string_user_id } from '../../../types/typeAliases';
2
+ import type { PipelineCollection } from '../../collection/PipelineCollection';
3
+ import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
4
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
5
+ import type { string_app_id } from '../../types/typeAliases';
6
+ import type { string_uri } from '../../types/typeAliases';
7
+ import type { string_user_id } from '../../types/typeAliases';
8
8
  /**
9
9
  * @@@
10
10
  *
@@ -31,14 +31,14 @@ export type RemoteServerOptions<TCustomOptions> = CommonToolsOptions & {
31
31
  * @example '/promptbook/socket.io'
32
32
  */
33
33
  readonly path: string_uri;
34
- } & (AnonymousRemoteServerOptions | CollectionRemoteServerOptions<TCustomOptions> | (AnonymousRemoteServerOptions & CollectionRemoteServerOptions<TCustomOptions>));
34
+ } & (AnonymousRemoteServerOptions | ApplicationRemoteServerOptions<TCustomOptions> | (AnonymousRemoteServerOptions & ApplicationRemoteServerOptions<TCustomOptions>));
35
35
  export type AnonymousRemoteServerOptions = {
36
36
  /**
37
37
  * Enable anonymous mode
38
38
  */
39
39
  readonly isAnonymousModeAllowed: true;
40
40
  };
41
- export type CollectionRemoteServerOptions<TCustomOptions> = {
41
+ export type ApplicationRemoteServerOptions<TCustomOptions> = {
42
42
  /**
43
43
  * Enable application mode
44
44
  */
@@ -52,9 +52,9 @@ export type CollectionRemoteServerOptions<TCustomOptions> = {
52
52
  /**
53
53
  * Creates llm execution tools for each client
54
54
  */
55
- createLlmExecutionTools(options: CollectionRemoteServerClientOptions<TCustomOptions>): Promisable<LlmExecutionTools>;
55
+ createLlmExecutionTools(options: ApplicationRemoteServerClientOptions<TCustomOptions>): Promisable<LlmExecutionTools>;
56
56
  };
57
- export type CollectionRemoteServerClientOptions<TCustomOptions> = {
57
+ export type ApplicationRemoteServerClientOptions<TCustomOptions> = {
58
58
  /**
59
59
  * @@@
60
60
  */
@@ -4,6 +4,7 @@ import type { ScraperIntermediateSource } from './ScraperIntermediateSource';
4
4
  /**
5
5
  * @@@
6
6
  *
7
+ * Note: [🌏] Converters are not usable in browser because they produce a files
7
8
  */
8
9
  export type Converter = {
9
10
  /**
@@ -7,7 +7,6 @@ import type { string_url } from '../../types/typeAliases';
7
7
  import type { ScraperAndConverterMetadata } from './register/ScraperAndConverterMetadata';
8
8
  /**
9
9
  * @@@
10
- *
11
10
  */
12
11
  export type Scraper = {
13
12
  /**
@@ -53,6 +52,7 @@ export type ScraperSourceHandler = {
53
52
  asText(): Promisable<string>;
54
53
  };
55
54
  /**
55
+ * TODO: [🧠] Maybe split `ScraperSourceHandler` into `ScraperWebsiteSourceHandler` + `ScraperFileSourceHandler`
56
56
  * TODO: [🥽] Add ` asBlob(): Promisable<Blob>;` or asFile
57
57
  * TODO: [🐝] @@@ Annotate all
58
58
  * TODO: [🔼] Export via types
@@ -9,3 +9,6 @@ export type ScraperIntermediateSource = IDestroyable & {
9
9
  */
10
10
  readonly filename: string_absolute_filename;
11
11
  };
12
+ /**
13
+ * Note: [🌏] Converters can be used only in node because they uses `ScraperIntermediateSource` which uses file system
14
+ */
@@ -28,6 +28,8 @@ export type ScraperAndConverterMetadata = Registered & {
28
28
  readonly mimeTypes: ReadonlyArray<string_mime_type>;
29
29
  /**
30
30
  * @@@
31
+ *
32
+ * Note: [🌏] Only `MarkdownScraper` makes sense to be available in the browser, for scraping non-markdown sources in the browser use a remote server
31
33
  */
32
34
  readonly isAvilableInBrowser: boolean;
33
35
  /**
@@ -5,3 +5,6 @@ import type { PromptbookFetch } from '../../../execution/PromptbookFetch';
5
5
  * @private as default `fetch` function used in Promptbook scrapers
6
6
  */
7
7
  export declare const scraperFetch: PromptbookFetch;
8
+ /**
9
+ * TODO: [🧠] Maybe rename because it is not used only for scrapers but also in `$getCompiledBook`
10
+ */
@@ -5,6 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
6
6
  *
7
7
  * @public exported from `@promptbook/documents`
8
+ * @public exported from `@promptbook/wizzard`
8
9
  * @public exported from `@promptbook/cli`
9
10
  */
10
11
  export declare const _DocumentScraperRegistration: Registration;
@@ -19,6 +19,7 @@ export declare const documentScraperMetadata: import("type-fest/source/readonly-
19
19
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
20
20
  *
21
21
  * @public exported from `@promptbook/core`
22
+ * @public exported from `@promptbook/wizzard`
22
23
  * @public exported from `@promptbook/cli`
23
24
  */
24
25
  export declare const _DocumentScraperMetadataRegistration: Registration;
@@ -5,6 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
6
6
  *
7
7
  * @public exported from `@promptbook/legacy-documents`
8
+ * @public exported from `@promptbook/wizzard`
8
9
  * @public exported from `@promptbook/cli`
9
10
  */
10
11
  export declare const _LegacyDocumentScraperRegistration: Registration;
@@ -19,6 +19,7 @@ export declare const legacyDocumentScraperMetadata: import("type-fest/source/rea
19
19
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
20
20
  *
21
21
  * @public exported from `@promptbook/core`
22
+ * @public exported from `@promptbook/wizzard`
22
23
  * @public exported from `@promptbook/cli`
23
24
  */
24
25
  export declare const _LegacyDocumentScraperMetadataRegistration: Registration;
@@ -5,6 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
6
6
  *
7
7
  * @public exported from `@promptbook/markdown-utils`
8
+ * @public exported from `@promptbook/wizzard`
8
9
  * @public exported from `@promptbook/cli`
9
10
  */
10
11
  export declare const _MarkdownScraperRegistration: Registration;
@@ -19,6 +19,7 @@ export declare const markdownScraperMetadata: import("type-fest/source/readonly-
19
19
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
20
20
  *
21
21
  * @public exported from `@promptbook/core`
22
+ * @public exported from `@promptbook/wizzard`
22
23
  * @public exported from `@promptbook/cli`
23
24
  */
24
25
  export declare const _MarkdownScraperMetadataRegistration: Registration;
@@ -37,4 +37,5 @@ export declare class PdfScraper implements Converter, Scraper {
37
37
  * TODO: [👣] Converted pdf documents can act as cached items - there is no need to run conversion each time
38
38
  * TODO: [🪂] Do it in parallel 11:11
39
39
  * Note: No need to aggregate usage here, it is done by intercepting the llmTools
40
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
40
41
  */
@@ -12,7 +12,7 @@ export declare const createPdfScraper: ((tools: Pick<ExecutionTools, 'llm'>, opt
12
12
  className: string;
13
13
  mimeTypes: string[];
14
14
  documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@";
15
- isAvilableInBrowser: true;
15
+ isAvilableInBrowser: false;
16
16
  requiredExecutables: never[];
17
17
  }>;
18
18
  /**
@@ -5,6 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
6
6
  *
7
7
  * @public exported from `@promptbook/pdf`
8
+ * @public exported from `@promptbook/wizzard`
8
9
  * @public exported from `@promptbook/cli`
9
10
  */
10
11
  export declare const _PdfScraperRegistration: Registration;
@@ -10,7 +10,7 @@ export declare const pdfScraperMetadata: import("type-fest/source/readonly-deep"
10
10
  className: string;
11
11
  mimeTypes: string[];
12
12
  documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@";
13
- isAvilableInBrowser: true;
13
+ isAvilableInBrowser: false;
14
14
  requiredExecutables: never[];
15
15
  }>;
16
16
  /**
@@ -19,6 +19,7 @@ export declare const pdfScraperMetadata: import("type-fest/source/readonly-deep"
19
19
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
20
20
  *
21
21
  * @public exported from `@promptbook/core`
22
+ * @public exported from `@promptbook/wizzard`
22
23
  * @public exported from `@promptbook/cli`
23
24
  */
24
25
  export declare const _PdfScraperMetadataRegistration: Registration;
@@ -12,7 +12,9 @@ export declare const createWebsiteScraper: ((tools: Pick<ExecutionTools, 'llm'>,
12
12
  className: string;
13
13
  mimeTypes: string[];
14
14
  documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@";
15
- isAvilableInBrowser: false;
15
+ isAvilableInBrowser: false; /**
16
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
17
+ */
16
18
  requiredExecutables: never[];
17
19
  }>;
18
20
  /**
@@ -5,6 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
6
6
  *
7
7
  * @public exported from `@promptbook/website-crawler`
8
+ * @public exported from `@promptbook/wizzard`
8
9
  * @public exported from `@promptbook/cli`
9
10
  */
10
11
  export declare const _WebsiteScraperRegistration: Registration;
@@ -19,6 +19,7 @@ export declare const websiteScraperMetadata: import("type-fest/source/readonly-d
19
19
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
20
20
  *
21
21
  * @public exported from `@promptbook/core`
22
+ * @public exported from `@promptbook/wizzard`
22
23
  * @public exported from `@promptbook/cli`
23
24
  */
24
25
  export declare const _WebsiteScraperMetadataRegistration: Registration;
@@ -1,4 +1,4 @@
1
1
  export {};
2
2
  /**
3
- * TODO: !! Make shared test between JavascriptEvalExecutionTools and JavascriptExecutionTools to test the same functionality when implemented via vm2
3
+ * TODO: Make shared test between JavascriptEvalExecutionTools and JavascriptExecutionTools to test the same functionality when implemented via vm2
4
4
  */
@@ -9,5 +9,6 @@ import type { really_any } from '../../../utils/organization/really_any';
9
9
  */
10
10
  export declare function preserve(func: (...params: ReadonlyArray<really_any>) => unknown): void;
11
11
  /**
12
- * TODO: !! [1] This maybe does memory leak
12
+ * TODO: Probbably remove in favour of `keepImported`
13
+ * TODO: [1] This maybe does memory leak
13
14
  */
@@ -1,5 +1,6 @@
1
1
  import type { TupleToUnion } from 'type-fest';
2
2
  import { RESERVED_PARAMETER_NAMES } from '../constants';
3
+ import type { really_unknown } from '../utils/organization/really_unknown';
3
4
  /**
4
5
  * Semantic helper
5
6
  */
@@ -107,6 +108,13 @@ export type string_parameter_value = string;
107
108
  * @see https://ptbk.io/parameters
108
109
  */
109
110
  export type Parameters = Exclude<Record<string_parameter_name, string_parameter_value>, ReservedParameters>;
111
+ /**
112
+ * Parameters to pass to execution of the pipeline
113
+ *
114
+ * Note: [🚉] This should be fully serializable as JSON
115
+ * @see https://ptbk.io/parameters
116
+ */
117
+ export type InputParameters = Exclude<Record<string_parameter_name, really_unknown>, ReservedParameters>;
110
118
  /**
111
119
  * Semantic helper
112
120
  * Unique identifier of reserved parameter
@@ -311,6 +319,12 @@ export type string_url = string;
311
319
  * For example `"https://collboard.com"`
312
320
  */
313
321
  export type string_base_url = string;
322
+ /**
323
+ * Semantic helper
324
+ *
325
+ * For example `"https://promptbook.studio/webgpt/"`
326
+ */
327
+ export type string_pipeline_root_url = string;
314
328
  /**
315
329
  * Semantic helper
316
330
  *
@@ -615,8 +629,8 @@ export type number_megabytes = number_positive;
615
629
  export type number_gigabytes = number_positive;
616
630
  export type number_terabytes = number_positive;
617
631
  /**.
618
- * TODO: [main] !!! Change "For example" to @example
619
- * TODO: !! Change to branded types
632
+ * TODO: [main] !!3 Change "For example" to @example
633
+ * TODO: Change to branded types
620
634
  * TODO: Delete type aliases that are not exported or used internally
621
635
  * Note: [💞] Ignore a discrepancy between file name and entity name
622
636
  */
@@ -2,7 +2,7 @@ import type { string_markdown } from '../../types/typeAliases';
2
2
  /**
3
3
  * Normalizes the markdown by flattening the structure
4
4
  *
5
- * - It always have h1 - if there is no h1 in the markdown, it will be added "# Untitled"
5
+ * - It always have h1 - if there is no h1 in the markdown, it will be added `DEFAULT_BOOK_TITLE`
6
6
  * - All other headings are normalized to h2
7
7
  *
8
8
  * @public exported from `@promptbook/markdown-utils`
@@ -1,10 +1,10 @@
1
1
  import type { string_html } from '../../types/typeAliases';
2
2
  import type { string_markdown } from '../../types/typeAliases';
3
3
  /**
4
- * Removes HTML or Markdown comments from a string.
4
+ * Removes Markdown (or HTML) comments
5
5
  *
6
6
  * @param {string} content - The string to remove comments from.
7
7
  * @returns {string} The input string with all comments removed.
8
8
  * @public exported from `@promptbook/markdown-utils`
9
9
  */
10
- export declare function removeContentComments<TContent extends string_html | string_markdown>(content: TContent): TContent;
10
+ export declare function removeMarkdownComments<TContent extends string_html | string_markdown>(content: TContent): TContent;
@@ -0,0 +1,9 @@
1
+ import type { really_any } from './really_any';
2
+ /**
3
+ * Just says that the variable is not used directlys but should be kept because the existence of the variable is important
4
+ *
5
+ * @param value any values
6
+ * @returns void
7
+ * @private within the repository
8
+ */
9
+ export declare function $sideEffect(...sideEffectSubjects: ReadonlyArray<really_any>): void;
@@ -40,6 +40,6 @@ export type CheckSerializableAsJsonOptions = {
40
40
  export declare function checkSerializableAsJson(options: CheckSerializableAsJsonOptions): void;
41
41
  /**
42
42
  * TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
43
- * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
43
+ * TODO: [🧠][main] !!3 In-memory cache of same values to prevent multiple checks
44
44
  * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
45
45
  */
@@ -1,4 +1,4 @@
1
- import { JsonValue } from 'type-fest';
1
+ import type { JsonValue } from 'type-fest';
2
2
  /**
3
3
  * Tests if the value is [🚉] serializable as JSON
4
4
  *
@@ -20,6 +20,6 @@ import { JsonValue } from 'type-fest';
20
20
  */
21
21
  export declare function isSerializableAsJson(value: unknown): value is JsonValue;
22
22
  /**
23
- * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
23
+ * TODO: [🧠][main] !!3 In-memory cache of same values to prevent multiple checks
24
24
  * TODO: [🧠][💺] Can be done this on type-level?
25
25
  */
@@ -0,0 +1,12 @@
1
+ import type { string_dirname } from '../../../types/typeAliases';
2
+ import type { string_filename } from '../../../types/typeAliases';
3
+ /**
4
+ * Determines if the given path is a root path.
5
+ *
6
+ * Note: This does not check if the file exists only if the path is valid
7
+ * @public exported from `@promptbook/utils`
8
+ */
9
+ export declare function isRootPath(value: string_dirname | string_filename): boolean;
10
+ /**
11
+ * TODO: [🍏] Make for MacOS paths
12
+ */
@@ -0,0 +1,4 @@
1
+ export {};
2
+ /**
3
+ * TODO: [🍏] Make for MacOS paths
4
+ */
@@ -7,3 +7,6 @@ import type { really_unknown } from '../../organization/really_unknown';
7
7
  * @public exported from `@promptbook/utils`
8
8
  */
9
9
  export declare function isValidFilePath(filename: really_unknown): filename is string_filename;
10
+ /**
11
+ * TODO: [🍏] Implement for MacOs
12
+ */
@@ -0,0 +1,16 @@
1
+ import type { ExecutionTools } from '../execution/ExecutionTools';
2
+ import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
3
+ import type { PipelineString } from '../pipeline/PipelineString';
4
+ import type { PrepareAndScrapeOptions } from '../prepare/PrepareAndScrapeOptions';
5
+ import type { string_filename } from '../types/typeAliases';
6
+ import type { string_pipeline_url } from '../types/typeAliases';
7
+ /**
8
+ * @see ./wizzard.ts `getPipeline` method
9
+ *
10
+ * @private usable through `ptbk run` and `@prompbook/wizzard`
11
+ */
12
+ export declare function $getCompiledBook(tools: Required<Pick<ExecutionTools, 'fs' | 'fetch'>>, pipelineSource: string_filename | string_pipeline_url | PipelineString, options?: PrepareAndScrapeOptions): Promise<PipelineJson>;
13
+ /**
14
+ * TODO: Write unit test
15
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
16
+ */
@@ -1,19 +1,63 @@
1
1
  import { Promisable } from 'type-fest';
2
+ import type { ExecutionTools } from '../execution/ExecutionTools';
2
3
  import type { PipelineExecutorResult } from '../execution/PipelineExecutorResult';
4
+ import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
5
+ import type { PipelineString } from '../pipeline/PipelineString';
3
6
  import type { TaskProgress } from '../types/TaskProgress';
4
- import type { Parameters } from '../types/typeAliases';
7
+ import type { InputParameters } from '../types/typeAliases';
8
+ import type { string_filename } from '../types/typeAliases';
5
9
  import type { string_pipeline_url } from '../types/typeAliases';
6
10
  /**
7
- * @@@
11
+ * Wizzard for simple usage of the Promptbook
12
+ * Look at `wizzard` for more details
8
13
  *
9
- * @public exported from `@promptbook/node`
14
+ * Note: This works only in Node.js environment and looks for the configuration, environment, tools and cache in the Node.js environment
15
+ *
16
+ * @private just for single instance
10
17
  */
11
- export declare const wizzard: {
18
+ declare class Wizzard {
19
+ /**
20
+ * Run the book
21
+ *
22
+ * It can be loaded from:
23
+ * 1) As a file ./books/write-cv.book.md
24
+ * 2) As a URL https://promptbook.studio/hejny/write-cv.book.md found in ./books folder recursively
25
+ * 2) As a URL https://promptbook.studio/hejny/write-cv.book.md fetched from the internet
26
+ * 3) As a string
27
+ *
28
+ * Note: This works simmilar to the `ptbk run` command
29
+ */
30
+ execute(book: string_pipeline_url | string_filename | PipelineString, inputParameters: InputParameters, onProgress?: (taskProgress: TaskProgress) => Promisable<void>): Promise<PipelineExecutorResult>;
31
+ private executionTools;
32
+ /**
33
+ * Provides the tools automatically for the Node.js environment
34
+ *
35
+ * @param pipelineSource
36
+ */
37
+ getExecutionTools(): Promise<Required<Pick<ExecutionTools, 'fs' | 'fetch'>>>;
12
38
  /**
13
- * @@@!!!!!!
39
+ * Load book from the source
40
+ *
41
+ * Pipelines can be loaded from:
42
+ * 1) As a file ./books/write-cv.book.md
43
+ * 2) As a URL https://promptbook.studio/hejny/write-cv.book.md found in ./books folder recursively
44
+ * 2) As a URL https://promptbook.studio/hejny/write-cv.book.md fetched from the internet
45
+ * 3) As a string
46
+ *
47
+ * @param pipelineSource
14
48
  */
15
- run(book: string_pipeline_url, inputParameters: Parameters, onProgress?: ((taskProgress: TaskProgress) => Promisable<void>) | undefined): Promise<PipelineExecutorResult>;
16
- };
49
+ getCompiledBook(pipelineSource: string_filename | string_pipeline_url | PipelineString): Promise<PipelineJson>;
50
+ }
51
+ /**
52
+ * Wizzard for simple usage of the Promptbook
53
+ *
54
+ * Note: This works only in Node.js environment and looks for the configuration, environment, tools and cache in the Node.js environment
55
+ *
56
+ * @singleton
57
+ * @public exported from `@promptbook/wizzard`
58
+ */
59
+ export declare const wizzard: Wizzard;
60
+ export {};
17
61
  /**
18
- * TODO: !!!!!! Add to readmes - one markdown here imported in all packages
62
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
19
63
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/openai",
3
- "version": "0.81.0-8",
3
+ "version": "0.82.0-0",
4
4
  "description": "It's time for a paradigm shift. The future of software in plain English, French or Latin",
5
5
  "--note-0": " <- [🐊]",
6
6
  "private": false,
@@ -54,7 +54,7 @@
54
54
  "module": "./esm/index.es.js",
55
55
  "typings": "./esm/typings/src/_packages/openai.index.d.ts",
56
56
  "peerDependencies": {
57
- "@promptbook/core": "0.81.0-8"
57
+ "@promptbook/core": "0.82.0-0"
58
58
  },
59
59
  "dependencies": {
60
60
  "colors": "1.4.0",
package/umd/index.umd.js CHANGED
@@ -24,7 +24,7 @@
24
24
  * @generated
25
25
  * @see https://github.com/webgptorg/promptbook
26
26
  */
27
- var PROMPTBOOK_ENGINE_VERSION = '0.81.0-7';
27
+ var PROMPTBOOK_ENGINE_VERSION = '0.81.0-23';
28
28
  /**
29
29
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
30
30
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -384,7 +384,7 @@
384
384
  /**
385
385
  * Make error report URL for the given error
386
386
  *
387
- * @private !!!!!!
387
+ * @private private within the repository
388
388
  */
389
389
  function getErrorReportUrl(error) {
390
390
  var report = {
@@ -505,7 +505,7 @@
505
505
  if (!(error instanceof Error)) {
506
506
  throw error;
507
507
  }
508
- throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.toString()), "\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
508
+ throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.stack || error.message), "\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
509
509
  }
510
510
  /*
511
511
  TODO: [0] Is there some more elegant way to check circular references?
@@ -535,7 +535,7 @@
535
535
  }
536
536
  /**
537
537
  * TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
538
- * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
538
+ * TODO: [🧠][main] !!3 In-memory cache of same values to prevent multiple checks
539
539
  * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
540
540
  */
541
541
 
@@ -547,7 +547,6 @@
547
547
  function deepClone(objectValue) {
548
548
  return JSON.parse(JSON.stringify(objectValue));
549
549
  /*
550
- !!!!!!!!
551
550
  TODO: [🧠] Is there a better implementation?
552
551
  > const propertyNames = Object.getOwnPropertyNames(objectValue);
553
552
  > for (const propertyName of propertyNames) {
@@ -786,6 +785,8 @@
786
785
  throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
787
786
  }
788
787
  parameterValue = valueToString(parameterValue);
788
+ // Escape curly braces in parameter values to prevent prompt-injection
789
+ parameterValue = parameterValue.replace(/[{}]/g, '\\$&');
789
790
  if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
790
791
  parameterValue = parameterValue
791
792
  .split('\n')
@@ -1525,7 +1526,7 @@
1525
1526
  prompt: computeUsage("$5.00 / 1M tokens"),
1526
1527
  output: computeUsage("$15.00 / 1M tokens"),
1527
1528
  },
1528
- //TODO: [main] !!! Add gpt-4o-mini-2024-07-18 and all others to be up to date
1529
+ //TODO: [main] !!3 Add gpt-4o-mini-2024-07-18 and all others to be up to date
1529
1530
  },
1530
1531
  /**/
1531
1532
  /**/
@@ -2114,7 +2115,7 @@
2114
2115
  assistant_id: this.assistantId,
2115
2116
  thread: {
2116
2117
  messages: [
2117
- // TODO: [🗯] !! Allow threads to be passed
2118
+ // TODO: [🗯] Allow threads to be passed
2118
2119
  { role: 'user', content: rawPromptContent },
2119
2120
  ],
2120
2121
  },
@@ -2217,7 +2218,7 @@
2217
2218
  * @public exported from `@promptbook/openai`
2218
2219
  */
2219
2220
  var createOpenAiAssistantExecutionTools = Object.assign(function (options) {
2220
- // TODO: [🧠][main] !!!! If browser, auto add `dangerouslyAllowBrowser`
2221
+ // TODO: [🧠][main] !!4 If browser, auto add `dangerouslyAllowBrowser`
2221
2222
  if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
2222
2223
  options = __assign(__assign({}, options), { dangerouslyAllowBrowser: true });
2223
2224
  }
@@ -2237,7 +2238,7 @@
2237
2238
  * @public exported from `@promptbook/openai`
2238
2239
  */
2239
2240
  var createOpenAiExecutionTools = Object.assign(function (options) {
2240
- // TODO: [🧠][main] !!!! If browser, auto add `dangerouslyAllowBrowser`
2241
+ // TODO: [🧠][main] !!4 If browser, auto add `dangerouslyAllowBrowser`
2241
2242
  if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
2242
2243
  options = __assign(__assign({}, options), { dangerouslyAllowBrowser: true });
2243
2244
  }
@@ -2408,6 +2409,7 @@
2408
2409
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
2409
2410
  *
2410
2411
  * @public exported from `@promptbook/openai`
2412
+ * @public exported from `@promptbook/wizzard`
2411
2413
  * @public exported from `@promptbook/cli`
2412
2414
  */
2413
2415
  var _OpenAiRegistration = $llmToolsRegister.register(createOpenAiExecutionTools);
@@ -2417,6 +2419,7 @@
2417
2419
  * Note: [🏐] Configurations registrations are done in @@@ BUT constructor @@@
2418
2420
  *
2419
2421
  * @public exported from `@promptbook/openai`
2422
+ * @public exported from `@promptbook/wizzard`
2420
2423
  * @public exported from `@promptbook/cli`
2421
2424
  */
2422
2425
  var _OpenAiAssistantRegistration = $llmToolsRegister.register(createOpenAiAssistantExecutionTools);