only_ever_generator 0.3.7 → 0.3.8

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,10 +57,7 @@ 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) {
@@ -88,8 +85,10 @@ class OnlyEverGenerator {
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
  });
@@ -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,