only_ever_generator 0.1.8 → 0.2.0

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.
@@ -1,30 +1,108 @@
1
1
  "use strict";
2
+ // const typologyPromptString = `
3
+ // As a dedicated assistant at a learning company, your role involves analyzing educational content to categorize and summarize it. You will process content (in JSON format) that represents text and images from diverse sources such as PDFs, book chapters, videos, and websites. Follow these steps:
2
4
  Object.defineProperty(exports, "__esModule", { value: true });
3
5
  exports.returnTypologyPrompt = void 0;
4
- const typologyPromptString = `
6
+ // 1. Classify the content into one to three predefined fields of knowledge.
7
+ // 2. Identify key concepts within the content.
8
+ // 3. Detect concrete facts that are empirically verified and relevant to the subject.
9
+ // 4. Decide whether the identified concepts and facts should be used to generate learning materials like flashcards based on their educational value.
10
+ // 5. If the generate_cards is true then summarize the content using a series of summary cards.
11
+ // Please format your findings in this JSON schema:
12
+ // json
13
+ // {
14
+ // "field": ["primary_field", "secondary_field", "tertiary_field"],
15
+ // "concepts": ["concept1", "concept2", "concept3", "..."],
16
+ // "facts": ["fact1", "fact2", "fact3", "..."],
17
+ // "generate_cards": [
18
+ // state: true or false,
19
+ // false_reason: "reason for marking the source as false. Leave empty for true."
20
+ // ],
21
+ // "summary_cards": ["summary_card1", "summary_card2", "summary_card3", "..."]
22
+ // }
23
+ // Further instruction on how to perform these tasks are below.
24
+ // Every source must be placed under a field. This is the broadest category of knowledge. A source should belong to at least one and at most 3 fields. Only include fields that a source is strongly associated with. The field names in your response must exactly match the names of 18 fields listed below.
25
+ // 1. Sciences: Focus on Biology, Chemistry, Physics, Astronomy, Mathematics, and Computer Science.
26
+ // 2. Technology & Engineering: Emphasize Information Technology, Engineering disciplines, AI, and Robotics.
27
+ // 3. Humanities & Cultural Studies: Highlight History, Literature, Languages, Arts, Philosophy, and Anthropological Studies.
28
+ // 4. Social Sciences & Global Studies: Include Sociology, Psychology, Economics, Political Science, Anthropology, and International Relations.
29
+ // 5. Business & Management: Encompass Entrepreneurship, Marketing, Finance, Leadership, and Ethics.
30
+ // 6. Health & Medicine: Cover Medical Sciences, Public Health, Nutrition, Wellness, and Mental Health.
31
+ // 7. Environmental Studies & Earth Sciences: Discuss Ecology, Climate Science, Geology, and Environmental Policy.
32
+ // 8. Education, Learning & Personal Development: Talk about Educational Theories, Teaching Methods, and Personal Skills.
33
+ // 9. Creative & Performing Arts: Include Visual Arts, Music, Theater, Dance, and Design Principles.
34
+ // 10. Law, Governance & Ethics: Focus on Legal Studies, Public Administration, Policy Analysis, and Ethical Decision-Making.
35
+ // 11. Recreation, Lifestyle & Practical Skills: Highlight Hobbies, Sports, Travel, Lifestyle Choices, and Practical Skills.
36
+ // 12. Technology & Media Literacy: Discuss Digital Literacy, Media Studies, and the Impact of Digital Media.
37
+ // 13. Philosophy & Critical Thinking: Emphasize Moral Philosophy, Ethical Frameworks, and Critical Thinking.
38
+ // 14. Space & Astronomical Sciences: Focus on Space Exploration, Astronomy, and Astrophysics.
39
+ // 15. Agriculture & Food Sciences: Discuss Sustainable Farming, Food Technology, and Nutrition.
40
+ // 16. Trades & Craftsmanship: Cover Hands-on Skills in Trades and Crafts.
41
+ // 17. Reference & Indexing: Include Summaries, Timelines, Directories, Glossaries, Bibliographies, and other Reference Material.
42
+ // 18. Other: Use for content that doesn’t fit into the above categories.
43
+ // Identify key concepts within the content after classifying the field. Concepts are the fundamental ideas or categories that form the basis of knowledge within any discipline. They help organize and explain information, making it accessible and relatable.
44
+ // 1. **Definition of a Concept**: Concepts should be significant ideas that recur within the content and are essential for understanding the main themes.
45
+ // 2. **Inclusion Criteria**: Include a concept only if it is discussed in detail, meaning it is explained thoroughly, tied to specific examples, or highlighted as a critical part of the subject matter.
46
+ // List the concepts in the following JSON format:
47
+ // json
48
+ // {
49
+ // "concepts": ["concept1", "concept2", "concept3", "..."]
50
+ // }
51
+ // After classifying the content and identifying key concepts, proceed to extract and list verifiable facts. Facts are objective statements that must be supported by empirical evidence or observation, such as specific data on events, people, numbers, dates, or well-established ideas.
52
+ // 1. **Definition of a Fact**: Ensure each fact is a standalone piece of information that is concrete and can be independently verified.
53
+ // 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.
54
+ // Record the facts in the following JSON format:
55
+ // json
56
+ // {
57
+ // "facts": ["fact1", "fact2", "fact3", "..."]
58
+ // }
59
+ // After analyzing the content, classifying its field, and identifying key concepts, and facts, assess whether the discovered elements warrant the creation of testing materials. 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 testing cards don't need to be generated then please provide a reason in less than 90 characters.
60
+ // 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.
61
+ // 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.
62
+ // Make your decision using this criterion and reflect it in the JSON format as follows:
63
+ // json
64
+ // "generate_cards":
65
+ // { state: true or false,
66
+ // false_reason: "reason for marking the source as false. Leave empty for true."
67
+ // }
68
+ // After analyzing the content, identifying key concepts, and facts, summarize the material using a series of engaging and informative cards. These cards should capture the essence of the content while highlighting the critical concepts and facts that you previously identified.
69
+ // 1. **Inclusion Criteria**: The generate_cards should be true. Return an empty array if the generate_cards is false.
70
+ // 2. **Summarization Objective**: Each card is a step in a journey through the content. The series should collectively summarize the source while emphasizing important learning points.
71
+ // 3. **Character Limit**: Maintain a limit of 320 characters per card to ensure each message is concise yet informative.
72
+ // 4. **Engagement and Flow**: Write in an engaging style that maintains the user’s interest. Arrange the cards in a logical order that reflects the flow of the original content.
73
+ // Format your output in JSON as follows:
74
+ // json
75
+ // {
76
+ // "summary_cards": ["summary_card1", "summary_card2", "summary_card3", "..."]
77
+ // }
78
+ // `;
79
+ const typologyPromptString = {
80
+ role: `
5
81
  As a dedicated assistant at a learning company, your role involves analyzing educational content to categorize and summarize it. You will process content (in JSON format) that represents text and images from diverse sources such as PDFs, book chapters, videos, and websites. Follow these steps:
6
82
 
7
83
  1. Classify the content into one to three predefined fields of knowledge.
8
- 2. Identify key concepts within the content.
9
- 3. Detect concrete facts that are empirically verified and relevant to the subject.
84
+ 2. Extract key concepts within the content.
85
+ 3. Extract concrete facts that are relevant to the subject and referenced in the content.
10
86
  4. Decide whether the identified concepts and facts should be used to generate learning materials like flashcards based on their educational value.
11
87
  5. If the generate_cards is true then summarize the content using a series of summary cards.
12
88
 
13
89
  Please format your findings in this JSON schema:
14
- json
15
90
  {
16
- "field": ["primary_field", "secondary_field", "tertiary_field"],
17
- "concepts": ["concept1", "concept2", "concept3", "..."],
18
- "facts": ["fact1", "fact2", "fact3", "..."],
19
- "generate_cards": [
20
- state: true or false,
21
- false_reason: "reason for marking the source as false. Leave empty for true."
22
- ],
23
- "summary_cards": ["summary_card1", "summary_card2", "summary_card3", "..."]
91
+ "field": ["primary_field", "secondary_field", "tertiary_field"],
92
+ "concepts": ["concept1", "concept2", "concept3", "..."],
93
+ "facts": ["fact1", "fact2", "fact3", "..."],
94
+ "generate_cards": {
95
+ "state": true or false,
96
+ "false_reason": "reason for marking the source as false. Leave empty for true."
97
+ },
98
+ "summary_cards": ["summary_card1", "summary_card2", "summary_card3", "..."]
24
99
  }
25
100
 
101
+
26
102
  Further instruction on how to perform these tasks are below.
27
- Every source must be placed under a field. This is the broadest category of knowledge. A source should belong to at least one and at most 3 fields. Only include fields that a source is strongly associated with. The field names in your response must exactly match the names of 18 fields listed below.
103
+ `,
104
+ fields: `
105
+ Every source must be placed under a field. This is the broadest category of knowledge. A source should belong to at least one and at most 3 fields. Only include fields that a source is strongly associated with. The field names in your response must exactly match the names of 18 fields listed below.
28
106
 
29
107
  1. Sciences: Focus on Biology, Chemistry, Physics, Astronomy, Mathematics, and Computer Science.
30
108
  2. Technology & Engineering: Emphasize Information Technology, Engineering disciplines, AI, and Robotics.
@@ -44,54 +122,68 @@ Every source must be placed under a field. This is the broadest category of know
44
122
  16. Trades & Craftsmanship: Cover Hands-on Skills in Trades and Crafts.
45
123
  17. Reference & Indexing: Include Summaries, Timelines, Directories, Glossaries, Bibliographies, and other Reference Material.
46
124
  18. Other: Use for content that doesn’t fit into the above categories.
125
+ `,
126
+ concepts: `
127
+ Extract key concepts within the content after classifying the field. Please be as exhaustive as possible.
47
128
 
48
- Identify key concepts within the content after classifying the field. Concepts are the fundamental ideas or categories that form the basis of knowledge within any discipline. They help organize and explain information, making it accessible and relatable.
49
-
50
- 1. **Definition of a Concept**: Concepts should be significant ideas that recur within the content and are essential for understanding the main themes.
51
- 2. **Inclusion Criteria**: Include a concept only if it is discussed in detail, meaning it is explained thoroughly, tied to specific examples, or highlighted as a critical part of the subject matter.
52
-
129
+ 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.
130
+ Inclusion Criteria: Include a concept only if it is discussed in detail, meaning it is explained thoroughly, tied to specific examples, or highlighted as a critical part of the subject matter.
53
131
  List the concepts in the following JSON format:
54
- json
132
+
55
133
  {
56
- "concepts": ["concept1", "concept2", "concept3", "..."]
134
+ "concepts":
135
+ [
136
+ "concept1",
137
+ "concept2",
138
+ "concept3",
139
+ "..."
140
+ ]
57
141
  }
58
- After classifying the content and identifying key concepts, proceed to extract and list verifiable facts. Facts are objective statements that must be supported by empirical evidence or observation, such as specific data on events, people, numbers, dates, or well-established ideas.
59
-
60
- 1. **Definition of a Fact**: Ensure each fact is a standalone piece of information that is concrete and can be independently verified.
61
- 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.
142
+ `,
143
+ facts: `
144
+ After classifying the content and identifying key concepts, proceed to extract and list verifiable facts.
62
145
 
146
+ Definition of a Fact: Ensure each fact is a standalone piece of information that is concrete and can be independently verified.
147
+ 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.
63
148
  Record the facts in the following JSON format:
64
- json
149
+
65
150
  {
66
- "facts": ["fact1", "fact2", "fact3", "..."]
151
+ "facts": ["fact1", "fact2", "fact3", "..."]
67
152
  }
153
+ `,
154
+ generate: `
68
155
  After analyzing the content, classifying its field, and identifying key concepts, and facts, assess whether the discovered elements warrant the creation of testing materials. 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 testing cards don't need to be generated then please provide a reason in less than 90 characters.
69
156
 
70
- 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.
71
- 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.
72
-
157
+ 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.
158
+ 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.
73
159
  Make your decision using this criterion and reflect it in the JSON format as follows:
74
- json
75
- "generate_cards":
76
- { state: true or false,
77
- false_reason: "reason for marking the source as false. Leave empty for true."
78
- }
79
160
 
161
+ "generate_cards":
162
+ { state: true or false,
163
+ false_reason: "reason for marking the source as false. Leave empty for true."
164
+ }
165
+ `,
166
+ summarize: `
80
167
  After analyzing the content, identifying key concepts, and facts, summarize the material using a series of engaging and informative cards. These cards should capture the essence of the content while highlighting the critical concepts and facts that you previously identified.
81
168
 
82
-
83
- 1. **Inclusion Criteria**: The generate_cards should be true. Return an empty array if the generate_cards is false.
84
- 2. **Summarization Objective**: Each card is a step in a journey through the content. The series should collectively summarize the source while emphasizing important learning points.
85
- 3. **Character Limit**: Maintain a limit of 320 characters per card to ensure each message is concise yet informative.
86
- 4. **Engagement and Flow**: Write in an engaging style that maintains the user’s interest. Arrange the cards in a logical order that reflects the flow of the original content.
87
-
169
+ Inclusion Criteria: The generate_cards should be true. Return an empty array if the generate_cards is false.
170
+ Summarization Objective: Each card is a step in a journey through the content. The series should collectively summarize the source while emphasizing important learning points.
171
+ Character Limit: Maintain a limit of 320 characters per card to ensure each message is concise yet informative.
172
+ Engagement and Flow: Write in an engaging style that maintains the user’s interest. Arrange the cards in a logical order that reflects the flow of the original content.
88
173
  Format your output in JSON as follows:
89
- json
174
+
90
175
  {
91
- "summary_cards": ["summary_card1", "summary_card2", "summary_card3", "..."]
176
+ "summary_cards": ["summary_card1", "summary_card2", "summary_card3", "..."]
92
177
  }
93
- `;
178
+ `,
179
+ };
94
180
  function returnTypologyPrompt() {
95
- return typologyPromptString;
181
+ let concatenatedString = '';
182
+ for (let key in typologyPromptString) {
183
+ if (typologyPromptString.hasOwnProperty(key)) {
184
+ concatenatedString += typologyPromptString[key];
185
+ }
186
+ }
187
+ return concatenatedString;
96
188
  }
97
189
  exports.returnTypologyPrompt = returnTypologyPrompt;
@@ -10,6 +10,8 @@ function gapFilling(typologyResponse, cardgenResponse) {
10
10
  let allFacts = [];
11
11
  let generatedConceptsList = [];
12
12
  let generatedFactsList = [];
13
+ let remainingConcepts = [];
14
+ let remainingFacts = [];
13
15
  if (!isEmpty(typologyResponse)) {
14
16
  allConcepts.push(...((_a = typologyResponse.concepts) !== null && _a !== void 0 ? _a : []));
15
17
  allFacts.push(...((_b = typologyResponse === null || typologyResponse === void 0 ? void 0 : typologyResponse.facts) !== null && _b !== void 0 ? _b : []));
@@ -18,18 +20,20 @@ function gapFilling(typologyResponse, cardgenResponse) {
18
20
  allConcepts.push(...((_c = cardgenResponse.missing_concepts) !== null && _c !== void 0 ? _c : []));
19
21
  allFacts.push(...((_d = cardgenResponse.missing_facts) !== null && _d !== void 0 ? _d : []));
20
22
  }
21
- for (let card of cardgenResponse.cards_data) {
22
- if (card.concepts.length != 0) {
23
- generatedConceptsList.push(...card.concepts);
24
- }
25
- if (card.facts.length != 0) {
26
- generatedFactsList.push(...card.facts);
23
+ if (cardgenResponse.cards_data !== undefined && cardgenResponse.cards_data.length != 0) {
24
+ for (let card of cardgenResponse.cards_data) {
25
+ if (card.concepts.length != 0) {
26
+ generatedConceptsList.push(...card.concepts);
27
+ }
28
+ if (card.facts.length != 0) {
29
+ generatedFactsList.push(...card.facts);
30
+ }
27
31
  }
32
+ let generatedConceptsSet = Array.from(new Set(generatedConceptsList));
33
+ let generatedFactsSet = Array.from(new Set(generatedFactsList));
34
+ remainingConcepts = allConcepts.filter((item) => !generatedConceptsSet.includes(item));
35
+ remainingFacts = allFacts.filter((item) => !generatedFactsSet.includes(item));
28
36
  }
29
- let generatedConceptsSet = Array.from(new Set(generatedConceptsList));
30
- let generatedFactsSet = Array.from(new Set(generatedFactsList));
31
- let remainingConcepts = allConcepts.filter((item) => !generatedConceptsSet.includes(item));
32
- let remainingFacts = allFacts.filter((item) => !generatedFactsSet.includes(item));
33
37
  return {
34
38
  // allConcepts: allConcepts,
35
39
  // allFacts: allFacts,
package/dist/index.js CHANGED
@@ -11,13 +11,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.OnlyEverGenerator = void 0;
12
12
  const app_1 = require("./bootstrap/app");
13
13
  Object.defineProperty(exports, "OnlyEverGenerator", { enumerable: true, get: function () { return app_1.OnlyEverGenerator; } });
14
- /// All the Codes Below uses express and are strictly for development purpose, while publishing the package, comment everything
15
- /// below this line
16
- // let oeGen = new OnlyEverGenerator(config.openAIKey,"gpt-3.5-turbo-1106" ,returnSourceData(),returnFields())
14
+ //. All the Codes Below uses express and are strictly for development purpose, while publishing the package, comment everything
15
+ // below this line
16
+ //let oeGen = new OnlyEverGenerator(config.openAIKey,"gpt-3.5-turbo-1106" ,'',returnSourceData(),returnFields())
17
17
  // app.get('/', async (req, res) => {
18
18
  // // let data = oeGen.returnParsedContent();
19
19
  // // let parsedData = parseResponse()
20
- // res.send(200);
20
+ // let cardPrompt = returnCardGenPrompt();
21
+ // res.send(cardPrompt);
21
22
  // });
22
23
  // app.get('/openAI', async (req,res)=> {
23
24
  // // let prompt = returnPromt();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "only_ever_generator",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "start": "npm run build && nodemon dist/index.js",
@@ -16,10 +16,12 @@ export class OnlyEverGenerator {
16
16
  public api_key: string = "";
17
17
  public openAiService: OpenAiService;
18
18
  parsedContent: string = "";
19
+ prompt: any;
19
20
  expectedFields: Array<string>;
20
21
  constructor(
21
22
  apiKey: string,
22
23
  model: string,
24
+ prompt: any,
23
25
  content: Array<any>,
24
26
  expected_fields: Array<string>
25
27
  ) {
@@ -99,6 +101,7 @@ export class OnlyEverGenerator {
99
101
  }
100
102
 
101
103
  return responseToReturn;
104
+ // return [typologyPrompt, cardPrompt];
102
105
 
103
106
  }
104
107
 
@@ -18,7 +18,8 @@ export class GenerateCards {
18
18
  };
19
19
  if(response.status_code == 200){
20
20
  response.metadata.status = "completed";
21
- return this.parse(response);
21
+ // return response;
22
+ return this.parse(response);
22
23
  } else {
23
24
  response.metadata.status = "failed";
24
25
  return response;
@@ -66,7 +67,10 @@ if(unparsedTestCards !== undefined && unparsedTestCards.length != 0) {
66
67
  data.card_content.back
67
68
  );
68
69
  let flashCardData = {
69
- type: data.type,
70
+ type: {
71
+ category: 'learning',
72
+ sub_type: data.type,
73
+ },
70
74
  heading: data.card_reference,
71
75
  displayTitle: displayTitle,
72
76
  content: {
@@ -75,6 +79,7 @@ if(unparsedTestCards !== undefined && unparsedTestCards.length != 0) {
75
79
  },
76
80
  concepts: data.concepts,
77
81
  facts: data.facts,
82
+ bloomLevel: data.bloom_level,
78
83
  };
79
84
 
80
85
  return flashCardData;
@@ -98,7 +103,10 @@ if(unparsedTestCards !== undefined && unparsedTestCards.length != 0) {
98
103
  mcqAnswers
99
104
  );
100
105
  let mcqCard = {
101
- type: data.type,
106
+ type: {
107
+ category: 'learning',
108
+ sub_type: data.type,
109
+ },
102
110
  heading: data.card_reference,
103
111
  displayTitle: displayTitle,
104
112
  content: {
@@ -107,6 +115,8 @@ if(unparsedTestCards !== undefined && unparsedTestCards.length != 0) {
107
115
  },
108
116
  concepts: data.concepts,
109
117
  facts: data.facts,
118
+ bloomLevel: data.bloom_level,
119
+
110
120
  };
111
121
  return mcqCard;
112
122
  }
@@ -129,7 +139,10 @@ if(unparsedTestCards !== undefined && unparsedTestCards.length != 0) {
129
139
  data.card_content.options
130
140
  );
131
141
  let clozeCardData = {
132
- type: data.type,
142
+ type: {
143
+ category: 'learning',
144
+ sub_type: data.type,
145
+ },
133
146
  heading: data.card_reference,
134
147
  displayTitle: displayTitle,
135
148
  content: {
@@ -138,15 +151,27 @@ if(unparsedTestCards !== undefined && unparsedTestCards.length != 0) {
138
151
  },
139
152
  concepts: data.concepts,
140
153
  facts: data.facts,
154
+ bloomLevel: data.bloom_level,
155
+
141
156
  };
142
157
 
143
158
  return clozeCardData;
144
159
  }
145
160
 
146
- generateClozeCardDisplayTitle(question: string, answers: any) {
147
- let optionsString = answers
148
- .map((item: { option: any }) => item.option)
161
+ generateClozeCardDisplayTitle(question: string, answers: Array<any>) {
162
+ let optionsString = '';
163
+ if(answers.length !== 0) {
164
+ optionsString = answers
165
+ .map((item: { option: any }) => {
166
+ if(item.option !== undefined) {
167
+ return item.option;
168
+ } else {
169
+ return '';
170
+ }
171
+ })
149
172
  .join(", ");
173
+ }
174
+
150
175
  return `${question} ---- ${optionsString}`;
151
176
  }
152
177
 
@@ -164,13 +189,18 @@ if(unparsedTestCards !== undefined && unparsedTestCards.length != 0) {
164
189
  }
165
190
  let displayTitle = this.generateMatchCardDisplayTitle(transformedData);
166
191
  let matchCard = {
167
- type: cardData.type,
192
+ type: {
193
+ category: 'learning',
194
+ sub_type: data.type,
195
+ },
168
196
  heading: cardData.card_reference,
169
197
  content: transformedData,
170
198
  // content: cardData.card_content,
171
199
  displayTitle: displayTitle,
172
200
  concepts: cardData.concepts,
173
201
  facts: cardData.facts,
202
+ bloomLevel: cardData.bloom_level,
203
+
174
204
  };
175
205
 
176
206
  return matchCard;