only_ever_generator 0.1.5 → 0.1.6
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 +8 -45
- package/dist/constants/prompts/card_gen_prompt.js +170 -170
- package/dist/constants/prompts/typology_prompt.js +89 -89
- package/dist/gap_fill/calculate_gap_fill.js +42 -0
- package/dist/index.js +54 -49
- package/dist/service/open_ai_request.js +57 -57
- package/package.json +33 -33
- package/readme.md +23 -23
- package/src/bootstrap/app.ts +128 -165
- package/src/card_gen/generate_cards.ts +197 -197
- package/src/config.ts +6 -6
- package/src/constants/api_constants.ts +2 -2
- package/src/constants/prompts/card_gen_prompt.ts +177 -177
- package/src/constants/prompts/typology_prompt.ts +93 -93
- package/src/constants/source_data.ts +35 -35
- package/src/gap_fill/calculate_gap_fill.ts +48 -0
- package/src/index.ts +66 -66
- package/src/parse/parse_card_response.ts +289 -289
- package/src/parse/parse_source_content.ts +70 -70
- package/src/parse/response_format_card.ts +210 -210
- package/src/parse/response_format_typology.ts +43 -43
- package/src/services/open_ai_service.ts +54 -54
- package/src/typology_gen/generate_typology.ts +64 -64
- package/src/utils/generate_args.ts +37 -37
- package/src/utils/parse_openai_response.ts +20 -20
- package/tsconfig.json +12 -12
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
export class ParseSourceContent{
|
|
2
|
-
public content: Array<any>;
|
|
3
|
-
|
|
4
|
-
titles_to_remove = ['See also', 'References', 'Further reading', 'External links', 'Notes and references', 'Bibliography', 'Notes', 'Cited sources'];
|
|
5
|
-
|
|
6
|
-
constructor(sourceContent:Array<any>){
|
|
7
|
-
this.content = sourceContent;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
parse() {
|
|
11
|
-
let dataAfterRemovingUnWantedBlocks = this.removeSectionsByTitle(this.content);
|
|
12
|
-
let afterSanitized = this.sanitizeBlocks(dataAfterRemovingUnWantedBlocks);
|
|
13
|
-
return JSON.stringify(afterSanitized);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
removeSectionsByTitle(data: Array<any>){
|
|
17
|
-
let dataAfterRemoving = [];
|
|
18
|
-
for(let elem of data){
|
|
19
|
-
if(elem.block_type == 'heading' && this.titles_to_remove.includes(elem.content)){
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
if(elem.children){
|
|
23
|
-
elem.children = this.removeSectionsByTitle(elem.children)
|
|
24
|
-
}
|
|
25
|
-
dataAfterRemoving.push(elem)
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
return dataAfterRemoving;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
sanitizeWikiContent(content: String) {
|
|
33
|
-
// Remove newline characters
|
|
34
|
-
content = content.replace(/\\n/g, ' ');
|
|
35
|
-
|
|
36
|
-
// Remove internal link references, keeping only the link text
|
|
37
|
-
// Pattern explanation: [[link|text|index|wiki]] --> text
|
|
38
|
-
content = content.replace(/\[\[.*?\|(.*?)\|.*?\|wiki\]\]/g, '$1');
|
|
39
|
-
|
|
40
|
-
// Remove external links, keeping only the link text
|
|
41
|
-
// Pattern explanation: [url text] --> text
|
|
42
|
-
content = content.replace(/\[http[s]?:\/\/[^\s]+ ([^\]]+)\]/g, '$1');
|
|
43
|
-
|
|
44
|
-
// Remove Markdown link references, keeping only the link text
|
|
45
|
-
// Pattern explanation:  --> link text
|
|
46
|
-
content = content.replace(/\!\[([^\]]+)\]\([^\)]+\)/g, '$1');
|
|
47
|
-
|
|
48
|
-
return content;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
sanitizeBlocks(blocks: Array<any>) {
|
|
52
|
-
let sanitizedBlocks = <any>[] ;
|
|
53
|
-
blocks.forEach(block => {
|
|
54
|
-
let sanitizedBlock: any = {};
|
|
55
|
-
for (let key in block) {
|
|
56
|
-
let value = block[key];
|
|
57
|
-
if (typeof value === 'string') {
|
|
58
|
-
sanitizedBlock[key] = this.sanitizeWikiContent(value);
|
|
59
|
-
} else if (Array.isArray(value)) {
|
|
60
|
-
sanitizedBlock[key] = this.sanitizeBlocks(value);
|
|
61
|
-
} else {
|
|
62
|
-
sanitizedBlock[key] = value;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
sanitizedBlocks.push(sanitizedBlock);
|
|
66
|
-
});
|
|
67
|
-
return sanitizedBlocks;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
export class ParseSourceContent{
|
|
2
|
+
public content: Array<any>;
|
|
3
|
+
|
|
4
|
+
titles_to_remove = ['See also', 'References', 'Further reading', 'External links', 'Notes and references', 'Bibliography', 'Notes', 'Cited sources'];
|
|
5
|
+
|
|
6
|
+
constructor(sourceContent:Array<any>){
|
|
7
|
+
this.content = sourceContent;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
parse() {
|
|
11
|
+
let dataAfterRemovingUnWantedBlocks = this.removeSectionsByTitle(this.content);
|
|
12
|
+
let afterSanitized = this.sanitizeBlocks(dataAfterRemovingUnWantedBlocks);
|
|
13
|
+
return JSON.stringify(afterSanitized);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
removeSectionsByTitle(data: Array<any>){
|
|
17
|
+
let dataAfterRemoving = [];
|
|
18
|
+
for(let elem of data){
|
|
19
|
+
if(elem.block_type == 'heading' && this.titles_to_remove.includes(elem.content)){
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if(elem.children){
|
|
23
|
+
elem.children = this.removeSectionsByTitle(elem.children)
|
|
24
|
+
}
|
|
25
|
+
dataAfterRemoving.push(elem)
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
return dataAfterRemoving;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
sanitizeWikiContent(content: String) {
|
|
33
|
+
// Remove newline characters
|
|
34
|
+
content = content.replace(/\\n/g, ' ');
|
|
35
|
+
|
|
36
|
+
// Remove internal link references, keeping only the link text
|
|
37
|
+
// Pattern explanation: [[link|text|index|wiki]] --> text
|
|
38
|
+
content = content.replace(/\[\[.*?\|(.*?)\|.*?\|wiki\]\]/g, '$1');
|
|
39
|
+
|
|
40
|
+
// Remove external links, keeping only the link text
|
|
41
|
+
// Pattern explanation: [url text] --> text
|
|
42
|
+
content = content.replace(/\[http[s]?:\/\/[^\s]+ ([^\]]+)\]/g, '$1');
|
|
43
|
+
|
|
44
|
+
// Remove Markdown link references, keeping only the link text
|
|
45
|
+
// Pattern explanation:  --> link text
|
|
46
|
+
content = content.replace(/\!\[([^\]]+)\]\([^\)]+\)/g, '$1');
|
|
47
|
+
|
|
48
|
+
return content;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
sanitizeBlocks(blocks: Array<any>) {
|
|
52
|
+
let sanitizedBlocks = <any>[] ;
|
|
53
|
+
blocks.forEach(block => {
|
|
54
|
+
let sanitizedBlock: any = {};
|
|
55
|
+
for (let key in block) {
|
|
56
|
+
let value = block[key];
|
|
57
|
+
if (typeof value === 'string') {
|
|
58
|
+
sanitizedBlock[key] = this.sanitizeWikiContent(value);
|
|
59
|
+
} else if (Array.isArray(value)) {
|
|
60
|
+
sanitizedBlock[key] = this.sanitizeBlocks(value);
|
|
61
|
+
} else {
|
|
62
|
+
sanitizedBlock[key] = value;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
sanitizedBlocks.push(sanitizedBlock);
|
|
66
|
+
});
|
|
67
|
+
return sanitizedBlocks;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
71
|
}
|
|
@@ -1,211 +1,211 @@
|
|
|
1
|
-
const responseData = {
|
|
2
|
-
"flash_cards": [
|
|
3
|
-
{
|
|
4
|
-
"question": "What is the primary function of the 'Electrolysis'?",
|
|
5
|
-
"answer": "Electrolysis is the passing of a direct electric current through an electrolyte producing chemical reactions at the electrodes and decomposition of the materials.",
|
|
6
|
-
"heading": "Overview"
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
"question": "What did Michael Faraday discover while studying the process of electrolysis under Humphry Davy?",
|
|
10
|
-
"answer": "Michael Faraday discovered two laws of electrolysis.",
|
|
11
|
-
"heading": "History"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"question": "What can electrolysis be used for in the manufacturing sector?",
|
|
15
|
-
"answer": "Electrolysis can be used for electroplating and electrochemical machining.",
|
|
16
|
-
"heading": "Manufacturing processes"
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
"question": "In the context of electrolysis, what does the term 'Decomposition potential' refer to?",
|
|
20
|
-
"answer": "Decomposition potential or decomposition voltage refers to the minimum voltage between anode and cathode of an electrolytic cell needed for electrolysis to occur.",
|
|
21
|
-
"heading": "Decomposition potential"
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
"mcqs": [
|
|
25
|
-
{
|
|
26
|
-
"question": "What is the primary purpose of 'Electrometallurgy'?",
|
|
27
|
-
"answers": [
|
|
28
|
-
{
|
|
29
|
-
"answer": "Production of aluminium",
|
|
30
|
-
"is_correct": true
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"answer": "Chlorine production",
|
|
34
|
-
"is_correct": false
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"answer": "Purifying copper",
|
|
38
|
-
"is_correct": false
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"answer": "Rust removal",
|
|
42
|
-
"is_correct": false
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"answer": "Hydrogen production",
|
|
46
|
-
"is_correct": false
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
"heading": "Industrial uses"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"question": "What can electrolysis be used for in the context of batteries?",
|
|
53
|
-
"answers": [
|
|
54
|
-
{
|
|
55
|
-
"answer": "Spontaneous redox reactions",
|
|
56
|
-
"is_correct": true
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"answer": "Energy-releasing reactions",
|
|
60
|
-
"is_correct": false
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"answer": "Disinfectant production",
|
|
64
|
-
"is_correct": false
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
"answer": "Fuel production",
|
|
68
|
-
"is_correct": false
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"answer": "Gas diffusion in reactors",
|
|
72
|
-
"is_correct": false
|
|
73
|
-
}
|
|
74
|
-
],
|
|
75
|
-
"heading": "Related processes"
|
|
76
|
-
}
|
|
77
|
-
],
|
|
78
|
-
"cloze_cards": [
|
|
79
|
-
{
|
|
80
|
-
"question": "Electrolysis is the passing of a {{c0:direct electric current}} through an {{c1:electrolyte}} producing {{c2:chemical reactions}} at the {{c3:electrodes}} and {{c4:decomposition}} of the materials.",
|
|
81
|
-
"options": [
|
|
82
|
-
{
|
|
83
|
-
"option": "direct electric current",
|
|
84
|
-
"cloze": "c0"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"option": "electrolyte",
|
|
88
|
-
"cloze": "c1"
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
"option": "chemical reactions",
|
|
92
|
-
"cloze": "c2"
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
"option": "electrodes",
|
|
96
|
-
"cloze": "c3"
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"option": "decomposition",
|
|
100
|
-
"cloze": "c4"
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
"option": "metallic objects",
|
|
104
|
-
"cloze": null
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
"question": "In electrolysis, the decomposition potential or decomposition voltage refers to the minimum voltage between {{c0:anode}} and {{c1:cathode}} of an electrolytic cell needed for electrolysis to occur.",
|
|
110
|
-
"options": [
|
|
111
|
-
{
|
|
112
|
-
"option": "anode",
|
|
113
|
-
"cloze": "c0"
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
"option": "cathode",
|
|
117
|
-
"cloze": "c1"
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
"option": "electrolyte",
|
|
121
|
-
"cloze": null
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
"option": "chemical reactions",
|
|
125
|
-
"cloze": null
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
"option": "oxygen",
|
|
129
|
-
"cloze": null
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
"option": "hydrogen",
|
|
133
|
-
"cloze": null
|
|
134
|
-
}
|
|
135
|
-
]
|
|
136
|
-
}
|
|
137
|
-
]
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
export function returnResponse(){
|
|
142
|
-
return responseData;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export function parseResponse(){
|
|
146
|
-
let cardData = [];
|
|
147
|
-
let data = returnResponse();
|
|
148
|
-
let keys = Object.keys(data);
|
|
149
|
-
if(keys){
|
|
150
|
-
for(let elem of keys){
|
|
151
|
-
if(elem == 'flash_cards'){
|
|
152
|
-
cardData.push(...parseFlashCard(data.flash_cards))
|
|
153
|
-
}else if(elem == 'cloze_cards'){
|
|
154
|
-
cardData.push(...parseClozeCards(data.cloze_cards))
|
|
155
|
-
}else if(elem == 'mcqs'){
|
|
156
|
-
cardData.push(...parseMcq(data.mcqs))
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return cardData;
|
|
161
|
-
}
|
|
162
|
-
/// takes array of
|
|
163
|
-
function parseFlashCard(cards: Array<any>){
|
|
164
|
-
let flashCardData = [];
|
|
165
|
-
for(let elem of cards){
|
|
166
|
-
flashCardData.push({
|
|
167
|
-
"type":"flash",
|
|
168
|
-
"heading": elem.heading,
|
|
169
|
-
"content": JSON.stringify({
|
|
170
|
-
"front_content": elem.question,
|
|
171
|
-
"back_content": elem.answer
|
|
172
|
-
})
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
return flashCardData;
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/// takes array of
|
|
180
|
-
function parseMcq(cardsData: Array<any>){
|
|
181
|
-
let mcqCards= [];
|
|
182
|
-
for(let elem of cardsData){
|
|
183
|
-
mcqCards.push({
|
|
184
|
-
"type":"mcq",
|
|
185
|
-
"heading": elem.heading,
|
|
186
|
-
"content": JSON.stringify({
|
|
187
|
-
"question": elem.question,
|
|
188
|
-
"answers": elem.answers
|
|
189
|
-
})
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
return mcqCards;
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/// takes array of
|
|
197
|
-
function parseClozeCards(cardsData: Array<any>){
|
|
198
|
-
let clozeCards= [];
|
|
199
|
-
for(let elem of cardsData){
|
|
200
|
-
clozeCards.push({
|
|
201
|
-
"type":"cloze",
|
|
202
|
-
"heading": elem.heading,
|
|
203
|
-
"content": JSON.stringify({
|
|
204
|
-
"question": elem.question,
|
|
205
|
-
"options": elem.options
|
|
206
|
-
})
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
return clozeCards;
|
|
210
|
-
|
|
1
|
+
const responseData = {
|
|
2
|
+
"flash_cards": [
|
|
3
|
+
{
|
|
4
|
+
"question": "What is the primary function of the 'Electrolysis'?",
|
|
5
|
+
"answer": "Electrolysis is the passing of a direct electric current through an electrolyte producing chemical reactions at the electrodes and decomposition of the materials.",
|
|
6
|
+
"heading": "Overview"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"question": "What did Michael Faraday discover while studying the process of electrolysis under Humphry Davy?",
|
|
10
|
+
"answer": "Michael Faraday discovered two laws of electrolysis.",
|
|
11
|
+
"heading": "History"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"question": "What can electrolysis be used for in the manufacturing sector?",
|
|
15
|
+
"answer": "Electrolysis can be used for electroplating and electrochemical machining.",
|
|
16
|
+
"heading": "Manufacturing processes"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"question": "In the context of electrolysis, what does the term 'Decomposition potential' refer to?",
|
|
20
|
+
"answer": "Decomposition potential or decomposition voltage refers to the minimum voltage between anode and cathode of an electrolytic cell needed for electrolysis to occur.",
|
|
21
|
+
"heading": "Decomposition potential"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"mcqs": [
|
|
25
|
+
{
|
|
26
|
+
"question": "What is the primary purpose of 'Electrometallurgy'?",
|
|
27
|
+
"answers": [
|
|
28
|
+
{
|
|
29
|
+
"answer": "Production of aluminium",
|
|
30
|
+
"is_correct": true
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"answer": "Chlorine production",
|
|
34
|
+
"is_correct": false
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"answer": "Purifying copper",
|
|
38
|
+
"is_correct": false
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"answer": "Rust removal",
|
|
42
|
+
"is_correct": false
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"answer": "Hydrogen production",
|
|
46
|
+
"is_correct": false
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"heading": "Industrial uses"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"question": "What can electrolysis be used for in the context of batteries?",
|
|
53
|
+
"answers": [
|
|
54
|
+
{
|
|
55
|
+
"answer": "Spontaneous redox reactions",
|
|
56
|
+
"is_correct": true
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"answer": "Energy-releasing reactions",
|
|
60
|
+
"is_correct": false
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"answer": "Disinfectant production",
|
|
64
|
+
"is_correct": false
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"answer": "Fuel production",
|
|
68
|
+
"is_correct": false
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"answer": "Gas diffusion in reactors",
|
|
72
|
+
"is_correct": false
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
"heading": "Related processes"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"cloze_cards": [
|
|
79
|
+
{
|
|
80
|
+
"question": "Electrolysis is the passing of a {{c0:direct electric current}} through an {{c1:electrolyte}} producing {{c2:chemical reactions}} at the {{c3:electrodes}} and {{c4:decomposition}} of the materials.",
|
|
81
|
+
"options": [
|
|
82
|
+
{
|
|
83
|
+
"option": "direct electric current",
|
|
84
|
+
"cloze": "c0"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"option": "electrolyte",
|
|
88
|
+
"cloze": "c1"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"option": "chemical reactions",
|
|
92
|
+
"cloze": "c2"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"option": "electrodes",
|
|
96
|
+
"cloze": "c3"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"option": "decomposition",
|
|
100
|
+
"cloze": "c4"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"option": "metallic objects",
|
|
104
|
+
"cloze": null
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"question": "In electrolysis, the decomposition potential or decomposition voltage refers to the minimum voltage between {{c0:anode}} and {{c1:cathode}} of an electrolytic cell needed for electrolysis to occur.",
|
|
110
|
+
"options": [
|
|
111
|
+
{
|
|
112
|
+
"option": "anode",
|
|
113
|
+
"cloze": "c0"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"option": "cathode",
|
|
117
|
+
"cloze": "c1"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"option": "electrolyte",
|
|
121
|
+
"cloze": null
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"option": "chemical reactions",
|
|
125
|
+
"cloze": null
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"option": "oxygen",
|
|
129
|
+
"cloze": null
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"option": "hydrogen",
|
|
133
|
+
"cloze": null
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
export function returnResponse(){
|
|
142
|
+
return responseData;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function parseResponse(){
|
|
146
|
+
let cardData = [];
|
|
147
|
+
let data = returnResponse();
|
|
148
|
+
let keys = Object.keys(data);
|
|
149
|
+
if(keys){
|
|
150
|
+
for(let elem of keys){
|
|
151
|
+
if(elem == 'flash_cards'){
|
|
152
|
+
cardData.push(...parseFlashCard(data.flash_cards))
|
|
153
|
+
}else if(elem == 'cloze_cards'){
|
|
154
|
+
cardData.push(...parseClozeCards(data.cloze_cards))
|
|
155
|
+
}else if(elem == 'mcqs'){
|
|
156
|
+
cardData.push(...parseMcq(data.mcqs))
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return cardData;
|
|
161
|
+
}
|
|
162
|
+
/// takes array of
|
|
163
|
+
function parseFlashCard(cards: Array<any>){
|
|
164
|
+
let flashCardData = [];
|
|
165
|
+
for(let elem of cards){
|
|
166
|
+
flashCardData.push({
|
|
167
|
+
"type":"flash",
|
|
168
|
+
"heading": elem.heading,
|
|
169
|
+
"content": JSON.stringify({
|
|
170
|
+
"front_content": elem.question,
|
|
171
|
+
"back_content": elem.answer
|
|
172
|
+
})
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return flashCardData;
|
|
176
|
+
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/// takes array of
|
|
180
|
+
function parseMcq(cardsData: Array<any>){
|
|
181
|
+
let mcqCards= [];
|
|
182
|
+
for(let elem of cardsData){
|
|
183
|
+
mcqCards.push({
|
|
184
|
+
"type":"mcq",
|
|
185
|
+
"heading": elem.heading,
|
|
186
|
+
"content": JSON.stringify({
|
|
187
|
+
"question": elem.question,
|
|
188
|
+
"answers": elem.answers
|
|
189
|
+
})
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return mcqCards;
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/// takes array of
|
|
197
|
+
function parseClozeCards(cardsData: Array<any>){
|
|
198
|
+
let clozeCards= [];
|
|
199
|
+
for(let elem of cardsData){
|
|
200
|
+
clozeCards.push({
|
|
201
|
+
"type":"cloze",
|
|
202
|
+
"heading": elem.heading,
|
|
203
|
+
"content": JSON.stringify({
|
|
204
|
+
"question": elem.question,
|
|
205
|
+
"options": elem.options
|
|
206
|
+
})
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return clozeCards;
|
|
210
|
+
|
|
211
211
|
}
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
const typologyResponse = {
|
|
2
|
-
"usage_data": {
|
|
3
|
-
"prompt_tokens": 11611,
|
|
4
|
-
"completion_tokens": 441,
|
|
5
|
-
"total_tokens": 12052
|
|
6
|
-
},
|
|
7
|
-
"generated_content": {
|
|
8
|
-
"field": [
|
|
9
|
-
"Sciences",
|
|
10
|
-
"Technology & Engineering",
|
|
11
|
-
"Education, Learning & Personal Development"
|
|
12
|
-
],
|
|
13
|
-
"concepts": [
|
|
14
|
-
"Electrolysis",
|
|
15
|
-
"Faraday's Laws of Electrolysis",
|
|
16
|
-
"Electrolytic Cell",
|
|
17
|
-
"Decomposition Potential",
|
|
18
|
-
"Oxidation and Reduction at the Electrodes",
|
|
19
|
-
"Electrolysis of Water",
|
|
20
|
-
"Electrolysis of Carbon Dioxide",
|
|
21
|
-
"Electrocrystallization"
|
|
22
|
-
],
|
|
23
|
-
"facts": [
|
|
24
|
-
"Electrolysis is the passing of a direct electric current through an electrolyte producing chemical reactions at the electrodes and decomposition of the materials.",
|
|
25
|
-
"In electrolysis, the quantity of the products is proportional to the current, and when two or more electrolytic cells are connected in series to the same power source, the products produced in the cells are proportional to their equivalent weight.",
|
|
26
|
-
"The main components required to achieve electrolysis are an electrolyte, electrodes, and an external power source.",
|
|
27
|
-
"Faraday's laws of electrolysis detail the amount of the products of electrolysis is related to the number of electrons in the reaction at the electrodes.",
|
|
28
|
-
"Decomposition potential or decomposition voltage refers to the minimum voltage between anode and cathode of an electrolytic cell that is needed for electrolysis to occur.",
|
|
29
|
-
"The electrochemical reduction of carbon dioxide can produce value-added chemicals such as methane, ethylene, and ethanol."
|
|
30
|
-
],
|
|
31
|
-
"generate_cards": true,
|
|
32
|
-
"summary_cards": [
|
|
33
|
-
"Electrolysis is the process of passing direct electric current through an electrolyte, resulting in chemical reactions and the decomposition of materials.",
|
|
34
|
-
"Faraday's laws of electrolysis determine the relationship between the amounts of products generated and the electrons involved in the reaction at the electrodes.",
|
|
35
|
-
"Decomposition potential is the minimum voltage required between anode and cathode for electrolysis to occur.",
|
|
36
|
-
"The electrochemical reduction of carbon dioxide is a potential method for producing valuable chemicals such as methane, ethylene, and ethanol."
|
|
37
|
-
]
|
|
38
|
-
},
|
|
39
|
-
"generated_at": "Tue, 20 Jan 1970 21:17:46 GMT"
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export function returnTypologyData(){
|
|
43
|
-
return typologyResponse as any;
|
|
1
|
+
const typologyResponse = {
|
|
2
|
+
"usage_data": {
|
|
3
|
+
"prompt_tokens": 11611,
|
|
4
|
+
"completion_tokens": 441,
|
|
5
|
+
"total_tokens": 12052
|
|
6
|
+
},
|
|
7
|
+
"generated_content": {
|
|
8
|
+
"field": [
|
|
9
|
+
"Sciences",
|
|
10
|
+
"Technology & Engineering",
|
|
11
|
+
"Education, Learning & Personal Development"
|
|
12
|
+
],
|
|
13
|
+
"concepts": [
|
|
14
|
+
"Electrolysis",
|
|
15
|
+
"Faraday's Laws of Electrolysis",
|
|
16
|
+
"Electrolytic Cell",
|
|
17
|
+
"Decomposition Potential",
|
|
18
|
+
"Oxidation and Reduction at the Electrodes",
|
|
19
|
+
"Electrolysis of Water",
|
|
20
|
+
"Electrolysis of Carbon Dioxide",
|
|
21
|
+
"Electrocrystallization"
|
|
22
|
+
],
|
|
23
|
+
"facts": [
|
|
24
|
+
"Electrolysis is the passing of a direct electric current through an electrolyte producing chemical reactions at the electrodes and decomposition of the materials.",
|
|
25
|
+
"In electrolysis, the quantity of the products is proportional to the current, and when two or more electrolytic cells are connected in series to the same power source, the products produced in the cells are proportional to their equivalent weight.",
|
|
26
|
+
"The main components required to achieve electrolysis are an electrolyte, electrodes, and an external power source.",
|
|
27
|
+
"Faraday's laws of electrolysis detail the amount of the products of electrolysis is related to the number of electrons in the reaction at the electrodes.",
|
|
28
|
+
"Decomposition potential or decomposition voltage refers to the minimum voltage between anode and cathode of an electrolytic cell that is needed for electrolysis to occur.",
|
|
29
|
+
"The electrochemical reduction of carbon dioxide can produce value-added chemicals such as methane, ethylene, and ethanol."
|
|
30
|
+
],
|
|
31
|
+
"generate_cards": true,
|
|
32
|
+
"summary_cards": [
|
|
33
|
+
"Electrolysis is the process of passing direct electric current through an electrolyte, resulting in chemical reactions and the decomposition of materials.",
|
|
34
|
+
"Faraday's laws of electrolysis determine the relationship between the amounts of products generated and the electrons involved in the reaction at the electrodes.",
|
|
35
|
+
"Decomposition potential is the minimum voltage required between anode and cathode for electrolysis to occur.",
|
|
36
|
+
"The electrochemical reduction of carbon dioxide is a potential method for producing valuable chemicals such as methane, ethylene, and ethanol."
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"generated_at": "Tue, 20 Jan 1970 21:17:46 GMT"
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export function returnTypologyData(){
|
|
43
|
+
return typologyResponse as any;
|
|
44
44
|
}
|