only_ever_generator 0.5.2 → 0.5.4
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 +7 -2
- package/dist/bootstrap/app.js.map +1 -0
- package/dist/card_gen/generate_cards.js +2 -2
- package/dist/card_gen/generate_cards.js.map +1 -0
- package/dist/constants/api_constants.js.map +1 -0
- package/dist/constants/prompt_data.js.map +1 -0
- package/dist/constants/prompts/card_gen_prompt.js +93 -164
- package/dist/constants/prompts/card_gen_prompt.js.map +1 -0
- package/dist/constants/prompts/typology_prompt.js +21 -20
- package/dist/constants/prompts/typology_prompt.js.map +1 -0
- package/dist/constants/source_data.js.map +1 -0
- package/dist/gap_fill/calculate_gap_fill.js.map +1 -0
- package/dist/index.js +17 -22
- package/dist/parse/parse_card/parse_cloze_card.js +55 -18
- package/dist/parse/parse_card/parse_cloze_card.js.map +1 -0
- package/dist/parse/parse_card/parse_match_card.js +30 -8
- package/dist/parse/parse_card/parse_match_card.js.map +1 -0
- package/dist/parse/parse_card/parse_mcq_card.js +1 -1
- package/dist/parse/parse_card/parse_mcq_card.js.map +1 -0
- package/dist/parse/parse_card_response.js +35 -3
- package/dist/parse/parse_card_response.js.map +1 -0
- package/dist/parse/parse_source_content.js.map +1 -0
- package/dist/parse/response_format_card.js.map +1 -0
- package/dist/parse/response_format_typology.js.map +1 -0
- package/dist/services/open_ai_service.js.map +1 -0
- package/dist/typology_gen/generate_typology.js.map +1 -0
- package/dist/utils/generate_args.js.map +1 -0
- package/dist/utils/parse_openai_response.js.map +1 -0
- package/package.json +1 -1
- package/prompts.json +23 -0
- package/src/bootstrap/app.ts +7 -1
- package/src/card_gen/generate_cards.ts +2 -2
- package/src/constants/prompts/card_gen_prompt.ts +93 -164
- package/src/constants/prompts/typology_prompt.ts +21 -20
- package/src/index.ts +13 -24
- package/src/parse/parse_card/parse_cloze_card.ts +51 -17
- package/src/parse/parse_card/parse_match_card.ts +42 -7
- package/src/parse/parse_card/parse_mcq_card.ts +1 -1
- package/src/parse/parse_card_response.ts +39 -3
|
@@ -1,215 +1,144 @@
|
|
|
1
1
|
const promptString: string = `
|
|
2
|
-
As a dedicated assistant at a learning company, your role is to
|
|
3
|
-
|
|
2
|
+
As a dedicated assistant at a learning company, your role is to create test cards based on the provided content. The purpose of these cards is to help learners master and understand the concepts and facts presented to you.
|
|
3
|
+
You will be provided with the following:
|
|
4
4
|
1. Title of the source
|
|
5
|
-
2.
|
|
6
|
-
3. The
|
|
7
|
-
4.
|
|
8
|
-
5.
|
|
9
|
-
6. Important facts in the source and the relevant main heading it references.
|
|
10
|
-
|
|
5
|
+
2. The content
|
|
6
|
+
3. The field of knowledge it belongs to
|
|
7
|
+
4. Key concepts in the source
|
|
8
|
+
5. Important facts in the source
|
|
11
9
|
**Follow these steps:**
|
|
12
|
-
1.
|
|
13
|
-
2. Generate test cards
|
|
14
|
-
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.
|
|
15
|
-
|
|
16
|
-
**Note:** Further detailed instructions on how to create the content, references and bloom level for each test card type will be provided subsequently.
|
|
17
|
-
|
|
10
|
+
1. Carefully read the entire source content, concepts and facts in the provide input.
|
|
11
|
+
2. Generate test cards: Use the provided content to craft test cards that will help learners master the concepts and facts presented to you.
|
|
18
12
|
**Format your response in the following JSON format:**
|
|
19
|
-
|
|
20
13
|
json
|
|
21
14
|
{
|
|
22
15
|
"test_cards": [
|
|
23
16
|
{
|
|
24
|
-
"type": "
|
|
25
|
-
"card_content": "{content}",
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
"facts": [{fact1}, {fact2}, {...}],
|
|
29
|
-
"bloom_level": 1 | 2 | 3 | 4 | 5
|
|
17
|
+
"type": "{card_type}",
|
|
18
|
+
"card_content": "{content}",
|
|
19
|
+
"concepts": ["concept1", "concept2", "..."],
|
|
20
|
+
"facts": ["fact1", "fact2", "..."]
|
|
30
21
|
},
|
|
31
|
-
{... as many as possible}
|
|
22
|
+
{... as many cards as possible}
|
|
32
23
|
]
|
|
33
24
|
}
|
|
34
25
|
|
|
26
|
+
**Note:** Detailed instructions on card_type(s) and how to create the content for each test card type will be provided subsequently.
|
|
35
27
|
|
|
36
28
|
**Criteria:**
|
|
37
|
-
|
|
38
29
|
* Each test card must include at least one concept or fact.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
|
|
42
|
-
**Further Instructions:**
|
|
43
|
-
|
|
44
|
-
* Ensure variety in the types of test cards (MCQs, cloze tests, matching).
|
|
45
|
-
* Balance the distribution of Bloom's Taxonomy levels across the test cards.
|
|
30
|
+
* The concepts and facts in each card MUST MATCH EXACTLY with those provided in the input.
|
|
31
|
+
* Ensure variety in the types of test cards created (if you are asked to create multiple types).
|
|
46
32
|
* Provide clear and concise content for each test card, ensuring it is relevant to the concepts and facts identified.
|
|
47
33
|
* Use appropriate and engaging language to enhance learning and retention.
|
|
48
34
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
**Guidance on the card content**
|
|
35
|
+
**Cloze**
|
|
52
36
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
3. Simplicity: Use simple and direct language. Avoid complex sentences or jargon unless testing understanding of that jargon.
|
|
56
|
-
4. Relevance: Ensure the test content is related to the key concepts or facts you want to test.
|
|
37
|
+
A test card where a portion of text is masked for the learner to identify from the provided options.
|
|
38
|
+
Follow the schema below to create new cloze cards specially focus on how correct options are enclosed with in {{}}.
|
|
57
39
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
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.
|
|
61
|
-
|
|
62
|
-
Test cards must be one of the following types:
|
|
63
|
-
|
|
64
|
-
1. Multiple Choice Questions (MCQ): Provide multiple choices to pick from. One or more should be correct.
|
|
40
|
+
Use the schema below to create new cloze cards.
|
|
65
41
|
|
|
42
|
+
json
|
|
66
43
|
{
|
|
67
|
-
"type": "
|
|
68
|
-
"card_content":
|
|
69
|
-
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
]
|
|
75
|
-
},
|
|
76
|
-
"concepts":
|
|
77
|
-
[
|
|
78
|
-
{
|
|
79
|
-
"concept_text": "concept1_content",
|
|
80
|
-
"reference": "main_heading"
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"concept_text": "concept2_content",
|
|
84
|
-
"reference": "main_heading"
|
|
44
|
+
"type": "cloze",
|
|
45
|
+
"card_content":
|
|
46
|
+
{
|
|
47
|
+
"prompt": "This is some {{sample}} text for {{showing}} how to create clozes.",
|
|
48
|
+
"correct_options": ["sample", "showing"],
|
|
49
|
+
"incorrect_options": ["incorrect_option1", "incorrect_option2", "..."],
|
|
50
|
+
"explanation": "optional 320 character explanation"
|
|
85
51
|
},
|
|
86
|
-
|
|
87
|
-
]
|
|
88
|
-
|
|
89
|
-
[
|
|
90
|
-
{
|
|
91
|
-
"fact_text": "fact1_content",
|
|
92
|
-
"reference": "main_heading"
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
"fact_text": "fact2_content",
|
|
96
|
-
"reference": "main_heading"
|
|
97
|
-
},
|
|
98
|
-
{...}
|
|
99
|
-
],
|
|
100
|
-
"bloom_level": <1-5>
|
|
52
|
+
"concepts": ["concept1", "concept2", "..."],
|
|
53
|
+
"facts": ["fact1", "fact2", ...]
|
|
54
|
+
|
|
101
55
|
}
|
|
102
56
|
|
|
103
|
-
• Minimum choices required: 2
|
|
104
|
-
• Maximum choices allowed: 8
|
|
105
|
-
• Minimum correct choices required: 1
|
|
106
|
-
• Maximum character length for the prompt: 90
|
|
107
|
-
• Maximum character length for each choice: 40
|
|
108
|
-
• Do not add numbering to the choice content since these will be randomly sorted when displaying to the user
|
|
109
57
|
|
|
110
|
-
|
|
111
|
-
|
|
58
|
+
* A valid cloze must include at least one or more words
|
|
59
|
+
* When appropriate, include a brief explanation (320 characters max) to help the learner understand the concept or fact and how to answer the question.
|
|
60
|
+
* Minimum clozes required: 1
|
|
61
|
+
* Minimum choices (correct options + incorrect options) required: 2
|
|
62
|
+
* Maximum choices (correct options + incorrect options) allowed: 8
|
|
63
|
+
* Maximum character length for the prompt: 320
|
|
64
|
+
* Maximum character length for an individual cloze: 90
|
|
65
|
+
**Flashcards**
|
|
66
|
+
|
|
67
|
+
Test cards that have a front and a back.
|
|
68
|
+
|
|
69
|
+
Use the schema below to create new flashcards.
|
|
112
70
|
|
|
71
|
+
json
|
|
113
72
|
{
|
|
114
|
-
"type": "
|
|
73
|
+
"type": "flash",
|
|
115
74
|
"card_content": {
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
|
|
119
|
-
{"option": "scale", "cloze": "c1"},
|
|
120
|
-
{"option": "mode", "cloze": "c2"},
|
|
121
|
-
{"option": "chords", "cloze": "null"},
|
|
122
|
-
"... up to 8 choices"
|
|
123
|
-
]
|
|
75
|
+
"front": "<content for the front>",
|
|
76
|
+
"back": "<content for the back>",
|
|
77
|
+
"explanation": "optional 320 character explanation"
|
|
124
78
|
},
|
|
125
|
-
"concepts":
|
|
126
|
-
[
|
|
127
|
-
{
|
|
128
|
-
"concept_text": "concept1_content",
|
|
129
|
-
"reference": "main_heading"
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
"concept_text": "concept2_content",
|
|
133
|
-
"reference": "main_heading"
|
|
134
|
-
},
|
|
135
|
-
{...}
|
|
136
|
-
],
|
|
137
|
-
"facts":
|
|
138
|
-
[
|
|
139
|
-
{
|
|
140
|
-
"fact_text": "fact1_content",
|
|
141
|
-
"reference": "main_heading"
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
"fact_text": "fact2_content",
|
|
145
|
-
"reference": "main_heading"
|
|
146
|
-
},
|
|
147
|
-
{...}
|
|
148
|
-
],
|
|
149
|
-
"bloom_level": <1-5>
|
|
79
|
+
"concepts": ["concept1", "concept2", "..."],
|
|
80
|
+
"facts": ["fact1", "fact2", "..."],
|
|
150
81
|
}
|
|
151
82
|
|
|
152
|
-
* Minimum choices required: 2
|
|
153
|
-
* Maximum choices allowed: 8
|
|
154
|
-
* Minimum correct choices required: 1
|
|
155
|
-
* Maximum character length for the prompt: 320
|
|
156
|
-
* Maximum character length for an individual cloze: 90
|
|
157
83
|
|
|
158
|
-
|
|
84
|
+
* Each side (front and back) must not exceed 320 characters.
|
|
85
|
+
* When appropriate, include a brief explanation (320 characters max) to help the learner understand the concept or fact and how to answer the question.
|
|
159
86
|
|
|
87
|
+
**Match**
|
|
88
|
+
Provide item pairs.
|
|
89
|
+
Use the schema below to create new match cards.
|
|
160
90
|
|
|
91
|
+
json
|
|
161
92
|
{
|
|
162
93
|
"type": "match",
|
|
163
|
-
"card_content"
|
|
94
|
+
"card_content":
|
|
95
|
+
[
|
|
164
96
|
{
|
|
165
97
|
"left_item" : "left_item text",
|
|
166
|
-
"right_item" :
|
|
98
|
+
"right_item" : "right_item text"
|
|
167
99
|
},
|
|
168
100
|
{
|
|
169
101
|
"left_item" : "left_item text",
|
|
170
|
-
"right_item" :
|
|
102
|
+
"right_item" : "right_item text"
|
|
171
103
|
},
|
|
172
104
|
{"... up to 8 total pairs"}
|
|
173
105
|
],
|
|
174
|
-
"concepts":
|
|
175
|
-
[
|
|
176
|
-
{
|
|
177
|
-
"concept_text": "concept1_content",
|
|
178
|
-
"reference": "main_heading"
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
"concept_text": "concept2_content",
|
|
182
|
-
"reference": "main_heading"
|
|
183
|
-
},
|
|
184
|
-
{...}
|
|
185
|
-
],
|
|
186
|
-
"facts":
|
|
187
|
-
[
|
|
188
|
-
{
|
|
189
|
-
"fact_text": "fact1_content",
|
|
190
|
-
"reference": "main_heading"
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
"fact_text": "fact2_content",
|
|
194
|
-
"reference": "main_heading"
|
|
195
|
-
},
|
|
196
|
-
{...}
|
|
197
|
-
],
|
|
198
|
-
"bloom_level": <1-5>
|
|
106
|
+
"concepts": ["concept1", "concept2", "..."],
|
|
107
|
+
"facts": ["fact1", "fact2", ...]
|
|
199
108
|
}
|
|
200
109
|
|
|
201
|
-
* Maximum character length for each item in a pair: 24
|
|
202
|
-
* Duplicate items are allowed on the left side but not on the right side. Or in other words the same item on the left can be paired with multiple items on the right.
|
|
203
110
|
|
|
111
|
+
* Maximum character length for each left/right item text : 30, strictly enforced.
|
|
112
|
+
* Duplicate items are allowed. Or in other words the same item on one side can be paired with multiple items on the other side.
|
|
204
113
|
|
|
114
|
+
**Multiple Choice Questions (MCQ)**
|
|
115
|
+
Provide multiple choices to pick from. One or more should be correct.
|
|
116
|
+
Use the schema below to create new MCQ cards.
|
|
117
|
+
json
|
|
118
|
+
{
|
|
119
|
+
"type": "mcq",
|
|
120
|
+
"card_content": {
|
|
121
|
+
"prompt": "<question text>",
|
|
122
|
+
"choices": [
|
|
123
|
+
{"choice": "choice content", "is_correct": true or false},
|
|
124
|
+
{"choice": "choice content", "is_correct": true or false},
|
|
125
|
+
"... up to 8 choices"
|
|
126
|
+
],
|
|
127
|
+
"explanation": "optional 320 character explanation"
|
|
128
|
+
},
|
|
129
|
+
"concepts": ["concept1", "concept2", "..."],
|
|
130
|
+
"facts": ["fact1", "fact2", ...]
|
|
131
|
+
}
|
|
205
132
|
|
|
206
|
-
** Overall Criteria for Testing Cards **
|
|
207
133
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
134
|
+
* When appropriate, include a brief explanation (320 characters max) to help the learner understand the concept or fact and how to answer the question.
|
|
135
|
+
* Minimum choices required: 2
|
|
136
|
+
* Maximum choices allowed: 8
|
|
137
|
+
* Minimum correct choices required: 1
|
|
138
|
+
* Maximum character length for the prompt: 320
|
|
139
|
+
* Maximum character length for each choice: 42
|
|
140
|
+
* DO NOT add numbering to the choice content since these will be randomly sorted when displaying to the user
|
|
141
|
+
Once you are done generating the test cards. Go back and evaulate the full list of concepts and facts provided as the input.
|
|
213
142
|
|
|
214
143
|
Are there any concept or fact that don't have a test card yet? If yes, go back and create one.
|
|
215
144
|
|
|
@@ -217,9 +146,9 @@ Once you are done creating come back to this step again to check if you have ful
|
|
|
217
146
|
|
|
218
147
|
Once you are done generating the test cards, review the full list of concepts and facts, including any missing ones you identified.
|
|
219
148
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
149
|
+
1. Ensure every concept and fact has at least one test card (if not more).
|
|
150
|
+
2. If any concept or fact is missing a test card, create one for it.
|
|
151
|
+
3. Repeat this step until all concepts and facts are covered.
|
|
223
152
|
|
|
224
153
|
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.
|
|
225
154
|
`;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
const typologyPromptString = `
|
|
2
|
-
You are a dedicated assistant that categorizes and summarizes educational content. You will process educational content (in JSON format) that represents text from diverse sources such as PDFs, book chapters,
|
|
2
|
+
You are a dedicated assistant that categorizes and summarizes educational content. You will process educational content (in JSON format) that represents text from diverse sources such as wikipedia, markdown notes, PDFs, book chapters, and websites.
|
|
3
|
+
You will be provided with the following:
|
|
4
|
+
1. Title of the source
|
|
5
|
+
2. A list of main headings in the source
|
|
6
|
+
3. The source content
|
|
3
7
|
|
|
8
|
+
Follow these steps:
|
|
4
9
|
1. Classify the content into one to three predefined fields of knowledge.
|
|
5
10
|
2. Extract key concepts within the content. Be exhaustive and thorough.
|
|
6
|
-
3. Extract concrete facts that are
|
|
7
|
-
4. Decide whether the
|
|
11
|
+
3. Extract concrete and relevant facts that are referenced in the content. Be exhaustive and thorough.
|
|
12
|
+
4. Decide whether the content has any educational value and should be used to generate test material and quizzes based on the identified concepts and facts.
|
|
8
13
|
5. If the generate_cards is true then summarize the content using a series of summary cards.
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
Output your answer as valid JSON, in the form:
|
|
11
16
|
json
|
|
12
17
|
{
|
|
13
18
|
"field": ["primary_field", "secondary_field", "tertiary_field"],
|
|
@@ -27,10 +32,10 @@ json
|
|
|
27
32
|
},
|
|
28
33
|
{...}
|
|
29
34
|
],
|
|
30
|
-
"generate_cards":
|
|
35
|
+
"generate_cards": [
|
|
31
36
|
state: true or false,
|
|
32
37
|
reason: "reason for marking the source as false. Leave empty for true."
|
|
33
|
-
|
|
38
|
+
],
|
|
34
39
|
"summary_cards": ["summary_card1_content", "summary_card2_content", "summary_card3_content", "..."]
|
|
35
40
|
}
|
|
36
41
|
|
|
@@ -58,9 +63,9 @@ Every source must be placed under a field. This is the broadest category of know
|
|
|
58
63
|
Extract key concepts within the content after classifying the field. This is a crucial part of the exercise. Be exhaustive and thorough.
|
|
59
64
|
|
|
60
65
|
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.
|
|
61
|
-
2. **Inclusion Criteria**: Include a concept only if it is discussed in detail
|
|
66
|
+
2. **Inclusion Criteria**: Include a concept only if it is discussed in detail and is an important part of the subject matter of the source.
|
|
62
67
|
3. **How to describe a concept**: The concept should be described so that a reader can comprehend the gist of it.
|
|
63
|
-
4. **Character Limit**: Maintain a limit of
|
|
68
|
+
4. **Character Limit**: Maintain a limit of 90 characters to ensure each concept is concise yet informative.
|
|
64
69
|
5. **Reference**: Every concept must include 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 heading must exactly match one of the headings provided to you. Sometimes concepts may need to reference the entire text or multiple headings, leave the reference empty for such cases.
|
|
65
70
|
|
|
66
71
|
List the concepts in the following JSON format:
|
|
@@ -74,12 +79,11 @@ json
|
|
|
74
79
|
},
|
|
75
80
|
{...}
|
|
76
81
|
]
|
|
77
|
-
|
|
78
82
|
After classifying the content and identifying key concepts, proceed to extract and list verifiable facts.
|
|
79
83
|
|
|
80
84
|
1. **Definition of a Fact**: Ensure each fact is a standalone piece of information that is concrete and can be independently verified.
|
|
81
|
-
2. **Selection Criteria**:
|
|
82
|
-
3. **Character Limit**: Maintain a limit of
|
|
85
|
+
2. **Selection Criteria**: Inlcude facts based on their significance to the content's main themes or concepts, their educational value and their foundational role in the subject.
|
|
86
|
+
3. **Character Limit**: Maintain a limit of 90 characters for the to ensure each message is concise yet informative.
|
|
83
87
|
4. **Reference**: Every fact must include 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 heading must exactly match one of the headings provided to you. Sometimes facts may need to reference the entire text or multiple headings, leave the reference empty for such cases.
|
|
84
88
|
|
|
85
89
|
List the facts in the following JSON format:
|
|
@@ -93,22 +97,17 @@ json
|
|
|
93
97
|
},
|
|
94
98
|
{...}
|
|
95
99
|
]
|
|
100
|
+
After you have examined the content —its field, its concepts, and its facts— determine whether it justifies the creation of quiz materials.
|
|
96
101
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
Consider if these elements provide significant educational value to an average learner by enhancing understanding, offering practical applications, or supporting crucial educational goals. If you decide that the source does not hold educational value that is worthy of generating testing material or quizzes for then please provide a reason in less than 90 characters.
|
|
100
|
-
|
|
101
|
-
1. **Value Assessment**: Determine if the concepts and facts are essential for understanding the broader topic, are likely to be used in practical scenarios, or help in achieving educational benchmarks.
|
|
102
|
-
2. **Criteria for Material Generation**: Generate testing materials if the concepts and facts are central to the content, have broad applicability, and are likely to reinforce or expand the learner’s knowledge significantly.
|
|
102
|
+
Consider whether these elements offer the average learner meaningful insights, practical uses, or serve important educational aims. If, in your judgment, the material falls short of providing such value, explain why in fewer than 90 characters.
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
Reflect your in the JSON format as follows:
|
|
105
105
|
|
|
106
106
|
json
|
|
107
107
|
"generate_cards":
|
|
108
108
|
{ state: true or false,
|
|
109
109
|
reason: "reason for marking the source as false. Leave empty for true."
|
|
110
110
|
}
|
|
111
|
-
|
|
112
111
|
After analyzing the content, identifying key concepts, and facts, summarize the material using a series of engaging and informative cards.
|
|
113
112
|
|
|
114
113
|
These cards should capture the essence of the content while highlighting the critical concepts and facts that you previously identified.
|
|
@@ -124,9 +123,11 @@ Format your output in JSON as follows:
|
|
|
124
123
|
|
|
125
124
|
json
|
|
126
125
|
{
|
|
127
|
-
"summary_cards": ["summary_card1_content", "summary_card2_content", "summary_card3_content", "..."]
|
|
126
|
+
"summary_cards": ["summary_card1_content", "summary_card2_content", "summary_card3_content", "... up to 8 summary cards"]
|
|
128
127
|
}
|
|
129
128
|
|
|
129
|
+
|
|
130
|
+
|
|
130
131
|
`;
|
|
131
132
|
|
|
132
133
|
|
package/src/index.ts
CHANGED
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
// import config from "./config";
|
|
8
8
|
// const app = express();
|
|
9
9
|
// const port = 3000;
|
|
10
|
-
|
|
11
|
-
import { OnlyEverGenerator } from "./bootstrap/app";
|
|
12
10
|
// import { returnPromptData } from "./constants/prompt_data";
|
|
13
11
|
// import { GenerateCards } from "./card_gen/generate_cards";
|
|
14
12
|
// import { OpenAiService } from "./services/open_ai_service";
|
|
@@ -17,13 +15,16 @@ import { OnlyEverGenerator } from "./bootstrap/app";
|
|
|
17
15
|
// import { returnCardGenPrompt } from "./constants/prompts/card_gen_prompt";
|
|
18
16
|
// import { GenerateArgs } from "./utils/generate_args";
|
|
19
17
|
|
|
18
|
+
import { OnlyEverGenerator } from "./bootstrap/app";
|
|
19
|
+
|
|
20
|
+
|
|
20
21
|
/// While Publishing the package , and using this code as a separate npm module
|
|
21
22
|
/// uncomment the below line and comment all the others, expect the import of OnlyEverGenerator
|
|
22
23
|
export {OnlyEverGenerator};
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
//below this line
|
|
26
|
-
// let oeGen = new OnlyEverGenerator(config.openAIKey, "gpt-4o", {
|
|
25
|
+
// . All the Codes Below uses express and are strictly for development purpose, while publishing the package, comment everything
|
|
26
|
+
// below this line
|
|
27
|
+
// let oeGen = new OnlyEverGenerator(config.openAIKey, "gpt-4o-mini", {
|
|
27
28
|
// prompt: returnPromptData(),
|
|
28
29
|
// content: returnSourceData(),
|
|
29
30
|
// });
|
|
@@ -56,28 +57,16 @@ import { OnlyEverGenerator } from "./bootstrap/app";
|
|
|
56
57
|
// "res_tokens": cardResp.usage_data?.completion_tokens,
|
|
57
58
|
// "model": '40-mini'
|
|
58
59
|
// };
|
|
59
|
-
// let parsedData = new ParseCardResponse().parse(cardResp,false);
|
|
60
|
+
// let parsedData = new ParseCardResponse().parse(cardResp,false, {});
|
|
60
61
|
// res.send(parsedData)
|
|
61
62
|
// });
|
|
62
63
|
|
|
63
|
-
//
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
// // true,
|
|
70
|
-
// // false,
|
|
71
|
-
// // {
|
|
72
|
-
// // typology_prompt: typologyPrompt,
|
|
73
|
-
// // card_gen_prompt: cardPrompt,
|
|
74
|
-
// // summary_prompt: "",
|
|
75
|
-
// // }
|
|
76
|
-
// // )
|
|
77
|
-
// // let typologyRequest = await oeGen.generate(false, true);
|
|
78
|
-
// // res.send(typologyRequest);
|
|
79
|
-
// // }
|
|
80
|
-
// // });
|
|
64
|
+
// app.get("/typology", async (req, res) => {
|
|
65
|
+
// {
|
|
66
|
+
// let typologyRequest = await oeGen.generate(true, true);
|
|
67
|
+
// res.send(typologyRequest);
|
|
68
|
+
// }
|
|
69
|
+
// });
|
|
81
70
|
|
|
82
71
|
// app.listen(port, () => {
|
|
83
72
|
// console.log(`Example app listening at http://localhost:${port}`);
|
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
export class ParseClozeCard {
|
|
2
2
|
parse(data: any) {
|
|
3
3
|
try {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const content = data.card_content;
|
|
5
|
+
let correctOptions = content.correct_options;
|
|
6
|
+
let incorrectOptions = content.incorrect_options;
|
|
7
|
+
let allOptions = [...correctOptions, ...incorrectOptions];
|
|
8
|
+
let displayTitle = this._generateClozeCardDisplayTitle(data.card_content.prompt, allOptions);
|
|
9
|
+
let preparedData = this._prepareQuestionAndCorrectAnswers(content.prompt, correctOptions);
|
|
10
|
+
let finalQuestion = preparedData.prompt;
|
|
11
|
+
let parsedCorrectOptions = preparedData.options;
|
|
12
|
+
let parsedIncorrectoptions = incorrectOptions.map((e:any)=>{
|
|
13
|
+
return {
|
|
14
|
+
"option":e,
|
|
15
|
+
"cloze": "null"
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
const finalParsedOptions = [...parsedCorrectOptions,...parsedIncorrectoptions];
|
|
8
19
|
let clozeCardData = {
|
|
9
20
|
type: {
|
|
10
21
|
category: "learning",
|
|
11
22
|
sub_type: data.type,
|
|
12
23
|
},
|
|
13
|
-
heading:
|
|
24
|
+
heading:"",
|
|
14
25
|
displayTitle: displayTitle,
|
|
15
26
|
content: {
|
|
16
|
-
question:
|
|
17
|
-
options:
|
|
27
|
+
question: finalQuestion,
|
|
28
|
+
options: finalParsedOptions,
|
|
18
29
|
},
|
|
19
30
|
concepts: data.concepts,
|
|
20
31
|
facts: data.facts,
|
|
@@ -28,20 +39,16 @@ export class ParseClozeCard {
|
|
|
28
39
|
}
|
|
29
40
|
|
|
30
41
|
_generateClozeCardDisplayTitle(question: string, answers: Array<any>) {
|
|
42
|
+
try{
|
|
31
43
|
let optionsString = "";
|
|
32
44
|
if (answers.length !== 0) {
|
|
33
45
|
optionsString = answers
|
|
34
|
-
.map((item: { option: any }) => {
|
|
35
|
-
if (item.option !== undefined) {
|
|
36
|
-
return item.option;
|
|
37
|
-
} else {
|
|
38
|
-
return "";
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
46
|
.join(", ");
|
|
42
47
|
}
|
|
43
48
|
|
|
44
|
-
return `${question} ---- ${optionsString}`;
|
|
49
|
+
return `${question} ---- ${optionsString}`;}catch(e){
|
|
50
|
+
throw Error("Error in generating display title");
|
|
51
|
+
}
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
/// validate the cloze card
|
|
@@ -53,6 +60,33 @@ export class ParseClozeCard {
|
|
|
53
60
|
// 6. Less than 2 options
|
|
54
61
|
// 7. Max character for individual cloze: 90
|
|
55
62
|
|
|
63
|
+
_prepareQuestionAndCorrectAnswers(rawPrompt:String, correctOptions: Array<any>){
|
|
64
|
+
try{
|
|
65
|
+
var finalCorrectOptions = <any>[];
|
|
66
|
+
const regex = /{{(.*?)}}/g;
|
|
67
|
+
|
|
68
|
+
const transformed = rawPrompt.replace(regex, (match, p1) => {
|
|
69
|
+
// p1 is the captured group inside {{ }} (e.g., "fruit", "green")
|
|
70
|
+
const idx = correctOptions.indexOf(p1);
|
|
71
|
+
if (idx !== -1) {
|
|
72
|
+
let cloze = `c${idx}`;
|
|
73
|
+
finalCorrectOptions.push( {
|
|
74
|
+
"option": p1,
|
|
75
|
+
"cloze": cloze,
|
|
76
|
+
});
|
|
77
|
+
return `{{c${idx}:${p1}}}`;
|
|
78
|
+
}
|
|
79
|
+
return match; // If not found in correct_options, leave as is or handle accordingly
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
"prompt": transformed,
|
|
83
|
+
"options": finalCorrectOptions
|
|
84
|
+
}} catch(e){
|
|
85
|
+
throw Error("Error in preparing question and correct answers");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
56
90
|
_validateCloze(clozeCard: any) {
|
|
57
91
|
let clozeRegex = /\{\{c(\d+):([^}]+)\}\}/g;
|
|
58
92
|
|
|
@@ -83,8 +117,8 @@ export class ParseClozeCard {
|
|
|
83
117
|
throw Error(" Clozes in question doesnt match to clozes in options");
|
|
84
118
|
}
|
|
85
119
|
return clozeCard;
|
|
86
|
-
} catch (e) {
|
|
87
|
-
|
|
120
|
+
} catch (e: any) {
|
|
121
|
+
throw Error(`Error in validating cloze card ${e.message}`);
|
|
88
122
|
}
|
|
89
123
|
}
|
|
90
124
|
}
|