only_ever_generator 8.4.6 → 8.4.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.
Files changed (118) hide show
  1. package/dist/bootstrap/app.d.ts +6 -3
  2. package/dist/bootstrap/app.d.ts.map +1 -1
  3. package/dist/bootstrap/app.js +11 -17
  4. package/dist/bootstrap/app.js.map +1 -1
  5. package/dist/card_gen/generate_cards.d.ts +2 -3
  6. package/dist/card_gen/generate_cards.d.ts.map +1 -1
  7. package/dist/card_gen/generate_cards.js +22 -15
  8. package/dist/card_gen/generate_cards.js.map +1 -1
  9. package/dist/constants/prompt_data.d.ts +4 -4
  10. package/dist/constants/prompt_data.js +302 -302
  11. package/dist/constants/prompts/card_gen_prompt.js +160 -160
  12. package/dist/constants/prompts/typology_prompt.js +131 -131
  13. package/dist/constants/source_data.d.ts +171 -171
  14. package/dist/constants/source_data.js +973 -973
  15. package/dist/embedding_generation/local_consolidation.js +104 -104
  16. package/dist/helper/build_concept_facts_schema.d.ts +42 -42
  17. package/dist/helper/build_concept_facts_schema.js +44 -44
  18. package/dist/helper/qdrant_db_methods.d.ts.map +1 -1
  19. package/dist/helper/schema_helper/build_card_schema.d.ts +1 -9
  20. package/dist/helper/schema_helper/build_card_schema.d.ts.map +1 -1
  21. package/dist/helper/schema_helper/build_card_schema.js +47 -50
  22. package/dist/helper/schema_helper/build_card_schema.js.map +1 -1
  23. package/dist/helper/schema_helper/build_concept_facts_schema.d.ts +1 -1
  24. package/dist/helper/schema_helper/build_concept_facts_schema.d.ts.map +1 -1
  25. package/dist/helper/schema_helper/build_concept_facts_schema.js +20 -5
  26. package/dist/helper/schema_helper/build_concept_facts_schema.js.map +1 -1
  27. package/dist/helper/schema_helper/build_summary_schema.d.ts +1 -1
  28. package/dist/helper/schema_helper/build_summary_schema.d.ts.map +1 -1
  29. package/dist/helper/schema_helper/build_summary_schema.js +18 -7
  30. package/dist/helper/schema_helper/build_summary_schema.js.map +1 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +5 -5
  33. package/dist/index.js.map +1 -1
  34. package/dist/parse/response_format_card.d.ts +176 -176
  35. package/dist/parse/response_format_card.js +371 -371
  36. package/dist/parse/response_format_typology.d.ts +1 -1
  37. package/dist/parse/response_format_typology.js +46 -46
  38. package/dist/services/get_prompts.d.ts +8 -7
  39. package/dist/services/get_prompts.d.ts.map +1 -1
  40. package/dist/services/get_prompts.js +69 -21
  41. package/dist/services/get_prompts.js.map +1 -1
  42. package/dist/typology_gen/generate_concept_facts.d.ts +2 -3
  43. package/dist/typology_gen/generate_concept_facts.d.ts.map +1 -1
  44. package/dist/typology_gen/generate_concept_facts.js +25 -15
  45. package/dist/typology_gen/generate_concept_facts.js.map +1 -1
  46. package/dist/typology_gen/generate_typology.d.ts +2 -1
  47. package/dist/typology_gen/generate_typology.d.ts.map +1 -1
  48. package/dist/typology_gen/generate_typology.js +24 -13
  49. package/dist/typology_gen/generate_typology.js.map +1 -1
  50. package/dist/typology_gen/summarize.d.ts +2 -3
  51. package/dist/typology_gen/summarize.d.ts.map +1 -1
  52. package/dist/typology_gen/summarize.js +24 -13
  53. package/dist/typology_gen/summarize.js.map +1 -1
  54. package/package.json +39 -38
  55. package/src/bootstrap/app.ts +418 -416
  56. package/src/card_gen/generate_cards.ts +347 -345
  57. package/src/config.ts +11 -11
  58. package/src/constants/api_constants.ts +7 -7
  59. package/src/constants/prompts/card_gen_prompt.ts +164 -164
  60. package/src/constants/prompts/typology_prompt.ts +139 -139
  61. package/src/embedding_generation/consolidation/global_consolidation.ts +96 -96
  62. package/src/embedding_generation/consolidation/local_consolidation.ts +141 -141
  63. package/src/embedding_generation/consolidation/write_consolidated_data.ts +98 -98
  64. package/src/embedding_generation/generate_embeddings.ts +42 -42
  65. package/src/embedding_generation/parse_embedding_response.ts +31 -31
  66. package/src/enums/card_type_enum.ts +6 -6
  67. package/src/gap_fill/calculate_gap_fill.ts +50 -50
  68. package/src/helper/get_id_from_title.ts +33 -33
  69. package/src/helper/mongo_helper.ts +29 -29
  70. package/src/helper/openai_helper.ts +20 -20
  71. package/src/helper/qdrant_db_methods.ts +77 -77
  72. package/src/helper/schema_helper/build_card_schema.ts +74 -98
  73. package/src/helper/schema_helper/build_classify_summarize_schema.ts +43 -43
  74. package/src/helper/schema_helper/build_concept_facts_schema.ts +45 -31
  75. package/src/helper/schema_helper/build_summary_schema.ts +43 -32
  76. package/src/index.ts +71 -73
  77. package/src/logger.ts +65 -65
  78. package/src/parse/parse_card/parse_cloze_card.ts +146 -146
  79. package/src/parse/parse_card/parse_flash_cards.ts +42 -42
  80. package/src/parse/parse_card/parse_match_card.ts +104 -104
  81. package/src/parse/parse_card/parse_mcq_card.ts +114 -114
  82. package/src/parse/parse_card_response.ts +197 -197
  83. package/src/parse/parse_source_content.ts +212 -212
  84. package/src/services/get_prompts.ts +164 -112
  85. package/src/services/open_ai_service.ts +89 -89
  86. package/src/services/qdrant_service.ts +10 -10
  87. package/src/types/base_param_type.ts +13 -13
  88. package/src/types/mongo_concept_fact_type.ts +12 -12
  89. package/src/types/parsed_card_type.ts +39 -39
  90. package/src/types/raw_card_response_types/generated_card_response_type.ts +59 -59
  91. package/src/types/source_taxonomy_type.ts +24 -24
  92. package/src/typology-parsed-response.ts +1932 -1932
  93. package/src/typology_gen/generate_concept_facts.ts +180 -169
  94. package/src/typology_gen/generate_typology.ts +203 -189
  95. package/src/typology_gen/summarize.ts +176 -164
  96. package/src/utils/distributed_quote_restoration.ts +80 -80
  97. package/src/utils/generate_args.ts +29 -29
  98. package/src/utils/parse_openai_response.ts +19 -19
  99. package/src/utils/sanitize_strings.ts +65 -65
  100. package/tsconfig.json +16 -16
  101. package/dist/constants/default_generation_variables.d.ts +0 -3
  102. package/dist/constants/default_generation_variables.d.ts.map +0 -1
  103. package/dist/constants/default_generation_variables.js +0 -580
  104. package/dist/constants/default_generation_variables.js.map +0 -1
  105. package/dist/services/prompts_test.d.ts +0 -10
  106. package/dist/services/prompts_test.d.ts.map +0 -1
  107. package/dist/services/prompts_test.js +0 -227
  108. package/dist/services/prompts_test.js.map +0 -1
  109. package/dist/types/generation_variables_schema.d.ts +0 -14
  110. package/dist/types/generation_variables_schema.d.ts.map +0 -1
  111. package/dist/types/generation_variables_schema.js +0 -3
  112. package/dist/types/generation_variables_schema.js.map +0 -1
  113. package/dist/utils/test.d.ts +0 -2
  114. package/dist/utils/test.d.ts.map +0 -1
  115. package/dist/utils/test.js +0 -5
  116. package/dist/utils/test.js.map +0 -1
  117. package/src/constants/default_generation_variables.ts +0 -624
  118. package/src/types/generation_variables_schema.ts +0 -16
@@ -1,65 +1,65 @@
1
- /**
2
- * Utility functions for sanitizing strings for OpenAI structured outputs
3
- * and restoring them back to their original form without requiring original mapping
4
- */
5
-
6
- // Use a unique, reversible encoding for quotes
7
- const QUOTE_PLACEHOLDER = "___QUOTE___";
8
-
9
- /**
10
- * Sanitizes an array of strings by replacing quotes with a safe placeholder
11
- * This approach is stateless and doesn't require storing mappings
12
- * @param strings - Array of strings to sanitize
13
- * @returns Array of sanitized strings
14
- */
15
- export function sanitizeStringsForSchema(strings: string[]): string[] {
16
- return strings.map((str) => str.replace(/"/g, QUOTE_PLACEHOLDER));
17
- }
18
-
19
- /**
20
- * Restores quotes in a string by replacing placeholders with actual quotes
21
- * This works without needing the original mapping
22
- * @param sanitizedString - String with quote placeholders
23
- * @returns Original string with quotes restored
24
- */
25
- export function restoreQuotesInString(sanitizedString: string): string {
26
- return sanitizedString.replace(new RegExp(QUOTE_PLACEHOLDER, "g"), '"');
27
- }
28
-
29
- /**
30
- * Recursively restores quotes in an object's string values
31
- * This works across Lambda functions without requiring original context
32
- * @param obj - Object to process
33
- * @returns Object with quotes restored
34
- */
35
- export function restoreQuotesInObject(obj: any): any {
36
- if (typeof obj === "string") {
37
- return restoreQuotesInString(obj);
38
- }
39
-
40
- if (Array.isArray(obj)) {
41
- return obj.map((item) => restoreQuotesInObject(item));
42
- }
43
-
44
- if (obj && typeof obj === "object") {
45
- const result: any = {};
46
- for (const [key, value] of Object.entries(obj)) {
47
- result[key] = restoreQuotesInObject(value);
48
- }
49
- return result;
50
- }
51
-
52
- return obj;
53
- }
54
-
55
- /**
56
- * Legacy function signature for backward compatibility
57
- * Now ignores the originalMapping parameter since it's not needed
58
- * @deprecated Use restoreQuotesInObject(obj) instead
59
- */
60
- export function restoreQuotesInObjectLegacy(
61
- obj: any,
62
- originalMapping?: Map<string, string>
63
- ): any {
64
- return restoreQuotesInObject(obj);
65
- }
1
+ /**
2
+ * Utility functions for sanitizing strings for OpenAI structured outputs
3
+ * and restoring them back to their original form without requiring original mapping
4
+ */
5
+
6
+ // Use a unique, reversible encoding for quotes
7
+ const QUOTE_PLACEHOLDER = "___QUOTE___";
8
+
9
+ /**
10
+ * Sanitizes an array of strings by replacing quotes with a safe placeholder
11
+ * This approach is stateless and doesn't require storing mappings
12
+ * @param strings - Array of strings to sanitize
13
+ * @returns Array of sanitized strings
14
+ */
15
+ export function sanitizeStringsForSchema(strings: string[]): string[] {
16
+ return strings.map((str) => str.replace(/"/g, QUOTE_PLACEHOLDER));
17
+ }
18
+
19
+ /**
20
+ * Restores quotes in a string by replacing placeholders with actual quotes
21
+ * This works without needing the original mapping
22
+ * @param sanitizedString - String with quote placeholders
23
+ * @returns Original string with quotes restored
24
+ */
25
+ export function restoreQuotesInString(sanitizedString: string): string {
26
+ return sanitizedString.replace(new RegExp(QUOTE_PLACEHOLDER, "g"), '"');
27
+ }
28
+
29
+ /**
30
+ * Recursively restores quotes in an object's string values
31
+ * This works across Lambda functions without requiring original context
32
+ * @param obj - Object to process
33
+ * @returns Object with quotes restored
34
+ */
35
+ export function restoreQuotesInObject(obj: any): any {
36
+ if (typeof obj === "string") {
37
+ return restoreQuotesInString(obj);
38
+ }
39
+
40
+ if (Array.isArray(obj)) {
41
+ return obj.map((item) => restoreQuotesInObject(item));
42
+ }
43
+
44
+ if (obj && typeof obj === "object") {
45
+ const result: any = {};
46
+ for (const [key, value] of Object.entries(obj)) {
47
+ result[key] = restoreQuotesInObject(value);
48
+ }
49
+ return result;
50
+ }
51
+
52
+ return obj;
53
+ }
54
+
55
+ /**
56
+ * Legacy function signature for backward compatibility
57
+ * Now ignores the originalMapping parameter since it's not needed
58
+ * @deprecated Use restoreQuotesInObject(obj) instead
59
+ */
60
+ export function restoreQuotesInObjectLegacy(
61
+ obj: any,
62
+ originalMapping?: Map<string, string>
63
+ ): any {
64
+ return restoreQuotesInObject(obj);
65
+ }
package/tsconfig.json CHANGED
@@ -1,17 +1,17 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
4
- "module": "commonjs" /* Specify what module code is generated. */,
5
- "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
6
- "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
7
- "strict": true,
8
- "declaration": true,
9
- "declarationMap": true,
10
- "emitDeclarationOnly": false,
11
- "rootDir": "./src",
12
- "outDir": "./dist", /* Enable all strict type-checking options. */
13
- "sourceMap": true
14
- },
15
- "include": ["src/**/*"],
16
- "exclude": ["node_modules", "**/*.test.ts"]
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
4
+ "module": "commonjs" /* Specify what module code is generated. */,
5
+ "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
6
+ "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
7
+ "strict": true,
8
+ "declaration": true,
9
+ "declarationMap": true,
10
+ "emitDeclarationOnly": false,
11
+ "rootDir": "./src",
12
+ "outDir": "./dist", /* Enable all strict type-checking options. */
13
+ "sourceMap": true
14
+ },
15
+ "include": ["src/**/*"],
16
+ "exclude": ["node_modules", "**/*.test.ts"]
17
17
  }
@@ -1,3 +0,0 @@
1
- import { GenerationVariablesSchema } from "../types/generation_variables_schema";
2
- export declare const defaultGenerationVariables: GenerationVariablesSchema;
3
- //# sourceMappingURL=default_generation_variables.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"default_generation_variables.d.ts","sourceRoot":"","sources":["../../src/constants/default_generation_variables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,eAAO,MAAM,0BAA0B,EAAE,yBA6mBxC,CAAC"}