only_ever_generator 5.0.0 → 5.0.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/card_gen/generate_cards.d.ts.map +1 -1
- package/dist/card_gen/generate_cards.js +6 -0
- package/dist/card_gen/generate_cards.js.map +1 -1
- package/dist/helper/schema_helper/build_card_schema.d.ts +6 -27
- package/dist/helper/schema_helper/build_card_schema.d.ts.map +1 -1
- package/dist/helper/schema_helper/build_card_schema.js +14 -19
- package/dist/helper/schema_helper/build_card_schema.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -760
- package/dist/index.js.map +1 -1
- package/dist/parse/parse_card/parse_cloze_card.d.ts +1 -0
- package/dist/parse/parse_card/parse_cloze_card.d.ts.map +1 -1
- package/dist/parse/parse_card/parse_cloze_card.js +1 -1
- package/dist/parse/parse_card/parse_cloze_card.js.map +1 -1
- package/dist/parse/parse_card/parse_flash_cards.d.ts +2 -1
- package/dist/parse/parse_card/parse_flash_cards.d.ts.map +1 -1
- package/dist/parse/parse_card/parse_flash_cards.js +1 -1
- package/dist/parse/parse_card/parse_flash_cards.js.map +1 -1
- package/dist/parse/parse_card/parse_match_card.d.ts +1 -0
- package/dist/parse/parse_card/parse_match_card.d.ts.map +1 -1
- package/dist/parse/parse_card/parse_match_card.js +1 -0
- package/dist/parse/parse_card/parse_match_card.js.map +1 -1
- package/dist/parse/parse_card/parse_mcq_card.d.ts +2 -1
- package/dist/parse/parse_card/parse_mcq_card.d.ts.map +1 -1
- package/dist/parse/parse_card/parse_mcq_card.js +1 -1
- package/dist/parse/parse_card/parse_mcq_card.js.map +1 -1
- package/dist/parse/parse_card_response.d.ts.map +1 -1
- package/dist/parse/parse_card_response.js +5 -0
- package/dist/parse/parse_card_response.js.map +1 -1
- package/dist/services/get_prompts.d.ts +14 -0
- package/dist/services/get_prompts.d.ts.map +1 -0
- package/dist/services/get_prompts.js +143 -0
- package/dist/services/get_prompts.js.map +1 -0
- package/dist/types/raw_card_response_types/generated_card_response_type.d.ts +1 -3
- package/dist/types/raw_card_response_types/generated_card_response_type.d.ts.map +1 -1
- package/dist/types/raw_card_response_types/generated_card_response_type.js.map +1 -1
- package/package.json +1 -1
- package/src/card_gen/generate_cards.ts +6 -1
- package/src/helper/schema_helper/build_card_schema.ts +14 -19
- package/src/index.ts +9 -761
- package/src/parse/parse_card/parse_cloze_card.ts +2 -1
- package/src/parse/parse_card/parse_flash_cards.ts +2 -1
- package/src/parse/parse_card/parse_match_card.ts +2 -0
- package/src/parse/parse_card/parse_mcq_card.ts +2 -1
- package/src/parse/parse_card_response.ts +6 -0
- package/src/services/get_prompts.ts +144 -0
- package/src/types/raw_card_response_types/generated_card_response_type.ts +1 -3
|
@@ -7,6 +7,7 @@ export class ParseClozeCard {
|
|
|
7
7
|
type: string;
|
|
8
8
|
concepts_facts: MongoConceptFactCards[];
|
|
9
9
|
bloom_level: number;
|
|
10
|
+
explanation: string;
|
|
10
11
|
}) {
|
|
11
12
|
try {
|
|
12
13
|
const content = data.card_content;
|
|
@@ -45,8 +46,8 @@ export class ParseClozeCard {
|
|
|
45
46
|
options: finalParsedOptions,
|
|
46
47
|
},
|
|
47
48
|
concepts_facts: data.concepts_facts,
|
|
48
|
-
explanation: data.card_content.explanation,
|
|
49
49
|
bloom_level: data.bloom_level,
|
|
50
|
+
explanation: data.explanation,
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
return this._validateCloze(clozeCardData);
|
|
@@ -7,6 +7,7 @@ export class ParseFlashCard {
|
|
|
7
7
|
type: string;
|
|
8
8
|
concepts_facts: MongoConceptFactCards[];
|
|
9
9
|
bloom_level: number;
|
|
10
|
+
explanation: string;
|
|
10
11
|
}) {
|
|
11
12
|
try {
|
|
12
13
|
let displayTitle = this.generateFlashCardDisplayTitle(
|
|
@@ -25,7 +26,7 @@ export class ParseFlashCard {
|
|
|
25
26
|
back_content: data.card_content.back,
|
|
26
27
|
},
|
|
27
28
|
concepts_facts: data.concepts_facts,
|
|
28
|
-
explanation: data.
|
|
29
|
+
explanation: data.explanation,
|
|
29
30
|
bloom_level: data.bloom_level,
|
|
30
31
|
};
|
|
31
32
|
|
|
@@ -18,6 +18,7 @@ export class ParseMatchCard {
|
|
|
18
18
|
type: string;
|
|
19
19
|
concepts_facts: MongoConceptFactCards[];
|
|
20
20
|
bloom_level: number;
|
|
21
|
+
explanation: string;
|
|
21
22
|
}) {
|
|
22
23
|
try {
|
|
23
24
|
let content = cardData.card_content;
|
|
@@ -35,6 +36,7 @@ export class ParseMatchCard {
|
|
|
35
36
|
displayTitle: displayTitle,
|
|
36
37
|
concepts_facts: cardData.concepts_facts,
|
|
37
38
|
bloom_level: cardData.bloom_level,
|
|
39
|
+
explanation: cardData.explanation,
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
return this._validateMatch(matchCard);
|
|
@@ -7,6 +7,7 @@ export class ParseMcqCard {
|
|
|
7
7
|
type: string;
|
|
8
8
|
concepts_facts: MongoConceptFactCards[];
|
|
9
9
|
bloom_level: number;
|
|
10
|
+
explanation: string;
|
|
10
11
|
}) {
|
|
11
12
|
try {
|
|
12
13
|
let mcqAnswers = [];
|
|
@@ -39,8 +40,8 @@ export class ParseMcqCard {
|
|
|
39
40
|
answers: mcqAnswers,
|
|
40
41
|
},
|
|
41
42
|
concepts_facts: data.concepts_facts,
|
|
42
|
-
explanation: data.card_content.explanation,
|
|
43
43
|
bloom_level: data.bloom_level,
|
|
44
|
+
explanation: data.explanation,
|
|
44
45
|
};
|
|
45
46
|
// return mcqCard;
|
|
46
47
|
const isValid = this._validate(mcqCard);
|
|
@@ -55,6 +55,7 @@ export class ParseCardResponse {
|
|
|
55
55
|
type: elem.type,
|
|
56
56
|
concepts_facts: managedCardConcepts,
|
|
57
57
|
bloom_level: elem.bloom_level,
|
|
58
|
+
explanation: elem.explanation,
|
|
58
59
|
});
|
|
59
60
|
if (flashCard != null && flashCard) {
|
|
60
61
|
flashCard.heading = this._getCardReference(
|
|
@@ -70,7 +71,9 @@ export class ParseCardResponse {
|
|
|
70
71
|
type: elem.type,
|
|
71
72
|
concepts_facts: managedCardConcepts,
|
|
72
73
|
bloom_level: elem.bloom_level,
|
|
74
|
+
explanation: elem.explanation,
|
|
73
75
|
});
|
|
76
|
+
|
|
74
77
|
if (mcqCard != null && mcqCard) {
|
|
75
78
|
mcqCard.heading = this._getCardReference(mcqCard, sourceTaxonomy);
|
|
76
79
|
cardData.push(mcqCard);
|
|
@@ -81,8 +84,10 @@ export class ParseCardResponse {
|
|
|
81
84
|
type: elem.type,
|
|
82
85
|
concepts_facts: managedCardConcepts,
|
|
83
86
|
bloom_level: elem.bloom_level,
|
|
87
|
+
explanation: elem.explanation,
|
|
84
88
|
});
|
|
85
89
|
if (clozeCard && clozeCard != null) {
|
|
90
|
+
clozeCard.explanation = elem.explanation;
|
|
86
91
|
clozeCard.heading = this._getCardReference(
|
|
87
92
|
clozeCard,
|
|
88
93
|
sourceTaxonomy
|
|
@@ -95,6 +100,7 @@ export class ParseCardResponse {
|
|
|
95
100
|
type: elem.type,
|
|
96
101
|
concepts_facts: managedCardConcepts,
|
|
97
102
|
bloom_level: elem.bloom_level,
|
|
103
|
+
explanation: elem.explanation,
|
|
98
104
|
});
|
|
99
105
|
if (matchCard && matchCard != null) {
|
|
100
106
|
matchCard.heading = this._getCardReference(
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { database, 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
|
+
|
|
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",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const cardGenInstructionsDocs = {
|
|
39
|
+
cloze: "6780d21318f81be17e39f5c1",
|
|
40
|
+
flash: "6780d21318f81be17e39f5d2",
|
|
41
|
+
match: "6780d21318f81be17e39f5d3",
|
|
42
|
+
mcq: "6780d21318f81be17e39f5d4",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const cardGenExamplesDocs = {
|
|
46
|
+
cloze: "688af4e5299b7c2c08a52fbe",
|
|
47
|
+
flash: "688af4e5299b7c2c08a52fcd",
|
|
48
|
+
match: "688af4e5299b7c2c08a52fce",
|
|
49
|
+
mcq: "688af4e5299b7c2c08a52fde",
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const bloomInstructionsDocs = {
|
|
53
|
+
bloom_1: "6780d21318f81be17e39f5b5",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const getPrompts = async (sourceType: string) => {
|
|
57
|
+
// const typologyDocs = JSON.parse(baseConfig.typologyPrompts);
|
|
58
|
+
// const cardGenerationDocs = JSON.parse(baseConfig.cardGenerationPrompts);
|
|
59
|
+
// const videoTypologyDocs = JSON.parse(baseConfig.videoTypologyPrompts);
|
|
60
|
+
const typologyObjectIds = Object.values(typologyDocs).map((e: any) =>
|
|
61
|
+
ObjectId.createFromHexString(e.toString())
|
|
62
|
+
);
|
|
63
|
+
const cardGenObjectIds = Object.values(cardGenDocs).map((e: any) =>
|
|
64
|
+
ObjectId.createFromHexString(e)
|
|
65
|
+
);
|
|
66
|
+
const typologyVideoObjectIds = Object.values(videoTypologyDocs).map(
|
|
67
|
+
(e: any) => ObjectId.createFromHexString(e)
|
|
68
|
+
);
|
|
69
|
+
const cardGenInstructionsObjectIds = Object.values(
|
|
70
|
+
cardGenInstructionsDocs
|
|
71
|
+
).map((e: any) => ObjectId.createFromHexString(e));
|
|
72
|
+
const cardGenExamplesObjectIds = Object.values(cardGenExamplesDocs).map(
|
|
73
|
+
(e: any) => ObjectId.createFromHexString(e)
|
|
74
|
+
);
|
|
75
|
+
const bloomInstructionsObjectIds = Object.values(bloomInstructionsDocs).map(
|
|
76
|
+
(e: any) => ObjectId.createFromHexString(e)
|
|
77
|
+
);
|
|
78
|
+
const typology = await getPromptString(typologyObjectIds);
|
|
79
|
+
const card_generation = await getPromptString(cardGenObjectIds);
|
|
80
|
+
const video_typology = await getPromptString(typologyVideoObjectIds);
|
|
81
|
+
const cardInstructions = await getPromptString(cardGenInstructionsObjectIds);
|
|
82
|
+
const cardExamples = await getPromptString(cardGenExamplesObjectIds);
|
|
83
|
+
const bloomInstructions = await getPromptString(bloomInstructionsObjectIds);
|
|
84
|
+
if (sourceType === "video") {
|
|
85
|
+
return {
|
|
86
|
+
typology: {
|
|
87
|
+
prompt: video_typology,
|
|
88
|
+
ids: Object.values(videoTypologyDocs),
|
|
89
|
+
},
|
|
90
|
+
card_gen: {
|
|
91
|
+
prompt: card_generation,
|
|
92
|
+
ids: Object.values(cardGenDocs),
|
|
93
|
+
},
|
|
94
|
+
card_instructions: cardInstructions,
|
|
95
|
+
card_examples: cardExamples,
|
|
96
|
+
bloom_instructions: bloomInstructions,
|
|
97
|
+
};
|
|
98
|
+
} else {
|
|
99
|
+
return {
|
|
100
|
+
typology: {
|
|
101
|
+
prompt: typology,
|
|
102
|
+
ids: Object.values(typologyDocs),
|
|
103
|
+
},
|
|
104
|
+
card_gen: {
|
|
105
|
+
prompt: card_generation,
|
|
106
|
+
ids: Object.values(cardGenDocs),
|
|
107
|
+
},
|
|
108
|
+
card_instructions: cardInstructions,
|
|
109
|
+
card_examples: cardExamples,
|
|
110
|
+
bloom_instructions: bloomInstructions,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
async function getPromptString(promptIds: ObjectId[]) {
|
|
114
|
+
let result = await database
|
|
115
|
+
.collection("_prompts")
|
|
116
|
+
.aggregate([
|
|
117
|
+
{
|
|
118
|
+
$match: {
|
|
119
|
+
_id: { $in: promptIds },
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
$group: {
|
|
124
|
+
_id: null,
|
|
125
|
+
allContent: { $push: "$prompt" },
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
/// concat each element in above created `allContent temp field`, and update that to "concatenatedContent"(temp field)
|
|
130
|
+
$project: {
|
|
131
|
+
concatenatedContent: {
|
|
132
|
+
$reduce: {
|
|
133
|
+
input: "$allContent",
|
|
134
|
+
initialValue: "",
|
|
135
|
+
in: { $concat: ["$$value", "$$this"] },
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
])
|
|
141
|
+
.toArray();
|
|
142
|
+
return result.length > 0 ? result[0].concatenatedContent : "";
|
|
143
|
+
}
|
|
144
|
+
};
|
|
@@ -24,13 +24,13 @@ export type RawTestCardResponseType = {
|
|
|
24
24
|
| RawMcqCardResponseType;
|
|
25
25
|
concepts: string[];
|
|
26
26
|
facts: string[];
|
|
27
|
+
explanation: string;
|
|
27
28
|
bloom_level: number;
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
export type RawFlashCardResponseType = {
|
|
31
32
|
front: string;
|
|
32
33
|
back: string;
|
|
33
|
-
explanation?: string;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export type RawMatchCardResponseType = {
|
|
@@ -42,12 +42,10 @@ export type RawClozeCardResponseType = {
|
|
|
42
42
|
correct_options: string[];
|
|
43
43
|
incorrect_options: string[];
|
|
44
44
|
prompt: string;
|
|
45
|
-
explanation?: string;
|
|
46
45
|
};
|
|
47
46
|
|
|
48
47
|
export type RawMcqCardResponseType = {
|
|
49
48
|
prompt: string;
|
|
50
|
-
explanation?: string;
|
|
51
49
|
choices: {
|
|
52
50
|
choice: string;
|
|
53
51
|
is_correct: boolean;
|