only_ever_generator 8.6.0 → 8.6.1

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 (72) hide show
  1. package/dist/bootstrap/app.d.ts +3 -6
  2. package/dist/bootstrap/app.d.ts.map +1 -1
  3. package/dist/bootstrap/app.js +19 -12
  4. package/dist/bootstrap/app.js.map +1 -1
  5. package/dist/card_gen/generate_cards.d.ts +3 -2
  6. package/dist/card_gen/generate_cards.d.ts.map +1 -1
  7. package/dist/card_gen/generate_cards.js +15 -9
  8. package/dist/card_gen/generate_cards.js.map +1 -1
  9. package/dist/constants/default_generation_variables.d.ts +3 -0
  10. package/dist/constants/default_generation_variables.d.ts.map +1 -0
  11. package/dist/constants/default_generation_variables.js +587 -0
  12. package/dist/constants/default_generation_variables.js.map +1 -0
  13. package/dist/helper/schema_helper/build_card_schema.d.ts +9 -1
  14. package/dist/helper/schema_helper/build_card_schema.d.ts.map +1 -1
  15. package/dist/helper/schema_helper/build_card_schema.js +50 -47
  16. package/dist/helper/schema_helper/build_card_schema.js.map +1 -1
  17. package/dist/helper/schema_helper/build_concept_facts_schema.d.ts +1 -1
  18. package/dist/helper/schema_helper/build_concept_facts_schema.d.ts.map +1 -1
  19. package/dist/helper/schema_helper/build_concept_facts_schema.js +5 -20
  20. package/dist/helper/schema_helper/build_concept_facts_schema.js.map +1 -1
  21. package/dist/helper/schema_helper/build_summary_schema.d.ts +1 -1
  22. package/dist/helper/schema_helper/build_summary_schema.d.ts.map +1 -1
  23. package/dist/helper/schema_helper/build_summary_schema.js +7 -18
  24. package/dist/helper/schema_helper/build_summary_schema.js.map +1 -1
  25. package/dist/index.js +3 -4
  26. package/dist/index.js.map +1 -1
  27. package/dist/services/get_prompts.d.ts +8 -8
  28. package/dist/services/get_prompts.d.ts.map +1 -1
  29. package/dist/services/get_prompts.js +22 -69
  30. package/dist/services/get_prompts.js.map +1 -1
  31. package/dist/services/prompts_test.d.ts +10 -0
  32. package/dist/services/prompts_test.d.ts.map +1 -0
  33. package/dist/services/prompts_test.js +227 -0
  34. package/dist/services/prompts_test.js.map +1 -0
  35. package/dist/types/generation_variables_schema.d.ts +15 -0
  36. package/dist/types/generation_variables_schema.d.ts.map +1 -0
  37. package/dist/types/generation_variables_schema.js +3 -0
  38. package/dist/types/generation_variables_schema.js.map +1 -0
  39. package/dist/typology_gen/generate_assessment.d.ts +3 -1
  40. package/dist/typology_gen/generate_assessment.d.ts.map +1 -1
  41. package/dist/typology_gen/generate_assessment.js +5 -12
  42. package/dist/typology_gen/generate_assessment.js.map +1 -1
  43. package/dist/typology_gen/generate_concept_facts.d.ts +3 -2
  44. package/dist/typology_gen/generate_concept_facts.d.ts.map +1 -1
  45. package/dist/typology_gen/generate_concept_facts.js +7 -4
  46. package/dist/typology_gen/generate_concept_facts.js.map +1 -1
  47. package/dist/typology_gen/generate_typology.d.ts +1 -2
  48. package/dist/typology_gen/generate_typology.d.ts.map +1 -1
  49. package/dist/typology_gen/generate_typology.js +3 -3
  50. package/dist/typology_gen/generate_typology.js.map +1 -1
  51. package/dist/typology_gen/summarize.d.ts +3 -2
  52. package/dist/typology_gen/summarize.d.ts.map +1 -1
  53. package/dist/typology_gen/summarize.js +6 -4
  54. package/dist/typology_gen/summarize.js.map +1 -1
  55. package/dist/utils/test.d.ts +2 -0
  56. package/dist/utils/test.d.ts.map +1 -0
  57. package/dist/utils/test.js +5 -0
  58. package/dist/utils/test.js.map +1 -0
  59. package/package.json +1 -1
  60. package/src/bootstrap/app.ts +24 -24
  61. package/src/card_gen/generate_cards.ts +25 -12
  62. package/src/constants/default_generation_variables.ts +631 -0
  63. package/src/helper/schema_helper/build_card_schema.ts +73 -49
  64. package/src/helper/schema_helper/build_concept_facts_schema.ts +4 -18
  65. package/src/helper/schema_helper/build_summary_schema.ts +6 -17
  66. package/src/index.ts +3 -4
  67. package/src/services/get_prompts.ts +23 -74
  68. package/src/types/generation_variables_schema.ts +17 -0
  69. package/src/typology_gen/generate_assessment.ts +8 -12
  70. package/src/typology_gen/generate_concept_facts.ts +10 -7
  71. package/src/typology_gen/generate_typology.ts +2 -4
  72. package/src/typology_gen/summarize.ts +9 -7
@@ -1,74 +1,98 @@
1
1
  import { sanitizeStringsForSchema } from "../../utils/sanitize_strings";
2
- import { setUpMongoClient, ObjectId } from "../mongo_helper";
3
2
 
4
- // flash:68ef4e1b5a123c94a835c6ab
5
- // cloze:68ef4eb45a123c94a835c6ac
6
- // mcq:68ef4f095a123c94a835c6ad
7
- // match:68ef4fae5a123c94a835c6ae
3
+ /**
4
+ * Builds card output schema by populating the integrated schemas with concepts, facts, and card-specific schemas
5
+ * @param concepts - Array of concept strings
6
+ * @param facts - Array of fact strings
7
+ * @param card_generation_types - Array of card types to generate (e.g., ["flash", "mcq", "cloze"])
8
+ * @param cardTypeSchemas - Object mapping card types to their integrated schemas from getPrompts (e.g., { flash: {...}, mcq: {...} })
9
+ * @returns Populated schema object ready for use
10
+ */
8
11
  export const buildCardSchema = async (
9
12
  concepts: string[],
10
13
  facts: string[],
11
- card_generation_types: string[]
14
+ card_generation_types: string[],
15
+ cardTypeSchemas: Record<string, any>
12
16
  ) => {
13
- const database = await setUpMongoClient();
14
- const objectId = new ObjectId("689c5cbd0d9d3bbda64b9584");
15
- const schemaObj = await database.collection("_prompts").findOne({
16
- _id: objectId,
17
- });
18
- if (!schemaObj) {
19
- throw new Error("Schema not found");
20
- }
21
- const schema = schemaObj.schema;
22
- if (!schema) {
23
- throw new Error("Schema not found");
17
+ if (!cardTypeSchemas || Object.keys(cardTypeSchemas).length === 0) {
18
+ throw new Error("Card type schemas are required");
24
19
  }
20
+
25
21
  const conceptsSanitized = sanitizeStringsForSchema(concepts);
26
22
  const factsSanitized = sanitizeStringsForSchema(facts);
27
23
 
28
- // Fetch individual card type schemas based on card_generation_types
29
- const cardTypeObjectIds: { [key: string]: ObjectId } = {
30
- flash: new ObjectId("68ef4e1b5a123c94a835c6ab"),
31
- cloze: new ObjectId("68ef4eb45a123c94a835c6ac"),
32
- mcq: new ObjectId("68ef4f095a123c94a835c6ad"),
33
- match: new ObjectId("68ef4fae5a123c94a835c6ae"),
34
- };
24
+ // Use the first available card type schema as the base (all have the same base structure)
25
+ const firstCardType = card_generation_types.find(
26
+ (type) => cardTypeSchemas[type]
27
+ );
28
+ if (!firstCardType) {
29
+ throw new Error("No valid card type schema found");
30
+ }
35
31
 
36
- const cardTypeSchemas: { [key: string]: any } = {};
32
+ // Deep clone to avoid mutating the original
33
+ const populatedSchema = JSON.parse(
34
+ JSON.stringify(cardTypeSchemas[firstCardType].schema)
35
+ );
37
36
 
38
- // Only fetch schemas for the requested card types
39
- for (const cardType of card_generation_types) {
40
- if (cardTypeObjectIds[cardType]) {
41
- const cardSchemaObj = await database.collection("_prompts").findOne({
42
- _id: cardTypeObjectIds[cardType],
43
- });
44
- if (cardSchemaObj && cardSchemaObj.schema) {
45
- cardTypeSchemas[cardType] = JSON.parse(cardSchemaObj.schema);
46
- }
47
- }
37
+ // Populate concepts enum
38
+ if (
39
+ populatedSchema.schema?.properties?.test_cards?.items?.properties?.concepts
40
+ ?.items?.enum
41
+ ) {
42
+ populatedSchema.schema.properties.test_cards.items.properties.concepts.items.enum =
43
+ conceptsSanitized;
48
44
  }
49
45
 
50
- // Deep clone to avoid mutating the original
51
- const populatedSchema = JSON.parse(schema);
52
- populatedSchema.schema.properties.test_cards.items.properties.concepts.items.enum =
53
- conceptsSanitized;
54
- populatedSchema.schema.properties.test_cards.items.properties.facts.items.enum =
55
- factsSanitized;
46
+ // Populate facts enum
47
+ if (
48
+ populatedSchema.schema?.properties?.test_cards?.items?.properties?.facts
49
+ ?.items?.enum
50
+ ) {
51
+ populatedSchema.schema.properties.test_cards.items.properties.facts.items.enum =
52
+ factsSanitized;
53
+ }
56
54
 
57
55
  // Replace the type enum with the requested card generation types
58
- populatedSchema.schema.properties.test_cards.items.properties.type.enum =
59
- card_generation_types;
56
+ if (
57
+ populatedSchema.schema?.properties?.test_cards?.items?.properties?.type
58
+ ?.enum
59
+ ) {
60
+ populatedSchema.schema.properties.test_cards.items.properties.type.enum =
61
+ card_generation_types;
62
+ }
60
63
 
61
- // Replace anyOf array with individual schemas based on card type
62
- if (Object.keys(cardTypeSchemas).length > 0) {
63
- populatedSchema.schema.properties.test_cards.items.properties.card_content =
64
- {
65
- anyOf: Object.values(cardTypeSchemas),
66
- };
64
+ // Extract card-specific schemas from the anyOf of each card type schema
65
+ const filteredCardTypeSchemas: any[] = [];
66
+ for (const cardType of card_generation_types) {
67
+ if (cardTypeSchemas[cardType]) {
68
+ const cardSchema = cardTypeSchemas[cardType];
69
+ // Extract the card-specific schema from the anyOf array
70
+ const cardContentSchema =
71
+ cardSchema.schema?.properties?.test_cards?.items?.properties
72
+ ?.card_content?.anyOf?.[0];
73
+ if (cardContentSchema) {
74
+ filteredCardTypeSchemas.push(cardContentSchema);
75
+ }
76
+ }
77
+ }
78
+
79
+ // Replace anyOf array with all card-specific schemas
80
+ if (filteredCardTypeSchemas.length > 0) {
81
+ if (
82
+ populatedSchema.schema?.properties?.test_cards?.items?.properties
83
+ ?.card_content
84
+ ) {
85
+ populatedSchema.schema.properties.test_cards.items.properties.card_content =
86
+ {
87
+ anyOf: filteredCardTypeSchemas,
88
+ };
89
+ }
67
90
  }
68
91
 
69
92
  console.log(
70
93
  "Populated Schema",
71
94
  JSON.stringify(populatedSchema.schema.properties.test_cards.items, null, 2)
72
95
  );
96
+
73
97
  return populatedSchema;
74
98
  };
@@ -5,27 +5,13 @@ import { sanitizeStringsForSchema } from "../../utils/sanitize_strings";
5
5
  // Function to populate enums in a parsed schema
6
6
  export async function buildConceptFactSchema(
7
7
  headings: string[],
8
- name: string = "concept_fact_gen_schema",
9
- strict: boolean = true
8
+ conceptFactSchema: any
10
9
  ) {
11
- const database = await setUpMongoClient();
12
- const objectId = new ObjectId("6895ac4baa1cad73b0018061");
13
- const schemaObj = await database.collection("_prompts").findOne({
14
- _id: objectId,
15
- });
16
- if (!schemaObj) {
17
- throw new Error("Schema not found");
18
- }
19
- const schema = schemaObj.schema;
20
- if (!schema) {
21
- throw new Error("Schema not found");
22
- }
23
- // Deep clone to avoid mutating the original
24
- const populatedSchema = JSON.parse(schema);
10
+ const populatedSchema = conceptFactSchema;
25
11
 
26
12
  // Update name and strict mode
27
- populatedSchema.name = name;
28
- populatedSchema.strict = strict;
13
+ populatedSchema.name = conceptFactSchema.name;
14
+ populatedSchema.strict = conceptFactSchema.strict;
29
15
 
30
16
  const allowedRefs = [...headings, ""];
31
17
 
@@ -4,27 +4,16 @@ import { setUpMongoClient, ObjectId } from "../mongo_helper";
4
4
  // Function to populate enums in a parsed schema
5
5
  export async function buildSummarySchema(
6
6
  headings: string[],
7
- name: string = "summary_cards",
8
- strict: boolean = true
7
+ summarySchema: any
9
8
  ) {
10
- const database = await setUpMongoClient();
11
- const objectId = new ObjectId("690ae043116a8c929f3a4cd5");
12
- const schemaObj = await database.collection("_prompts").findOne({
13
- _id: objectId,
14
- });
15
- if (!schemaObj) {
16
- throw new Error("Schema not found");
9
+ if (!summarySchema) {
10
+ return {};
17
11
  }
18
- const schema = schemaObj.schema;
19
- if (!schema) {
20
- throw new Error("Schema not found");
21
- }
22
- // Deep clone to avoid mutating the original
23
- const populatedSchema = JSON.parse(schema);
12
+ const populatedSchema = summarySchema;
24
13
 
25
14
  // Update name and strict mode
26
- populatedSchema.name = name;
27
- populatedSchema.strict = strict;
15
+ populatedSchema.name = summarySchema.name;
16
+ populatedSchema.strict = summarySchema.strict;
28
17
 
29
18
  // Sanitize headings to remove quotes for OpenAI structured outputs
30
19
  const sanitizedStrings = sanitizeStringsForSchema(headings);
package/src/index.ts CHANGED
@@ -44,14 +44,13 @@ export { OnlyEverGenerator };
44
44
  // type: document.type,
45
45
  // },
46
46
  // };
47
+ // const generationVariablesSchema: GenerationVariablesSchema =
48
+ // defaultGenerationVariables;
47
49
  // const generator = new OnlyEverGenerator(
48
50
  // openAiKey ?? "",
49
51
  // "gpt-4o-mini",
50
52
  // generationContent,
51
- // promptIdForClassify ?? "",
52
- // promptIdForConceptFacts ?? "",
53
- // promptIdForCardGeneration ?? "",
54
- // promptIdForSummarize ?? "",
53
+ // generationVariablesSchema,
55
54
  // false,
56
55
  // 1
57
56
  // );
@@ -1,38 +1,12 @@
1
1
  import { setUpMongoClient, ObjectId } from "../helper/mongo_helper";
2
- const typologyDocs = {
3
- role: "676528fc59c0563f42607add",
4
- input: "6765298059c0563f42607ade",
5
- steps: "6765298b59c0563f42607adf",
6
- schema: "6765299559c0563f42607ae0",
7
- fields: "676529a259c0563f42607ae1",
8
- concepts: "676529b759c0563f42607ae2",
9
- facts: "67652b1659c0563f42607aea",
10
- generate: "676529c259c0563f42607ae3",
11
- summarize: "676529d259c0563f42607ae4",
12
- };
13
-
14
- const cardGenDocs = {
15
- role: "676526c959c0563f42607ad4",
16
- inputs: "676526c959c0563f42607ad5",
17
- steps: "676526c959c0563f42607ad6",
18
- schema: "676526c959c0563f42607ad7",
19
- cloze: "6765270859c0563f42607ad8",
20
- flash: "6765274159c0563f42607ad9",
21
- match: "6765276959c0563f42607adb",
22
- mcq: "6765275f59c0563f42607ada",
23
- coverage: "6765277a59c0563f42607adc",
24
- };
25
2
 
26
- const videoTypologyDocs = {
27
- role: "676529e259c0563f42607ae5",
28
- inputs: "676529f059c0563f42607ae6",
29
- steps: "6765298b59c0563f42607adf",
30
- schema: "67652a2559c0563f42607ae7",
31
- fields: "676529a259c0563f42607ae1",
32
- concepts: "67652a3459c0563f42607ae8",
33
- facts: "67652a4459c0563f42607ae9",
34
- generate: "676529c259c0563f42607ae3",
35
- summarize: "676529d259c0563f42607ae4",
3
+ export const promptIds = {
4
+ classify: "pmpt_687a8872d1c8819088a9cdc97dcb688b0893663621695594",
5
+ conceptFacts: "pmpt_687aa547f99c8193b99467ca53630c2607f5a8caf451e7e8",
6
+ cardGeneration: "pmpt_688118a923e4819098176a13a2f401920d2ea17d881cc6c6",
7
+ missingConceptsFacts: "pmpt_687ab50298dc8194b214804999d23df10e03b855371691f9",
8
+ summarize: "pmpt_6902c30a973481968395935cc6dfa78605f50d2b01d4afbd",
9
+ assessment: "pmpt_69346ba0e8d88194b4e999d561510f99086d01dad36145c5",
36
10
  };
37
11
 
38
12
  const cardGenInstructionsDocs = {
@@ -60,15 +34,15 @@ export const getPrompts = async (
60
34
  // const typologyDocs = JSON.parse(baseConfig.typologyPrompts);
61
35
  // const cardGenerationDocs = JSON.parse(baseConfig.cardGenerationPrompts);
62
36
  // const videoTypologyDocs = JSON.parse(baseConfig.videoTypologyPrompts);
63
- const typologyObjectIds = Object.values(typologyDocs).map((e: any) =>
64
- ObjectId.createFromHexString(e.toString())
65
- );
66
- const cardGenObjectIds = Object.values(cardGenDocs).map((e: any) =>
67
- ObjectId.createFromHexString(e)
68
- );
69
- const typologyVideoObjectIds = Object.values(videoTypologyDocs).map(
70
- (e: any) => ObjectId.createFromHexString(e)
71
- );
37
+ // const typologyObjectIds = Object.values(typologyDocs).map((e: any) =>
38
+ // ObjectId.createFromHexString(e.toString())
39
+ // );
40
+ // const cardGenObjectIds = Object.values(cardGenDocs).map((e: any) =>
41
+ // ObjectId.createFromHexString(e)
42
+ // );
43
+ // const typologyVideoObjectIds = Object.values(videoTypologyDocs).map(
44
+ // (e: any) => ObjectId.createFromHexString(e)
45
+ // );
72
46
 
73
47
  // Filter card generation instructions and examples based on cardGenerationType array
74
48
  const filteredCardGenInstructions: Record<string, string> = {};
@@ -94,41 +68,16 @@ export const getPrompts = async (
94
68
  const bloomInstructionsObjectIds = Object.values(bloomInstructionsDocs).map(
95
69
  (e: any) => ObjectId.createFromHexString(e)
96
70
  );
97
- const typology = await getPromptString(typologyObjectIds);
98
- const card_generation = await getPromptString(cardGenObjectIds);
99
- const video_typology = await getPromptString(typologyVideoObjectIds);
71
+
100
72
  const cardInstructions = await getPromptString(cardGenInstructionsObjectIds);
101
73
  const cardExamples = await getPromptString(cardGenExamplesObjectIds);
102
74
  const bloomInstructions = await getPromptString(bloomInstructionsObjectIds);
103
- if (sourceType === "video") {
104
- return {
105
- typology: {
106
- prompt: video_typology,
107
- ids: Object.values(videoTypologyDocs),
108
- },
109
- card_gen: {
110
- prompt: card_generation,
111
- ids: Object.values(cardGenDocs),
112
- },
113
- card_instructions: cardInstructions,
114
- card_examples: cardExamples,
115
- bloom_instructions: bloomInstructions,
116
- };
117
- } else {
118
- return {
119
- typology: {
120
- prompt: typology,
121
- ids: Object.values(typologyDocs),
122
- },
123
- card_gen: {
124
- prompt: card_generation,
125
- ids: Object.values(cardGenDocs),
126
- },
127
- card_instructions: cardInstructions,
128
- card_examples: cardExamples,
129
- bloom_instructions: bloomInstructions,
130
- };
131
- }
75
+ return {
76
+ card_instructions: cardInstructions,
77
+ card_examples: cardExamples,
78
+ bloom_instructions: bloomInstructions,
79
+ };
80
+
132
81
  async function getPromptString(promptIds: ObjectId[]) {
133
82
  const database = await setUpMongoClient();
134
83
  let result = await database
@@ -0,0 +1,17 @@
1
+ export type GenerationVariablesSchema = {
2
+ bloom_instructions: any;
3
+ output_schema: {
4
+ concepts_facts: any;
5
+ summary: any;
6
+ classification: any;
7
+ assessment: any;
8
+ };
9
+ cards: Record<
10
+ string,
11
+ {
12
+ instructions: string;
13
+ examples: string;
14
+ schema: any;
15
+ }
16
+ >;
17
+ };
@@ -3,12 +3,15 @@ import { OpenAIHelper } from "../helper/openai_helper";
3
3
  import { OpenAiService } from "../services/open_ai_service";
4
4
  import { log_error, ParsingError } from "../logger";
5
5
  import { ObjectId, setUpMongoClient } from "../helper/mongo_helper";
6
+ import { promptIds } from "../services/get_prompts";
7
+ import { GenerationVariablesSchema } from "../types/generation_variables_schema";
6
8
 
7
9
  export class GenerateAssessment {
8
10
  public openAiService: OpenAiService;
9
11
  public openAIHelper: OpenAIHelper;
10
12
  public sourceId: string;
11
13
  public fields: any[];
14
+ public generationVariablesSchema: GenerationVariablesSchema;
12
15
  public content: {
13
16
  concepts_facts: any[];
14
17
  source_content: any[];
@@ -20,26 +23,19 @@ export class GenerateAssessment {
20
23
  source_content: any[];
21
24
  },
22
25
  sourceId: string,
23
- fields: string[]
26
+ fields: string[],
27
+ generationVariablesSchema: GenerationVariablesSchema
24
28
  ) {
25
29
  this.openAiService = openAiService;
26
30
  this.openAIHelper = new OpenAIHelper(this.openAiService.api_key);
27
31
  this.content = content;
28
32
  this.sourceId = sourceId;
29
33
  this.fields = fields;
34
+ this.generationVariablesSchema = generationVariablesSchema;
30
35
  }
31
36
 
32
37
  async buildOutputSchema() {
33
- const database = await setUpMongoClient();
34
- const objectId = new ObjectId("693fa4c454d182062f9d56ed");
35
- const schemaObj = await database.collection("_prompts").findOne({
36
- _id: objectId,
37
- });
38
- if (!schemaObj) {
39
- throw new Error("Schema not found");
40
- }
41
-
42
- const schema = JSON.parse(schemaObj.schema);
38
+ const schema = this.generationVariablesSchema.output_schema.assessment;
43
39
 
44
40
  // Extract concept IDs and fact IDs from concepts_facts
45
41
  const conceptIds = this.content.concepts_facts
@@ -97,7 +93,7 @@ export class GenerateAssessment {
97
93
  };
98
94
  const response: any = await this.openAIHelper.openAI.responses.create({
99
95
  prompt: {
100
- id: "pmpt_69346ba0e8d88194b4e999d561510f99086d01dad36145c5",
96
+ id: promptIds.assessment,
101
97
  variables: {
102
98
  field: fieldsString.join(",").toString(),
103
99
  bloom_level_name: "1",
@@ -7,12 +7,15 @@ import {
7
7
  restoreQuotesInString,
8
8
  } from "../utils/sanitize_strings";
9
9
  import { jsonrepair } from "jsonrepair";
10
+ import { GenerationVariablesSchema } from "../types/generation_variables_schema";
11
+ import { promptIds } from "../services/get_prompts";
10
12
 
11
13
  export class GenerateConceptFacts {
12
14
  public openAiService: OpenAiService;
13
15
  public openAIHelper: OpenAIHelper;
14
16
  public sourceId: string;
15
17
  public generationCurriculum: boolean;
18
+ public generationVariablesSchema: GenerationVariablesSchema;
16
19
  public content: {
17
20
  title: string;
18
21
  h1_headings?: string[];
@@ -20,7 +23,6 @@ export class GenerateConceptFacts {
20
23
  content: any[];
21
24
  };
22
25
  public type: string = "";
23
- public promptIdForConceptFacts: string;
24
26
  constructor(
25
27
  openAiService: OpenAiService,
26
28
  sourceId: string,
@@ -31,16 +33,16 @@ export class GenerateConceptFacts {
31
33
  content: any[];
32
34
  },
33
35
  type: string,
34
- promptIdForConceptFacts: string,
35
- generationCurriculum: boolean
36
+ generationCurriculum: boolean,
37
+ generationVariablesSchema: GenerationVariablesSchema
36
38
  ) {
37
39
  this.openAiService = openAiService;
38
40
  this.openAIHelper = new OpenAIHelper(this.openAiService.api_key);
39
41
  this.content = content;
40
- this.promptIdForConceptFacts = promptIdForConceptFacts;
41
42
  this.type = type;
42
43
  this.sourceId = sourceId;
43
44
  this.generationCurriculum = generationCurriculum;
45
+ this.generationVariablesSchema = generationVariablesSchema;
44
46
  }
45
47
 
46
48
  async generate() {
@@ -49,15 +51,16 @@ export class GenerateConceptFacts {
49
51
  this.type === "text"
50
52
  ? this.content.h1_headings || [""]
51
53
  : this.content.timecodes || [""];
54
+ // const schema =
55
+ // this.generationVariablesSchema.output_schema.concepts_facts;
52
56
  const schema = await buildConceptFactSchema(
53
57
  headings.length > 0 ? headings : [""],
54
- "concept_fact_gen_schema",
55
- true
58
+ this.generationVariablesSchema.output_schema.concepts_facts
56
59
  );
57
60
  const openAiResponse: any =
58
61
  await this.openAIHelper.openAI.responses.create({
59
62
  prompt: {
60
- id: this.promptIdForConceptFacts,
63
+ id: promptIds.conceptFacts,
61
64
  // version: "200",
62
65
  variables: {
63
66
  heading_type: this.type == "video" ? "timecode" : "h1 heading",
@@ -1,5 +1,6 @@
1
1
  import { OpenAIHelper } from "../helper/openai_helper";
2
2
  import { log_error, ParsingError } from "../logger";
3
+ import { promptIds } from "../services/get_prompts";
3
4
  import { OpenAiService } from "../services/open_ai_service";
4
5
  import { restoreQuotesInString } from "../utils/sanitize_strings";
5
6
  import { jsonrepair } from "jsonrepair";
@@ -15,7 +16,6 @@ export class GenerateTypology {
15
16
  timecodes?: string[];
16
17
  content: any[];
17
18
  };
18
- public promptIdForTypology: string;
19
19
  expectedFields: Array<string>;
20
20
  constructor(
21
21
  openAiService: OpenAiService,
@@ -28,7 +28,6 @@ export class GenerateTypology {
28
28
  content: any[];
29
29
  },
30
30
  expected_fields: Array<string>,
31
- promptIdForTypology: string,
32
31
  generationCurriculum: boolean
33
32
  ) {
34
33
  this.openAiService = openAiService;
@@ -38,7 +37,6 @@ export class GenerateTypology {
38
37
  this.expectedFields = expected_fields.map((elem: string) =>
39
38
  elem.toString().toUpperCase()
40
39
  );
41
- this.promptIdForTypology = promptIdForTypology;
42
40
  this.generationCurriculum = generationCurriculum;
43
41
  }
44
42
  async generate() {
@@ -46,7 +44,7 @@ export class GenerateTypology {
46
44
  const openAIHelper = new OpenAIHelper(this.openAiService.api_key);
47
45
  const openAiResponse: any = await openAIHelper.openAI.responses.create({
48
46
  prompt: {
49
- id: this.promptIdForTypology,
47
+ id: promptIds.classify,
50
48
  variables: {
51
49
  heading_type: this.type == "video" ? "timecode" : "h1 heading",
52
50
  },
@@ -4,12 +4,15 @@ import { log_error, ParsingError } from "../logger";
4
4
  import { restoreQuotesInString } from "../utils/sanitize_strings";
5
5
  import { buildSummarySchema } from "../helper/schema_helper/build_summary_schema";
6
6
  import { jsonrepair } from "jsonrepair";
7
+ import { GenerationVariablesSchema } from "../types/generation_variables_schema";
8
+ import { promptIds } from "../services/get_prompts";
7
9
 
8
10
  export class GenerateSummaryCards {
9
11
  public openAiService: OpenAiService;
10
12
  public openAIHelper: OpenAIHelper;
11
13
  public sourceId: string;
12
14
  public generationCurriculum: boolean;
15
+ public generationVariablesSchema: GenerationVariablesSchema;
13
16
  public content: {
14
17
  title: string;
15
18
  h1_headings?: string[];
@@ -17,7 +20,6 @@ export class GenerateSummaryCards {
17
20
  content: any[];
18
21
  };
19
22
  public type: string = "";
20
- public promptIdForSummaryCards: string;
21
23
  constructor(
22
24
  openAiService: OpenAiService,
23
25
  sourceId: string,
@@ -28,16 +30,16 @@ export class GenerateSummaryCards {
28
30
  content: any[];
29
31
  },
30
32
  type: string,
31
- promptIdForSummaryCards: string,
32
- generationCurriculum: boolean
33
+ generationCurriculum: boolean,
34
+ generationVariablesSchema: GenerationVariablesSchema
33
35
  ) {
34
36
  this.openAiService = openAiService;
35
37
  this.openAIHelper = new OpenAIHelper(this.openAiService.api_key);
36
38
  this.content = content;
37
- this.promptIdForSummaryCards = promptIdForSummaryCards;
38
39
  this.type = type;
39
40
  this.sourceId = sourceId;
40
41
  this.generationCurriculum = generationCurriculum;
42
+ this.generationVariablesSchema = generationVariablesSchema;
41
43
  }
42
44
 
43
45
  async generate() {
@@ -48,13 +50,13 @@ export class GenerateSummaryCards {
48
50
  : this.content.timecodes || [""];
49
51
  const schema = await buildSummarySchema(
50
52
  headings.length > 0 ? headings : [""],
51
- "summary_cards",
52
- true
53
+ this.generationVariablesSchema.output_schema.summary
53
54
  );
55
+ // const schema = this.generationVariablesSchema.output_schema.summary;
54
56
  const openAiResponse: any =
55
57
  await this.openAIHelper.openAI.responses.create({
56
58
  prompt: {
57
- id: this.promptIdForSummaryCards,
59
+ id: promptIds.summarize,
58
60
  variables: {
59
61
  heading_type: this.type == "video" ? "timecode" : "h1 heading",
60
62
  },