only_ever_generator 0.3.7 → 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.
@@ -57,14 +57,11 @@ class OnlyEverGenerator {
57
57
  else if (elem == "generate_card") {
58
58
  /// for cards gen to occur, there must be presence of source taxonomy
59
59
  if (this.shouldTheCardBeGeneratedAfterTypologyResponse()) {
60
- this.cardgenResponse = yield this.generateCard(this.promptForCardGen, "Here are the facts and concepts on which cards needs to be generate, refrain from generating missing facts , concepts similar to available below : " + JSON.stringify({
61
- "facts": this.typologyResponse.facts,
62
- "concepts": this.typologyResponse.concepts
63
- }), false);
60
+ this.cardgenResponse = yield this.generateCard(this.promptForCardGen, JSON.stringify(this.typologyResponse), false);
64
61
  responseToReturn.push(this.cardgenResponse);
65
62
  /// check if gap fill is required ie coverage determination
66
63
  if (this.cardgenResponse.status_code == 200) {
67
- this.gapFillResponse = yield this.generationForGapFill(this.typologyResponse, this.cardgenResponse);
64
+ this.gapFillResponse = yield this._generationForGapFill(this.typologyResponse, this.cardgenResponse);
68
65
  responseToReturn.push(this.gapFillResponse);
69
66
  }
70
67
  }
@@ -82,14 +79,16 @@ class OnlyEverGenerator {
82
79
  return false;
83
80
  }
84
81
  }
85
- generationForGapFill(typologyData, cardGenData) {
82
+ _generationForGapFill(typologyData, cardGenData) {
86
83
  return __awaiter(this, void 0, void 0, function* () {
87
84
  let gapFill = (0, calculate_gap_fill_1.gapFilling)(typologyData, cardGenData);
88
85
  let response;
89
86
  if (gapFill.remainingConcepts.length !== 0 ||
90
87
  gapFill.remainingFacts.length !== 0) {
91
- response = yield this.generateCard(this.promptForCardGen, "Only Generate Cards For the missing concepts and facts given below \n" +
92
- JSON.stringify(gapFill) + "\n The cards already generated are below, refrain for generating cards similar to these " + JSON.stringify(cardGenData.cards_data), true);
88
+ response = yield this.generateCard(this.promptForCardGen +
89
+ "Generate cards only suitable for the given remaining concepts and facts" +
90
+ JSON.stringify(gapFill) +
91
+ "Exclude generating cards with content in the following", JSON.stringify(cardGenData.cards_data), true);
93
92
  }
94
93
  return response;
95
94
  });
@@ -109,5 +108,21 @@ class OnlyEverGenerator {
109
108
  return response;
110
109
  });
111
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
+ }
112
127
  }
113
128
  exports.OnlyEverGenerator = OnlyEverGenerator;
@@ -17,16 +17,16 @@ class GenerateCards {
17
17
  }
18
18
  generateCards(prompt, parsedContent, isGapFill, headings) {
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
- var _a, _b, _c;
20
+ var _a, _b, _c, _d;
21
21
  let response = yield ((_a = this.openAiService) === null || _a === void 0 ? void 0 : _a.sendRequest(prompt, parsedContent));
22
22
  // console.log("response to card generation ", response);
23
23
  response["type"] = isGapFill ? "gap_fill" : "card_gen";
24
24
  response.metadata = {
25
- "req_time": response.generated_at,
25
+ "req_time": (_b = response.generated_at) !== null && _b !== void 0 ? _b : new Date(),
26
26
  "req_type": response.type,
27
- "req_tokens": (_b = response.usage_data) === null || _b === void 0 ? void 0 : _b.prompt_tokens,
28
- "res_tokens": (_c = response.usage_data) === null || _c === void 0 ? void 0 : _c.completion_tokens,
29
- // "created_at":response.created_at,
27
+ "req_tokens": (_c = response.usage_data) === null || _c === void 0 ? void 0 : _c.prompt_tokens,
28
+ "res_tokens": (_d = response.usage_data) === null || _d === void 0 ? void 0 : _d.completion_tokens,
29
+ "model": this.openAiService.model
30
30
  };
31
31
  if (response.status_code == 200) {
32
32
  response.metadata.status = "completed";
@@ -163,7 +163,7 @@ class GenerateCards {
163
163
  }
164
164
  }
165
165
  parseClozeCard(data) {
166
- let displayTitle = this.generateClozeCardDisplayTitle(data.card_content.text, data.card_content.options);
166
+ let displayTitle = this.generateClozeCardDisplayTitle(data.card_content.prompt, data.card_content.options);
167
167
  let clozeCardData = {
168
168
  type: {
169
169
  category: 'learning',
@@ -172,7 +172,7 @@ class GenerateCards {
172
172
  heading: data.card_reference,
173
173
  displayTitle: displayTitle,
174
174
  content: {
175
- question: data.card_content.text,
175
+ question: data.card_content.prompt,
176
176
  options: data.card_content.options,
177
177
  },
178
178
  concepts: data.concepts,
@@ -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;