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.
@@ -35,6 +35,10 @@ function gapFilling(typologyResponse, cardgenResponse) {
35
35
  remainingFacts = allFacts.filter((item) => !generatedFactsSet.includes(item));
36
36
  }
37
37
  return {
38
+ // allConcepts: allConcepts,
39
+ // allFacts: allFacts,
40
+ // generatedConcepts: generatedConceptsSet,
41
+ // generatedFacts: generatedFactsSet,
38
42
  remainingConcepts: remainingConcepts,
39
43
  remainingFacts: remainingFacts,
40
44
  };
@@ -22,15 +22,16 @@ class GenerateTypology {
22
22
  }
23
23
  generate() {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
- var _a, _b, _c;
25
+ var _a, _b, _c, _d;
26
26
  try {
27
27
  const response = yield ((_a = this.openAiService) === null || _a === void 0 ? void 0 : _a.sendRequest(this.prompt, this.content));
28
28
  response['type'] = 'typology';
29
29
  response.metadata = {
30
- "req_time": response.generated_at,
30
+ "req_time": (_b = response.generated_at) !== null && _b !== void 0 ? _b : new Date(),
31
31
  "req_type": response.type,
32
- "req_tokens": (_b = response.usage_data) === null || _b === void 0 ? void 0 : _b.prompt_tokens,
33
- "res_tokens": (_c = response.usage_data) === null || _c === void 0 ? void 0 : _c.completion_tokens,
32
+ "req_tokens": (_c = response.usage_data) === null || _c === void 0 ? void 0 : _c.prompt_tokens,
33
+ "res_tokens": (_d = response.usage_data) === null || _d === void 0 ? void 0 : _d.completion_tokens,
34
+ "model": this.openAiService.model
34
35
  };
35
36
  if (response.status_code == 200) {
36
37
  return this.parseTypologyOnSuccess(response);
@@ -15,7 +15,6 @@ function parseOpenAiSuccessResponse(responseData) {
15
15
  exports.parseOpenAiSuccessResponse = parseOpenAiSuccessResponse;
16
16
  function parseOpenAiFailureResponse(errorResponse) {
17
17
  var _a, _b;
18
- let usuage = errorResponse.usuage;
19
18
  // let statusCode =
20
19
  return {
21
20
  'status_code': errorResponse.status,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "only_ever_generator",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "start": "npm run build && nodemon dist/index.js",
@@ -72,10 +72,7 @@ export class OnlyEverGenerator {
72
72
  if(this.shouldTheCardBeGeneratedAfterTypologyResponse()){
73
73
  this.cardgenResponse = await this.generateCard(
74
74
  this.promptForCardGen,
75
- "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({
76
- "facts": this.typologyResponse.facts,
77
- "concepts": this.typologyResponse.concepts
78
- }),
75
+ JSON.stringify(this.typologyResponse),
79
76
  false,
80
77
  )
81
78
  responseToReturn.push(this.cardgenResponse);
@@ -110,10 +107,11 @@ export class OnlyEverGenerator {
110
107
  gapFill.remainingFacts.length !== 0
111
108
  ) {
112
109
  response = await this.generateCard(
113
- this.promptForCardGen ,
114
-
115
- "Only Generate Cards For the missing concepts and facts given below \n" +
116
- JSON.stringify(gapFill) + "\n The cards already generated are below, refrain for generating cards similar to these "+ JSON.stringify(cardGenData.cards_data),
110
+ this.promptForCardGen +
111
+ "Generate cards only suitable for the given remaining concepts and facts" +
112
+ JSON.stringify(gapFill) +
113
+ "Exclude generating cards with content in the following",
114
+ JSON.stringify(cardGenData.cards_data),
117
115
  true
118
116
  );
119
117
  }
@@ -12,11 +12,11 @@ export class GenerateCards {
12
12
  // console.log("response to card generation ", response);
13
13
  response["type"] = isGapFill ? "gap_fill":"card_gen";
14
14
  response.metadata = {
15
- "req_time": response.generated_at,
15
+ "req_time": response.generated_at ?? new Date(),
16
16
  "req_type": response.type,
17
17
  "req_tokens": response.usage_data?.prompt_tokens,
18
18
  "res_tokens": response.usage_data?.completion_tokens,
19
- // "created_at":response.created_at,
19
+ "model": this.openAiService.model
20
20
  };
21
21
  if(response.status_code == 200){
22
22
  response.metadata.status = "completed";
@@ -165,7 +165,7 @@ return question;
165
165
 
166
166
  parseClozeCard(data: any) {
167
167
  let displayTitle = this.generateClozeCardDisplayTitle(
168
- data.card_content.text,
168
+ data.card_content.prompt,
169
169
  data.card_content.options
170
170
  );
171
171
  let clozeCardData = {
@@ -176,7 +176,7 @@ return question;
176
176
  heading: data.card_reference,
177
177
  displayTitle: displayTitle,
178
178
  content: {
179
- question: data.card_content.text,
179
+ question: data.card_content.prompt,
180
180
  options: data.card_content.options,
181
181
  },
182
182
  concepts: data.concepts,