only_ever_generator 0.4.3 → 0.4.5

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/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  // import express from "express";
3
3
  // import {
4
+ // returnCardResponse,
5
+ // returnHeadings,
4
6
  // returnSourceData,
5
7
  // } from "./constants/source_data";
6
8
  // import config from "./config";
@@ -28,9 +30,22 @@ Object.defineProperty(exports, "OnlyEverGenerator", { enumerable: true, get: fun
28
30
  // // let content = returnSourceData().toString()
29
31
  // // let headings = returnHeadings();
30
32
  // // // let aiRequest = await openAIRequest(prompt,content);
31
- // let aiRequest = await oeGen.generate(false,true);
33
+ // let aiRequest = await oeGen.generate(true,true);
32
34
  // res.send(aiRequest);
33
35
  // });
36
+ // app.get("/parseCardData", async(req,res)=>{
37
+ // let cardResp = returnCardResponse();
38
+ // let headings = returnHeadings();
39
+ // cardResp.metadata = {
40
+ // "req_time": cardResp.generated_at ?? new Date(),
41
+ // "req_type": cardResp.type,
42
+ // "req_tokens": cardResp.usage_data?.prompt_tokens,
43
+ // "res_tokens": cardResp.usage_data?.completion_tokens,
44
+ // "model": '40-mini'
45
+ // };
46
+ // let parsedData = new GenerateCards(new OpenAiService("","")).parse(cardResp,false,headings);
47
+ // res.send(parsedData)
48
+ // });
34
49
  // // app.get("/typology", async (req, res) => {
35
50
  // // {
36
51
  // // let typologyPrompt = returnTypologyPrompt();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "only_ever_generator",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "start": "npm run build && nodemon dist/index.js",
@@ -30,56 +30,61 @@ export class GenerateCards {
30
30
  }
31
31
 
32
32
  parse(generatedData: any, isGapFill: boolean, headings:Array<any>) {
33
- try{
34
- const cardData = [];
35
33
  let usage_data = generatedData.metadata;
36
34
  const status_code = generatedData.status_code;
37
- const missing_concepts = generatedData.generated_content.missing_concepts;
38
- const missing_facts = generatedData.generated_content.missing_facts;
35
+ try{
36
+ const cardData = [];
39
37
  const unparsedTestCards = generatedData.generated_content.test_cards;
40
38
  const type = generatedData.type;
41
- if(unparsedTestCards !== undefined && unparsedTestCards.length != 0) {
42
- for (let elem of unparsedTestCards) {
43
- if(headings.includes(elem.card_reference)){
44
-
45
- }else{
46
- elem.card_reference = '';
47
- }
48
- if (elem.type == "flash") {
49
- cardData.push(this.parseFlashCard(elem));
50
- } else if (elem.type == "mcq") {
51
- cardData.push(this.parseMcqCard(elem));
52
- } else if (elem.type == "cloze") {
53
- cardData.push(this.parseClozeCard(elem));
54
- } else if (elem.type == "match") {
55
- cardData.push(this.parseMatchCard(elem));
39
+ if(unparsedTestCards !== undefined && unparsedTestCards.length != 0) {
40
+ for (let elem of unparsedTestCards) {
41
+ // if(headings.includes(elem.card_reference)){
42
+
43
+ // }else{
44
+ // elem.card_reference = '';
45
+ // }
46
+ if (elem.type == "flash") {
47
+ cardData.push(this.parseFlashCard(elem));
48
+ } else if (elem.type == "mcq") {
49
+ cardData.push(this.parseMcqCard(elem));
50
+ } else if (elem.type == "cloze") {
51
+ cardData.push(this.parseClozeCard(elem));
52
+ } else if (elem.type == "match") {
53
+ cardData.push(this.parseMatchCard(elem));
54
+ }
55
+ }
56
+ } else {
57
+ if(!isGapFill) {
58
+ usage_data.status = "failed";
59
+ }
56
60
  }
57
- }
58
- } else {
59
- if(!isGapFill) {
60
- usage_data.status = "failed";
61
- }
62
- }
63
61
 
64
62
 
65
63
 
66
64
  return {
67
- status_code: isGapFill? status_code : cardData.length> 0 ? status_code: 500,
65
+ status_code: 500,
68
66
  metadata: usage_data,
69
67
  type: type,
70
- missing_concepts: missing_concepts,
71
- missing_facts: missing_facts,
68
+ missing_concepts: [],
69
+ missing_facts: [],
72
70
  cards_data: cardData,
73
71
  };
74
72
  }catch (e:any){
75
73
  new ErrorLogger({
76
74
  "type": 'card_parsing',
77
75
  "data": e.message,
76
+ "response": generatedData,
78
77
  }).log();
79
78
  return {
80
79
  status_code: 500,
81
- type: 'card_gen',
80
+ metadata : usage_data,
81
+ type: generatedData.type,
82
82
  }
83
+
84
+ // return {
85
+ // status_code: 500,
86
+ // type: 'card_gen',
87
+ // }
83
88
  }
84
89
  }
85
90
 
@@ -1,118 +1,109 @@
1
- const promptString: string = `
2
- As a dedicated assistant at a learning company, your role is to analyze educational content and create test cards that help learners understand and remember key concepts and facts. You will be provided with:
1
+ const promptString: string = `As a dedicated assistant at a learning company, your role is to analyze educational content and create test cards that help learners understand and remember key concepts and facts. You will be provided with:
3
2
 
4
3
  1. Title of the source
5
4
  2. Main headings
6
5
  3. The content
7
- 4. The field of knowledge it belongs
8
- 5. Key concepts in the source
9
- 6. Important facts in the source.
10
- 7. Summary of the content using cards
6
+ 4. The field of knowledge it belongs to
7
+ 5. Key concepts in the source and the relevant main heading it references.
8
+ 6. Important facts in the source and the relevant main heading it references.
11
9
 
12
- Follow these steps:
10
+ **Follow these steps:**
11
+ 1. Read the entire source, concepts and facts in the provide input.
12
+ 2. Generate test cards for concepts: Take each concept and re-read the text under the reference heading for that concept. Start by trying to create a card that is at the highest bloom level possible (5 being the highest). Then work your way down to the lower bloom levels. Generate as many cards as possible for each concept. Keep going through the list of concepts till you have completed all of them.
13
+ 3. Generate test cards for facts: Take each fact and re-read the text under the reference heading for that fact. Generate as many cards as possible to test that concept. Keep going through the list of concepts till you have completed all of them.
13
14
 
14
- 1. Analyze the content to identify any key concepts missing from the provided list.
15
- 2. Analyze the content to identify any important facts missing from the provided list.
16
- 3. Generate test cards for each concept and fact, tethered to either the entire source or specific headings.
17
- 4. Ensure all concepts and facts have at least one test card.
15
+ **Note:** Further detailed instructions on how to create the content for each test card type will be provided subsequently.
16
+
17
+ **Format your response in the following JSON format:**
18
18
 
19
- Please format your response in the following format.
20
19
  json
21
- "missing_concepts": ["concept1", "concept2", "concept3", "..."],
22
- "missing_facts": ["fact1", "fact2", "fact3", "..."],
20
+ {
23
21
  "test_cards": [
24
22
  {
25
- "type": "flash" | "mcq" | "cloze" | "match",
26
- "card_content": {schema for content is explained below in detail}
27
- "card_reference": "heading",
28
- "concepts": ["Concept1", "Concept2", "..."],
29
- "facts": ["Fact1", "Fact2", "..."]
23
+ "type": "mcq" | "cloze" | "match",
24
+ "card_content": "{content}",
25
+ "concepts": [
26
+ "concept1",
27
+ "concept2",
28
+ "..."
29
+ ],
30
+ "facts": [
31
+ "fact1",
32
+ "fact2",
33
+ "..."
34
+ ],
35
+ "bloom_level": 1 | 2 | 3 | 4 | 5
30
36
  }
31
37
  ]
38
+ }
32
39
 
33
- **Criteria**
34
- • Each test card must include at least one concept or fact.
35
- • Flashcards must not exceed 15% of the total number of cards.
36
- • Each concept and fact must have at least one test card.
37
-
38
- Further instructions are provided below.
39
-
40
- You are provided with a list of identified concepts. Review this list and the content to determine if any concepts are missing.
41
-
42
- 1. **Definition of a Concept**: Concepts are fundamental ideas that form the basis of knowledge in any discipline. They help organize and explain information, making it accessible and relatable.
43
- 2. **Inclusion Criteria**: Include a concept only if it has not been previously included in the list provided to you.
44
40
 
45
- List the concepts in the following JSON format:
41
+ **Criteria:**
46
42
 
47
- json
48
- {
49
- "missing_concepts":
50
- [
51
- "concept1",
52
- "concept2",
53
- "concept3",
54
- "..."
55
- ]
56
- }
57
- You are provided with a list of identified facts. Review this list and the content to determine if any facts are missing.
43
+ * Each test card must include at least one concept or fact.
44
+ * Each concept and fact must have at least one test card.
45
+ * The final output should include test cards that cover the first 5 levels of Bloom's Taxonomy.
58
46
 
59
- 1. **Definition of a Fact**: Standalone information that is concrete and independently verifiable.
60
- 2. **Selection Criteria**: Choose facts based on their significance to the content's main themes or concepts, their educational value, or their foundational role in the subject. Only inlcude those that have not present in the list provided to you.
47
+ **Further Instructions:**
61
48
 
62
- Record the facts in the following JSON format:
63
- json
64
- {
65
- "missing_facts": ["fact1", "fact2", "fact3", "..."]
66
- }
49
+ * Ensure variety in the types of test cards (MCQs, cloze tests, matching).
50
+ * Balance the distribution of Bloom's Taxonomy levels across the test cards.
51
+ * Provide clear and concise content for each test card, ensuring it is relevant to the concepts and facts identified.
52
+ * Use appropriate and engaging language to enhance learning and retention.
67
53
 
68
- After you have the complete list of concepts and facts, including any missing ones you identified, proceed to generate test cards for each.
54
+ This section provides detailed guidance on how to generate cards.
69
55
 
70
- 1. Clarity: Ensure the test content is clear and unambiguous.
71
- 2. Specificity: Be specific about what you are asking. Avoid vague or overly broad questions or prompts.
72
- 3. Simplicity: Use simple and direct language. Avoid complex sentences or jargon unless testing understanding of that jargon.
73
- 4. Relevance: Ensure the test content is directly related to the key concepts or facts you want to test.
56
+ **Guidance on the card content**
74
57
 
75
- Include the following property for each card:
58
+ 1. Clarity: Ensure the test content is clear and unambiguous.
59
+ 2. Specificity: Be specific about what you are asking. Avoid vague or overly broad questions or prompts.
60
+ 3. Simplicity: Use simple and direct language. Avoid complex sentences or jargon unless testing understanding of that jargon.
61
+ 4. Relevance: Ensure the test content is related to the key concepts or facts you want to test.
76
62
 
77
- bloom_level: Indicate the level of Bloom’s Taxonomy the card corresponds to (from level 1 to level 5). Ensure that you produce a balanced number of cards across all levels, focusing on levels 1 through 5. Aim for a diverse range of cognitive challenges.
63
+ Include the following properties for each card:
78
64
 
79
- Ensure that you produce at least one card for each concept and fact. Do not skip any concepts or facts, and be thorough in your coverage. Cards should span across different levels of Bloom’s Taxonomy, from level 1 (Remembering) to level 5 (Evaluating), but exclude level 6 (Creating).
65
+ bloom_level: Indicate the level of Bloom’s Taxonomy the card corresponds to (from level 1 to level 5). Ensure that you produce a balanced number of cards across all levels, focusing on levels 1 (Remembering) through 5 (Evaluating). Aim for a diverse range of cognitive challenges.
80
66
 
81
67
  Test cards must be one of the following types:
82
68
 
83
- 1. Flashcards: Have a front and back.
84
-
85
- json:
86
- {
87
- "type": "flash",
88
- "card_content": {
89
- "front": "<content for the front>",
90
- "back": "<content for the back>"
91
- },
92
- "card_reference": "heading",
93
- "concepts": ["Concept1", "Concept2", "..."],
94
- "facts": ["Fact1", "Fact2", "..."],
95
- "bloom_level": <1-5>
96
- }
97
-
98
- - Each side must not exceed 300 characters.
99
- 2. Multiple Choice Questions (MCQ): Provide multiple choices to pick from. One or more should be correct.
69
+ 1. Multiple Choice Questions (MCQ): Provide multiple choices to pick from. One or more should be correct.
100
70
 
101
- json:
71
+ json
102
72
  {
103
- "type": "mcq",
104
- "card_content": {
105
- "prompt": "<question text>",
106
- "choices": [
107
- {"choice": "choice 1", "is_correct": true or false},
108
- {"choice": "choice 2", "is_correct": true or false},
109
- "... up to 8 choices"
110
- ]
111
- },
112
- "card_reference": "heading",
113
- "concepts": ["Concept1", "Concept2", "..."],
114
- "facts": ["Fact1", "Fact2", "..."],
115
- "bloom_level": <1-5>
73
+ "type": "mcq",
74
+ "card_content": {
75
+ "prompt": "<question text>",
76
+ "choices": [
77
+ {"choice": "choice content", "is_correct": true or false},
78
+ {"choice": "choice content", "is_correct": true or false},
79
+ "... up to 8 choices"
80
+ ]
81
+ },
82
+ "concepts":
83
+ [
84
+ {
85
+ "concept_text": "concept1_content",
86
+ "reference": "source_title#main_heading"
87
+ },
88
+ {
89
+ "concept_text": "concept2_content",
90
+ "reference": "source_title#main_heading"
91
+ },
92
+ {...}
93
+ ],
94
+ "facts":
95
+ [
96
+ {
97
+ "factt_text": "fact1_content",
98
+ "reference": "source_title#main_heading"
99
+ },
100
+ {
101
+ "fact_text": "fact2_content",
102
+ "reference": "source_title#main_heading"
103
+ },
104
+ {...}
105
+ ],
106
+ "bloom_level": <1-5>
116
107
  }
117
108
 
118
109
  • Minimum choices required: 2
@@ -120,26 +111,48 @@ json:
120
111
  • Minimum correct choices required: 1
121
112
  • Maximum character length for the prompt: 320
122
113
  • Maximum character length for each choice: 42
114
+ • Do not add numbering to the choice content since these will be randomly sorted when displaying to the user
123
115
 
124
- 3. Cloze: A test card where a portion of text is masked for the learner to identify from the provided options. Use double curly braces {{c<n>: cloze_text}} to indicate a cloze, where n is the index number of the cloze (starting from 0) and cloze_text is the word or phrase being clozed.
116
+ 2. Cloze: A test card where a portion of text is masked for the learner to identify from the provided options. Use double curly braces {{c<n>: cloze_text}} to indicate a cloze, where n is the index number of the cloze (starting from 0) and cloze_text is the word or phrase being clozed.
125
117
 
126
118
  json
127
119
  {
128
- "type": "cloze",
129
- "card_content": {
130
- "prompt": "Accidentals in music denote {{c0:notes}} that do not belong to the {{c1:scale}} or {{c2:mode}} indicated by the key signature.",
131
- "options": [
132
- {"option": "notes", "cloze": "c0"},
133
- {"option": "scale", "cloze": "c1"},
134
- {"option": "mode", "cloze": "c2"},
135
- {"option": "chords", "cloze": "null"},
136
- "... up to 8 choices"
137
- ]
138
- },
139
- "card_reference": "heading",
140
- "concepts": ["Concept1", "Concept2", "..."],
141
- "facts": ["Fact1", "Fact2", "..."],
142
- "bloom_level": <1-5>
120
+ "type": "cloze",
121
+ "card_content": {
122
+ "prompt": "Accidentals in music denote {{c0:notes}} that do not belong to the {{c1:scale}} or {{c2:mode}} indicated by the key signature.",
123
+ "options": [
124
+ {"option": "notes", "cloze": "c0"},
125
+ {"option": "scale", "cloze": "c1"},
126
+ {"option": "mode", "cloze": "c2"},
127
+ {"option": "chords", "cloze": "null"},
128
+ "... up to 8 choices"
129
+ ]
130
+ },
131
+ "concepts":
132
+ [
133
+ {
134
+ "concept_text": "concept1_content",
135
+ "reference": "source_title#main_heading"
136
+ },
137
+ {
138
+ "concept_text": "concept2_content",
139
+ "reference": "source_title#main_heading"
140
+ },
141
+ {...}
142
+ ],
143
+ "facts":
144
+ [
145
+ {
146
+ "factt_text": "fact1_content",
147
+ "reference": "source_title#main_heading"
148
+ },
149
+ {
150
+ "fact_text": "fact2_content",
151
+ "reference": "source_title#main_heading"
152
+ },
153
+ {...}
154
+ ],
155
+ "bloom_level": <1-5>
143
156
  }
144
157
 
145
158
  • Minimum choices required: 2
@@ -152,49 +165,75 @@ json
152
165
 
153
166
  json
154
167
  {
155
- "type": "match",
156
- "card_content": [
157
- {
158
- "left_item": "left choice",
159
- "right_item": [right item]
160
- },
161
- {
162
- "left_item":" left choice",
163
- "right_item": [right item]
164
- },
165
- {
166
- "left_item": "left choice",
167
- "right_item": [right item]
168
- },
169
- "... up to 8 total pairs"
170
- ],
171
- "card_reference": "heading",
172
- "concepts": ["Concept1", "Concept2", "..."],
173
- "facts": ["Fact1", "Fact2", "..."],
174
- "bloom_level": <1-5>
168
+ "type": "match",
169
+ "card_content": [
170
+ {
171
+ "left_item": "left choice",
172
+ "right_item": [right item]
173
+ },
174
+ {
175
+ "left_item":" left choice",
176
+ "right_item": [right item]
177
+ },
178
+ {
179
+ "left_item": "left choice",
180
+ "right_item": [right item]
181
+ },
182
+ "... up to 8 total pairs"
183
+ ],
184
+ "concepts":
185
+ [
186
+ {
187
+ "concept_text": "concept1_content",
188
+ "reference": "source_title#main_heading"
189
+ },
190
+ {
191
+ "concept_text": "concept2_content",
192
+ "reference": "source_title#main_heading"
193
+ },
194
+ {...}
195
+ ],
196
+ "facts":
197
+ [
198
+ {
199
+ "factt_text": "fact1_content",
200
+ "reference": "source_title#main_heading"
201
+ },
202
+ {
203
+ "fact_text": "fact2_content",
204
+ "reference": "source_title#main_heading"
205
+ },
206
+ {...}
207
+ ],
208
+ "bloom_level": <1-5>
175
209
  }
176
210
 
177
211
  • Maximum character length for each item in a pair: 42
178
-
179
212
 
180
- Each test card needs a reference. A reference can either be the entire source or a specific heading in the source. Whenever possible, pick a main heading to direct the user to the most relevant part of the source material. The reference schema is as follows: ""main_heading, where #main_heading is optional.
181
- Once you are done generating the test cards. Go back and evaulate the full list of concepts and fact that include any of the missing concepts or facts along with the list that was provided as the input.
213
+
214
+ ** Criteria **
215
+
216
+ 1. Ensure that you produce at least one if not more card for each concept and fact.
217
+ 2. For each concept and fact start by trying to create a card at the highest bloom level possible.
218
+ 3. Do not skip any concepts or facts, and be thorough in your coverage.
219
+ 4. Cards should span across different levels of Bloom’s Taxonomy, from level 1 (Remembering) to level 5 (Evaluating), but exclude level 6 (Creating)
220
+
221
+ Once you are done generating the test cards. Go back and evaulate the full list of concepts and facts provided as the input.
182
222
 
183
223
  Are there any concept or fact that don't have a test card yet? If yes, go back and create one.
184
224
 
185
225
  Once you are done creating come back to this step again to check if you have full coverage of all the concepts and facts in the source. You can stop generating test questions once you achieve full coverage.
186
- Generate atleast 10 cards.
187
226
 
227
+ Once you are done generating the test cards, review the full list of concepts and facts, including any missing ones you identified.
228
+
229
+ 1. Ensure every concept and fact has at least one test card (if not more).
230
+ 2. If any concept or fact is missing a test card, create one for it.
231
+ 3. Repeat this step until all concepts and facts are covered.
232
+
233
+ Only stop generating test questions once you believe there is sufficient testing material for learners to fully understand the concepts and remember the facts. The same concept or fact can have multiple test cards, so continue creating test cards until you are confident that there are enough for learners to fully grasp the source material.
188
234
  `;
189
235
  export function returnCardGenPrompt(cardGenPrompt: any){
190
236
  return promptString;
191
237
  }
192
- // let concatenatedString: string = '';
193
- // for (let key in cardGenPrompt) {
194
- // if (cardGenPrompt.hasOwnProperty(key)) {
195
- // concatenatedString += cardGenPrompt[key];
196
- // }
197
- // }
198
- // return concatenatedString;
199
- // }
238
+
200
239
 
@@ -15,7 +15,7 @@ json
15
15
  [
16
16
  {
17
17
  "concept_text": "concept_content",
18
- "reference": "source_title#main_heading"
18
+ "reference": "main_heading"
19
19
  },
20
20
  {...}
21
21
  ],
@@ -23,7 +23,7 @@ json
23
23
  [
24
24
  {
25
25
  "fact_text": "fact_content",
26
- "reference": "source_title#main_heading"
26
+ "reference": "main_heading"
27
27
  },
28
28
  {...}
29
29
  ],
@@ -70,7 +70,7 @@ json
70
70
  [
71
71
  {
72
72
  "concept_text": "concept_content",
73
- "reference": "source_title#main_heading"
73
+ "reference": "main_heading"
74
74
  },
75
75
  {...}
76
76
  ]
@@ -88,7 +88,7 @@ json
88
88
  [
89
89
  {
90
90
  "fact_text": "fact_content",
91
- "reference": "source_title#main_heading"
91
+ "reference": "main_heading"
92
92
  },
93
93
  {...}
94
94
  ]