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.
- package/dist/bootstrap/app.d.ts +3 -6
- package/dist/bootstrap/app.d.ts.map +1 -1
- package/dist/bootstrap/app.js +19 -12
- package/dist/bootstrap/app.js.map +1 -1
- package/dist/card_gen/generate_cards.d.ts +3 -2
- package/dist/card_gen/generate_cards.d.ts.map +1 -1
- package/dist/card_gen/generate_cards.js +15 -9
- package/dist/card_gen/generate_cards.js.map +1 -1
- package/dist/constants/default_generation_variables.d.ts +3 -0
- package/dist/constants/default_generation_variables.d.ts.map +1 -0
- package/dist/constants/default_generation_variables.js +587 -0
- package/dist/constants/default_generation_variables.js.map +1 -0
- package/dist/helper/schema_helper/build_card_schema.d.ts +9 -1
- package/dist/helper/schema_helper/build_card_schema.d.ts.map +1 -1
- package/dist/helper/schema_helper/build_card_schema.js +50 -47
- package/dist/helper/schema_helper/build_card_schema.js.map +1 -1
- package/dist/helper/schema_helper/build_concept_facts_schema.d.ts +1 -1
- package/dist/helper/schema_helper/build_concept_facts_schema.d.ts.map +1 -1
- package/dist/helper/schema_helper/build_concept_facts_schema.js +5 -20
- package/dist/helper/schema_helper/build_concept_facts_schema.js.map +1 -1
- package/dist/helper/schema_helper/build_summary_schema.d.ts +1 -1
- package/dist/helper/schema_helper/build_summary_schema.d.ts.map +1 -1
- package/dist/helper/schema_helper/build_summary_schema.js +7 -18
- package/dist/helper/schema_helper/build_summary_schema.js.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/dist/services/get_prompts.d.ts +8 -8
- package/dist/services/get_prompts.d.ts.map +1 -1
- package/dist/services/get_prompts.js +22 -69
- package/dist/services/get_prompts.js.map +1 -1
- package/dist/services/prompts_test.d.ts +10 -0
- package/dist/services/prompts_test.d.ts.map +1 -0
- package/dist/services/prompts_test.js +227 -0
- package/dist/services/prompts_test.js.map +1 -0
- package/dist/types/generation_variables_schema.d.ts +15 -0
- package/dist/types/generation_variables_schema.d.ts.map +1 -0
- package/dist/types/generation_variables_schema.js +3 -0
- package/dist/types/generation_variables_schema.js.map +1 -0
- package/dist/typology_gen/generate_assessment.d.ts +3 -1
- package/dist/typology_gen/generate_assessment.d.ts.map +1 -1
- package/dist/typology_gen/generate_assessment.js +5 -12
- package/dist/typology_gen/generate_assessment.js.map +1 -1
- package/dist/typology_gen/generate_concept_facts.d.ts +3 -2
- package/dist/typology_gen/generate_concept_facts.d.ts.map +1 -1
- package/dist/typology_gen/generate_concept_facts.js +7 -4
- package/dist/typology_gen/generate_concept_facts.js.map +1 -1
- package/dist/typology_gen/generate_typology.d.ts +1 -2
- package/dist/typology_gen/generate_typology.d.ts.map +1 -1
- package/dist/typology_gen/generate_typology.js +3 -3
- package/dist/typology_gen/generate_typology.js.map +1 -1
- package/dist/typology_gen/summarize.d.ts +3 -2
- package/dist/typology_gen/summarize.d.ts.map +1 -1
- package/dist/typology_gen/summarize.js +6 -4
- package/dist/typology_gen/summarize.js.map +1 -1
- package/dist/utils/test.d.ts +2 -0
- package/dist/utils/test.d.ts.map +1 -0
- package/dist/utils/test.js +5 -0
- package/dist/utils/test.js.map +1 -0
- package/package.json +1 -1
- package/src/bootstrap/app.ts +24 -24
- package/src/card_gen/generate_cards.ts +25 -12
- package/src/constants/default_generation_variables.ts +631 -0
- package/src/helper/schema_helper/build_card_schema.ts +73 -49
- package/src/helper/schema_helper/build_concept_facts_schema.ts +4 -18
- package/src/helper/schema_helper/build_summary_schema.ts +6 -17
- package/src/index.ts +3 -4
- package/src/services/get_prompts.ts +23 -74
- package/src/types/generation_variables_schema.ts +17 -0
- package/src/typology_gen/generate_assessment.ts +8 -12
- package/src/typology_gen/generate_concept_facts.ts +10 -7
- package/src/typology_gen/generate_typology.ts +2 -4
- package/src/typology_gen/summarize.ts +9 -7
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getPrompts = void 0;
|
|
13
|
+
const mongo_helper_1 = require("../helper/mongo_helper");
|
|
14
|
+
const cardGenInstructionsDocs = {
|
|
15
|
+
cloze: "6780d21318f81be17e39f5c1",
|
|
16
|
+
flash: "6780d21318f81be17e39f5d2",
|
|
17
|
+
match: "6780d21318f81be17e39f5d3",
|
|
18
|
+
mcq: "6780d21318f81be17e39f5d4",
|
|
19
|
+
};
|
|
20
|
+
const cardGenExamplesDocs = {
|
|
21
|
+
cloze: "688af4e5299b7c2c08a52fbe",
|
|
22
|
+
flash: "688af4e5299b7c2c08a52fcd",
|
|
23
|
+
match: "688af4e5299b7c2c08a52fce",
|
|
24
|
+
mcq: "688af4e5299b7c2c08a52fde",
|
|
25
|
+
};
|
|
26
|
+
const bloomInstructionsDocs = {
|
|
27
|
+
bloom_1: "6780d21318f81be17e39f5b5",
|
|
28
|
+
};
|
|
29
|
+
const cardOutputSchemaDocs = {
|
|
30
|
+
basic: "689c5cbd0d9d3bbda64b9584",
|
|
31
|
+
flash: "68ef4e1b5a123c94a835c6ab",
|
|
32
|
+
cloze: "68ef4eb45a123c94a835c6ac",
|
|
33
|
+
mcq: "68ef4f095a123c94a835c6ad",
|
|
34
|
+
match: "68ef4fae5a123c94a835c6ae",
|
|
35
|
+
};
|
|
36
|
+
const outputSchemaDocs = {
|
|
37
|
+
summary: "690ae043116a8c929f3a4cd5",
|
|
38
|
+
concepts_facts: "6895ac4baa1cad73b0018061",
|
|
39
|
+
classification: "6895ab99aa1cad73b0018060",
|
|
40
|
+
};
|
|
41
|
+
const getPrompts = (sourceType, cardGenerationType) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
var _a, _b, _c, _d, _e;
|
|
43
|
+
// Filter card generation instructions and examples based on cardGenerationType array
|
|
44
|
+
const filteredCardGenInstructions = {};
|
|
45
|
+
const filteredCardGenExamples = {};
|
|
46
|
+
cardGenerationType.forEach((type) => {
|
|
47
|
+
if (cardGenInstructionsDocs[type]) {
|
|
48
|
+
filteredCardGenInstructions[type] =
|
|
49
|
+
cardGenInstructionsDocs[type];
|
|
50
|
+
}
|
|
51
|
+
if (cardGenExamplesDocs[type]) {
|
|
52
|
+
filteredCardGenExamples[type] =
|
|
53
|
+
cardGenExamplesDocs[type];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
// Get bloom instructions (same for all cards)
|
|
57
|
+
const bloomInstructionsObjectIds = Object.values(bloomInstructionsDocs).map((e) => mongo_helper_1.ObjectId.createFromHexString(e));
|
|
58
|
+
const bloomInstructions = yield getPromptString(bloomInstructionsObjectIds);
|
|
59
|
+
// Fetch output schemas (summary, concepts_facts, classification)
|
|
60
|
+
const outputSchemas = {};
|
|
61
|
+
for (const [key, schemaId] of Object.entries(outputSchemaDocs)) {
|
|
62
|
+
try {
|
|
63
|
+
const schemaObjectId = mongo_helper_1.ObjectId.createFromHexString(schemaId);
|
|
64
|
+
const schema = yield getSchema(schemaObjectId);
|
|
65
|
+
if (schema) {
|
|
66
|
+
outputSchemas[key] = schema;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
console.error(`Error fetching output schema for ${key}:`, error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Get basic schema (template for all cards)
|
|
74
|
+
const basicSchemaId = cardOutputSchemaDocs.basic;
|
|
75
|
+
let baseSchema = null;
|
|
76
|
+
if (basicSchemaId) {
|
|
77
|
+
try {
|
|
78
|
+
const basicSchemaObjectId = mongo_helper_1.ObjectId.createFromHexString(basicSchemaId);
|
|
79
|
+
baseSchema = yield getSchema(basicSchemaObjectId);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.error(`Error fetching basic schema:`, error);
|
|
83
|
+
baseSchema = null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Fetch card type schemas (for integration with base schema)
|
|
87
|
+
const cardTypeSchemas = {};
|
|
88
|
+
for (const type of cardGenerationType) {
|
|
89
|
+
const schemaId = cardOutputSchemaDocs[type];
|
|
90
|
+
if (schemaId) {
|
|
91
|
+
try {
|
|
92
|
+
const cardTypeSchemaObjectId = mongo_helper_1.ObjectId.createFromHexString(schemaId);
|
|
93
|
+
const cardTypeSchema = yield getSchema(cardTypeSchemaObjectId);
|
|
94
|
+
if (cardTypeSchema) {
|
|
95
|
+
cardTypeSchemas[type] = cardTypeSchema;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
console.error(`Error fetching schema for ${type}:`, error);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Fetch prompts individually and map them by card type
|
|
104
|
+
const cards = {};
|
|
105
|
+
// Fetch instructions, examples, and schemas for each card type
|
|
106
|
+
for (const type of cardGenerationType) {
|
|
107
|
+
const instructionId = filteredCardGenInstructions[type];
|
|
108
|
+
const exampleId = filteredCardGenExamples[type];
|
|
109
|
+
const schemaId = cardOutputSchemaDocs[type];
|
|
110
|
+
let instructions = "";
|
|
111
|
+
let examples = "";
|
|
112
|
+
let schema = null;
|
|
113
|
+
// Fetch instructions
|
|
114
|
+
if (instructionId) {
|
|
115
|
+
try {
|
|
116
|
+
const instructionObjectId = mongo_helper_1.ObjectId.createFromHexString(instructionId);
|
|
117
|
+
instructions = yield getPromptString([instructionObjectId]);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
console.error(`Error fetching instructions for ${type}:`, error);
|
|
121
|
+
instructions = "";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Fetch examples
|
|
125
|
+
if (exampleId) {
|
|
126
|
+
try {
|
|
127
|
+
const exampleObjectId = mongo_helper_1.ObjectId.createFromHexString(exampleId);
|
|
128
|
+
examples = yield getPromptString([exampleObjectId]);
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
console.error(`Error fetching examples for ${type}:`, error);
|
|
132
|
+
examples = "";
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Build schema for this card type by replacing content in base schema
|
|
136
|
+
if (baseSchema && cardTypeSchemas[type]) {
|
|
137
|
+
try {
|
|
138
|
+
// Deep clone the base schema to avoid mutating the original
|
|
139
|
+
schema = JSON.parse(JSON.stringify(baseSchema));
|
|
140
|
+
// Replace card_content.anyOf with the card-specific schema
|
|
141
|
+
if ((_e = (_d = (_c = (_b = (_a = schema.schema) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.test_cards) === null || _c === void 0 ? void 0 : _c.items) === null || _d === void 0 ? void 0 : _d.properties) === null || _e === void 0 ? void 0 : _e.card_content) {
|
|
142
|
+
schema.schema.properties.test_cards.items.properties.card_content = {
|
|
143
|
+
anyOf: [cardTypeSchemas[type]],
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
console.error(`Error building schema for ${type}:`, error);
|
|
149
|
+
// Fallback to base schema if there's an error
|
|
150
|
+
schema = baseSchema ? JSON.parse(JSON.stringify(baseSchema)) : null;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
else if (baseSchema) {
|
|
154
|
+
// If no card-specific schema, use base schema as fallback
|
|
155
|
+
schema = JSON.parse(JSON.stringify(baseSchema));
|
|
156
|
+
}
|
|
157
|
+
// Always include the card type with instructions, examples, and schema (even if empty)
|
|
158
|
+
cards[type] = {
|
|
159
|
+
instructions: instructions || "",
|
|
160
|
+
examples: examples || "",
|
|
161
|
+
schema: schema,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
bloom_instructions: bloomInstructions,
|
|
166
|
+
output_schema: outputSchemas,
|
|
167
|
+
cards,
|
|
168
|
+
};
|
|
169
|
+
function getPromptString(promptIds) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
if (promptIds.length === 0) {
|
|
172
|
+
return "";
|
|
173
|
+
}
|
|
174
|
+
const database = yield (0, mongo_helper_1.setUpMongoClient)();
|
|
175
|
+
let result = yield database
|
|
176
|
+
.collection("_prompts")
|
|
177
|
+
.aggregate([
|
|
178
|
+
{
|
|
179
|
+
$match: {
|
|
180
|
+
_id: { $in: promptIds },
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
$group: {
|
|
185
|
+
_id: null,
|
|
186
|
+
allContent: { $push: "$prompt" },
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
/// concat each element in above created `allContent temp field`, and update that to "concatenatedContent"(temp field)
|
|
191
|
+
$project: {
|
|
192
|
+
concatenatedContent: {
|
|
193
|
+
$reduce: {
|
|
194
|
+
input: "$allContent",
|
|
195
|
+
initialValue: "",
|
|
196
|
+
in: { $concat: ["$$value", "$$this"] },
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
])
|
|
202
|
+
.toArray();
|
|
203
|
+
return result.length > 0 ? result[0].concatenatedContent : "";
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function getSchema(schemaId) {
|
|
207
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
208
|
+
const database = yield (0, mongo_helper_1.setUpMongoClient)();
|
|
209
|
+
const schemaObj = yield database.collection("_prompts").findOne({
|
|
210
|
+
_id: schemaId,
|
|
211
|
+
});
|
|
212
|
+
if (!schemaObj || !schemaObj.schema) {
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
try {
|
|
216
|
+
// Parse the schema string to JSON object
|
|
217
|
+
return JSON.parse(schemaObj.schema);
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
console.error(`Error parsing schema for ${schemaId}:`, error);
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
exports.getPrompts = getPrompts;
|
|
227
|
+
//# sourceMappingURL=prompts_test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts_test.js","sourceRoot":"","sources":["../../src/services/prompts_test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAoE;AAEpE,MAAM,uBAAuB,GAAG;IAC9B,KAAK,EAAE,0BAA0B;IACjC,KAAK,EAAE,0BAA0B;IACjC,KAAK,EAAE,0BAA0B;IACjC,GAAG,EAAE,0BAA0B;CAChC,CAAC;AAEF,MAAM,mBAAmB,GAAG;IAC1B,KAAK,EAAE,0BAA0B;IACjC,KAAK,EAAE,0BAA0B;IACjC,KAAK,EAAE,0BAA0B;IACjC,GAAG,EAAE,0BAA0B;CAChC,CAAC;AAEF,MAAM,qBAAqB,GAAG;IAC5B,OAAO,EAAE,0BAA0B;CACpC,CAAC;AAEF,MAAM,oBAAoB,GAAG;IAC3B,KAAK,EAAE,0BAA0B;IACjC,KAAK,EAAE,0BAA0B;IACjC,KAAK,EAAE,0BAA0B;IACjC,GAAG,EAAE,0BAA0B;IAC/B,KAAK,EAAE,0BAA0B;CAClC,CAAC;AAEF,MAAM,gBAAgB,GAAG;IACvB,OAAO,EAAE,0BAA0B;IACnC,cAAc,EAAE,0BAA0B;IAC1C,cAAc,EAAE,0BAA0B;CAC3C,CAAC;AAEK,MAAM,UAAU,GAAG,CACxB,UAAkB,EACl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CAAC;AAvMW,QAAA,UAAU,cAuMrB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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<string, {
|
|
10
|
+
instructions: string;
|
|
11
|
+
examples: string;
|
|
12
|
+
schema: any;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=generation_variables_schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation_variables_schema.d.ts","sourceRoot":"","sources":["../../src/types/generation_variables_schema.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GAAG;IACtC,kBAAkB,EAAE,GAAG,CAAC;IACxB,aAAa,EAAE;QACb,cAAc,EAAE,GAAG,CAAC;QACpB,OAAO,EAAE,GAAG,CAAC;QACb,cAAc,EAAE,GAAG,CAAC;QACpB,UAAU,EAAE,GAAG,CAAC;KACjB,CAAC;IACF,KAAK,EAAE,MAAM,CACX,MAAM,EACN;QACE,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,GAAG,CAAC;KACb,CACF,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation_variables_schema.js","sourceRoot":"","sources":["../../src/types/generation_variables_schema.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { OpenAIHelper } from "../helper/openai_helper";
|
|
2
2
|
import { OpenAiService } from "../services/open_ai_service";
|
|
3
|
+
import { GenerationVariablesSchema } from "../types/generation_variables_schema";
|
|
3
4
|
export declare class GenerateAssessment {
|
|
4
5
|
openAiService: OpenAiService;
|
|
5
6
|
openAIHelper: OpenAIHelper;
|
|
6
7
|
sourceId: string;
|
|
7
8
|
fields: any[];
|
|
9
|
+
generationVariablesSchema: GenerationVariablesSchema;
|
|
8
10
|
content: {
|
|
9
11
|
concepts_facts: any[];
|
|
10
12
|
source_content: any[];
|
|
@@ -12,7 +14,7 @@ export declare class GenerateAssessment {
|
|
|
12
14
|
constructor(openAiService: OpenAiService, content: {
|
|
13
15
|
concepts_facts: any[];
|
|
14
16
|
source_content: any[];
|
|
15
|
-
}, sourceId: string, fields: string[]);
|
|
17
|
+
}, sourceId: string, fields: string[], generationVariablesSchema: GenerationVariablesSchema);
|
|
16
18
|
buildOutputSchema(): Promise<any>;
|
|
17
19
|
generate(): Promise<{
|
|
18
20
|
assessment_questions: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_assessment.d.ts","sourceRoot":"","sources":["../../src/typology_gen/generate_assessment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAI5D,qBAAa,kBAAkB;IACtB,aAAa,EAAE,aAAa,CAAC;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,OAAO,EAAE;QACd,cAAc,EAAE,GAAG,EAAE,CAAC;QACtB,cAAc,EAAE,GAAG,EAAE,CAAC;KACvB,CAAC;gBAEA,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE;QACP,cAAc,EAAE,GAAG,EAAE,CAAC;QACtB,cAAc,EAAE,GAAG,EAAE,CAAC;KACvB,EACD,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"generate_assessment.d.ts","sourceRoot":"","sources":["../../src/typology_gen/generate_assessment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAI5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,qBAAa,kBAAkB;IACtB,aAAa,EAAE,aAAa,CAAC;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,yBAAyB,EAAE,yBAAyB,CAAC;IACrD,OAAO,EAAE;QACd,cAAc,EAAE,GAAG,EAAE,CAAC;QACtB,cAAc,EAAE,GAAG,EAAE,CAAC;KACvB,CAAC;gBAEA,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE;QACP,cAAc,EAAE,GAAG,EAAE,CAAC;QACtB,cAAc,EAAE,GAAG,EAAE,CAAC;KACvB,EACD,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EAAE,EAChB,yBAAyB,EAAE,yBAAyB;IAUhD,iBAAiB;IAiCjB,QAAQ;;;;IAwFd,SAAS,CAAC,QAAQ,EAAE,GAAG;CAoBxB"}
|
|
@@ -13,27 +13,20 @@ exports.GenerateAssessment = void 0;
|
|
|
13
13
|
const jsonrepair_1 = require("jsonrepair");
|
|
14
14
|
const openai_helper_1 = require("../helper/openai_helper");
|
|
15
15
|
const logger_1 = require("../logger");
|
|
16
|
-
const
|
|
16
|
+
const get_prompts_1 = require("../services/get_prompts");
|
|
17
17
|
class GenerateAssessment {
|
|
18
|
-
constructor(openAiService, content, sourceId, fields) {
|
|
18
|
+
constructor(openAiService, content, sourceId, fields, generationVariablesSchema) {
|
|
19
19
|
this.openAiService = openAiService;
|
|
20
20
|
this.openAIHelper = new openai_helper_1.OpenAIHelper(this.openAiService.api_key);
|
|
21
21
|
this.content = content;
|
|
22
22
|
this.sourceId = sourceId;
|
|
23
23
|
this.fields = fields;
|
|
24
|
+
this.generationVariablesSchema = generationVariablesSchema;
|
|
24
25
|
}
|
|
25
26
|
buildOutputSchema() {
|
|
26
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
28
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
28
|
-
const
|
|
29
|
-
const objectId = new mongo_helper_1.ObjectId("693fa4c454d182062f9d56ed");
|
|
30
|
-
const schemaObj = yield database.collection("_prompts").findOne({
|
|
31
|
-
_id: objectId,
|
|
32
|
-
});
|
|
33
|
-
if (!schemaObj) {
|
|
34
|
-
throw new Error("Schema not found");
|
|
35
|
-
}
|
|
36
|
-
const schema = JSON.parse(schemaObj.schema);
|
|
29
|
+
const schema = this.generationVariablesSchema.output_schema.assessment;
|
|
37
30
|
// Extract concept IDs and fact IDs from concepts_facts
|
|
38
31
|
const conceptIds = this.content.concepts_facts
|
|
39
32
|
.filter((item) => item.type === "concept")
|
|
@@ -82,7 +75,7 @@ class GenerateAssessment {
|
|
|
82
75
|
};
|
|
83
76
|
const response = yield this.openAIHelper.openAI.responses.create({
|
|
84
77
|
prompt: {
|
|
85
|
-
id:
|
|
78
|
+
id: get_prompts_1.promptIds.assessment,
|
|
86
79
|
variables: {
|
|
87
80
|
field: fieldsString.join(",").toString(),
|
|
88
81
|
bloom_level_name: "1",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_assessment.js","sourceRoot":"","sources":["../../src/typology_gen/generate_assessment.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAwC;AACxC,2DAAuD;AAEvD,sCAAoD;
|
|
1
|
+
{"version":3,"file":"generate_assessment.js","sourceRoot":"","sources":["../../src/typology_gen/generate_assessment.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAwC;AACxC,2DAAuD;AAEvD,sCAAoD;AAEpD,yDAAoD;AAGpD,MAAa,kBAAkB;IAU7B,YACE,aAA4B,EAC5B,OAGC,EACD,QAAgB,EAChB,MAAgB,EAChB,yBAAoD;QAEpD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,YAAY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ationVariablesSchema } from "../types/generation_variables_schema";
|
|
3
4
|
export declare class GenerateConceptFacts {
|
|
4
5
|
openAiService: OpenAiService;
|
|
5
6
|
openAIHelper: OpenAIHelper;
|
|
6
7
|
sourceId: string;
|
|
7
8
|
generationCurriculum: boolean;
|
|
9
|
+
generationVariablesSchema: GenerationVariablesSchema;
|
|
8
10
|
content: {
|
|
9
11
|
title: string;
|
|
10
12
|
h1_headings?: string[];
|
|
@@ -12,13 +14,12 @@ export declare class GenerateConceptFacts {
|
|
|
12
14
|
content: any[];
|
|
13
15
|
};
|
|
14
16
|
type: string;
|
|
15
|
-
promptIdForConceptFacts: string;
|
|
16
17
|
constructor(openAiService: OpenAiService, sourceId: string, content: {
|
|
17
18
|
title: string;
|
|
18
19
|
h1_headings?: string[];
|
|
19
20
|
timecodes?: string[];
|
|
20
21
|
content: any[];
|
|
21
|
-
}, type: string,
|
|
22
|
+
}, type: string, generationCurriculum: boolean, generationVariablesSchema: GenerationVariablesSchema);
|
|
22
23
|
generate(): Promise<{
|
|
23
24
|
concepts_facts: any;
|
|
24
25
|
metadata: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_concept_facts.d.ts","sourceRoot":"","sources":["../../src/typology_gen/generate_concept_facts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"generate_concept_facts.d.ts","sourceRoot":"","sources":["../../src/typology_gen/generate_concept_facts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAO5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAGjF,qBAAa,oBAAoB;IACxB,aAAa,EAAE,aAAa,CAAC;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,yBAAyB,EAAE,yBAAyB,CAAC;IACrD,OAAO,EAAE;QACd,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,EAAE,GAAG,EAAE,CAAC;KAChB,CAAC;IACK,IAAI,EAAE,MAAM,CAAM;gBAEvB,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,EAAE,GAAG,EAAE,CAAC;KAChB,EACD,IAAI,EAAE,MAAM,EACZ,oBAAoB,EAAE,OAAO,EAC7B,yBAAyB,EAAE,yBAAyB;IAWhD,QAAQ;;;;IAwGd,SAAS,CAAC,QAAQ,EAAE,GAAG;CAkCxB"}
|
|
@@ -15,16 +15,17 @@ const openai_helper_1 = require("../helper/openai_helper");
|
|
|
15
15
|
const logger_1 = require("../logger");
|
|
16
16
|
const sanitize_strings_1 = require("../utils/sanitize_strings");
|
|
17
17
|
const jsonrepair_1 = require("jsonrepair");
|
|
18
|
+
const get_prompts_1 = require("../services/get_prompts");
|
|
18
19
|
class GenerateConceptFacts {
|
|
19
|
-
constructor(openAiService, sourceId, content, type,
|
|
20
|
+
constructor(openAiService, sourceId, content, type, generationCurriculum, generationVariablesSchema) {
|
|
20
21
|
this.type = "";
|
|
21
22
|
this.openAiService = openAiService;
|
|
22
23
|
this.openAIHelper = new openai_helper_1.OpenAIHelper(this.openAiService.api_key);
|
|
23
24
|
this.content = content;
|
|
24
|
-
this.promptIdForConceptFacts = promptIdForConceptFacts;
|
|
25
25
|
this.type = type;
|
|
26
26
|
this.sourceId = sourceId;
|
|
27
27
|
this.generationCurriculum = generationCurriculum;
|
|
28
|
+
this.generationVariablesSchema = generationVariablesSchema;
|
|
28
29
|
}
|
|
29
30
|
generate() {
|
|
30
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -33,10 +34,12 @@ class GenerateConceptFacts {
|
|
|
33
34
|
const headings = this.type === "text"
|
|
34
35
|
? this.content.h1_headings || [""]
|
|
35
36
|
: this.content.timecodes || [""];
|
|
36
|
-
const schema =
|
|
37
|
+
// const schema =
|
|
38
|
+
// this.generationVariablesSchema.output_schema.concepts_facts;
|
|
39
|
+
const schema = yield (0, build_concept_facts_schema_1.buildConceptFactSchema)(headings.length > 0 ? headings : [""], this.generationVariablesSchema.output_schema.concepts_facts);
|
|
37
40
|
const openAiResponse = yield this.openAIHelper.openAI.responses.create({
|
|
38
41
|
prompt: {
|
|
39
|
-
id:
|
|
42
|
+
id: get_prompts_1.promptIds.conceptFacts,
|
|
40
43
|
// version: "200",
|
|
41
44
|
variables: {
|
|
42
45
|
heading_type: this.type == "video" ? "timecode" : "h1 heading",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_concept_facts.js","sourceRoot":"","sources":["../../src/typology_gen/generate_concept_facts.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mGAA4F;AAC5F,2DAAuD;AAEvD,sCAAiE;AACjE,gEAGmC;AACnC,2CAAwC;AAExC,MAAa,oBAAoB;IAa/B,YACE,aAA4B,EAC5B,QAAgB,EAChB,OAKC,EACD,IAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"generate_concept_facts.js","sourceRoot":"","sources":["../../src/typology_gen/generate_concept_facts.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mGAA4F;AAC5F,2DAAuD;AAEvD,sCAAiE;AACjE,gEAGmC;AACnC,2CAAwC;AAExC,yDAAoD;AAEpD,MAAa,oBAAoB;IAa/B,YACE,aAA4B,EAC5B,QAAgB,EAChB,OAKC,EACD,IAAY,EACZ,oBAA6B,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AAQ,CACT,CAAC;YACJ,CAAC;QACH,CAAC;QAED,6EAA6E;QAC7E,MAAM,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;QACjD,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE;gBACtC,uCACK,IAAI,KACP,SAAS,EAAE,IAAA,wCAAqB,EAAC,IAAI,CAAC,SAAS,CAAC,IAChD;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;QACD,MAAM,IAAI,qBAAY,CACpB,0CAA0C,EAC1C,QAAQ,CACT,CAAC;IACJ,CAAC;CACF;AA7KD,oDA6KC"}
|
|
@@ -10,14 +10,13 @@ export declare class GenerateTypology {
|
|
|
10
10
|
timecodes?: string[];
|
|
11
11
|
content: any[];
|
|
12
12
|
};
|
|
13
|
-
promptIdForTypology: string;
|
|
14
13
|
expectedFields: Array<string>;
|
|
15
14
|
constructor(openAiService: OpenAiService, type: string, sourceId: string, content: {
|
|
16
15
|
title: string;
|
|
17
16
|
h1_headings?: string[];
|
|
18
17
|
timecodes?: string[];
|
|
19
18
|
content: any[];
|
|
20
|
-
}, expected_fields: Array<string>,
|
|
19
|
+
}, expected_fields: Array<string>, generationCurriculum: boolean);
|
|
21
20
|
generate(): Promise<any>;
|
|
22
21
|
parseTypologyOnSuccess(responseData: any): {
|
|
23
22
|
status_code: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_typology.d.ts","sourceRoot":"","sources":["../../src/typology_gen/generate_typology.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate_typology.d.ts","sourceRoot":"","sources":["../../src/typology_gen/generate_typology.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAI5D,qBAAa,gBAAgB;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAM;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,OAAO,EAAE;QACd,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,EAAE,GAAG,EAAE,CAAC;KAChB,CAAC;IACF,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAE5B,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,EAAE,GAAG,EAAE,CAAC;KAChB,EACD,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,EAC9B,oBAAoB,EAAE,OAAO;IAWzB,QAAQ;IA2Fd,sBAAsB,CAAC,YAAY,EAAE,GAAG;;;;;;;;;;IAgBxC,SAAS,CAAC,QAAQ,EAAE,GAAG;IAoCvB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;;;;IAQ3B,sBAAsB,CAAC,YAAY,EAAE,GAAG;;;;CAQ/C"}
|
|
@@ -12,17 +12,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.GenerateTypology = void 0;
|
|
13
13
|
const openai_helper_1 = require("../helper/openai_helper");
|
|
14
14
|
const logger_1 = require("../logger");
|
|
15
|
+
const get_prompts_1 = require("../services/get_prompts");
|
|
15
16
|
const sanitize_strings_1 = require("../utils/sanitize_strings");
|
|
16
17
|
const jsonrepair_1 = require("jsonrepair");
|
|
17
18
|
class GenerateTypology {
|
|
18
|
-
constructor(openAiService, type, sourceId, content, expected_fields,
|
|
19
|
+
constructor(openAiService, type, sourceId, content, expected_fields, generationCurriculum) {
|
|
19
20
|
this.type = "";
|
|
20
21
|
this.openAiService = openAiService;
|
|
21
22
|
this.type = type;
|
|
22
23
|
this.sourceId = sourceId;
|
|
23
24
|
this.content = content;
|
|
24
25
|
this.expectedFields = expected_fields.map((elem) => elem.toString().toUpperCase());
|
|
25
|
-
this.promptIdForTypology = promptIdForTypology;
|
|
26
26
|
this.generationCurriculum = generationCurriculum;
|
|
27
27
|
}
|
|
28
28
|
generate() {
|
|
@@ -32,7 +32,7 @@ class GenerateTypology {
|
|
|
32
32
|
const openAIHelper = new openai_helper_1.OpenAIHelper(this.openAiService.api_key);
|
|
33
33
|
const openAiResponse = yield openAIHelper.openAI.responses.create({
|
|
34
34
|
prompt: {
|
|
35
|
-
id:
|
|
35
|
+
id: get_prompts_1.promptIds.classify,
|
|
36
36
|
variables: {
|
|
37
37
|
heading_type: this.type == "video" ? "timecode" : "h1 heading",
|
|
38
38
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_typology.js","sourceRoot":"","sources":["../../src/typology_gen/generate_typology.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAuD;AACvD,sCAAoD;AAEpD,gEAAkE;AAClE,2CAAwC;AAExC,MAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"generate_typology.js","sourceRoot":"","sources":["../../src/typology_gen/generate_typology.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAuD;AACvD,sCAAoD;AACpD,yDAAoD;AAEpD,gEAAkE;AAClE,2CAAwC;AAExC,MAAa,gBAAgB;IAY3B,YACE,aAA4B,EAC5B,IAAY,EACZ,QAAgB,EAChB,OAKC,EACD,eAA8B,EAC9B,oBAA6B;QArBxB,SAAI,GAAW,EAAE,CAAC;QAuBvB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,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";
|
|
3
|
+
import { GenerationVariablesSchema } from "../types/generation_variables_schema";
|
|
3
4
|
export declare class GenerateSummaryCards {
|
|
4
5
|
openAiService: OpenAiService;
|
|
5
6
|
openAIHelper: OpenAIHelper;
|
|
6
7
|
sourceId: string;
|
|
7
8
|
generationCurriculum: boolean;
|
|
9
|
+
generationVariablesSchema: GenerationVariablesSchema;
|
|
8
10
|
content: {
|
|
9
11
|
title: string;
|
|
10
12
|
h1_headings?: string[];
|
|
@@ -12,13 +14,12 @@ export declare class GenerateSummaryCards {
|
|
|
12
14
|
content: any[];
|
|
13
15
|
};
|
|
14
16
|
type: string;
|
|
15
|
-
promptIdForSummaryCards: string;
|
|
16
17
|
constructor(openAiService: OpenAiService, sourceId: string, content: {
|
|
17
18
|
title: string;
|
|
18
19
|
h1_headings?: string[];
|
|
19
20
|
timecodes?: string[];
|
|
20
21
|
content: any[];
|
|
21
|
-
}, type: string,
|
|
22
|
+
}, type: string, generationCurriculum: boolean, generationVariablesSchema: GenerationVariablesSchema);
|
|
22
23
|
generate(): Promise<{
|
|
23
24
|
summary_cards: any;
|
|
24
25
|
metadata: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarize.d.ts","sourceRoot":"","sources":["../../src/typology_gen/summarize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"summarize.d.ts","sourceRoot":"","sources":["../../src/typology_gen/summarize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAK5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAGjF,qBAAa,oBAAoB;IACxB,aAAa,EAAE,aAAa,CAAC;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,yBAAyB,EAAE,yBAAyB,CAAC;IACrD,OAAO,EAAE;QACd,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,EAAE,GAAG,EAAE,CAAC;KAChB,CAAC;IACK,IAAI,EAAE,MAAM,CAAM;gBAEvB,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,EAAE,GAAG,EAAE,CAAC;KAChB,EACD,IAAI,EAAE,MAAM,EACZ,oBAAoB,EAAE,OAAO,EAC7B,yBAAyB,EAAE,yBAAyB;IAWhD,QAAQ;;;;IAsGd,SAAS,CAAC,QAAQ,EAAE,GAAG;CAkCxB"}
|
|
@@ -15,16 +15,17 @@ const logger_1 = require("../logger");
|
|
|
15
15
|
const sanitize_strings_1 = require("../utils/sanitize_strings");
|
|
16
16
|
const build_summary_schema_1 = require("../helper/schema_helper/build_summary_schema");
|
|
17
17
|
const jsonrepair_1 = require("jsonrepair");
|
|
18
|
+
const get_prompts_1 = require("../services/get_prompts");
|
|
18
19
|
class GenerateSummaryCards {
|
|
19
|
-
constructor(openAiService, sourceId, content, type,
|
|
20
|
+
constructor(openAiService, sourceId, content, type, generationCurriculum, generationVariablesSchema) {
|
|
20
21
|
this.type = "";
|
|
21
22
|
this.openAiService = openAiService;
|
|
22
23
|
this.openAIHelper = new openai_helper_1.OpenAIHelper(this.openAiService.api_key);
|
|
23
24
|
this.content = content;
|
|
24
|
-
this.promptIdForSummaryCards = promptIdForSummaryCards;
|
|
25
25
|
this.type = type;
|
|
26
26
|
this.sourceId = sourceId;
|
|
27
27
|
this.generationCurriculum = generationCurriculum;
|
|
28
|
+
this.generationVariablesSchema = generationVariablesSchema;
|
|
28
29
|
}
|
|
29
30
|
generate() {
|
|
30
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -33,10 +34,11 @@ class GenerateSummaryCards {
|
|
|
33
34
|
const headings = this.type === "text"
|
|
34
35
|
? this.content.h1_headings || [""]
|
|
35
36
|
: this.content.timecodes || [""];
|
|
36
|
-
const schema = yield (0, build_summary_schema_1.buildSummarySchema)(headings.length > 0 ? headings : [""],
|
|
37
|
+
const schema = yield (0, build_summary_schema_1.buildSummarySchema)(headings.length > 0 ? headings : [""], this.generationVariablesSchema.output_schema.summary);
|
|
38
|
+
// const schema = this.generationVariablesSchema.output_schema.summary;
|
|
37
39
|
const openAiResponse = yield this.openAIHelper.openAI.responses.create({
|
|
38
40
|
prompt: {
|
|
39
|
-
id:
|
|
41
|
+
id: get_prompts_1.promptIds.summarize,
|
|
40
42
|
variables: {
|
|
41
43
|
heading_type: this.type == "video" ? "timecode" : "h1 heading",
|
|
42
44
|
},
|