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.
- package/dist/bootstrap/app.js +23 -8
- package/dist/card_gen/generate_cards.js +7 -7
- package/dist/constants/api_constants.js +1 -2
- package/dist/constants/prompt_data.js +1 -2
- package/dist/constants/prompts/card_gen_prompt.js +1 -2
- package/dist/constants/prompts/typology_prompt.js +1 -2
- package/dist/constants/source_data.js +940 -534
- package/dist/gap_fill/calculate_gap_fill.js +5 -2
- package/dist/parse/response_format_card.js +2 -3
- package/dist/parse/response_format_typology.js +1 -2
- package/dist/typology_gen/generate_typology.js +5 -4
- package/dist/utils/parse_openai_response.js +2 -4
- package/package.json +7 -7
- package/readme.md +12 -0
- package/src/bootstrap/app.ts +31 -10
- package/src/card_gen/generate_cards.ts +4 -4
- package/src/constants/source_data.ts +937 -530
- package/src/gap_fill/calculate_gap_fill.ts +4 -0
- package/src/typology_gen/generate_typology.ts +2 -1
- package/src/utils/parse_openai_response.ts +0 -1
package/dist/bootstrap/app.js
CHANGED
|
@@ -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,
|
|
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.
|
|
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
|
-
|
|
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
|
|
92
|
-
|
|
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": (
|
|
28
|
-
"res_tokens": (
|
|
29
|
-
|
|
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.
|
|
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.
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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;
|