@promptbook/vercel 0.103.0-32 → 0.103.0-34

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 (23) hide show
  1. package/esm/index.es.js +1 -1
  2. package/esm/typings/src/_packages/cli.index.d.ts +0 -2
  3. package/esm/typings/src/_packages/core.index.d.ts +2 -0
  4. package/esm/typings/src/_packages/types.index.d.ts +2 -2
  5. package/esm/typings/src/_packages/wizard.index.d.ts +0 -2
  6. package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +1 -1
  7. package/esm/typings/src/execution/ExecutionTask.d.ts +12 -3
  8. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +5 -0
  9. package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +5 -0
  10. package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +5 -0
  11. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -0
  12. package/esm/typings/src/execution/utils/logLlmCall.d.ts +8 -0
  13. package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +26 -17
  14. package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +2 -3
  15. package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +2 -2
  16. package/esm/typings/src/transpilers/openai/OpenAiSdkTranspiler.d.ts +9 -9
  17. package/esm/typings/src/types/LlmCall.d.ts +20 -0
  18. package/esm/typings/src/version.d.ts +1 -1
  19. package/package.json +2 -2
  20. package/umd/index.umd.js +1 -1
  21. package/esm/typings/src/transpilers/_common/BookTranspilerDefinition.d.ts +0 -37
  22. package/esm/typings/src/transpilers/langchain/LangchainTranspiler.d.ts +0 -7
  23. package/esm/typings/src/transpilers/langchain/register.d.ts +0 -15
package/esm/index.es.js CHANGED
@@ -16,7 +16,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
16
16
  * @generated
17
17
  * @see https://github.com/webgptorg/promptbook
18
18
  */
19
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-32';
19
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-34';
20
20
  /**
21
21
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
22
22
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -30,7 +30,6 @@ import { _PdfScraperRegistration } from '../scrapers/pdf/register-constructor';
30
30
  import { _PdfScraperMetadataRegistration } from '../scrapers/pdf/register-metadata';
31
31
  import { _WebsiteScraperRegistration } from '../scrapers/website/register-constructor';
32
32
  import { _WebsiteScraperMetadataRegistration } from '../scrapers/website/register-metadata';
33
- import { _LangchainTranspilerRegistration } from '../transpilers/langchain/register';
34
33
  import { _OpenAiSdkTranspilerRegistration } from '../transpilers/openai/register';
35
34
  export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
36
35
  export { _CLI };
@@ -64,5 +63,4 @@ export { _PdfScraperRegistration };
64
63
  export { _PdfScraperMetadataRegistration };
65
64
  export { _WebsiteScraperRegistration };
66
65
  export { _WebsiteScraperMetadataRegistration };
67
- export { _LangchainTranspilerRegistration };
68
66
  export { _OpenAiSdkTranspilerRegistration };
@@ -172,6 +172,7 @@ import { BlackholeStorage } from '../storage/blackhole/BlackholeStorage';
172
172
  import { MemoryStorage } from '../storage/memory/MemoryStorage';
173
173
  import { PrefixStorage } from '../storage/utils/PrefixStorage';
174
174
  import { $bookTranspilersRegister } from '../transpilers/_common/register/$bookTranspilersRegister';
175
+ import { OpenAiSdkTranspiler } from '../transpilers/openai/OpenAiSdkTranspiler';
175
176
  import { MODEL_VARIANTS } from '../types/ModelVariant';
176
177
  import { NonTaskSectionTypes } from '../types/SectionType';
177
178
  import { SectionTypes } from '../types/SectionType';
@@ -352,6 +353,7 @@ export { BlackholeStorage };
352
353
  export { MemoryStorage };
353
354
  export { PrefixStorage };
354
355
  export { $bookTranspilersRegister };
356
+ export { OpenAiSdkTranspiler };
355
357
  export { MODEL_VARIANTS };
356
358
  export { NonTaskSectionTypes };
357
359
  export { SectionTypes };
@@ -168,9 +168,9 @@ import type { PromptbookStorage } from '../storage/_common/PromptbookStorage';
168
168
  import type { FileCacheStorageOptions } from '../storage/file-cache-storage/FileCacheStorageOptions';
169
169
  import type { IndexedDbStorageOptions } from '../storage/local-storage/utils/IndexedDbStorageOptions';
170
170
  import type { BookTranspiler } from '../transpilers/_common/BookTranspiler';
171
- import type { BookTranspilerDefinition } from '../transpilers/_common/BookTranspilerDefinition';
172
171
  import type { BookTranspilerOptions } from '../transpilers/_common/BookTranspilerOptions';
173
172
  import type { IntermediateFilesStrategy } from '../types/IntermediateFilesStrategy';
173
+ import type { LlmCall } from '../types/LlmCall';
174
174
  import type { ModelRequirements } from '../types/ModelRequirements';
175
175
  import type { CompletionModelRequirements } from '../types/ModelRequirements';
176
176
  import type { ChatModelRequirements } from '../types/ModelRequirements';
@@ -506,9 +506,9 @@ export type { PromptbookStorage };
506
506
  export type { FileCacheStorageOptions };
507
507
  export type { IndexedDbStorageOptions };
508
508
  export type { BookTranspiler };
509
- export type { BookTranspilerDefinition };
510
509
  export type { BookTranspilerOptions };
511
510
  export type { IntermediateFilesStrategy };
511
+ export type { LlmCall };
512
512
  export type { ModelRequirements };
513
513
  export type { CompletionModelRequirements };
514
514
  export type { ChatModelRequirements };
@@ -29,7 +29,6 @@ import { _PdfScraperRegistration } from '../scrapers/pdf/register-constructor';
29
29
  import { _PdfScraperMetadataRegistration } from '../scrapers/pdf/register-metadata';
30
30
  import { _WebsiteScraperRegistration } from '../scrapers/website/register-constructor';
31
31
  import { _WebsiteScraperMetadataRegistration } from '../scrapers/website/register-metadata';
32
- import { _LangchainTranspilerRegistration } from '../transpilers/langchain/register';
33
32
  import { _OpenAiSdkTranspilerRegistration } from '../transpilers/openai/register';
34
33
  import { wizard } from '../wizard/wizard';
35
34
  export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
@@ -63,6 +62,5 @@ export { _PdfScraperRegistration };
63
62
  export { _PdfScraperMetadataRegistration };
64
63
  export { _WebsiteScraperRegistration };
65
64
  export { _WebsiteScraperMetadataRegistration };
66
- export { _LangchainTranspilerRegistration };
67
65
  export { _OpenAiSdkTranspilerRegistration };
68
66
  export { wizard };
@@ -4,7 +4,7 @@ import { string_book } from './string_book';
4
4
  *
5
5
  * @public exported from `@promptbook/core`
6
6
  */
7
- export declare const PADDING_LINES = 4;
7
+ export declare const PADDING_LINES = 11;
8
8
  /**
9
9
  * A function that adds padding to the book content
10
10
  *
@@ -1,8 +1,9 @@
1
1
  import type { Observable } from 'rxjs';
2
2
  import { PartialDeep } from 'type-fest';
3
- import type { number_percent } from '../types/typeAliases';
4
- import type { task_id } from '../types/typeAliases';
3
+ import type { LlmCall } from '../types/LlmCall';
4
+ import type { number_percent, task_id } from '../types/typeAliases';
5
5
  import type { string_SCREAMING_CASE } from '../utils/normalization/normalizeTo_SCREAMING_CASE';
6
+ import type { really_any } from '../utils/organization/really_any';
6
7
  import type { string_promptbook_version } from '../version';
7
8
  import type { AbstractTaskResult } from './AbstractTaskResult';
8
9
  import type { PipelineExecutorResult } from './PipelineExecutorResult';
@@ -32,7 +33,7 @@ type CreateTaskOptions<TTaskResult extends AbstractTaskResult> = {
32
33
  }) => void, updateTldr: (tldrInfo: {
33
34
  readonly percent: number_percent;
34
35
  readonly message: string;
35
- }) => void): Promise<TTaskResult>;
36
+ }) => void, logLlmCall: (llmCall: LlmCall) => void): Promise<TTaskResult>;
36
37
  };
37
38
  /**
38
39
  * Helper to create a new task
@@ -136,6 +137,14 @@ export type AbstractTask<TTaskResult extends AbstractTaskResult> = {
136
137
  * List of warnings that occurred during the task processing
137
138
  */
138
139
  readonly warnings: Array<Error>;
140
+ /**
141
+ * List of LLM calls that occurred during the task processing
142
+ */
143
+ readonly llmCalls: Array<LlmCall>;
144
+ /**
145
+ * Optional nonce to correlate logs with version of the Promptbook engine
146
+ */
147
+ readonly ptbkNonce?: really_any;
139
148
  };
140
149
  export type Task = ExecutionTask | PreparationTask;
141
150
  export {};
@@ -2,6 +2,7 @@ import type { PartialDeep, Promisable, ReadonlyDeep } from 'type-fest';
2
2
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
3
3
  import type { InputParameters } from '../../types/typeAliases';
4
4
  import type { PipelineExecutorResult } from '../PipelineExecutorResult';
5
+ import type { LlmCall } from '../../types/LlmCall';
5
6
  import type { CreatePipelineExecutorOptions } from './00-CreatePipelineExecutorOptions';
6
7
  /**
7
8
  * Options for executing an entire pipeline, including input parameters, pipeline context, and progress callbacks.
@@ -17,6 +18,10 @@ type ExecutePipelineOptions = Required<CreatePipelineExecutorOptions> & {
17
18
  * Optional callback invoked with partial results as the pipeline execution progresses.
18
19
  */
19
20
  onProgress?(newOngoingResult: PartialDeep<PipelineExecutorResult>): Promisable<void>;
21
+ /**
22
+ * Optional callback invoked with each LLM call.
23
+ */
24
+ logLlmCall?(llmCall: LlmCall): Promisable<void>;
20
25
  /**
21
26
  * The pipeline definition to execute.
22
27
  */
@@ -2,6 +2,7 @@ import type { PartialDeep, Promisable, ReadonlyDeep, WritableDeep } from 'type-f
2
2
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
3
3
  import type { TaskJson } from '../../pipeline/PipelineJson/TaskJson';
4
4
  import type { Parameters } from '../../types/typeAliases';
5
+ import type { LlmCall } from '../../types/LlmCall';
5
6
  import type { ExecutionReportJson } from '../execution-report/ExecutionReportJson';
6
7
  import type { PipelineExecutorResult } from '../PipelineExecutorResult';
7
8
  import type { CreatePipelineExecutorOptions } from './00-CreatePipelineExecutorOptions';
@@ -27,6 +28,10 @@ type executeSingleTaskOptions = Required<CreatePipelineExecutorOptions> & {
27
28
  * Callback invoked with partial results as the execution progresses.
28
29
  */
29
30
  onProgress(newOngoingResult: PartialDeep<PipelineExecutorResult>): Promisable<void>;
31
+ /**
32
+ * Optional callback invoked with each LLM call.
33
+ */
34
+ logLlmCall?(llmCall: LlmCall): Promisable<void>;
30
35
  /**
31
36
  * Mutable execution report object for tracking execution details.
32
37
  */
@@ -1,5 +1,6 @@
1
1
  import type { PartialDeep, Promisable } from 'type-fest';
2
2
  import type { TODO_any } from '../../utils/organization/TODO_any';
3
+ import type { LlmCall } from '../../types/LlmCall';
3
4
  import type { PipelineExecutorResult } from '../PipelineExecutorResult';
4
5
  import type { ExecuteAttemptsOptions } from './40-executeAttempts';
5
6
  /**
@@ -13,6 +14,10 @@ type ExecuteFormatCellsOptions = ExecuteAttemptsOptions & {
13
14
  * Callback invoked with partial results as the execution progresses.
14
15
  */
15
16
  onProgress(newOngoingResult: PartialDeep<PipelineExecutorResult>): Promisable<void>;
17
+ /**
18
+ * Optional callback invoked with each LLM call.
19
+ */
20
+ logLlmCall?(llmCall: LlmCall): Promisable<void>;
16
21
  };
17
22
  /**
18
23
  * Executes a pipeline task that requires mapping or iterating over subvalues of a parameter (such as rows in a CSV).
@@ -3,6 +3,7 @@ import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
3
3
  import type { TaskJson } from '../../pipeline/PipelineJson/TaskJson';
4
4
  import type { Parameters, string_parameter_name } from '../../types/typeAliases';
5
5
  import type { TODO_string } from '../../utils/organization/TODO_string';
6
+ import type { LlmCall } from '../../types/LlmCall';
6
7
  import type { ExecutionReportJson } from '../execution-report/ExecutionReportJson';
7
8
  import type { PipelineExecutorResult } from '../PipelineExecutorResult';
8
9
  import type { CreatePipelineExecutorOptions } from './00-CreatePipelineExecutorOptions';
@@ -50,6 +51,10 @@ export type ExecuteAttemptsOptions = Required<Omit<CreatePipelineExecutorOptions
50
51
  * Callback invoked with partial results as the execution progresses.
51
52
  */
52
53
  onProgress(newOngoingResult: PartialDeep<PipelineExecutorResult>): Promisable<void>;
54
+ /**
55
+ * Optional callback invoked with each LLM call.
56
+ */
57
+ logLlmCall?(llmCall: LlmCall): Promisable<void>;
53
58
  /**
54
59
  * The execution report object, which is updated during execution.
55
60
  */
@@ -0,0 +1,8 @@
1
+ import type { LlmCall } from '../../types/LlmCall';
2
+ import type { ExecutionPromptReportJson } from '../execution-report/ExecutionPromptReportJson';
3
+ /**
4
+ * Logs an LLM call with the given report.
5
+ *
6
+ * @private internal utility of `createPipelineExecutor`
7
+ */
8
+ export declare function logLlmCall(logLlmCall: (llmCall: LlmCall) => void, report: ExecutionPromptReportJson): void;
@@ -1,19 +1,28 @@
1
- import type { BookTranspilerOptions } from './BookTranspilerOptions';
1
+ import { BookTranspilerOptions, ExecutionTools, Registered, string_book, string_name, string_script, string_title } from '../../_packages/types.index';
2
2
  /**
3
- * Transpiler takes a book and transpiles it into another format.
4
- */
5
- export type BookTranspiler =
6
- /**
7
- * Transpiles a book.
8
- *
9
- * @param book book to transpile
10
- * @param options additional options for the transpiler
11
- * @returns transpiled book
12
- */
13
- (book: string, options: BookTranspilerOptions) => Promise<string>;
14
- /**
15
- * TODO: [🧠] Should there be a BookTranspiler class or just a function?
16
- * Maybe a class with a constructor that takes ExecutionTools.
17
- * Then the instance would be a function.
18
- * @see LlmExecutionTools
3
+ * Transpiler takes a book and transpiles it into another format (e.g., Langchain).
19
4
  */
5
+ export type BookTranspiler = Registered & {
6
+ /**
7
+ * The name of the transpiler.
8
+ * It is used to identify the transpiler in the register.
9
+ *
10
+ * @example 'python-langchain'
11
+ */
12
+ readonly name: string_name;
13
+ /**
14
+ * The title of the transpiler.
15
+ * It is used to display the transpiler in the UI.
16
+ *
17
+ * @example 'Python Langchain'
18
+ */
19
+ readonly title: string_title;
20
+ /**
21
+ * Transpiles a book.
22
+ *
23
+ * @param book book to transpile
24
+ * @param options additional options for the transpiler
25
+ * @returns transpiled book
26
+ */
27
+ transpileBook(book: string_book, tools: ExecutionTools, options?: BookTranspilerOptions): Promise<string_script>;
28
+ };
@@ -1,9 +1,8 @@
1
+ import { CommonToolsOptions } from '../../execution/CommonToolsOptions';
1
2
  /**
2
3
  * Options for the BookTranspiler.
3
- *
4
- * @see https://github.com/webgptorg/promptbook/issues/249
5
4
  */
6
- export type BookTranspilerOptions = {
5
+ export type BookTranspilerOptions = Omit<CommonToolsOptions, 'maxRequestsPerMinute'> & {
7
6
  /**
8
7
  * If true, the transpiler will log verbose information to the console.
9
8
  *
@@ -1,5 +1,5 @@
1
1
  import { $Register } from '../../../utils/misc/$Register';
2
- import type { BookTranspilerDefinition } from '../BookTranspilerDefinition';
2
+ import { BookTranspiler } from '../BookTranspiler';
3
3
  /**
4
4
  * Register for book transpilers.
5
5
  *
@@ -9,7 +9,7 @@ import type { BookTranspilerDefinition } from '../BookTranspilerDefinition';
9
9
  *
10
10
  * @public exported from `@promptbook/core`
11
11
  */
12
- export declare const $bookTranspilersRegister: $Register<BookTranspilerDefinition>;
12
+ export declare const $bookTranspilersRegister: $Register<BookTranspiler>;
13
13
  /**
14
14
  * TODO: [®] DRY Register logic
15
15
  */
@@ -1,13 +1,13 @@
1
- import type { BookTranspilerDefinition } from '../_common/BookTranspilerDefinition';
1
+ import { BookTranspilerOptions, ExecutionTools, string_book, string_script } from '../../_packages/types.index';
2
2
  /**
3
3
  * Transpiler to Javascript code using OpenAI SDK.
4
4
  *
5
- * @private TODO: !!!! Which package should export this?
6
- */
7
- export declare const OpenAiSdkTranspiler: BookTranspilerDefinition;
8
- /**
9
- * TODO: [🧠] What should be the scope of the transpiled code?
10
- * - Just a single function?
11
- * - A class?
12
- * - A whole package?
5
+ * @public exported from `@promptbook/core`
13
6
  */
7
+ export declare const OpenAiSdkTranspiler: {
8
+ readonly name: "openai-sdk";
9
+ readonly title: "OpenAI SDK";
10
+ readonly packageName: "@promptbook/core";
11
+ readonly className: "OpenAiSdkTranspiler";
12
+ readonly transpileBook: (book: string_book, tools: ExecutionTools, options?: BookTranspilerOptions) => Promise<string_script>;
13
+ };
@@ -0,0 +1,20 @@
1
+ import type { ExecutionPromptReportJson } from '../execution/execution-report/ExecutionPromptReportJson';
2
+ import type { string_model_name } from './typeAliases';
3
+ /**
4
+ * Represents a single LLM call with its report.
5
+ *
6
+ * @see https://github.com/webgptorg/promptbook/issues/24
7
+ */
8
+ export type LlmCall = {
9
+ /**
10
+ * The name of the model used for the call.
11
+ */
12
+ readonly modelName: string_model_name;
13
+ /**
14
+ * The report of the LLM execution.
15
+ */
16
+ readonly report: ExecutionPromptReportJson;
17
+ };
18
+ /**
19
+ * TODO: !!! Maybe different shape of LlmCall
20
+ */
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.103.0-31`).
18
+ * It follows semantic versioning (e.g., `0.103.0-33`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/vercel",
3
- "version": "0.103.0-32",
3
+ "version": "0.103.0-34",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -94,7 +94,7 @@
94
94
  "module": "./esm/index.es.js",
95
95
  "typings": "./esm/typings/src/_packages/vercel.index.d.ts",
96
96
  "peerDependencies": {
97
- "@promptbook/core": "0.103.0-32"
97
+ "@promptbook/core": "0.103.0-34"
98
98
  },
99
99
  "dependencies": {
100
100
  "colors": "^1.4.0",
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-32';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-34';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -1,37 +0,0 @@
1
- import type { ExecutionTools } from '../../execution/ExecutionTools';
2
- import type { string_name, string_title } from '../../types/typeAliases';
3
- import type { Registered } from '../../utils/misc/$Register';
4
- import type { BookTranspiler } from './BookTranspiler';
5
- /**
6
- * Definition of a book transpiler.
7
- *
8
- * @see https://github.com/webgptorg/promptbook/issues/249
9
- */
10
- export type BookTranspilerDefinition = Registered & {
11
- /**
12
- * The name of the transpiler.
13
- * It is used to identify the transpiler in the register.
14
- *
15
- * @example 'python-langchain'
16
- */
17
- readonly name: string_name;
18
- /**
19
- * The title of the transpiler.
20
- * It is used to display the transpiler in the UI.
21
- *
22
- * @example 'Python Langchain'
23
- */
24
- readonly title: string_title;
25
- /**
26
- * The factory function to create a transpiler instance.
27
- * It can be async.
28
- *
29
- * @param tools the execution tools that can be used by the transpiler
30
- * @returns the transpiler instance
31
- */
32
- readonly new: (tools: ExecutionTools) => BookTranspiler | Promise<BookTranspiler>;
33
- };
34
- /**
35
- * TODO: [🧠] What other information should be in the public profile of the transpiler?
36
- * - input format, output format, version, description, icon, etc.
37
- */
@@ -1,7 +0,0 @@
1
- import type { BookTranspilerDefinition } from '../_common/BookTranspilerDefinition';
2
- /**
3
- * Transpiler to Python code using LangChain library.
4
- *
5
- * @private TODO: !!!! Which package should export this?
6
- */
7
- export declare const LangchainTranspiler: BookTranspilerDefinition;
@@ -1,15 +0,0 @@
1
- import { Registration } from '../../_packages/types.index';
2
- /**
3
- * Registration of LLM provider
4
- *
5
- * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
- *
7
- * @public exported from `@promptbook/wizard`
8
- * @public exported from `@promptbook/cli`
9
- *
10
- * TODO: !!!! Which package should export this? - `@promptbook/core` vs `@promptbook/transpilers` vs `@promptbook/langchain`
11
- */
12
- export declare const _LangchainTranspilerRegistration: Registration;
13
- /**
14
- * Note: [💞] Ignore a discrepancy between file name and entity name
15
- */