@promptbook/markdown-utils 0.92.0-5 → 0.92.0-8

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.
@@ -91,6 +91,8 @@ import { filterModels } from '../llm-providers/_common/filterModels';
91
91
  import { $llmToolsMetadataRegister } from '../llm-providers/_common/register/$llmToolsMetadataRegister';
92
92
  import { $llmToolsRegister } from '../llm-providers/_common/register/$llmToolsRegister';
93
93
  import { createLlmToolsFromConfiguration } from '../llm-providers/_common/register/createLlmToolsFromConfiguration';
94
+ import { MODEL_TRUST_LEVEL } from '../llm-providers/_common/register/LlmToolsMetadata';
95
+ import { MODEL_ORDER } from '../llm-providers/_common/register/LlmToolsMetadata';
94
96
  import { cacheLlmTools } from '../llm-providers/_common/utils/cache/cacheLlmTools';
95
97
  import { countUsage } from '../llm-providers/_common/utils/count-total-usage/countUsage';
96
98
  import { limitTotalUsage } from '../llm-providers/_common/utils/count-total-usage/limitTotalUsage';
@@ -230,6 +232,8 @@ export { filterModels };
230
232
  export { $llmToolsMetadataRegister };
231
233
  export { $llmToolsRegister };
232
234
  export { createLlmToolsFromConfiguration };
235
+ export { MODEL_TRUST_LEVEL };
236
+ export { MODEL_ORDER };
233
237
  export { cacheLlmTools };
234
238
  export { countUsage };
235
239
  export { limitTotalUsage };
@@ -7,6 +7,7 @@ import { serializeError } from '../errors/utils/serializeError';
7
7
  import { forEachAsync } from '../execution/utils/forEachAsync';
8
8
  import { isValidCsvString } from '../formats/csv/utils/isValidCsvString';
9
9
  import { isValidJsonString } from '../formats/json/utils/isValidJsonString';
10
+ import { jsonParse } from '../formats/json/utils/jsonParse';
10
11
  import { isValidXmlString } from '../formats/xml/utils/isValidXmlString';
11
12
  import { prompt } from '../pipeline/prompt-notation';
12
13
  import { promptTemplate } from '../pipeline/prompt-notation';
@@ -91,6 +92,7 @@ export { serializeError };
91
92
  export { forEachAsync };
92
93
  export { isValidCsvString };
93
94
  export { isValidJsonString };
95
+ export { jsonParse };
94
96
  export { isValidXmlString };
95
97
  export { prompt };
96
98
  export { promptTemplate };
@@ -1,5 +1,5 @@
1
- import type { LlmExecutionToolsWithTotalUsage } from '../../llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
2
1
  import type { CacheLlmToolsOptions } from '../../llm-providers/_common/utils/cache/CacheLlmToolsOptions';
2
+ import type { LlmExecutionToolsWithTotalUsage } from '../../llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
3
3
  import type { string_promptbook_server_url } from '../../types/typeAliases';
4
4
  type ProvideLlmToolsForCliOptions = Pick<CacheLlmToolsOptions, 'isCacheReloaded'> & {
5
5
  /**
@@ -1,6 +1,6 @@
1
+ import type { FilesystemTools } from '../../execution/FilesystemTools';
1
2
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
2
3
  import type { string_filename } from '../../types/typeAliases';
3
- import type { FilesystemTools } from '../../execution/FilesystemTools';
4
4
  /**
5
5
  * Loads the books from the archive file with `.bookc` extension
6
6
  *
@@ -10,7 +10,7 @@ import type { FilesystemTools } from '../../execution/FilesystemTools';
10
10
  *
11
11
  * @private utility of Prompbook
12
12
  */
13
- export declare function loadArchive(filePath: string_filename, fs: FilesystemTools): Promise<Array<PipelineJson>>;
13
+ export declare function loadArchive(filePath: string_filename, fs: FilesystemTools): Promise<ReadonlyArray<PipelineJson>>;
14
14
  /**
15
15
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
16
16
  */
@@ -3,12 +3,17 @@ import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
3
3
  import type { TaskJson } from '../../pipeline/PipelineJson/TaskJson';
4
4
  import type { string_markdown } from '../../types/typeAliases';
5
5
  import type { string_parameter_value } from '../../types/typeAliases';
6
+ import type { ExecutionTools } from '../ExecutionTools';
6
7
  /**
7
8
  * @@@
8
9
  *
9
10
  * @private internal type of `getKnowledgeFoTask`
10
11
  */
11
12
  type GetKnowledgeForTaskOptions = {
13
+ /**
14
+ * The execution tools to be used during the execution of the pipeline
15
+ */
16
+ readonly tools: ExecutionTools;
12
17
  /**
13
18
  * @@@
14
19
  */
@@ -21,7 +26,14 @@ type GetKnowledgeForTaskOptions = {
21
26
  /**
22
27
  * @@@
23
28
  *
29
+ * Here is the place where RAG (retrieval-augmented generation) happens
30
+ *
24
31
  * @private internal utility of `createPipelineExecutor`
25
32
  */
26
33
  export declare function getKnowledgeForTask(options: GetKnowledgeForTaskOptions): Promise<string_parameter_value & string_markdown>;
27
34
  export {};
35
+ /**
36
+ * TODO: !!!! Verify if this is working
37
+ * TODO: [♨] Implement Better - use keyword search
38
+ * TODO: [♨] Examples of values
39
+ */
@@ -2,12 +2,17 @@ import type { ReadonlyDeep } from 'type-fest';
2
2
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
3
3
  import type { TaskJson } from '../../pipeline/PipelineJson/TaskJson';
4
4
  import type { ReservedParameters } from '../../types/typeAliases';
5
+ import type { ExecutionTools } from '../ExecutionTools';
5
6
  /**
6
7
  * @@@
7
8
  *
8
9
  * @private internal type of `getReservedParametersForTask`
9
10
  */
10
11
  type GetReservedParametersForTaskOptions = {
12
+ /**
13
+ * The execution tools to be used during the execution of the pipeline
14
+ */
15
+ readonly tools: ExecutionTools;
11
16
  /**
12
17
  * @@@
13
18
  */
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Converts a JavaScript Object Notation (JSON) string into an object.
3
+ *
4
+ * Note: This is wrapper around `JSON.parse()` with better error and type handling
5
+ *
6
+ * @public exported from `@promptbook/utils`
7
+ */
8
+ export declare function jsonParse<T>(value: string): T;
9
+ /**
10
+ * TODO: !!!! Use in Promptbook.studio
11
+ */
@@ -3,6 +3,41 @@ import type { string_title } from '../../../types/typeAliases';
3
3
  import type { Registered } from '../../../utils/$Register';
4
4
  import type { string_SCREAMING_CASE } from '../../../utils/normalization/normalizeTo_SCREAMING_CASE';
5
5
  import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
6
+ /**
7
+ * How is the model provider trusted?
8
+ *
9
+ * @public exported from `@promptbook/core`
10
+ */
11
+ export declare const MODEL_TRUST_LEVEL: {
12
+ readonly FULL: "Model is running on the local machine, training data and model weights are known, data are ethically sourced";
13
+ readonly OPEN: "Model is open source, training data and model weights are known";
14
+ readonly PARTIALLY_OPEN: "Model is open source, but training data and model weights are not (fully) known";
15
+ readonly CLOSED_LOCAL: "Model can be run locally, but it is not open source";
16
+ readonly CLOSED_FREE: "Model is behind API gateway but free to use";
17
+ readonly CLOSED_BUSINESS: "Model is behind API gateway and paid but has good SLA, TOS, privacy policy and in general is a good to use in business applications";
18
+ readonly CLOSED: "Model is behind API gateway and paid";
19
+ readonly UNTRUSTED: "Model has questions about the training data and ethics, but it is not known if it is a problem or not";
20
+ readonly VURNABLE: "Model has some known serious vulnerabilities, leaks, ethical problems, etc.";
21
+ };
22
+ /**
23
+ * How is the model provider important?
24
+ *
25
+ * @public exported from `@promptbook/core`
26
+ */
27
+ export declare const MODEL_ORDER: {
28
+ /**
29
+ * Top-tier models, e.g. OpenAI, Anthropic,...
30
+ */
31
+ readonly TOP_TIER: 333;
32
+ /**
33
+ * Mid-tier models, e.g. Llama, Mistral, etc.
34
+ */
35
+ readonly NORMAL: 100;
36
+ /**
37
+ * Low-tier models, e.g. Phi, Tiny, etc.
38
+ */
39
+ readonly LOW_TIER: 0;
40
+ };
6
41
  /**
7
42
  * @@@
8
43
  *
@@ -13,6 +48,14 @@ export type LlmToolsMetadata = Registered & {
13
48
  * @@@
14
49
  */
15
50
  readonly title: string_title;
51
+ /**
52
+ * How is the model is trusted?
53
+ */
54
+ readonly trustLevel: keyof typeof MODEL_TRUST_LEVEL;
55
+ /**
56
+ * How is the model provider important and should be sorted in the list of available providers?
57
+ */
58
+ readonly order: typeof MODEL_ORDER[keyof typeof MODEL_ORDER] | number;
16
59
  /**
17
60
  * List of environment variables that can be used to configure the provider
18
61
  *
@@ -28,7 +28,9 @@ export type paths = {
28
28
  headers: {
29
29
  readonly [name: string]: unknown;
30
30
  };
31
- content?: never;
31
+ content: {
32
+ readonly "text/markdown": string;
33
+ };
32
34
  };
33
35
  };
34
36
  };
@@ -71,16 +73,44 @@ export type paths = {
71
73
  };
72
74
  readonly responses: {
73
75
  /** @description Successful login */
74
- readonly 200: {
76
+ readonly 201: {
75
77
  headers: {
76
78
  readonly [name: string]: unknown;
77
79
  };
78
80
  content: {
79
81
  readonly "application/json": {
82
+ readonly isSuccess?: boolean;
83
+ readonly message?: string;
84
+ readonly error?: Record<string, never>;
80
85
  readonly identification?: Record<string, never>;
81
86
  };
82
87
  };
83
88
  };
89
+ /** @description Bad request or login failed */
90
+ readonly 400: {
91
+ headers: {
92
+ readonly [name: string]: unknown;
93
+ };
94
+ content: {
95
+ readonly "application/json": {
96
+ readonly error?: Record<string, never>;
97
+ };
98
+ };
99
+ };
100
+ /** @description Authentication error */
101
+ readonly 401: {
102
+ headers: {
103
+ readonly [name: string]: unknown;
104
+ };
105
+ content: {
106
+ readonly "application/json": {
107
+ /** @enum {boolean} */
108
+ readonly isSuccess?: false;
109
+ readonly message?: string;
110
+ readonly error?: Record<string, never>;
111
+ };
112
+ };
113
+ };
84
114
  };
85
115
  };
86
116
  readonly delete?: never;
@@ -118,6 +148,15 @@ export type paths = {
118
148
  readonly "application/json": readonly string[];
119
149
  };
120
150
  };
151
+ /** @description No collection available */
152
+ readonly 500: {
153
+ headers: {
154
+ readonly [name: string]: unknown;
155
+ };
156
+ content: {
157
+ readonly "text/plain": string;
158
+ };
159
+ };
121
160
  };
122
161
  };
123
162
  readonly put?: never;
@@ -128,7 +167,7 @@ export type paths = {
128
167
  readonly patch?: never;
129
168
  readonly trace?: never;
130
169
  };
131
- readonly [path: `/books/${string}`]: {
170
+ readonly "/books/{bookId}": {
132
171
  readonly parameters: {
133
172
  readonly query?: never;
134
173
  readonly header?: never;
@@ -165,7 +204,20 @@ export type paths = {
165
204
  headers: {
166
205
  readonly [name: string]: unknown;
167
206
  };
168
- content?: never;
207
+ content: {
208
+ readonly "application/json": {
209
+ readonly error?: Record<string, never>;
210
+ };
211
+ };
212
+ };
213
+ /** @description No collection available */
214
+ readonly 500: {
215
+ headers: {
216
+ readonly [name: string]: unknown;
217
+ };
218
+ content: {
219
+ readonly "text/plain": string;
220
+ };
169
221
  };
170
222
  };
171
223
  };
@@ -203,7 +255,139 @@ export type paths = {
203
255
  readonly [name: string]: unknown;
204
256
  };
205
257
  content: {
206
- readonly "application/json": readonly Record<string, never>[];
258
+ readonly "application/json": readonly {
259
+ readonly nonce?: string;
260
+ readonly taskId?: string;
261
+ readonly taskType?: string;
262
+ readonly status?: string;
263
+ /** Format: date-time */
264
+ readonly createdAt?: string;
265
+ /** Format: date-time */
266
+ readonly updatedAt?: string;
267
+ }[];
268
+ };
269
+ };
270
+ };
271
+ };
272
+ readonly put?: never;
273
+ readonly post?: never;
274
+ readonly delete?: never;
275
+ readonly options?: never;
276
+ readonly head?: never;
277
+ readonly patch?: never;
278
+ readonly trace?: never;
279
+ };
280
+ readonly "/executions/last": {
281
+ readonly parameters: {
282
+ readonly query?: never;
283
+ readonly header?: never;
284
+ readonly path?: never;
285
+ readonly cookie?: never;
286
+ };
287
+ /**
288
+ * Get the last execution
289
+ * @description Returns details of the last execution task.
290
+ */
291
+ readonly get: {
292
+ readonly parameters: {
293
+ readonly query?: never;
294
+ readonly header?: never;
295
+ readonly path?: never;
296
+ readonly cookie?: never;
297
+ };
298
+ readonly requestBody?: never;
299
+ readonly responses: {
300
+ /** @description The last execution task with full details. */
301
+ readonly 200: {
302
+ headers: {
303
+ readonly [name: string]: unknown;
304
+ };
305
+ content: {
306
+ readonly "application/json": {
307
+ readonly nonce?: string;
308
+ readonly taskId?: string;
309
+ readonly taskType?: string;
310
+ readonly status?: string;
311
+ readonly errors?: readonly Record<string, never>[];
312
+ readonly warnings?: readonly Record<string, never>[];
313
+ /** Format: date-time */
314
+ readonly createdAt?: string;
315
+ /** Format: date-time */
316
+ readonly updatedAt?: string;
317
+ readonly currentValue?: Record<string, never>;
318
+ };
319
+ };
320
+ };
321
+ /** @description No execution tasks found. */
322
+ readonly 404: {
323
+ headers: {
324
+ readonly [name: string]: unknown;
325
+ };
326
+ content: {
327
+ readonly "text/plain": string;
328
+ };
329
+ };
330
+ };
331
+ };
332
+ readonly put?: never;
333
+ readonly post?: never;
334
+ readonly delete?: never;
335
+ readonly options?: never;
336
+ readonly head?: never;
337
+ readonly patch?: never;
338
+ readonly trace?: never;
339
+ };
340
+ readonly "/executions/{taskId}": {
341
+ readonly parameters: {
342
+ readonly query?: never;
343
+ readonly header?: never;
344
+ readonly path?: never;
345
+ readonly cookie?: never;
346
+ };
347
+ /**
348
+ * Get specific execution
349
+ * @description Returns details of a specific execution task.
350
+ */
351
+ readonly get: {
352
+ readonly parameters: {
353
+ readonly query?: never;
354
+ readonly header?: never;
355
+ readonly path: {
356
+ /** @description The ID of the execution task to retrieve. */
357
+ readonly taskId: string;
358
+ };
359
+ readonly cookie?: never;
360
+ };
361
+ readonly requestBody?: never;
362
+ readonly responses: {
363
+ /** @description The execution task with full details. */
364
+ readonly 200: {
365
+ headers: {
366
+ readonly [name: string]: unknown;
367
+ };
368
+ content: {
369
+ readonly "application/json": {
370
+ readonly nonce?: string;
371
+ readonly taskId?: string;
372
+ readonly taskType?: string;
373
+ readonly status?: string;
374
+ readonly errors?: readonly Record<string, never>[];
375
+ readonly warnings?: readonly Record<string, never>[];
376
+ /** Format: date-time */
377
+ readonly createdAt?: string;
378
+ /** Format: date-time */
379
+ readonly updatedAt?: string;
380
+ readonly currentValue?: Record<string, never>;
381
+ };
382
+ };
383
+ };
384
+ /** @description Execution task not found. */
385
+ readonly 404: {
386
+ headers: {
387
+ readonly [name: string]: unknown;
388
+ };
389
+ content: {
390
+ readonly "text/plain": string;
207
391
  };
208
392
  };
209
393
  };
@@ -239,8 +423,13 @@ export type paths = {
239
423
  readonly requestBody: {
240
424
  readonly content: {
241
425
  readonly "application/json": {
426
+ /** @description URL of the pipeline to execute */
242
427
  readonly pipelineUrl?: string;
428
+ /** @description Alternative field for pipelineUrl */
429
+ readonly book?: string;
430
+ /** @description Parameters for pipeline execution */
243
431
  readonly inputParameters?: Record<string, never>;
432
+ /** @description User identification data */
244
433
  readonly identification?: Record<string, never>;
245
434
  };
246
435
  };
@@ -257,6 +446,91 @@ export type paths = {
257
446
  };
258
447
  /** @description Invalid input. */
259
448
  readonly 400: {
449
+ headers: {
450
+ readonly [name: string]: unknown;
451
+ };
452
+ content: {
453
+ readonly "application/json": {
454
+ readonly error?: Record<string, never>;
455
+ };
456
+ };
457
+ };
458
+ /** @description Pipeline not found. */
459
+ readonly 404: {
460
+ headers: {
461
+ readonly [name: string]: unknown;
462
+ };
463
+ content: {
464
+ readonly "text/plain": string;
465
+ };
466
+ };
467
+ };
468
+ };
469
+ readonly delete?: never;
470
+ readonly options?: never;
471
+ readonly head?: never;
472
+ readonly patch?: never;
473
+ readonly trace?: never;
474
+ };
475
+ readonly "/api-docs": {
476
+ readonly parameters: {
477
+ readonly query?: never;
478
+ readonly header?: never;
479
+ readonly path?: never;
480
+ readonly cookie?: never;
481
+ };
482
+ /**
483
+ * API documentation UI
484
+ * @description Swagger UI for API documentation
485
+ */
486
+ readonly get: {
487
+ readonly parameters: {
488
+ readonly query?: never;
489
+ readonly header?: never;
490
+ readonly path?: never;
491
+ readonly cookie?: never;
492
+ };
493
+ readonly requestBody?: never;
494
+ readonly responses: {
495
+ /** @description HTML Swagger UI */
496
+ readonly 200: {
497
+ headers: {
498
+ readonly [name: string]: unknown;
499
+ };
500
+ content?: never;
501
+ };
502
+ };
503
+ };
504
+ readonly put?: never;
505
+ readonly post?: never;
506
+ readonly delete?: never;
507
+ readonly options?: never;
508
+ readonly head?: never;
509
+ readonly patch?: never;
510
+ readonly trace?: never;
511
+ };
512
+ readonly "/swagger": {
513
+ readonly parameters: {
514
+ readonly query?: never;
515
+ readonly header?: never;
516
+ readonly path?: never;
517
+ readonly cookie?: never;
518
+ };
519
+ /**
520
+ * API documentation UI (alternative path)
521
+ * @description Swagger UI for API documentation
522
+ */
523
+ readonly get: {
524
+ readonly parameters: {
525
+ readonly query?: never;
526
+ readonly header?: never;
527
+ readonly path?: never;
528
+ readonly cookie?: never;
529
+ };
530
+ readonly requestBody?: never;
531
+ readonly responses: {
532
+ /** @description HTML Swagger UI */
533
+ readonly 200: {
260
534
  headers: {
261
535
  readonly [name: string]: unknown;
262
536
  };
@@ -264,6 +538,47 @@ export type paths = {
264
538
  };
265
539
  };
266
540
  };
541
+ readonly put?: never;
542
+ readonly post?: never;
543
+ readonly delete?: never;
544
+ readonly options?: never;
545
+ readonly head?: never;
546
+ readonly patch?: never;
547
+ readonly trace?: never;
548
+ };
549
+ readonly "/openapi": {
550
+ readonly parameters: {
551
+ readonly query?: never;
552
+ readonly header?: never;
553
+ readonly path?: never;
554
+ readonly cookie?: never;
555
+ };
556
+ /**
557
+ * OpenAPI specification
558
+ * @description Returns the OpenAPI JSON specification
559
+ */
560
+ readonly get: {
561
+ readonly parameters: {
562
+ readonly query?: never;
563
+ readonly header?: never;
564
+ readonly path?: never;
565
+ readonly cookie?: never;
566
+ };
567
+ readonly requestBody?: never;
568
+ readonly responses: {
569
+ /** @description OpenAPI specification */
570
+ readonly 200: {
571
+ headers: {
572
+ readonly [name: string]: unknown;
573
+ };
574
+ content: {
575
+ readonly "application/json": Record<string, never>;
576
+ };
577
+ };
578
+ };
579
+ };
580
+ readonly put?: never;
581
+ readonly post?: never;
267
582
  readonly delete?: never;
268
583
  readonly options?: never;
269
584
  readonly head?: never;
@@ -273,7 +588,34 @@ export type paths = {
273
588
  };
274
589
  export type webhooks = Record<string, never>;
275
590
  export type components = {
276
- schemas: never;
591
+ schemas: {
592
+ readonly Error: {
593
+ readonly error?: Record<string, never>;
594
+ };
595
+ readonly ExecutionTaskSummary: {
596
+ readonly nonce?: string;
597
+ readonly taskId?: string;
598
+ readonly taskType?: string;
599
+ readonly status?: string;
600
+ /** Format: date-time */
601
+ readonly createdAt?: string;
602
+ /** Format: date-time */
603
+ readonly updatedAt?: string;
604
+ };
605
+ readonly ExecutionTaskFull: {
606
+ readonly nonce?: string;
607
+ readonly taskId?: string;
608
+ readonly taskType?: string;
609
+ readonly status?: string;
610
+ readonly errors?: readonly Record<string, never>[];
611
+ readonly warnings?: readonly Record<string, never>[];
612
+ /** Format: date-time */
613
+ readonly createdAt?: string;
614
+ /** Format: date-time */
615
+ readonly updatedAt?: string;
616
+ readonly currentValue?: Record<string, never>;
617
+ };
618
+ };
277
619
  responses: never;
278
620
  parameters: never;
279
621
  requestBodies: never;