only_ever_generator 8.3.0 → 8.3.2
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.js +19 -19
- package/dist/bootstrap/app.js.map +1 -1
- package/dist/card_gen/generate_cards.d.ts.map +1 -1
- package/dist/card_gen/generate_cards.js +70 -3
- package/dist/card_gen/generate_cards.js.map +1 -1
- package/dist/helper/schema_helper/build_card_schema.d.ts +0 -165
- package/dist/helper/schema_helper/build_card_schema.d.ts.map +1 -1
- package/dist/helper/schema_helper/build_card_schema.js +1 -146
- package/dist/helper/schema_helper/build_card_schema.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/bootstrap/app.ts +22 -22
- package/src/card_gen/generate_cards.ts +101 -30
- package/src/helper/schema_helper/build_card_schema.ts +0 -147
- package/src/index.ts +62 -0
package/dist/bootstrap/app.js
CHANGED
|
@@ -136,25 +136,25 @@ class OnlyEverGenerator {
|
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
else if (elem == "generate_card") {
|
|
139
|
-
if (this.shouldTheCardBeGeneratedAfterTypologyResponse()) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
139
|
+
// if (this.shouldTheCardBeGeneratedAfterTypologyResponse()) {
|
|
140
|
+
console.log("Generating card");
|
|
141
|
+
this.parsedContent.taxonomy = {
|
|
142
|
+
concepts_facts: (_j = (_h = this.typologyResponse) === null || _h === void 0 ? void 0 : _h.concepts_facts) !== null && _j !== void 0 ? _j : [],
|
|
143
|
+
fields: this.expectedFields,
|
|
144
|
+
summary_cards: (_l = (_k = this.typologyResponse) === null || _k === void 0 ? void 0 : _k.summary_cards) !== null && _l !== void 0 ? _l : [],
|
|
145
|
+
learn_value: (_o = (_m = this.typologyResponse) === null || _m === void 0 ? void 0 : _m.learn_value) !== null && _o !== void 0 ? _o : {
|
|
146
|
+
value: 0,
|
|
147
|
+
reason: "",
|
|
148
|
+
bloom_levels: [],
|
|
149
|
+
bloom_levels_reason: "",
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
this.cardgenResponse = yield this.generateCard(this.n, card_generation_types);
|
|
153
|
+
responseToReturn.push({
|
|
154
|
+
type: "card_gen",
|
|
155
|
+
data: this.cardgenResponse,
|
|
156
|
+
});
|
|
157
|
+
// }
|
|
158
158
|
}
|
|
159
159
|
return responseToReturn;
|
|
160
160
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/bootstrap/app.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAGoC;AACpC,wEAAmE;AACnE,iEAA4D;AAC5D,yEAAqE;AACrE,0DAAsD;AACtD,qFAAiF;AACjF,mGAA+F;AAC/F,qGAAiG;AAIjG,mFAA8E;AAC9E,yDAAiE;AAEjE,MAAa,iBAAiB;IAyB5B,YACE,MAAc,EACd,KAAa,EACb,iBAAgC,EAChC,mBAA2B,EAC3B,uBAA+B,EAC/B,0BAAkC,EAClC,uBAA+B,EAE/B,oBAA6B,EAC7B,CAAqB;QAlChB,YAAO,GAAW,EAAE,CAAC;QAG5B,yDAAyD;QACzD,kBAAa,GAOT,SAAS,CAAC;QACP,yBAAoB,GAAY,KAAK,CAAC;QAKtC,MAAC,GAAW,CAAC,CAAC;QAErB,mBAAc,GAAkB,EAAE,CAAC;QACnC,qBAAgB,GAAS,SAAS,CAAC;QACnC,oBAAe,GAA8B,EAAE,CAAC;QAChD,sBAAiB,GAAG,EAAE,CAAC;QAcrB,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;Q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AAmB,CACvB,cAMG,EACH,QAAgB,EAChB,SAAiB;;YAEjB,MAAM,UAAU,GAAG,MAAM,IAAI,0CAAmB,EAAE,CAAC,WAAW,CAC5D,cAAc,EACd,QAAQ,EACR,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,GAAG,CACjB,CAAC;YAEF,OAAO,UAAU,CAAC;QACpB,CAAC;KAAA;CACF;AApVD,8CAoVC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_cards.d.ts","sourceRoot":"","sources":["../../src/card_gen/generate_cards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"generate_cards.d.ts","sourceRoot":"","sources":["../../src/card_gen/generate_cards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAIvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAK3D,KAAK,qBAAqB,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;CAC/B,CAAC;AAGF,MAAM,MAAM,yBAAyB,GAAG,CAAC,qBAAqB,GAAG,SAAS,CAAC,EAAE,CAAC;AAE9E,qBAAa,aAAa;IACxB,aAAa,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,cAAc,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IACpB,0BAA0B,EAAE,MAAM,CAAC;IACnC,oBAAoB,EAAE,OAAO,CAAC;gBAEnC,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,cAAc,EAExB,0BAA0B,EAAE,MAAM,EAClC,oBAAoB,EAAE,OAAO,EAC7B,WAAW,EAAE,MAAM;IAYf,cAAc,CAAC,qBAAqB,EAAE,MAAM,EAAE;IAuI9C,aAAa,CACjB,CAAC,EAAE,MAAM,EACT,qBAAqB,EAAE,MAAM,EAAE,GAC9B,OAAO,CAAC,yBAAyB,CAAC;IAwE/B,oBAAoB,CACxB,CAAC,EAAE,MAAM,EACT,oBAAoB,EAAE,MAAM,GAC3B,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IA0E7C,SAAS,CAAC,QAAQ,EAAE,GAAG;CAWxB"}
|
|
@@ -8,6 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.GenerateCards = void 0;
|
|
13
16
|
const openai_helper_1 = require("../helper/openai_helper");
|
|
@@ -15,6 +18,7 @@ const build_card_schema_1 = require("../helper/schema_helper/build_card_schema")
|
|
|
15
18
|
const logger_1 = require("../logger");
|
|
16
19
|
const parse_card_response_1 = require("../parse/parse_card_response");
|
|
17
20
|
const get_prompts_1 = require("../services/get_prompts");
|
|
21
|
+
const axios_1 = __importDefault(require("axios"));
|
|
18
22
|
class GenerateCards {
|
|
19
23
|
constructor(openAiService, sourceId, content, taxonomy, promptIdForCardsGeneration, generationCurriculum, source_type) {
|
|
20
24
|
this.openAiService = openAiService;
|
|
@@ -37,7 +41,35 @@ class GenerateCards {
|
|
|
37
41
|
.map((fact) => fact.text);
|
|
38
42
|
const schema = yield (0, build_card_schema_1.buildCardSchema)(concepts, facts, card_generation_types);
|
|
39
43
|
try {
|
|
40
|
-
let response =
|
|
44
|
+
// let response: any = await this.openAIHelper.openAI.responses.create({
|
|
45
|
+
// prompt: {
|
|
46
|
+
// id: this.promptIdForCardsGeneration,
|
|
47
|
+
// variables: {
|
|
48
|
+
// bloom_level: "1",
|
|
49
|
+
// card_types: card_generation_types.join(","),
|
|
50
|
+
// bloom_instructions: variables.bloom_instructions,
|
|
51
|
+
// card_instructions: variables.card_instructions,
|
|
52
|
+
// card_examples: variables.card_examples,
|
|
53
|
+
// },
|
|
54
|
+
// },
|
|
55
|
+
// max_output_tokens: 30000,
|
|
56
|
+
// input: [
|
|
57
|
+
// {
|
|
58
|
+
// role: "user",
|
|
59
|
+
// content: [{ type: "input_text", text: this.content }],
|
|
60
|
+
// },
|
|
61
|
+
// ],
|
|
62
|
+
// store: true,
|
|
63
|
+
// text: {
|
|
64
|
+
// format: {
|
|
65
|
+
// type: "json_schema",
|
|
66
|
+
// name: schema.name,
|
|
67
|
+
// strict: schema.strict,
|
|
68
|
+
// schema: schema.schema,
|
|
69
|
+
// },
|
|
70
|
+
// },
|
|
71
|
+
// });
|
|
72
|
+
const response = yield axios_1.default.post("https://api.openai.com/v1/responses", {
|
|
41
73
|
prompt: {
|
|
42
74
|
id: this.promptIdForCardsGeneration,
|
|
43
75
|
variables: {
|
|
@@ -48,7 +80,6 @@ class GenerateCards {
|
|
|
48
80
|
card_examples: variables.card_examples,
|
|
49
81
|
},
|
|
50
82
|
},
|
|
51
|
-
max_output_tokens: 30000,
|
|
52
83
|
input: [
|
|
53
84
|
{
|
|
54
85
|
role: "user",
|
|
@@ -64,7 +95,14 @@ class GenerateCards {
|
|
|
64
95
|
schema: schema.schema,
|
|
65
96
|
},
|
|
66
97
|
},
|
|
98
|
+
}, {
|
|
99
|
+
headers: {
|
|
100
|
+
"Content-Type": "application/json",
|
|
101
|
+
Authorization: `Bearer ${this.openAiService.api_key}`,
|
|
102
|
+
// "OpenAI-Beta": "response-format=json_schema",
|
|
103
|
+
},
|
|
67
104
|
});
|
|
105
|
+
console.log(response.data);
|
|
68
106
|
if (!response) {
|
|
69
107
|
yield (0, logger_1.log_error)({
|
|
70
108
|
flow: this.generationCurriculum
|
|
@@ -96,6 +134,7 @@ class GenerateCards {
|
|
|
96
134
|
type: {
|
|
97
135
|
request_type: "depth",
|
|
98
136
|
n: 1,
|
|
137
|
+
card_types: card_generation_types.join(","),
|
|
99
138
|
},
|
|
100
139
|
});
|
|
101
140
|
}
|
|
@@ -112,6 +151,7 @@ class GenerateCards {
|
|
|
112
151
|
type: {
|
|
113
152
|
request_type: "depth",
|
|
114
153
|
n: 1,
|
|
154
|
+
card_types: card_generation_types.join(","),
|
|
115
155
|
},
|
|
116
156
|
});
|
|
117
157
|
}
|
|
@@ -126,9 +166,35 @@ class GenerateCards {
|
|
|
126
166
|
// parsedContent
|
|
127
167
|
// );
|
|
128
168
|
console.log("generation started");
|
|
129
|
-
|
|
169
|
+
// Use Promise.allSettled to allow individual types to fail without affecting others
|
|
170
|
+
const settledResponses = yield Promise.allSettled(card_generation_types.map((card_generation_type) => __awaiter(this, void 0, void 0, function* () {
|
|
130
171
|
return yield this.generateCardsForType(n, card_generation_type);
|
|
131
172
|
})));
|
|
173
|
+
// Extract fulfilled responses and log rejected ones
|
|
174
|
+
let responses = settledResponses.map((result, index) => {
|
|
175
|
+
if (result.status === "fulfilled") {
|
|
176
|
+
return result.value;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
// Log the rejection but continue with other types
|
|
180
|
+
console.error(`Failed to generate cards for type ${card_generation_types[index]}:`, result.reason);
|
|
181
|
+
(0, logger_1.log_error)({
|
|
182
|
+
flow: this.generationCurriculum
|
|
183
|
+
? "curriculum_manual_generation"
|
|
184
|
+
: "manual_generation",
|
|
185
|
+
data: result.reason,
|
|
186
|
+
timestamp: new Date(),
|
|
187
|
+
error: "error_in_card_generation_for_type",
|
|
188
|
+
source_id: this.sourceId,
|
|
189
|
+
type: {
|
|
190
|
+
request_type: "depth",
|
|
191
|
+
n: n,
|
|
192
|
+
card_types: card_generation_types[index],
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
132
198
|
// Flatten all parsed cards from all responses
|
|
133
199
|
// const allParsedCards: AllParsedCards = [];
|
|
134
200
|
// for (const response of responses) {
|
|
@@ -226,6 +292,7 @@ class GenerateCards {
|
|
|
226
292
|
bloom_level: 1,
|
|
227
293
|
},
|
|
228
294
|
});
|
|
295
|
+
return undefined;
|
|
229
296
|
}
|
|
230
297
|
});
|
|
231
298
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_cards.js","sourceRoot":"","sources":["../../src/card_gen/generate_cards.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate_cards.js","sourceRoot":"","sources":["../../src/card_gen/generate_cards.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2DAAuD;AACvD,iFAA4E;AAC5E,sCAAiE;AACjE,sEAAiE;AAKjE,yDAAqD;AACrD,kDAA0B;AAa1B,MAAa,aAAa;IASxB,YACE,aAA4B,EAC5B,QAAgB,EAChB,OAAe,EACf,QAAwB,EAExB,0BAAkC,EAClC,oBAA6B,EAC7B,WAAmB;QAEnB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,YAAY,GAAG,IAAI,4BAAY,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACjE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,0BAA0B,GAAG,0BAA0B,CAAC;QAC7D,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QACjD,IA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AM,IAAA,kBAAS,EAAC;oBACd,IAAI,EAAE,IAAI,CAAC,oBAAoB;wBAC7B,CAAC,CAAC,8BAA8B;wBAChC,CAAC,CAAC,mBAAmB;oBACvB,IAAI,EAAE,CAAC;oBACP,SAAS,EAAE,IAAI,IAAI,EAAE;oBACrB,KAAK,EAAE,0BAA0B;oBACjC,SAAS,EAAE,IAAI,CAAC,QAAQ;oBACxB,IAAI,EAAE;wBACJ,YAAY,EAAE,OAAO;wBACrB,CAAC,EAAE,CAAC;wBACJ,UAAU,EAAE,oBAAoB;wBAChC,WAAW,EAAE,CAAC;qBACf;iBACF,CAAC,CAAC;gBACH,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;KAAA;IAED,SAAS,CAAC,QAAa;QACrB,IAAI,CAAC;YACH,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC;YACnE,OAAO,cAAc,CAAC;QACxB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,qBAAY,CACpB,0CAA0C,EAC1C,QAAQ,CACT,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAvUD,sCAuUC"}
|
|
@@ -1,167 +1,2 @@
|
|
|
1
1
|
export declare const buildCardSchema: (concepts: string[], facts: string[], card_generation_types: string[]) => Promise<any>;
|
|
2
|
-
export declare const cardSchema: (concepts: string[], facts: string[]) => {
|
|
3
|
-
type: string;
|
|
4
|
-
properties: {
|
|
5
|
-
test_cards: {
|
|
6
|
-
type: string;
|
|
7
|
-
items: {
|
|
8
|
-
type: string;
|
|
9
|
-
properties: {
|
|
10
|
-
type: {
|
|
11
|
-
type: string;
|
|
12
|
-
enum: string[];
|
|
13
|
-
};
|
|
14
|
-
card_content: {
|
|
15
|
-
anyOf: ({
|
|
16
|
-
type: string;
|
|
17
|
-
properties: {
|
|
18
|
-
front: {
|
|
19
|
-
type: string;
|
|
20
|
-
maxLength: number;
|
|
21
|
-
};
|
|
22
|
-
back: {
|
|
23
|
-
type: string;
|
|
24
|
-
maxLength: number;
|
|
25
|
-
};
|
|
26
|
-
prompt?: undefined;
|
|
27
|
-
correct_options?: undefined;
|
|
28
|
-
incorrect_options?: undefined;
|
|
29
|
-
choices?: undefined;
|
|
30
|
-
};
|
|
31
|
-
required: string[];
|
|
32
|
-
additionalProperties: boolean;
|
|
33
|
-
minItems?: undefined;
|
|
34
|
-
maxItems?: undefined;
|
|
35
|
-
items?: undefined;
|
|
36
|
-
} | {
|
|
37
|
-
type: string;
|
|
38
|
-
minItems: number;
|
|
39
|
-
maxItems: number;
|
|
40
|
-
items: {
|
|
41
|
-
anyOf: {
|
|
42
|
-
type: string;
|
|
43
|
-
properties: {
|
|
44
|
-
left_item: {
|
|
45
|
-
type: string;
|
|
46
|
-
maxLength: number;
|
|
47
|
-
};
|
|
48
|
-
right_item: {
|
|
49
|
-
type: string;
|
|
50
|
-
maxLength: number;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
required: string[];
|
|
54
|
-
additionalProperties: boolean;
|
|
55
|
-
}[];
|
|
56
|
-
};
|
|
57
|
-
properties?: undefined;
|
|
58
|
-
required?: undefined;
|
|
59
|
-
additionalProperties?: undefined;
|
|
60
|
-
} | {
|
|
61
|
-
type: string;
|
|
62
|
-
properties: {
|
|
63
|
-
prompt: {
|
|
64
|
-
type: string;
|
|
65
|
-
maxLength: number;
|
|
66
|
-
pattern: string;
|
|
67
|
-
};
|
|
68
|
-
correct_options: {
|
|
69
|
-
type: string;
|
|
70
|
-
minItems: number;
|
|
71
|
-
maxItems: number;
|
|
72
|
-
items: {
|
|
73
|
-
type: string;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
incorrect_options: {
|
|
77
|
-
type: string;
|
|
78
|
-
minItems: number;
|
|
79
|
-
maxItems: number;
|
|
80
|
-
items: {
|
|
81
|
-
type: string;
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
front?: undefined;
|
|
85
|
-
back?: undefined;
|
|
86
|
-
choices?: undefined;
|
|
87
|
-
};
|
|
88
|
-
required: string[];
|
|
89
|
-
additionalProperties: boolean;
|
|
90
|
-
minItems?: undefined;
|
|
91
|
-
maxItems?: undefined;
|
|
92
|
-
items?: undefined;
|
|
93
|
-
} | {
|
|
94
|
-
type: string;
|
|
95
|
-
properties: {
|
|
96
|
-
prompt: {
|
|
97
|
-
type: string;
|
|
98
|
-
maxLength: number;
|
|
99
|
-
pattern?: undefined;
|
|
100
|
-
};
|
|
101
|
-
choices: {
|
|
102
|
-
type: string;
|
|
103
|
-
minItems: number;
|
|
104
|
-
maxItems: number;
|
|
105
|
-
items: {
|
|
106
|
-
type: string;
|
|
107
|
-
properties: {
|
|
108
|
-
choice: {
|
|
109
|
-
type: string;
|
|
110
|
-
maxLength: number;
|
|
111
|
-
};
|
|
112
|
-
is_correct: {
|
|
113
|
-
type: string;
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
required: string[];
|
|
117
|
-
additionalProperties: boolean;
|
|
118
|
-
};
|
|
119
|
-
};
|
|
120
|
-
front?: undefined;
|
|
121
|
-
back?: undefined;
|
|
122
|
-
correct_options?: undefined;
|
|
123
|
-
incorrect_options?: undefined;
|
|
124
|
-
};
|
|
125
|
-
required: string[];
|
|
126
|
-
additionalProperties: boolean;
|
|
127
|
-
minItems?: undefined;
|
|
128
|
-
maxItems?: undefined;
|
|
129
|
-
items?: undefined;
|
|
130
|
-
})[];
|
|
131
|
-
};
|
|
132
|
-
explanation: {
|
|
133
|
-
type: string;
|
|
134
|
-
maxLength: number;
|
|
135
|
-
description: string;
|
|
136
|
-
};
|
|
137
|
-
concepts: {
|
|
138
|
-
type: string;
|
|
139
|
-
minItems: number;
|
|
140
|
-
items: {
|
|
141
|
-
type: string;
|
|
142
|
-
enum: string[];
|
|
143
|
-
};
|
|
144
|
-
};
|
|
145
|
-
facts: {
|
|
146
|
-
type: string;
|
|
147
|
-
minItems: number;
|
|
148
|
-
items: {
|
|
149
|
-
type: string;
|
|
150
|
-
enum: string[];
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
bloom_alignment: {
|
|
154
|
-
type: string;
|
|
155
|
-
maxLength: number;
|
|
156
|
-
description: string;
|
|
157
|
-
};
|
|
158
|
-
};
|
|
159
|
-
required: string[];
|
|
160
|
-
additionalProperties: boolean;
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
required: string[];
|
|
165
|
-
additionalProperties: boolean;
|
|
166
|
-
};
|
|
167
2
|
//# sourceMappingURL=build_card_schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_card_schema.d.ts","sourceRoot":"","sources":["../../../src/helper/schema_helper/build_card_schema.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAAE,EAClB,OAAO,MAAM,EAAE,EACf,uBAAuB,MAAM,EAAE,iBA+DhC,CAAC
|
|
1
|
+
{"version":3,"file":"build_card_schema.d.ts","sourceRoot":"","sources":["../../../src/helper/schema_helper/build_card_schema.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAAE,EAClB,OAAO,MAAM,EAAE,EACf,uBAAuB,MAAM,EAAE,iBA+DhC,CAAC"}
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.buildCardSchema = void 0;
|
|
13
13
|
const sanitize_strings_1 = require("../../utils/sanitize_strings");
|
|
14
14
|
const mongo_helper_1 = require("../mongo_helper");
|
|
15
15
|
// flash:68ef4e1b5a123c94a835c6ab
|
|
@@ -70,149 +70,4 @@ const buildCardSchema = (concepts, facts, card_generation_types) => __awaiter(vo
|
|
|
70
70
|
return populatedSchema;
|
|
71
71
|
});
|
|
72
72
|
exports.buildCardSchema = buildCardSchema;
|
|
73
|
-
const cardSchema = (concepts, facts) => {
|
|
74
|
-
return {
|
|
75
|
-
type: "object",
|
|
76
|
-
properties: {
|
|
77
|
-
test_cards: {
|
|
78
|
-
type: "array",
|
|
79
|
-
items: {
|
|
80
|
-
type: "object",
|
|
81
|
-
properties: {
|
|
82
|
-
type: {
|
|
83
|
-
type: "string",
|
|
84
|
-
enum: ["mcq", "cloze", "match", "flash"],
|
|
85
|
-
},
|
|
86
|
-
card_content: {
|
|
87
|
-
anyOf: [
|
|
88
|
-
// Flash Card
|
|
89
|
-
{
|
|
90
|
-
type: "object",
|
|
91
|
-
properties: {
|
|
92
|
-
front: { type: "string", maxLength: 320 },
|
|
93
|
-
back: { type: "string", maxLength: 320 },
|
|
94
|
-
},
|
|
95
|
-
required: ["front", "back"],
|
|
96
|
-
additionalProperties: false,
|
|
97
|
-
},
|
|
98
|
-
// Match Card
|
|
99
|
-
{
|
|
100
|
-
type: "array",
|
|
101
|
-
minItems: 1,
|
|
102
|
-
maxItems: 9,
|
|
103
|
-
items: {
|
|
104
|
-
anyOf: [
|
|
105
|
-
{
|
|
106
|
-
type: "object",
|
|
107
|
-
properties: {
|
|
108
|
-
left_item: { type: "string", maxLength: 30 },
|
|
109
|
-
right_item: { type: "string", maxLength: 30 },
|
|
110
|
-
},
|
|
111
|
-
required: ["left_item", "right_item"],
|
|
112
|
-
additionalProperties: false,
|
|
113
|
-
},
|
|
114
|
-
// {
|
|
115
|
-
// type: "object",
|
|
116
|
-
// properties: {
|
|
117
|
-
// explanation: { type: "string", maxLength: 320 },
|
|
118
|
-
// },
|
|
119
|
-
// required: ["explanation"],
|
|
120
|
-
// additionalProperties: false,
|
|
121
|
-
// },
|
|
122
|
-
],
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
// Cloze Card
|
|
126
|
-
{
|
|
127
|
-
type: "object",
|
|
128
|
-
properties: {
|
|
129
|
-
prompt: {
|
|
130
|
-
type: "string",
|
|
131
|
-
maxLength: 320,
|
|
132
|
-
pattern: ".*{{.+?}}.*",
|
|
133
|
-
},
|
|
134
|
-
correct_options: {
|
|
135
|
-
type: "array",
|
|
136
|
-
minItems: 1,
|
|
137
|
-
maxItems: 4,
|
|
138
|
-
items: { type: "string" },
|
|
139
|
-
},
|
|
140
|
-
incorrect_options: {
|
|
141
|
-
type: "array",
|
|
142
|
-
minItems: 1,
|
|
143
|
-
maxItems: 7,
|
|
144
|
-
items: { type: "string" },
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
required: ["prompt", "correct_options", "incorrect_options"],
|
|
148
|
-
additionalProperties: false,
|
|
149
|
-
},
|
|
150
|
-
// MCQ Card
|
|
151
|
-
{
|
|
152
|
-
type: "object",
|
|
153
|
-
properties: {
|
|
154
|
-
prompt: { type: "string", maxLength: 320 },
|
|
155
|
-
choices: {
|
|
156
|
-
type: "array",
|
|
157
|
-
minItems: 2,
|
|
158
|
-
maxItems: 8,
|
|
159
|
-
items: {
|
|
160
|
-
type: "object",
|
|
161
|
-
properties: {
|
|
162
|
-
choice: { type: "string", maxLength: 42 },
|
|
163
|
-
is_correct: { type: "boolean" },
|
|
164
|
-
},
|
|
165
|
-
required: ["choice", "is_correct"],
|
|
166
|
-
additionalProperties: false,
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
// explanation: { type: "string", maxLength: 320 },
|
|
170
|
-
},
|
|
171
|
-
required: ["prompt", "choices"],
|
|
172
|
-
additionalProperties: false,
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
},
|
|
176
|
-
explanation: {
|
|
177
|
-
type: "string",
|
|
178
|
-
maxLength: 320,
|
|
179
|
-
description: "Explanation for the card (≤320 characters). " +
|
|
180
|
-
"If no useful explanation exists, return an empty string. " +
|
|
181
|
-
"Include only if it helps the learner understand the concept(s) or fact(s) being tested. " +
|
|
182
|
-
"Do not explain anything unrelated, repeat answers verbatim, or add meta-comments. " +
|
|
183
|
-
"Keep it clear and concise; you may draw on personal knowledge where appropriate.",
|
|
184
|
-
},
|
|
185
|
-
concepts: {
|
|
186
|
-
type: "array",
|
|
187
|
-
minItems: 1,
|
|
188
|
-
items: { type: "string", enum: concepts },
|
|
189
|
-
},
|
|
190
|
-
facts: {
|
|
191
|
-
type: "array",
|
|
192
|
-
minItems: 1,
|
|
193
|
-
items: { type: "string", enum: facts },
|
|
194
|
-
},
|
|
195
|
-
bloom_alignment: {
|
|
196
|
-
type: "string",
|
|
197
|
-
maxLength: 240,
|
|
198
|
-
description: "Explain why this card fits the bloom level you were asked to create (max. 240 chars)",
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
required: [
|
|
202
|
-
"type",
|
|
203
|
-
"card_content",
|
|
204
|
-
"concepts",
|
|
205
|
-
"facts",
|
|
206
|
-
"bloom_alignment",
|
|
207
|
-
"explanation",
|
|
208
|
-
],
|
|
209
|
-
additionalProperties: false,
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
required: ["test_cards"],
|
|
214
|
-
additionalProperties: false,
|
|
215
|
-
};
|
|
216
|
-
};
|
|
217
|
-
exports.cardSchema = cardSchema;
|
|
218
73
|
//# sourceMappingURL=build_card_schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_card_schema.js","sourceRoot":"","sources":["../../../src/helper/schema_helper/build_card_schema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mEAAwE;AACxE,kDAA4D;AAE5D,iCAAiC;AACjC,iCAAiC;AACjC,+BAA+B;AAC/B,iCAAiC;AAC1B,MAAM,eAAe,GAAG,CAC7B,QAAkB,EAClB,KAAe,EACf,qBAA+B,EAC/B,EAAE;IACF,IAAA,oBAAK,GAAE,CAAC;IACR,MAAM,QAAQ,GAAG,IAAI,uBAAQ,CAAC,0BAA0B,CAAC,CAAC;IAC1D,MAAM,SAAS,GAAG,MAAM,uBAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,OAA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C,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3C,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI;QAC/E,iBAAiB,CAAC;IACpB,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI;QAC5E,cAAc,CAAC;IAEjB,iEAAiE;IACjE,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI;QACrE,qBAAqB,CAAC;IAExB,iEAAiE;IACjE,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5C,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,YAAY;YACxE;gBACE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC;aACtC,CAAC;IACN,CAAC;IAED,OAAO,CAAC,GAAG,CACT,kBAAkB,EAClB,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAC5E,CAAC;IACF,OAAO,eAAe,CAAC;AACzB,CAAC,CAAA,CAAC;AAlEW,QAAA,eAAe,mBAkE1B
|
|
1
|
+
{"version":3,"file":"build_card_schema.js","sourceRoot":"","sources":["../../../src/helper/schema_helper/build_card_schema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mEAAwE;AACxE,kDAA4D;AAE5D,iCAAiC;AACjC,iCAAiC;AACjC,+BAA+B;AAC/B,iCAAiC;AAC1B,MAAM,eAAe,GAAG,CAC7B,QAAkB,EAClB,KAAe,EACf,qBAA+B,EAC/B,EAAE;IACF,IAAA,oBAAK,GAAE,CA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","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIpD,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
15
|
exports.OnlyEverGenerator = void 0;
|
|
16
|
+
const express_1 = __importDefault(require("express"));
|
|
4
17
|
const app_1 = require("./bootstrap/app");
|
|
5
18
|
Object.defineProperty(exports, "OnlyEverGenerator", { enumerable: true, get: function () { return app_1.OnlyEverGenerator; } });
|
|
19
|
+
const mongodb_1 = require("mongodb");
|
|
20
|
+
const mongo_helper_1 = require("./helper/mongo_helper");
|
|
21
|
+
const app = (0, express_1.default)();
|
|
22
|
+
app.get("/generate", (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
var _a, _b, _c;
|
|
24
|
+
const source = new mongodb_1.ObjectId("691acee5ecae1cfe8c5c2e72");
|
|
25
|
+
(0, mongo_helper_1.setUp)();
|
|
26
|
+
const openAiKey = process.env.OPEN_AI_KEY;
|
|
27
|
+
const document = yield mongo_helper_1.database
|
|
28
|
+
.collection("_source")
|
|
29
|
+
.findOne({ _id: source });
|
|
30
|
+
if (!document) {
|
|
31
|
+
return res.status(404).json({ error: "Source not found" });
|
|
32
|
+
}
|
|
33
|
+
const promptIdForClassify = "pmpt_687a8872d1c8819088a9cdc97dcb688b0893663621695594";
|
|
34
|
+
const promptIdForConceptFacts = "pmpt_687aa547f99c8193b99467ca53630c2607f5a8caf451e7e8";
|
|
35
|
+
const promptIdForCardGeneration = "pmpt_688118a923e4819098176a13a2f401920d2ea17d881cc6c6";
|
|
36
|
+
const promptIdForMissingConceptsFacts = "pmpt_687ab50298dc8194b214804999d23df10e03b855371691f9";
|
|
37
|
+
const promptIdForSummarize = "pmpt_6902c30a973481968395935cc6dfa78605f50d2b01d4afbd";
|
|
38
|
+
// const generationCurriculum = process.env.GENERATION_CURRICULUM;
|
|
39
|
+
const n = process.env.N;
|
|
40
|
+
const generationContent = {
|
|
41
|
+
content: {
|
|
42
|
+
source_id: document.source_id,
|
|
43
|
+
title: document.title,
|
|
44
|
+
headings: document.headings,
|
|
45
|
+
content: document.content,
|
|
46
|
+
fields: [],
|
|
47
|
+
taxonomy: {
|
|
48
|
+
concepts_facts: (_a = document.concepts_facts) !== null && _a !== void 0 ? _a : [],
|
|
49
|
+
fields: (_b = document.fields) !== null && _b !== void 0 ? _b : [],
|
|
50
|
+
summary_cards: (_c = document.summary_cards) !== null && _c !== void 0 ? _c : [],
|
|
51
|
+
learn_value: document.learn_value,
|
|
52
|
+
},
|
|
53
|
+
type: document.type,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
const generator = new app_1.OnlyEverGenerator(openAiKey !== null && openAiKey !== void 0 ? openAiKey : "", "gpt-4o-mini", generationContent, promptIdForClassify !== null && promptIdForClassify !== void 0 ? promptIdForClassify : "", promptIdForConceptFacts !== null && promptIdForConceptFacts !== void 0 ? promptIdForConceptFacts : "", promptIdForCardGeneration !== null && promptIdForCardGeneration !== void 0 ? promptIdForCardGeneration : "", promptIdForSummarize !== null && promptIdForSummarize !== void 0 ? promptIdForSummarize : "", false, 1);
|
|
57
|
+
const response = yield generator.generate(false, true, ["cloze"]);
|
|
58
|
+
res.json(response);
|
|
59
|
+
}));
|
|
60
|
+
app.listen(3000, () => {
|
|
61
|
+
console.log("Server is running on port 3000");
|
|
62
|
+
});
|
|
6
63
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,yCAAoD;AAI3C,kGAJA,uBAAiB,OAIA;AAH1B,qCAAmC;AACnC,wDAAwD;AAIxD,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;AAEtB,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;;IACtC,MAAM,MAAM,GAAG,IAAI,kBAAQ,CAAC,0BAA0B,CAAC,CAAC;IACxD,IAAA,oBAAK,GAAE,CAAC;IACR,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC;IAC1C,MAAM,QAAQ,GAAG,MAAM,uBAAQ;SAC5B,UAAU,CAAC,SAAS,CAAC;SACrB,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;IAC5B,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,MAAM,mBAAmB,GACvB,uDAAuD,CAAC;IAC1D,MAAM,uBAAuB,GAC3B,uDAAuD,CAAC;IAC1D,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AAC,CAAC;AACrB,CAAC,CAAA,CAAC,CAAC;AAEH,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;IACpB,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;AAChD,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/bootstrap/app.ts
CHANGED
|
@@ -177,28 +177,28 @@ export class OnlyEverGenerator {
|
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
} else if (elem == "generate_card") {
|
|
180
|
-
if (this.shouldTheCardBeGeneratedAfterTypologyResponse()) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
180
|
+
// if (this.shouldTheCardBeGeneratedAfterTypologyResponse()) {
|
|
181
|
+
console.log("Generating card");
|
|
182
|
+
this.parsedContent!.taxonomy = {
|
|
183
|
+
concepts_facts: this.typologyResponse?.concepts_facts ?? [],
|
|
184
|
+
fields: this.expectedFields,
|
|
185
|
+
summary_cards: this.typologyResponse?.summary_cards ?? [],
|
|
186
|
+
learn_value: this.typologyResponse?.learn_value ?? {
|
|
187
|
+
value: 0,
|
|
188
|
+
reason: "",
|
|
189
|
+
bloom_levels: [],
|
|
190
|
+
bloom_levels_reason: "",
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
this.cardgenResponse = await this.generateCard(
|
|
194
|
+
this.n,
|
|
195
|
+
card_generation_types
|
|
196
|
+
);
|
|
197
|
+
responseToReturn.push({
|
|
198
|
+
type: "card_gen",
|
|
199
|
+
data: this.cardgenResponse,
|
|
200
|
+
});
|
|
201
|
+
// }
|
|
202
202
|
}
|
|
203
203
|
return responseToReturn;
|
|
204
204
|
} catch (error) {
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { OpenAIHelper } from "../helper/openai_helper";
|
|
2
|
-
import {
|
|
3
|
-
buildCardSchema,
|
|
4
|
-
cardSchema,
|
|
5
|
-
} from "../helper/schema_helper/build_card_schema";
|
|
2
|
+
import { buildCardSchema } from "../helper/schema_helper/build_card_schema";
|
|
6
3
|
import { ErrorLogger, log_error, ParsingError } from "../logger";
|
|
7
4
|
import { ParseCardResponse } from "../parse/parse_card_response";
|
|
8
5
|
import { OpenAiService } from "../services/open_ai_service";
|
|
@@ -10,6 +7,7 @@ import { GeneratedCardResponseType } from "../types/raw_card_response_types/gene
|
|
|
10
7
|
import { SourceTaxonomy } from "../types/source_taxonomy_type";
|
|
11
8
|
import { ParsedCardType } from "../types/parsed_card_type";
|
|
12
9
|
import { getPrompts } from "../services/get_prompts";
|
|
10
|
+
import axios from "axios";
|
|
13
11
|
|
|
14
12
|
// Type for the response structure returned by generateCardsForType
|
|
15
13
|
type GenerateCardsResponse = {
|
|
@@ -65,35 +63,73 @@ export class GenerateCards {
|
|
|
65
63
|
card_generation_types
|
|
66
64
|
);
|
|
67
65
|
try {
|
|
68
|
-
let response: any = await this.openAIHelper.openAI.responses.create({
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
66
|
+
// let response: any = await this.openAIHelper.openAI.responses.create({
|
|
67
|
+
// prompt: {
|
|
68
|
+
// id: this.promptIdForCardsGeneration,
|
|
69
|
+
// variables: {
|
|
70
|
+
// bloom_level: "1",
|
|
71
|
+
// card_types: card_generation_types.join(","),
|
|
72
|
+
// bloom_instructions: variables.bloom_instructions,
|
|
73
|
+
// card_instructions: variables.card_instructions,
|
|
74
|
+
// card_examples: variables.card_examples,
|
|
75
|
+
// },
|
|
76
|
+
// },
|
|
77
|
+
// max_output_tokens: 30000,
|
|
80
78
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
// input: [
|
|
80
|
+
// {
|
|
81
|
+
// role: "user",
|
|
82
|
+
// content: [{ type: "input_text", text: this.content }],
|
|
83
|
+
// },
|
|
84
|
+
// ],
|
|
85
|
+
// store: true,
|
|
86
|
+
// text: {
|
|
87
|
+
// format: {
|
|
88
|
+
// type: "json_schema",
|
|
89
|
+
// name: schema.name,
|
|
90
|
+
// strict: schema.strict,
|
|
91
|
+
// schema: schema.schema,
|
|
92
|
+
// },
|
|
93
|
+
// },
|
|
94
|
+
// });
|
|
95
|
+
const response: any = await axios.post(
|
|
96
|
+
"https://api.openai.com/v1/responses",
|
|
97
|
+
{
|
|
98
|
+
prompt: {
|
|
99
|
+
id: this.promptIdForCardsGeneration,
|
|
100
|
+
variables: {
|
|
101
|
+
bloom_level: "1",
|
|
102
|
+
card_types: card_generation_types.join(","),
|
|
103
|
+
bloom_instructions: variables.bloom_instructions,
|
|
104
|
+
card_instructions: variables.card_instructions,
|
|
105
|
+
card_examples: variables.card_examples,
|
|
106
|
+
},
|
|
85
107
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
108
|
+
input: [
|
|
109
|
+
{
|
|
110
|
+
role: "user",
|
|
111
|
+
content: [{ type: "input_text", text: this.content }],
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
store: true,
|
|
115
|
+
text: {
|
|
116
|
+
format: {
|
|
117
|
+
type: "json_schema",
|
|
118
|
+
name: schema.name,
|
|
119
|
+
strict: schema.strict,
|
|
120
|
+
schema: schema.schema,
|
|
121
|
+
},
|
|
94
122
|
},
|
|
95
123
|
},
|
|
96
|
-
|
|
124
|
+
{
|
|
125
|
+
headers: {
|
|
126
|
+
"Content-Type": "application/json",
|
|
127
|
+
Authorization: `Bearer ${this.openAiService.api_key}`,
|
|
128
|
+
// "OpenAI-Beta": "response-format=json_schema",
|
|
129
|
+
},
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
console.log(response.data);
|
|
97
133
|
if (!response) {
|
|
98
134
|
await log_error({
|
|
99
135
|
flow: this.generationCurriculum
|
|
@@ -125,6 +161,7 @@ export class GenerateCards {
|
|
|
125
161
|
type: {
|
|
126
162
|
request_type: "depth",
|
|
127
163
|
n: 1,
|
|
164
|
+
card_types: card_generation_types.join(","),
|
|
128
165
|
},
|
|
129
166
|
});
|
|
130
167
|
} else {
|
|
@@ -140,6 +177,7 @@ export class GenerateCards {
|
|
|
140
177
|
type: {
|
|
141
178
|
request_type: "depth",
|
|
142
179
|
n: 1,
|
|
180
|
+
card_types: card_generation_types.join(","),
|
|
143
181
|
},
|
|
144
182
|
});
|
|
145
183
|
}
|
|
@@ -156,12 +194,44 @@ export class GenerateCards {
|
|
|
156
194
|
// parsedContent
|
|
157
195
|
// );
|
|
158
196
|
console.log("generation started");
|
|
159
|
-
|
|
197
|
+
|
|
198
|
+
// Use Promise.allSettled to allow individual types to fail without affecting others
|
|
199
|
+
const settledResponses = await Promise.allSettled(
|
|
160
200
|
card_generation_types.map(async (card_generation_type) => {
|
|
161
201
|
return await this.generateCardsForType(n, card_generation_type);
|
|
162
202
|
})
|
|
163
203
|
);
|
|
164
204
|
|
|
205
|
+
// Extract fulfilled responses and log rejected ones
|
|
206
|
+
let responses: GenerateCardsResponseList = settledResponses.map(
|
|
207
|
+
(result, index) => {
|
|
208
|
+
if (result.status === "fulfilled") {
|
|
209
|
+
return result.value;
|
|
210
|
+
} else {
|
|
211
|
+
// Log the rejection but continue with other types
|
|
212
|
+
console.error(
|
|
213
|
+
`Failed to generate cards for type ${card_generation_types[index]}:`,
|
|
214
|
+
result.reason
|
|
215
|
+
);
|
|
216
|
+
log_error({
|
|
217
|
+
flow: this.generationCurriculum
|
|
218
|
+
? "curriculum_manual_generation"
|
|
219
|
+
: "manual_generation",
|
|
220
|
+
data: result.reason,
|
|
221
|
+
timestamp: new Date(),
|
|
222
|
+
error: "error_in_card_generation_for_type",
|
|
223
|
+
source_id: this.sourceId,
|
|
224
|
+
type: {
|
|
225
|
+
request_type: "depth",
|
|
226
|
+
n: n,
|
|
227
|
+
card_types: card_generation_types[index],
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
|
|
165
235
|
// Flatten all parsed cards from all responses
|
|
166
236
|
// const allParsedCards: AllParsedCards = [];
|
|
167
237
|
// for (const response of responses) {
|
|
@@ -262,6 +332,7 @@ export class GenerateCards {
|
|
|
262
332
|
bloom_level: 1,
|
|
263
333
|
},
|
|
264
334
|
});
|
|
335
|
+
return undefined;
|
|
265
336
|
}
|
|
266
337
|
}
|
|
267
338
|
|
|
@@ -72,150 +72,3 @@ export const buildCardSchema = async (
|
|
|
72
72
|
);
|
|
73
73
|
return populatedSchema;
|
|
74
74
|
};
|
|
75
|
-
|
|
76
|
-
export const cardSchema = (concepts: string[], facts: string[]) => {
|
|
77
|
-
return {
|
|
78
|
-
type: "object",
|
|
79
|
-
properties: {
|
|
80
|
-
test_cards: {
|
|
81
|
-
type: "array",
|
|
82
|
-
items: {
|
|
83
|
-
type: "object",
|
|
84
|
-
properties: {
|
|
85
|
-
type: {
|
|
86
|
-
type: "string",
|
|
87
|
-
enum: ["mcq", "cloze", "match", "flash"],
|
|
88
|
-
},
|
|
89
|
-
card_content: {
|
|
90
|
-
anyOf: [
|
|
91
|
-
// Flash Card
|
|
92
|
-
{
|
|
93
|
-
type: "object",
|
|
94
|
-
properties: {
|
|
95
|
-
front: { type: "string", maxLength: 320 },
|
|
96
|
-
back: { type: "string", maxLength: 320 },
|
|
97
|
-
},
|
|
98
|
-
required: ["front", "back"],
|
|
99
|
-
additionalProperties: false,
|
|
100
|
-
},
|
|
101
|
-
// Match Card
|
|
102
|
-
{
|
|
103
|
-
type: "array",
|
|
104
|
-
minItems: 1,
|
|
105
|
-
maxItems: 9,
|
|
106
|
-
items: {
|
|
107
|
-
anyOf: [
|
|
108
|
-
{
|
|
109
|
-
type: "object",
|
|
110
|
-
properties: {
|
|
111
|
-
left_item: { type: "string", maxLength: 30 },
|
|
112
|
-
right_item: { type: "string", maxLength: 30 },
|
|
113
|
-
},
|
|
114
|
-
required: ["left_item", "right_item"],
|
|
115
|
-
additionalProperties: false,
|
|
116
|
-
},
|
|
117
|
-
// {
|
|
118
|
-
// type: "object",
|
|
119
|
-
// properties: {
|
|
120
|
-
// explanation: { type: "string", maxLength: 320 },
|
|
121
|
-
// },
|
|
122
|
-
// required: ["explanation"],
|
|
123
|
-
// additionalProperties: false,
|
|
124
|
-
// },
|
|
125
|
-
],
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
// Cloze Card
|
|
129
|
-
{
|
|
130
|
-
type: "object",
|
|
131
|
-
properties: {
|
|
132
|
-
prompt: {
|
|
133
|
-
type: "string",
|
|
134
|
-
maxLength: 320,
|
|
135
|
-
pattern: ".*{{.+?}}.*",
|
|
136
|
-
},
|
|
137
|
-
correct_options: {
|
|
138
|
-
type: "array",
|
|
139
|
-
minItems: 1,
|
|
140
|
-
maxItems: 4,
|
|
141
|
-
items: { type: "string" },
|
|
142
|
-
},
|
|
143
|
-
incorrect_options: {
|
|
144
|
-
type: "array",
|
|
145
|
-
minItems: 1,
|
|
146
|
-
maxItems: 7,
|
|
147
|
-
items: { type: "string" },
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
required: ["prompt", "correct_options", "incorrect_options"],
|
|
151
|
-
additionalProperties: false,
|
|
152
|
-
},
|
|
153
|
-
// MCQ Card
|
|
154
|
-
{
|
|
155
|
-
type: "object",
|
|
156
|
-
properties: {
|
|
157
|
-
prompt: { type: "string", maxLength: 320 },
|
|
158
|
-
choices: {
|
|
159
|
-
type: "array",
|
|
160
|
-
minItems: 2,
|
|
161
|
-
maxItems: 8,
|
|
162
|
-
items: {
|
|
163
|
-
type: "object",
|
|
164
|
-
properties: {
|
|
165
|
-
choice: { type: "string", maxLength: 42 },
|
|
166
|
-
is_correct: { type: "boolean" },
|
|
167
|
-
},
|
|
168
|
-
required: ["choice", "is_correct"],
|
|
169
|
-
additionalProperties: false,
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
// explanation: { type: "string", maxLength: 320 },
|
|
173
|
-
},
|
|
174
|
-
required: ["prompt", "choices"],
|
|
175
|
-
additionalProperties: false,
|
|
176
|
-
},
|
|
177
|
-
],
|
|
178
|
-
},
|
|
179
|
-
explanation: {
|
|
180
|
-
type: "string",
|
|
181
|
-
maxLength: 320,
|
|
182
|
-
description:
|
|
183
|
-
"Explanation for the card (≤320 characters). " +
|
|
184
|
-
"If no useful explanation exists, return an empty string. " +
|
|
185
|
-
"Include only if it helps the learner understand the concept(s) or fact(s) being tested. " +
|
|
186
|
-
"Do not explain anything unrelated, repeat answers verbatim, or add meta-comments. " +
|
|
187
|
-
"Keep it clear and concise; you may draw on personal knowledge where appropriate.",
|
|
188
|
-
},
|
|
189
|
-
concepts: {
|
|
190
|
-
type: "array",
|
|
191
|
-
minItems: 1,
|
|
192
|
-
items: { type: "string", enum: concepts },
|
|
193
|
-
},
|
|
194
|
-
facts: {
|
|
195
|
-
type: "array",
|
|
196
|
-
minItems: 1,
|
|
197
|
-
items: { type: "string", enum: facts },
|
|
198
|
-
},
|
|
199
|
-
bloom_alignment: {
|
|
200
|
-
type: "string",
|
|
201
|
-
maxLength: 240,
|
|
202
|
-
description:
|
|
203
|
-
"Explain why this card fits the bloom level you were asked to create (max. 240 chars)",
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
required: [
|
|
207
|
-
"type",
|
|
208
|
-
"card_content",
|
|
209
|
-
"concepts",
|
|
210
|
-
"facts",
|
|
211
|
-
"bloom_alignment",
|
|
212
|
-
"explanation",
|
|
213
|
-
],
|
|
214
|
-
additionalProperties: false,
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
required: ["test_cards"],
|
|
219
|
-
additionalProperties: false,
|
|
220
|
-
};
|
|
221
|
-
};
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,65 @@
|
|
|
1
|
+
import express from "express";
|
|
1
2
|
import { OnlyEverGenerator } from "./bootstrap/app";
|
|
3
|
+
import { ObjectId } from "mongodb";
|
|
4
|
+
import { database, setUp } from "./helper/mongo_helper";
|
|
2
5
|
|
|
3
6
|
export { OnlyEverGenerator };
|
|
7
|
+
|
|
8
|
+
// const app = express();
|
|
9
|
+
|
|
10
|
+
// app.get("/generate", async (req, res) => {
|
|
11
|
+
// const source = new ObjectId("691acee5ecae1cfe8c5c2e72");
|
|
12
|
+
// setUp();
|
|
13
|
+
// const openAiKey = process.env.OPEN_AI_KEY;
|
|
14
|
+
// const document = await database
|
|
15
|
+
// .collection("_source")
|
|
16
|
+
// .findOne({ _id: source });
|
|
17
|
+
// if (!document) {
|
|
18
|
+
// return res.status(404).json({ error: "Source not found" });
|
|
19
|
+
// }
|
|
20
|
+
// const promptIdForClassify =
|
|
21
|
+
// "pmpt_687a8872d1c8819088a9cdc97dcb688b0893663621695594";
|
|
22
|
+
// const promptIdForConceptFacts =
|
|
23
|
+
// "pmpt_687aa547f99c8193b99467ca53630c2607f5a8caf451e7e8";
|
|
24
|
+
// const promptIdForCardGeneration =
|
|
25
|
+
// "pmpt_688118a923e4819098176a13a2f401920d2ea17d881cc6c6";
|
|
26
|
+
// const promptIdForMissingConceptsFacts =
|
|
27
|
+
// "pmpt_687ab50298dc8194b214804999d23df10e03b855371691f9";
|
|
28
|
+
// const promptIdForSummarize =
|
|
29
|
+
// "pmpt_6902c30a973481968395935cc6dfa78605f50d2b01d4afbd";
|
|
30
|
+
// // const generationCurriculum = process.env.GENERATION_CURRICULUM;
|
|
31
|
+
// const n = process.env.N;
|
|
32
|
+
// const generationContent = {
|
|
33
|
+
// content: {
|
|
34
|
+
// source_id: document.source_id,
|
|
35
|
+
// title: document.title,
|
|
36
|
+
// headings: document.headings,
|
|
37
|
+
// content: document.content,
|
|
38
|
+
// fields: [],
|
|
39
|
+
// taxonomy: {
|
|
40
|
+
// concepts_facts: document.concepts_facts ?? [],
|
|
41
|
+
// fields: document.fields ?? [],
|
|
42
|
+
// summary_cards: document.summary_cards ?? [],
|
|
43
|
+
// learn_value: document.learn_value,
|
|
44
|
+
// },
|
|
45
|
+
// type: document.type,
|
|
46
|
+
// },
|
|
47
|
+
// };
|
|
48
|
+
// const generator = new OnlyEverGenerator(
|
|
49
|
+
// openAiKey ?? "",
|
|
50
|
+
// "gpt-4o-mini",
|
|
51
|
+
// generationContent,
|
|
52
|
+
// promptIdForClassify ?? "",
|
|
53
|
+
// promptIdForConceptFacts ?? "",
|
|
54
|
+
// promptIdForCardGeneration ?? "",
|
|
55
|
+
// promptIdForSummarize ?? "",
|
|
56
|
+
// false,
|
|
57
|
+
// 1
|
|
58
|
+
// );
|
|
59
|
+
// const response = await generator.generate(false, true, ["cloze"]);
|
|
60
|
+
// res.json(response);
|
|
61
|
+
// });
|
|
62
|
+
|
|
63
|
+
// app.listen(3000, () => {
|
|
64
|
+
// console.log("Server is running on port 3000");
|
|
65
|
+
// });
|