@promptbook/utils 0.50.0-9 → 0.51.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 (49) hide show
  1. package/esm/index.es.js +189 -72
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/_packages/execute-javascript.index.d.ts +44 -1
  4. package/esm/typings/_packages/openai.index.d.ts +2 -1
  5. package/esm/typings/_packages/types.index.d.ts +3 -2
  6. package/esm/typings/_packages/utils.index.d.ts +9 -2
  7. package/esm/typings/conversion/utils/extractParametersFromPromptTemplate.d.ts +13 -0
  8. package/esm/typings/conversion/utils/extractParametersFromPromptTemplate.test.d.ts +1 -0
  9. package/esm/typings/conversion/utils/extractVariables.d.ts +4 -3
  10. package/esm/typings/execution/ExecutionTools.d.ts +3 -1
  11. package/esm/typings/execution/PromptbookExecutor.d.ts +1 -1
  12. package/esm/typings/execution/plugins/llm-execution-tools/openai/computeOpenaiUsage.d.ts +0 -3
  13. package/esm/typings/execution/plugins/llm-execution-tools/openai/computeUsage.d.ts +13 -0
  14. package/esm/typings/execution/plugins/llm-execution-tools/openai/computeUsage.test.d.ts +1 -0
  15. package/esm/typings/execution/plugins/llm-execution-tools/openai/models.d.ts +25 -0
  16. package/esm/typings/types/ModelRequirements.d.ts +1 -0
  17. package/esm/typings/types/PromptbookJson/PromptTemplateJson.d.ts +2 -1
  18. package/esm/typings/utils/extractParameters.d.ts +1 -3
  19. package/esm/typings/utils/sets/difference.d.ts +4 -0
  20. package/esm/typings/utils/sets/difference.test.d.ts +1 -0
  21. package/esm/typings/utils/sets/intersection.d.ts +4 -0
  22. package/esm/typings/utils/sets/intersection.test.d.ts +1 -0
  23. package/esm/typings/utils/sets/union.d.ts +4 -0
  24. package/esm/typings/utils/sets/union.test.d.ts +1 -0
  25. package/package.json +1 -1
  26. package/umd/index.umd.js +194 -71
  27. package/umd/index.umd.js.map +1 -1
  28. package/umd/typings/_packages/execute-javascript.index.d.ts +44 -1
  29. package/umd/typings/_packages/openai.index.d.ts +2 -1
  30. package/umd/typings/_packages/types.index.d.ts +3 -2
  31. package/umd/typings/_packages/utils.index.d.ts +9 -2
  32. package/umd/typings/conversion/utils/extractParametersFromPromptTemplate.d.ts +13 -0
  33. package/umd/typings/conversion/utils/extractParametersFromPromptTemplate.test.d.ts +1 -0
  34. package/umd/typings/conversion/utils/extractVariables.d.ts +4 -3
  35. package/umd/typings/execution/ExecutionTools.d.ts +3 -1
  36. package/umd/typings/execution/PromptbookExecutor.d.ts +1 -1
  37. package/umd/typings/execution/plugins/llm-execution-tools/openai/computeOpenaiUsage.d.ts +0 -3
  38. package/umd/typings/execution/plugins/llm-execution-tools/openai/computeUsage.d.ts +13 -0
  39. package/umd/typings/execution/plugins/llm-execution-tools/openai/computeUsage.test.d.ts +1 -0
  40. package/umd/typings/execution/plugins/llm-execution-tools/openai/models.d.ts +25 -0
  41. package/umd/typings/types/ModelRequirements.d.ts +1 -0
  42. package/umd/typings/types/PromptbookJson/PromptTemplateJson.d.ts +2 -1
  43. package/umd/typings/utils/extractParameters.d.ts +1 -3
  44. package/umd/typings/utils/sets/difference.d.ts +4 -0
  45. package/umd/typings/utils/sets/difference.test.d.ts +1 -0
  46. package/umd/typings/utils/sets/intersection.d.ts +4 -0
  47. package/umd/typings/utils/sets/intersection.test.d.ts +1 -0
  48. package/umd/typings/utils/sets/union.d.ts +4 -0
  49. package/umd/typings/utils/sets/union.test.d.ts +1 -0
@@ -0,0 +1,25 @@
1
+ import { number_usd } from '../../../../types/typeAliases';
2
+ import type { AvailableModel } from '../../../LlmExecutionTools';
3
+ /**
4
+ * List of available OpenAI models with pricing
5
+ *
6
+ * Note: Done at 2024-05-20
7
+ *
8
+ * @see https://platform.openai.com/docs/models/
9
+ * @see https://openai.com/api/pricing/
10
+ */
11
+ export declare const OPENAI_MODELS: Array<AvailableModel & {
12
+ pricing?: {
13
+ prompt: number_usd;
14
+ output: number_usd;
15
+ };
16
+ }>;
17
+ /**
18
+ * TODO: [🧠] Some mechanism to propagate unsureness
19
+ * TODO: [🕚] Make this list dynamic - dynamically can be listed modelNames but not modelVariant, legacy status, context length and pricing
20
+ * @see https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4
21
+ * @see https://openai.com/api/pricing/
22
+ * @see /other/playground/playground.ts
23
+ * TODO: [🍓] Make better
24
+ * TODO: Change model titles to human eg: "gpt-4-turbo-2024-04-09" -> "GPT-4 Turbo (2024-04-09)"
25
+ */
@@ -39,4 +39,5 @@ export type ModelRequirements = {
39
39
  /**
40
40
  * TODO: Maybe figure out better word than "variant"
41
41
  * TODO: Add here more requirement options like max context size, max tokens, etc.
42
+ * TODO: [👙][🧠] Just selecting gpt3 or gpt4 level of model
42
43
  */
@@ -32,7 +32,7 @@ export type Expectations = Partial<Record<Lowercase<ExpectationUnit>, {
32
32
  /**
33
33
  * Units of text measurement
34
34
  */
35
- export declare const EXPECTATION_UNITS: readonly ["CHARACTERS", "WORDS", "SENTENCES", "PARAGRAPHS", "LINES", "PAGES"];
35
+ export declare const EXPECTATION_UNITS: readonly ["CHARACTERS", "WORDS", "SENTENCES", "LINES", "PARAGRAPHS", "PAGES"];
36
36
  /**
37
37
  * Unit of text measurement
38
38
  */
@@ -133,4 +133,5 @@ export {};
133
133
  /**
134
134
  * TODO: [💝] Unite object for expecting amount and format - remove expectFormat
135
135
  * TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
136
+ * TODO: [👙][🧠] Just selecting gpt3 or gpt4 level of model
136
137
  */
@@ -4,7 +4,5 @@ import { string_name, string_template } from '../types/typeAliases';
4
4
  *
5
5
  * @param template the template with parameters in {curly} braces
6
6
  * @returns the list of parameter names
7
- *
8
- * @private within the library
9
7
  */
10
- export declare function extractParameters(template: string_template): Array<string_name>;
8
+ export declare function extractParameters(template: string_template): Set<string_name>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Create difference set of two sets.
3
+ */
4
+ export declare function difference<TItem>(a: Set<TItem>, b: Set<TItem>, isEqual?: (a: TItem, b: TItem) => boolean): Set<TItem>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Creates a new set with all elements that are present in all sets
3
+ */
4
+ export declare function intersection<TItem>(...sets: Array<Set<TItem>>): Set<TItem>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Creates a new set with all elements that are present in either set
3
+ */
4
+ export declare function union<TItem>(...sets: Array<Set<TItem>>): Set<TItem>;
@@ -0,0 +1 @@
1
+ export {};