@promptbook/openai 0.43.0 → 0.44.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 (67) hide show
  1. package/esm/typings/_packages/utils.index.d.ts +19 -1
  2. package/esm/typings/utils/normalization/DIACRITIC_VARIANTS_LETTERS.d.ts +10 -0
  3. package/esm/typings/utils/normalization/IKeywords.d.ts +18 -0
  4. package/esm/typings/utils/normalization/capitalize.d.ts +5 -0
  5. package/esm/typings/utils/normalization/capitalize.test.d.ts +1 -0
  6. package/esm/typings/utils/normalization/decapitalize.d.ts +5 -0
  7. package/esm/typings/utils/normalization/decapitalize.test.d.ts +1 -0
  8. package/esm/typings/utils/normalization/isValidKeyword.d.ts +8 -0
  9. package/esm/typings/utils/normalization/isValidKeyword.test.d.ts +1 -0
  10. package/esm/typings/utils/normalization/nameToUriPart.d.ts +1 -0
  11. package/esm/typings/utils/normalization/nameToUriPart.test.d.ts +1 -0
  12. package/esm/typings/utils/normalization/nameToUriParts.d.ts +1 -0
  13. package/esm/typings/utils/normalization/nameToUriParts.test.d.ts +1 -0
  14. package/esm/typings/utils/normalization/normalize-to-kebab-case.d.ts +1 -0
  15. package/esm/typings/utils/normalization/normalize-to-kebab-case.test.d.ts +1 -0
  16. package/esm/typings/utils/normalization/normalizeTo_PascalCase.d.ts +1 -0
  17. package/esm/typings/utils/normalization/normalizeTo_PascalCase.test.d.ts +1 -0
  18. package/esm/typings/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +4 -0
  19. package/esm/typings/utils/normalization/normalizeTo_SCREAMING_CASE.test.d.ts +1 -0
  20. package/esm/typings/utils/normalization/normalizeTo_camelCase.d.ts +4 -0
  21. package/esm/typings/utils/normalization/normalizeTo_camelCase.test.d.ts +1 -0
  22. package/esm/typings/utils/normalization/normalizeTo_snake_case.d.ts +1 -0
  23. package/esm/typings/utils/normalization/normalizeTo_snake_case.test.d.ts +1 -0
  24. package/esm/typings/utils/normalization/normalizeWhitespaces.d.ts +4 -0
  25. package/esm/typings/utils/normalization/normalizeWhitespaces.test.d.ts +1 -0
  26. package/esm/typings/utils/normalization/parseKeywords.d.ts +14 -0
  27. package/esm/typings/utils/normalization/parseKeywords.test.d.ts +1 -0
  28. package/esm/typings/utils/normalization/parseKeywordsFromString.d.ts +8 -0
  29. package/esm/typings/utils/normalization/parseKeywordsFromString.test.d.ts +1 -0
  30. package/esm/typings/utils/normalization/removeDiacritics.d.ts +4 -0
  31. package/esm/typings/utils/normalization/removeDiacritics.test.d.ts +1 -0
  32. package/esm/typings/utils/normalization/searchKeywords.d.ts +5 -0
  33. package/esm/typings/utils/normalization/searchKeywords.test.d.ts +1 -0
  34. package/package.json +2 -2
  35. package/umd/typings/_packages/utils.index.d.ts +19 -1
  36. package/umd/typings/utils/normalization/DIACRITIC_VARIANTS_LETTERS.d.ts +10 -0
  37. package/umd/typings/utils/normalization/IKeywords.d.ts +18 -0
  38. package/umd/typings/utils/normalization/capitalize.d.ts +5 -0
  39. package/umd/typings/utils/normalization/capitalize.test.d.ts +1 -0
  40. package/umd/typings/utils/normalization/decapitalize.d.ts +5 -0
  41. package/umd/typings/utils/normalization/decapitalize.test.d.ts +1 -0
  42. package/umd/typings/utils/normalization/isValidKeyword.d.ts +8 -0
  43. package/umd/typings/utils/normalization/isValidKeyword.test.d.ts +1 -0
  44. package/umd/typings/utils/normalization/nameToUriPart.d.ts +1 -0
  45. package/umd/typings/utils/normalization/nameToUriPart.test.d.ts +1 -0
  46. package/umd/typings/utils/normalization/nameToUriParts.d.ts +1 -0
  47. package/umd/typings/utils/normalization/nameToUriParts.test.d.ts +1 -0
  48. package/umd/typings/utils/normalization/normalize-to-kebab-case.d.ts +1 -0
  49. package/umd/typings/utils/normalization/normalize-to-kebab-case.test.d.ts +1 -0
  50. package/umd/typings/utils/normalization/normalizeTo_PascalCase.d.ts +1 -0
  51. package/umd/typings/utils/normalization/normalizeTo_PascalCase.test.d.ts +1 -0
  52. package/umd/typings/utils/normalization/normalizeTo_SCREAMING_CASE.d.ts +4 -0
  53. package/umd/typings/utils/normalization/normalizeTo_SCREAMING_CASE.test.d.ts +1 -0
  54. package/umd/typings/utils/normalization/normalizeTo_camelCase.d.ts +4 -0
  55. package/umd/typings/utils/normalization/normalizeTo_camelCase.test.d.ts +1 -0
  56. package/umd/typings/utils/normalization/normalizeTo_snake_case.d.ts +1 -0
  57. package/umd/typings/utils/normalization/normalizeTo_snake_case.test.d.ts +1 -0
  58. package/umd/typings/utils/normalization/normalizeWhitespaces.d.ts +4 -0
  59. package/umd/typings/utils/normalization/normalizeWhitespaces.test.d.ts +1 -0
  60. package/umd/typings/utils/normalization/parseKeywords.d.ts +14 -0
  61. package/umd/typings/utils/normalization/parseKeywords.test.d.ts +1 -0
  62. package/umd/typings/utils/normalization/parseKeywordsFromString.d.ts +8 -0
  63. package/umd/typings/utils/normalization/parseKeywordsFromString.test.d.ts +1 -0
  64. package/umd/typings/utils/normalization/removeDiacritics.d.ts +4 -0
  65. package/umd/typings/utils/normalization/removeDiacritics.test.d.ts +1 -0
  66. package/umd/typings/utils/normalization/searchKeywords.d.ts +5 -0
  67. package/umd/typings/utils/normalization/searchKeywords.test.d.ts +1 -0
@@ -2,8 +2,8 @@ import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptb
2
2
  import { parseNumber } from '../conversion/utils/parseNumber';
3
3
  import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
4
4
  import { replaceParameters } from '../execution/utils/replaceParameters';
5
- import { ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults } from '../types/execution-report/ExecutionReportStringOptions';
6
5
  import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
6
+ import { ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults } from '../types/execution-report/ExecutionReportStringOptions';
7
7
  import { CountUtils } from '../utils/expectation-counters';
8
8
  import { countCharacters } from '../utils/expectation-counters/countCharacters';
9
9
  import { countLines } from '../utils/expectation-counters/countLines';
@@ -27,6 +27,24 @@ export { assertsExecutionSuccessful, countCharacters, countLines, countPages, co
27
27
  extractAllListItemsFromMarkdown, extractBlock, // <- [🌻]
28
28
  extractOneBlockFromMarkdown, isValidJsonString, parseNumber, // <- [🌻]
29
29
  prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
30
+ import { capitalize } from '../utils/normalization/capitalize';
31
+ import { decapitalize } from '../utils/normalization/decapitalize';
32
+ import { DIACRITIC_VARIANTS_LETTERS } from '../utils/normalization/DIACRITIC_VARIANTS_LETTERS';
33
+ import { IKeywords, string_keyword } from '../utils/normalization/IKeywords';
34
+ import { isValidKeyword } from '../utils/normalization/isValidKeyword';
35
+ import { nameToUriPart } from '../utils/normalization/nameToUriPart';
36
+ import { nameToUriParts } from '../utils/normalization/nameToUriParts';
37
+ import { normalizeToKebabCase } from '../utils/normalization/normalize-to-kebab-case';
38
+ import { normalizeTo_camelCase } from '../utils/normalization/normalizeTo_camelCase';
39
+ import { normalizeTo_PascalCase } from '../utils/normalization/normalizeTo_PascalCase';
40
+ import { normalizeTo_SCREAMING_CASE } from '../utils/normalization/normalizeTo_SCREAMING_CASE';
41
+ import { normalizeTo_snake_case } from '../utils/normalization/normalizeTo_snake_case';
42
+ import { normalizeWhitespaces } from '../utils/normalization/normalizeWhitespaces';
43
+ import { parseKeywords } from '../utils/normalization/parseKeywords';
44
+ import { parseKeywordsFromString } from '../utils/normalization/parseKeywordsFromString';
45
+ import { removeDiacritics } from '../utils/normalization/removeDiacritics';
46
+ import { searchKeywords } from '../utils/normalization/searchKeywords';
47
+ export { capitalize, decapitalize, DIACRITIC_VARIANTS_LETTERS, IKeywords, isValidKeyword, nameToUriPart, nameToUriParts, normalizeTo_camelCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_snake_case, normalizeToKebabCase, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, removeDiacritics, searchKeywords, string_keyword, };
30
48
  /**
31
49
  * TODO: [🧠] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
32
50
  */
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Map of letters from diacritic variant to diacritless variant
3
+ * Contains lowercase and uppercase separatelly
4
+ *
5
+ * > "á" => "a"
6
+ * > "ě" => "e"
7
+ * > "Ă" => "A"
8
+ * > ...
9
+ */
10
+ export declare const DIACRITIC_VARIANTS_LETTERS: Record<string, string>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Semantic helper
3
+ *
4
+ * Keyword is string without diacritics in lowercase [a-z1-9]
5
+ * Words are splitted between multiple keywords @see IKeywords
6
+ *
7
+ * For example `"keyword"`
8
+ */
9
+ export type string_keyword = string;
10
+ /**
11
+ * Semantic helper
12
+ * Set of keywords @see string_keyword
13
+ *
14
+ */
15
+ export type IKeywords = Set<string_keyword>;
16
+ /**
17
+ * TODO: [🌮] Keywords with weight
18
+ */
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Makes first letter of a string uppercase
3
+ *
4
+ */
5
+ export declare function capitalize(word: string): string;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Makes first letter of a string uppercase
3
+ *
4
+ */
5
+ export declare function decapitalize(word: string): string;
@@ -0,0 +1,8 @@
1
+ import { string_keyword } from './IKeywords';
2
+ /**
3
+ * Tests if keyword is valid
4
+ *
5
+ * @param keyword to test
6
+ * @returns if keyword is valid or not
7
+ */
8
+ export declare function isValidKeyword(keyword: string): keyword is string_keyword;
@@ -0,0 +1 @@
1
+ export declare function nameToUriPart(name: string): string;
@@ -0,0 +1 @@
1
+ export declare function nameToUriParts(name: string): string[];
@@ -0,0 +1 @@
1
+ export declare function normalizeToKebabCase(sentence: string): string;
@@ -0,0 +1 @@
1
+ export declare function normalizeTo_PascalCase(sentence: string): string;
@@ -0,0 +1,4 @@
1
+ export declare function normalizeTo_SCREAMING_CASE(sentence: string): string;
2
+ /**
3
+ * TODO: [🌺] Use some intermediate util splitWords
4
+ */
@@ -0,0 +1,4 @@
1
+ export declare function normalizeTo_camelCase(sentence: string, __firstLetterCapital?: boolean): string;
2
+ /**
3
+ * TODO: [🌺] Use some intermediate util splitWords
4
+ */
@@ -0,0 +1 @@
1
+ export declare function normalizeTo_snake_case(sentence: string): string;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Take every whitespace (space, new line, tab) and replace it with a single space.
3
+ */
4
+ export declare function normalizeWhitespaces(sentence: string): string;
@@ -0,0 +1,14 @@
1
+ import { IKeywords } from './IKeywords';
2
+ /**
3
+ * Parses keywords from any object and recursively walks through
4
+ *
5
+ * Tip: If you want to parse multiple inputs, just wrap them in an array
6
+ *
7
+ * @param input of any kind
8
+ * @returns {Set} of keywords without diacritics in lowercase
9
+ */
10
+ export declare function parseKeywords(input: unknown): IKeywords;
11
+ /**
12
+ * Note: Not using spread in input param because of keeping second parameter for options
13
+ * TODO: [🌺] Use some intermediate util splitWords
14
+ */
@@ -0,0 +1,8 @@
1
+ import { IKeywords } from './IKeywords';
2
+ /**
3
+ * Parses keywords from a string
4
+ *
5
+ * @param {string} input
6
+ * @returns {Set} of keywords without diacritics in lowercase
7
+ */
8
+ export declare function parseKeywordsFromString(input: string): IKeywords;
@@ -0,0 +1,4 @@
1
+ /**
2
+ *
3
+ */
4
+ export declare function removeDiacritics(input: string): string;
@@ -0,0 +1,5 @@
1
+ import { IKeywords } from './IKeywords';
2
+ /**
3
+ *
4
+ */
5
+ export declare function searchKeywords(haystack: IKeywords, needle: IKeywords): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/openai",
3
- "version": "0.43.0",
3
+ "version": "0.44.0-0",
4
4
  "description": "Library to supercharge your use of large language models",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -38,7 +38,7 @@
38
38
  "openai": "4.2.0"
39
39
  },
40
40
  "peerDependencies": {
41
- "@promptbook/core": "0.43.0"
41
+ "@promptbook/core": "0.44.0-0"
42
42
  },
43
43
  "main": "./umd/index.umd.js",
44
44
  "module": "./esm/index.es.js",
@@ -2,8 +2,8 @@ import { prettifyPromptbookString } from '../conversion/prettify/prettifyPromptb
2
2
  import { parseNumber } from '../conversion/utils/parseNumber';
3
3
  import { assertsExecutionSuccessful } from '../execution/assertsExecutionSuccessful';
4
4
  import { replaceParameters } from '../execution/utils/replaceParameters';
5
- import { ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults } from '../types/execution-report/ExecutionReportStringOptions';
6
5
  import { executionReportJsonToString } from '../types/execution-report/executionReportJsonToString';
6
+ import { ExecutionReportStringOptions, ExecutionReportStringOptionsDefaults } from '../types/execution-report/ExecutionReportStringOptions';
7
7
  import { CountUtils } from '../utils/expectation-counters';
8
8
  import { countCharacters } from '../utils/expectation-counters/countCharacters';
9
9
  import { countLines } from '../utils/expectation-counters/countLines';
@@ -27,6 +27,24 @@ export { assertsExecutionSuccessful, countCharacters, countLines, countPages, co
27
27
  extractAllListItemsFromMarkdown, extractBlock, // <- [🌻]
28
28
  extractOneBlockFromMarkdown, isValidJsonString, parseNumber, // <- [🌻]
29
29
  prettifyPromptbookString, removeContentComments, removeEmojis, removeMarkdownFormatting, removeQuotes, replaceParameters, trimCodeBlock, trimEndOfCodeBlock, unwrapResult, };
30
+ import { capitalize } from '../utils/normalization/capitalize';
31
+ import { decapitalize } from '../utils/normalization/decapitalize';
32
+ import { DIACRITIC_VARIANTS_LETTERS } from '../utils/normalization/DIACRITIC_VARIANTS_LETTERS';
33
+ import { IKeywords, string_keyword } from '../utils/normalization/IKeywords';
34
+ import { isValidKeyword } from '../utils/normalization/isValidKeyword';
35
+ import { nameToUriPart } from '../utils/normalization/nameToUriPart';
36
+ import { nameToUriParts } from '../utils/normalization/nameToUriParts';
37
+ import { normalizeToKebabCase } from '../utils/normalization/normalize-to-kebab-case';
38
+ import { normalizeTo_camelCase } from '../utils/normalization/normalizeTo_camelCase';
39
+ import { normalizeTo_PascalCase } from '../utils/normalization/normalizeTo_PascalCase';
40
+ import { normalizeTo_SCREAMING_CASE } from '../utils/normalization/normalizeTo_SCREAMING_CASE';
41
+ import { normalizeTo_snake_case } from '../utils/normalization/normalizeTo_snake_case';
42
+ import { normalizeWhitespaces } from '../utils/normalization/normalizeWhitespaces';
43
+ import { parseKeywords } from '../utils/normalization/parseKeywords';
44
+ import { parseKeywordsFromString } from '../utils/normalization/parseKeywordsFromString';
45
+ import { removeDiacritics } from '../utils/normalization/removeDiacritics';
46
+ import { searchKeywords } from '../utils/normalization/searchKeywords';
47
+ export { capitalize, decapitalize, DIACRITIC_VARIANTS_LETTERS, IKeywords, isValidKeyword, nameToUriPart, nameToUriParts, normalizeTo_camelCase, normalizeTo_PascalCase, normalizeTo_SCREAMING_CASE, normalizeTo_snake_case, normalizeToKebabCase, normalizeWhitespaces, parseKeywords, parseKeywordsFromString, removeDiacritics, searchKeywords, string_keyword, };
30
48
  /**
31
49
  * TODO: [🧠] Maybe create some indipendent package like `markdown-tools` from both here exported and @private utilities
32
50
  */
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Map of letters from diacritic variant to diacritless variant
3
+ * Contains lowercase and uppercase separatelly
4
+ *
5
+ * > "á" => "a"
6
+ * > "ě" => "e"
7
+ * > "Ă" => "A"
8
+ * > ...
9
+ */
10
+ export declare const DIACRITIC_VARIANTS_LETTERS: Record<string, string>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Semantic helper
3
+ *
4
+ * Keyword is string without diacritics in lowercase [a-z1-9]
5
+ * Words are splitted between multiple keywords @see IKeywords
6
+ *
7
+ * For example `"keyword"`
8
+ */
9
+ export type string_keyword = string;
10
+ /**
11
+ * Semantic helper
12
+ * Set of keywords @see string_keyword
13
+ *
14
+ */
15
+ export type IKeywords = Set<string_keyword>;
16
+ /**
17
+ * TODO: [🌮] Keywords with weight
18
+ */
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Makes first letter of a string uppercase
3
+ *
4
+ */
5
+ export declare function capitalize(word: string): string;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Makes first letter of a string uppercase
3
+ *
4
+ */
5
+ export declare function decapitalize(word: string): string;
@@ -0,0 +1,8 @@
1
+ import { string_keyword } from './IKeywords';
2
+ /**
3
+ * Tests if keyword is valid
4
+ *
5
+ * @param keyword to test
6
+ * @returns if keyword is valid or not
7
+ */
8
+ export declare function isValidKeyword(keyword: string): keyword is string_keyword;
@@ -0,0 +1 @@
1
+ export declare function nameToUriPart(name: string): string;
@@ -0,0 +1 @@
1
+ export declare function nameToUriParts(name: string): string[];
@@ -0,0 +1 @@
1
+ export declare function normalizeToKebabCase(sentence: string): string;
@@ -0,0 +1 @@
1
+ export declare function normalizeTo_PascalCase(sentence: string): string;
@@ -0,0 +1,4 @@
1
+ export declare function normalizeTo_SCREAMING_CASE(sentence: string): string;
2
+ /**
3
+ * TODO: [🌺] Use some intermediate util splitWords
4
+ */
@@ -0,0 +1,4 @@
1
+ export declare function normalizeTo_camelCase(sentence: string, __firstLetterCapital?: boolean): string;
2
+ /**
3
+ * TODO: [🌺] Use some intermediate util splitWords
4
+ */
@@ -0,0 +1 @@
1
+ export declare function normalizeTo_snake_case(sentence: string): string;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Take every whitespace (space, new line, tab) and replace it with a single space.
3
+ */
4
+ export declare function normalizeWhitespaces(sentence: string): string;
@@ -0,0 +1,14 @@
1
+ import { IKeywords } from './IKeywords';
2
+ /**
3
+ * Parses keywords from any object and recursively walks through
4
+ *
5
+ * Tip: If you want to parse multiple inputs, just wrap them in an array
6
+ *
7
+ * @param input of any kind
8
+ * @returns {Set} of keywords without diacritics in lowercase
9
+ */
10
+ export declare function parseKeywords(input: unknown): IKeywords;
11
+ /**
12
+ * Note: Not using spread in input param because of keeping second parameter for options
13
+ * TODO: [🌺] Use some intermediate util splitWords
14
+ */
@@ -0,0 +1,8 @@
1
+ import { IKeywords } from './IKeywords';
2
+ /**
3
+ * Parses keywords from a string
4
+ *
5
+ * @param {string} input
6
+ * @returns {Set} of keywords without diacritics in lowercase
7
+ */
8
+ export declare function parseKeywordsFromString(input: string): IKeywords;
@@ -0,0 +1,4 @@
1
+ /**
2
+ *
3
+ */
4
+ export declare function removeDiacritics(input: string): string;
@@ -0,0 +1,5 @@
1
+ import { IKeywords } from './IKeywords';
2
+ /**
3
+ *
4
+ */
5
+ export declare function searchKeywords(haystack: IKeywords, needle: IKeywords): boolean;