@promptbook/openai 0.81.0-22 → 0.81.0-23

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 (36) hide show
  1. package/README.md +4 -20
  2. package/esm/index.es.js +9 -7
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +2 -0
  5. package/esm/typings/src/_packages/types.index.d.ts +2 -0
  6. package/esm/typings/src/cli/cli-commands/make.d.ts +1 -1
  7. package/esm/typings/src/cli/cli-commands/run.d.ts +2 -2
  8. package/esm/typings/src/collection/constructors/createCollectionFromDirectory.d.ts +11 -0
  9. package/esm/typings/src/collection/constructors/createCollectionFromUrl.d.ts +1 -1
  10. package/esm/typings/src/commands/index.d.ts +1 -1
  11. package/esm/typings/src/config.d.ts +2 -2
  12. package/esm/typings/src/conversion/parsePipeline.d.ts +1 -1
  13. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +3 -3
  14. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +7 -7
  15. package/esm/typings/src/errors/utils/getErrorReportUrl.d.ts +1 -1
  16. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  17. package/esm/typings/src/llm-providers/anthropic-claude/createAnthropicClaudeExecutionTools.d.ts +2 -2
  18. package/esm/typings/src/llm-providers/anthropic-claude/playground/playground.d.ts +2 -2
  19. package/esm/typings/src/llm-providers/openai/playground/playground.d.ts +1 -1
  20. package/esm/typings/src/llm-providers/vercel/playground/playground.d.ts +1 -1
  21. package/esm/typings/src/other/templates/getBookTemplates.d.ts +1 -1
  22. package/esm/typings/src/personas/preparePersona.d.ts +4 -4
  23. package/esm/typings/src/pipeline/PipelineString.d.ts +0 -3
  24. package/esm/typings/src/pipeline/book-notation.d.ts +0 -1
  25. package/esm/typings/src/pipeline/isValidPipelineString.d.ts +3 -1
  26. package/esm/typings/src/pipeline/validatePipelineString.d.ts +14 -0
  27. package/esm/typings/src/prepare/isPipelinePrepared.d.ts +1 -1
  28. package/esm/typings/src/prepare/prepareTasks.d.ts +1 -1
  29. package/esm/typings/src/scripting/javascript/JavascriptEvalExecutionTools.test.d.ts +1 -1
  30. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  31. package/esm/typings/src/types/typeAliases.d.ts +8 -2
  32. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +1 -1
  33. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +1 -1
  34. package/package.json +2 -2
  35. package/umd/index.umd.js +9 -7
  36. package/umd/index.umd.js.map +1 -1
@@ -19,7 +19,7 @@ import type { PipelineString } from '../pipeline/PipelineString';
19
19
  export declare function parsePipeline(pipelineString: PipelineString): PipelineJson;
20
20
  /**
21
21
  * TODO: [🧠] Maybe more things here can be refactored as high-level abstractions
22
- * TODO: [main] !!!! Warn if used only sync version
22
+ * TODO: [main] !!4 Warn if used only sync version
23
23
  * TODO: [🚞] Report here line/column of error
24
24
  * TODO: Use spaceTrim more effectively
25
25
  * TODO: [🧠] Parameter flags - isInput, isOutput, isInternal
@@ -22,9 +22,9 @@ export type renderPipelineMermaidOptions = {
22
22
  */
23
23
  export declare function renderPromptbookMermaid(pipelineJson: PipelineJson, options?: renderPipelineMermaidOptions): string;
24
24
  /**
25
- * TODO: [🧠] !! FOREACH in mermaid graph
26
- * TODO: [🧠] !! Knowledge in mermaid graph
27
- * TODO: [🧠] !! Personas in mermaid graph
25
+ * TODO: [🧠] FOREACH in mermaid graph
26
+ * TODO: [🧠] Knowledge in mermaid graph
27
+ * TODO: [🧠] Personas in mermaid graph
28
28
  * TODO: Maybe use some Mermaid package instead of string templating
29
29
  * TODO: [🕌] When more than 2 functionalities, split into separate functions
30
30
  */
@@ -18,9 +18,9 @@ export declare function validatePipeline(pipeline: PipelineJson): PipelineJson;
18
18
  /**
19
19
  * @private internal function for `validatePipeline`
20
20
  */
21
- export declare function validatePipelineCore(pipeline: PipelineJson): void;
21
+ export declare function validatePipeline_InnerFunction(pipeline: PipelineJson): void;
22
22
  /**
23
- * TODO: !! [🧞‍♀️] Do not allow joker + foreach
23
+ * TODO: [🧞‍♀️] Do not allow joker + foreach
24
24
  * TODO: [🧠] Work with promptbookVersion
25
25
  * TODO: Use here some json-schema, Zod or something similar and change it to:
26
26
  * > /**
@@ -32,11 +32,11 @@ export declare function validatePipelineCore(pipeline: PipelineJson): void;
32
32
  * > ex port function validatePipeline(promptbook: really_unknown): asserts promptbook is PipelineJson {
33
33
  */
34
34
  /**
35
- * TODO: [🧳][main] !!!! Validate that all examples match expectations
36
- * TODO: [🧳][🐝][main] !!!! Validate that knowledge is valid (non-void)
37
- * TODO: [🧳][main] !!!! Validate that persona can be used only with CHAT variant
38
- * TODO: [🧳][main] !!!! Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
39
- * TODO: [🧳][main] !!!! Validate that reserved parameter is not used as joker
35
+ * TODO: [🧳][main] !!4 Validate that all examples match expectations
36
+ * TODO: [🧳][🐝][main] !!4 Validate that knowledge is valid (non-void)
37
+ * TODO: [🧳][main] !!4 Validate that persona can be used only with CHAT variant
38
+ * TODO: [🧳][main] !!4 Validate that parameter with reserved name not used RESERVED_PARAMETER_NAMES
39
+ * TODO: [🧳][main] !!4 Validate that reserved parameter is not used as joker
40
40
  * TODO: [🧠] Validation not only logic itself but imports around - files and websites and rerefenced pipelines exists
41
41
  * TODO: [🛠] Actions, instruments (and maybe knowledge) => Functions and tools
42
42
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Make error report URL for the given error
3
3
  *
4
- * @private !!!!!!
4
+ * @private private within the repository
5
5
  */
6
6
  export declare function getErrorReportUrl(error: Error): URL;
@@ -16,7 +16,7 @@ export declare const ANTHROPIC_CLAUDE_MODELS: ReadonlyArray<AvailableModel & {
16
16
  }>;
17
17
  /**
18
18
  * Note: [🤖] Add models of new variant
19
- * TODO: [🧠][main] !!! Add embedding models OR Anthropic has only chat+completion models?
19
+ * TODO: [🧠][main] !!3 Add embedding models OR Anthropic has only chat+completion models?
20
20
  * TODO: [🧠] Some mechanism to propagate unsureness
21
21
  * TODO: [🧠][👮‍♀️] Put here more info like description, isVision, trainingDateCutoff, languages, strengths ( Top-level performance, intelligence, fluency, and understanding), contextWindow,...
22
22
  * TODO: [🎰] Some mechanism to auto-update available models
@@ -11,8 +11,8 @@ export declare const createAnthropicClaudeExecutionTools: ((options: AnthropicCl
11
11
  className: string;
12
12
  };
13
13
  /**
14
- * TODO: [🧠][main] !!!! Make anonymous this with all LLM providers
15
- * TODO: [🧠][🧱][main] !!!! Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
14
+ * TODO: [🧠][main] !!4 Make anonymous this with all LLM providers
15
+ * TODO: [🧠][🧱][main] !!4 Maybe change all `new AnthropicClaudeExecutionTools` -> `createAnthropicClaudeExecutionTools` in manual
16
16
  * TODO: [🧠] Maybe auto-detect usage in browser and determine default value of `isProxied`
17
17
  * TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
18
18
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ts-node
2
2
  export {};
3
3
  /**
4
- * TODO: [main] !!! Playground with WebGPT / Promptbook.studio anonymous server
5
- * TODO: [main] !!! Test here that `systemMessage`, `temperature` and `seed` are working correctly
4
+ * TODO: [main] !!3 Playground with WebGPT / Promptbook.studio anonymous server
5
+ * TODO: [main] !!3 Test here that `systemMessage`, `temperature` and `seed` are working correctly
6
6
  * Note: [⚫] Code in this file should never be published in any package
7
7
  */
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ts-node
2
2
  export {};
3
3
  /**
4
- * TODO: [main] !!! Test here that `systemMessage`, `temperature` and `seed` are working correctly
4
+ * TODO: [main] !!3 Test here that `systemMessage`, `temperature` and `seed` are working correctly
5
5
  * Note: [⚫] Code in this file should never be published in any package
6
6
  */
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ts-node
2
2
  export {};
3
3
  /**
4
- * TODO: [main] !!! Test here that `systemMessage`, `temperature` and `seed` are working correctly
4
+ * TODO: [main] !!3 Test here that `systemMessage`, `temperature` and `seed` are working correctly
5
5
  * Note: [⚫] Code in this file should never be published in any package
6
6
  */
@@ -18,5 +18,5 @@ export declare function getBookTemplates(formfactorName?: string_formfactor_name
18
18
  /**
19
19
  * TODO: Unit test
20
20
  * TODO: [🧠] Which is the best place for this function
21
- * TODO: !!!!!! For GENERIC template ensure at least one pipeline is present for typescript in `getBookTemplates`
21
+ * TODO: !!6 For GENERIC template ensure at least one pipeline is present for typescript in `getBookTemplates`
22
22
  */
@@ -10,8 +10,8 @@ import type { string_persona_description } from '../types/typeAliases';
10
10
  */
11
11
  export declare function preparePersona(personaDescription: string_persona_description, tools: Pick<ExecutionTools, 'llm'>, options: PrepareAndScrapeOptions): Promise<PersonaPreparedJson['modelRequirements']>;
12
12
  /**
13
- * TODO: [🔃][main] !! If the persona was prepared with different version or different set of models, prepare it once again
14
- * TODO: [🏢] !! Check validity of `modelName` in pipeline
15
- * TODO: [🏢] !! Check validity of `systemMessage` in pipeline
16
- * TODO: [🏢] !! Check validity of `temperature` in pipeline
13
+ * TODO: [🔃][main] If the persona was prepared with different version or different set of models, prepare it once again
14
+ * TODO: [🏢] Check validity of `modelName` in pipeline
15
+ * TODO: [🏢] Check validity of `systemMessage` in pipeline
16
+ * TODO: [🏢] Check validity of `temperature` in pipeline
17
17
  */
@@ -7,6 +7,3 @@
7
7
  export type PipelineString = string & {
8
8
  readonly _type: 'Promptbook';
9
9
  };
10
- /**
11
- * TODO: [💩] Better validation (validatePipelineString) or remove branded type and make it just string
12
- */
@@ -9,7 +9,6 @@ import type { PipelineString } from './PipelineString';
9
9
  */
10
10
  export declare function book(strings: TemplateStringsArray, ...values: Array<string>): PipelineString;
11
11
  /**
12
- * TODO: Use ACRY book\`...\ notation instead of as PipelineString
13
12
  * TODO: [🧠][🈴] Where is the best location for this file
14
13
  * Note: [💞] Ignore a discrepancy between file name and entity name
15
14
  */
@@ -3,9 +3,11 @@ import type { PipelineString } from './PipelineString';
3
3
  * Function `isValidPipelineString` will validate the if the string is a valid pipeline string
4
4
  * It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
5
5
  *
6
+ * @param {string} pipelineString the candidate for a pipeline string
7
+ * @returns {boolean} if the string is a valid pipeline string
6
8
  * @public exported from `@promptbook/core`
7
9
  */
8
- export declare function isValidPipelineString(value: string): value is PipelineString;
10
+ export declare function isValidPipelineString(pipelineString: string): pipelineString is PipelineString;
9
11
  /**
10
12
  * TODO: [🧠][🈴] Where is the best location for this file
11
13
  */
@@ -0,0 +1,14 @@
1
+ import type { PipelineString } from './PipelineString';
2
+ /**
3
+ * Function `validatePipelineString` will validate the if the string is a valid pipeline string
4
+ * It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
5
+ *
6
+ * @param {string} pipelineString the candidate for a pipeline string
7
+ * @returns {PipelineString} the same string as input, but validated as valid
8
+ * @throws {ParseError} if the string is not a valid pipeline string
9
+ * @public exported from `@promptbook/core`
10
+ */
11
+ export declare function validatePipelineString(pipelineString: string): PipelineString;
12
+ /**
13
+ * TODO: [🧠][🈴] Where is the best location for this file
14
+ */
@@ -8,7 +8,7 @@ import type { PipelineJson } from '../pipeline/PipelineJson/PipelineJson';
8
8
  */
9
9
  export declare function isPipelinePrepared(pipeline: PipelineJson): boolean;
10
10
  /**
11
- * TODO: [🔃][main] !! If the pipeline was prepared with different version or different set of models, prepare it once again
11
+ * TODO: [🔃][main] If the pipeline was prepared with different version or different set of models, prepare it once again
12
12
  * TODO: [🐠] Maybe base this on `makeValidator`
13
13
  * TODO: [🧊] Pipeline can be partially prepared, this should return true ONLY if fully prepared
14
14
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -25,7 +25,7 @@ export {};
25
25
  * TODO: [😂] Adding knowledge should be convert to async high-level abstractions, simmilar thing with expectations to sync high-level abstractions
26
26
  * TODO: [🧠] Add context to each task (if missing)
27
27
  * TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
28
- * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
28
+ * TODO: [♨][main] !!3 Prepare index the examples and maybe tasks
29
29
  * TODO: Write tests for `preparePipeline`
30
30
  * TODO: [🏏] Leverage the batch API and build queues @see https://platform.openai.com/docs/guides/batch
31
31
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
@@ -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
  */
@@ -10,5 +10,5 @@ import type { really_any } from '../../../utils/organization/really_any';
10
10
  export declare function preserve(func: (...params: ReadonlyArray<really_any>) => unknown): void;
11
11
  /**
12
12
  * TODO: Probbably remove in favour of `keepImported`
13
- * TODO: !! [1] This maybe does memory leak
13
+ * TODO: [1] This maybe does memory leak
14
14
  */
@@ -319,6 +319,12 @@ export type string_url = string;
319
319
  * For example `"https://collboard.com"`
320
320
  */
321
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;
322
328
  /**
323
329
  * Semantic helper
324
330
  *
@@ -623,8 +629,8 @@ export type number_megabytes = number_positive;
623
629
  export type number_gigabytes = number_positive;
624
630
  export type number_terabytes = number_positive;
625
631
  /**.
626
- * TODO: [main] !!! Change "For example" to @example
627
- * TODO: !! Change to branded types
632
+ * TODO: [main] !!3 Change "For example" to @example
633
+ * TODO: Change to branded types
628
634
  * TODO: Delete type aliases that are not exported or used internally
629
635
  * Note: [💞] Ignore a discrepancy between file name and entity name
630
636
  */
@@ -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
  */
@@ -20,6 +20,6 @@ import type { 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
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/openai",
3
- "version": "0.81.0-22",
3
+ "version": "0.81.0-23",
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-22"
57
+ "@promptbook/core": "0.81.0-23"
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-21';
27
+ var PROMPTBOOK_ENGINE_VERSION = '0.81.0-22';
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 = {
@@ -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
 
@@ -785,6 +785,8 @@
785
785
  throw new PipelineExecutionError("Parameter `{".concat(parameterName, "}` is not defined"));
786
786
  }
787
787
  parameterValue = valueToString(parameterValue);
788
+ // Escape curly braces in parameter values to prevent prompt-injection
789
+ parameterValue = parameterValue.replace(/[{}]/g, '\\$&');
788
790
  if (parameterValue.includes('\n') && /^\s*\W{0,3}\s*$/.test(precol)) {
789
791
  parameterValue = parameterValue
790
792
  .split('\n')
@@ -1524,7 +1526,7 @@
1524
1526
  prompt: computeUsage("$5.00 / 1M tokens"),
1525
1527
  output: computeUsage("$15.00 / 1M tokens"),
1526
1528
  },
1527
- //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
1528
1530
  },
1529
1531
  /**/
1530
1532
  /**/
@@ -2113,7 +2115,7 @@
2113
2115
  assistant_id: this.assistantId,
2114
2116
  thread: {
2115
2117
  messages: [
2116
- // TODO: [🗯] !! Allow threads to be passed
2118
+ // TODO: [🗯] Allow threads to be passed
2117
2119
  { role: 'user', content: rawPromptContent },
2118
2120
  ],
2119
2121
  },
@@ -2216,7 +2218,7 @@
2216
2218
  * @public exported from `@promptbook/openai`
2217
2219
  */
2218
2220
  var createOpenAiAssistantExecutionTools = Object.assign(function (options) {
2219
- // TODO: [🧠][main] !!!! If browser, auto add `dangerouslyAllowBrowser`
2221
+ // TODO: [🧠][main] !!4 If browser, auto add `dangerouslyAllowBrowser`
2220
2222
  if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
2221
2223
  options = __assign(__assign({}, options), { dangerouslyAllowBrowser: true });
2222
2224
  }
@@ -2236,7 +2238,7 @@
2236
2238
  * @public exported from `@promptbook/openai`
2237
2239
  */
2238
2240
  var createOpenAiExecutionTools = Object.assign(function (options) {
2239
- // TODO: [🧠][main] !!!! If browser, auto add `dangerouslyAllowBrowser`
2241
+ // TODO: [🧠][main] !!4 If browser, auto add `dangerouslyAllowBrowser`
2240
2242
  if (($isRunningInBrowser() || $isRunningInWebWorker()) && !options.dangerouslyAllowBrowser) {
2241
2243
  options = __assign(__assign({}, options), { dangerouslyAllowBrowser: true });
2242
2244
  }