only_ever_generator 0.3.8 → 0.3.9

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.
@@ -61,7 +61,7 @@ class OnlyEverGenerator {
61
61
  responseToReturn.push(this.cardgenResponse);
62
62
  /// check if gap fill is required ie coverage determination
63
63
  if (this.cardgenResponse.status_code == 200) {
64
- this.gapFillResponse = yield this.generationForGapFill(this.typologyResponse, this.cardgenResponse);
64
+ this.gapFillResponse = yield this._generationForGapFill(this.typologyResponse, this.cardgenResponse);
65
65
  responseToReturn.push(this.gapFillResponse);
66
66
  }
67
67
  }
@@ -79,7 +79,7 @@ class OnlyEverGenerator {
79
79
  return false;
80
80
  }
81
81
  }
82
- generationForGapFill(typologyData, cardGenData) {
82
+ _generationForGapFill(typologyData, cardGenData) {
83
83
  return __awaiter(this, void 0, void 0, function* () {
84
84
  let gapFill = (0, calculate_gap_fill_1.gapFilling)(typologyData, cardGenData);
85
85
  let response;
@@ -108,5 +108,21 @@ class OnlyEverGenerator {
108
108
  return response;
109
109
  });
110
110
  }
111
+ gapFill(factsMaps, aiCards) {
112
+ return __awaiter(this, void 0, void 0, function* () {
113
+ /// factsmap
114
+ /// {
115
+ /// remaining_facts: [],
116
+ /// remaining_concepts: [],
117
+ //}
118
+ /// aicards is data
119
+ let response;
120
+ response = yield this.generateCard(this.promptForCardGen +
121
+ "Generate cards only suitable for the given remaining concepts and facts" +
122
+ JSON.stringify(factsMaps) +
123
+ "Exclude generating cards with content in the following", JSON.stringify(aiCards), true);
124
+ return response;
125
+ });
126
+ }
111
127
  }
112
128
  exports.OnlyEverGenerator = OnlyEverGenerator;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.openAiEndPoint = void 0;
3
+ exports.openAiEndPoint = openAiEndPoint;
4
4
  function openAiEndPoint() {
5
5
  return 'https://api.openai.com/v1/chat/completions';
6
6
  }
7
- exports.openAiEndPoint = openAiEndPoint;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.returnPromptData = void 0;
3
+ exports.returnPromptData = returnPromptData;
4
4
  const card_gen_prompt_1 = require("./prompts/card_gen_prompt");
5
5
  const typology_prompt_1 = require("./prompts/typology_prompt");
6
6
  const promptData = {
@@ -300,4 +300,3 @@ function returnPromptData() {
300
300
  "card_generation": (0, card_gen_prompt_1.returnCardGenPrompt)(''),
301
301
  };
302
302
  }
303
- exports.returnPromptData = returnPromptData;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.returnCardGenPrompt = void 0;
3
+ exports.returnCardGenPrompt = returnCardGenPrompt;
4
4
  const promptString = `
5
5
  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:
6
6
 
@@ -175,7 +175,6 @@ Generate atleast 10 cards.
175
175
  function returnCardGenPrompt(cardGenPrompt) {
176
176
  return promptString;
177
177
  }
178
- exports.returnCardGenPrompt = returnCardGenPrompt;
179
178
  // let concatenatedString: string = '';
180
179
  // for (let key in cardGenPrompt) {
181
180
  // if (cardGenPrompt.hasOwnProperty(key)) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.returnTypologyPrompt = void 0;
3
+ exports.returnTypologyPrompt = returnTypologyPrompt;
4
4
  const typologyPromptString = `
5
5
  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
6
 
@@ -94,4 +94,3 @@ json
94
94
  function returnTypologyPrompt() {
95
95
  return typologyPromptString;
96
96
  }
97
- exports.returnTypologyPrompt = returnTypologyPrompt;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.returnHeadings = exports.returnSourceData = exports.returnFields = void 0;
3
+ exports.returnFields = returnFields;
4
+ exports.returnSourceData = returnSourceData;
5
+ exports.returnHeadings = returnHeadings;
4
6
  const sourceString = [
5
7
  {
6
8
  "block_type": "paragraph",
@@ -1254,7 +1256,6 @@ const headings = [
1254
1256
  function returnFields() {
1255
1257
  return ["Sciences", "Technology & Engineering", "Humanities & Cultural Studies", "Social Sciences & Global Studies", "Business & Management", "Health & Medicine", "Environmental Studies & Earth Sciences", "Education, Learning & Personal Development", "Creative & Performing Arts", "Law, Governance & Ethics", "Recreation, Lifestyle & Practical Skills", "Technology & Media Literacy", "Philosophy & Critical Thinking", "Space & Astronomical Sciences", "Agriculture & Food Sciences", "Trades & Craftsmanship", "Reference & Indexing", "Other"];
1256
1258
  }
1257
- exports.returnFields = returnFields;
1258
1259
  const sourceContent = {
1259
1260
  type: 'source',
1260
1261
  title: 'Time zone',
@@ -1309,8 +1310,6 @@ const sourceContent = {
1309
1310
  function returnSourceData() {
1310
1311
  return sourceContent;
1311
1312
  }
1312
- exports.returnSourceData = returnSourceData;
1313
1313
  function returnHeadings() {
1314
1314
  return headings;
1315
1315
  }
1316
- exports.returnHeadings = returnHeadings;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.gapFilling = void 0;
3
+ exports.gapFilling = gapFilling;
4
4
  function isEmpty(obj) {
5
5
  return Object.keys(obj).length === 0;
6
6
  }
@@ -43,4 +43,3 @@ function gapFilling(typologyResponse, cardgenResponse) {
43
43
  remainingFacts: remainingFacts,
44
44
  };
45
45
  }
46
- exports.gapFilling = gapFilling;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseResponse = exports.returnResponse = void 0;
3
+ exports.returnResponse = returnResponse;
4
+ exports.parseResponse = parseResponse;
4
5
  const responseData = {
5
6
  "flash_cards": [
6
7
  {
@@ -142,7 +143,6 @@ const responseData = {
142
143
  function returnResponse() {
143
144
  return responseData;
144
145
  }
145
- exports.returnResponse = returnResponse;
146
146
  function parseResponse() {
147
147
  let cardData = [];
148
148
  let data = returnResponse();
@@ -162,7 +162,6 @@ function parseResponse() {
162
162
  }
163
163
  return cardData;
164
164
  }
165
- exports.parseResponse = parseResponse;
166
165
  /// takes array of
167
166
  function parseFlashCard(cards) {
168
167
  let flashCardData = [];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.returnTypologyData = void 0;
3
+ exports.returnTypologyData = returnTypologyData;
4
4
  const typologyResponse = {
5
5
  "usage_data": {
6
6
  "prompt_tokens": 11611,
@@ -44,4 +44,3 @@ const typologyResponse = {
44
44
  function returnTypologyData() {
45
45
  return typologyResponse;
46
46
  }
47
- exports.returnTypologyData = returnTypologyData;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseOpenAiFailureResponse = exports.parseOpenAiSuccessResponse = void 0;
3
+ exports.parseOpenAiSuccessResponse = parseOpenAiSuccessResponse;
4
+ exports.parseOpenAiFailureResponse = parseOpenAiFailureResponse;
4
5
  function parseOpenAiSuccessResponse(responseData) {
5
6
  let choices = JSON.parse(responseData.choices[0].message.content);
6
7
  let usuage = responseData.usage;
@@ -12,7 +13,6 @@ function parseOpenAiSuccessResponse(responseData) {
12
13
  'generated_at': new Date(createdTime * 1000)
13
14
  };
14
15
  }
15
- exports.parseOpenAiSuccessResponse = parseOpenAiSuccessResponse;
16
16
  function parseOpenAiFailureResponse(errorResponse) {
17
17
  var _a, _b;
18
18
  // let statusCode =
@@ -21,4 +21,3 @@ function parseOpenAiFailureResponse(errorResponse) {
21
21
  'message': (_b = (_a = errorResponse.data) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.code
22
22
  };
23
23
  }
24
- exports.parseOpenAiFailureResponse = parseOpenAiFailureResponse;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "only_ever_generator",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "start": "npm run build && nodemon dist/index.js",
@@ -13,16 +13,16 @@
13
13
  "devDependencies": {
14
14
  "@types/express": "^4.17.21",
15
15
  "@types/node": "^20.14.2",
16
+ "dotenv": "^16.4.5",
17
+ "express": "^4.19.2",
16
18
  "nodemon": "^3.1.3",
17
19
  "ts-node": "^10.9.2",
18
- "typescript": "^5.4.5",
19
- "dotenv": "^16.4.5",
20
- "express": "^4.19.2"
20
+ "typescript": "^5.5.4"
21
21
  },
22
22
  "dependencies": {
23
- "axios": "^1.7.2"
24
-
25
-
23
+ "axios": "^1.7.7",
24
+ "n": "^10.0.0",
25
+ "stable": "^0.1.8"
26
26
  },
27
27
  "eslintConfig": {
28
28
  "parser": "typescript-eslint-parser",
package/readme.md CHANGED
@@ -20,4 +20,16 @@ let oeGenerator = new OnlyEverGenerator(
20
20
  let responsesArray = await oeGenerator.generate(true,true);
21
21
 
22
22
 
23
+ Exposed a new method ```gapFill``` from OnlyEverGenerator
24
+
25
+
26
+ async gapFill(factsMaps: any, aiCards: Array<any>) {}
27
+ /// factsmap
28
+ /// {
29
+ /// remaining_facts: [],
30
+ /// remaining_concepts: [],
31
+ //}
32
+
33
+ /// aicards is array of ai cards
34
+
23
35
  ```
@@ -79,7 +79,7 @@ export class OnlyEverGenerator {
79
79
 
80
80
  /// check if gap fill is required ie coverage determination
81
81
  if(this.cardgenResponse.status_code == 200) {
82
- this.gapFillResponse = await this.generationForGapFill(this.typologyResponse, this.cardgenResponse);
82
+ this.gapFillResponse = await this._generationForGapFill(this.typologyResponse, this.cardgenResponse);
83
83
  responseToReturn.push(this.gapFillResponse);
84
84
  }
85
85
 
@@ -99,7 +99,7 @@ export class OnlyEverGenerator {
99
99
 
100
100
  }
101
101
 
102
- async generationForGapFill(typologyData: any, cardGenData: any) {
102
+ async _generationForGapFill(typologyData: any, cardGenData: any) {
103
103
  let gapFill = gapFilling(typologyData, cardGenData);
104
104
  let response :any ;
105
105
  if (
@@ -145,6 +145,29 @@ export class OnlyEverGenerator {
145
145
  return response;
146
146
  }
147
147
 
148
+ async gapFill(factsMaps: any, aiCards: Array<any>) {
149
+ /// factsmap
150
+ /// {
151
+ /// remaining_facts: [],
152
+ /// remaining_concepts: [],
153
+ //}
154
+
155
+ /// aicards is data
156
+ let response :any ;
157
+
158
+ response = await this.generateCard(
159
+ this.promptForCardGen +
160
+ "Generate cards only suitable for the given remaining concepts and facts" +
161
+ JSON.stringify(factsMaps) +
162
+ "Exclude generating cards with content in the following",
163
+ JSON.stringify(aiCards),
164
+ true
165
+ );
166
+
167
+ return response;
168
+
169
+ }
170
+
148
171
 
149
172
 
150
173
  }