only_ever_generator 0.7.3 → 0.7.5
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
CHANGED
|
@@ -95,14 +95,14 @@ class OnlyEverGenerator {
|
|
|
95
95
|
this.typologyResponse.concepts = gapFill.remainingConcepts;
|
|
96
96
|
response = yield this.generateCard(this.promptForCardGen +
|
|
97
97
|
"Generate cards only suitable for the given remaining concepts and facts" +
|
|
98
|
-
JSON.stringify(gapFill), "", true);
|
|
98
|
+
JSON.stringify(gapFill), "", true, 1);
|
|
99
99
|
}
|
|
100
100
|
return response;
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
-
generateCard(
|
|
104
|
-
return __awaiter(this,
|
|
105
|
-
let generateCardsResp = yield new generate_cards_1.GenerateCards(this.openAiService).generateCards(prompt !== null && prompt !== void 0 ? prompt : "", JSON.stringify(this.parsedContent) + additionalContent, isGapFill, this.parsedContent.taxonomy);
|
|
103
|
+
generateCard(prompt_1, additionalContent_1, isGapFill_1) {
|
|
104
|
+
return __awaiter(this, arguments, void 0, function* (prompt, additionalContent, isGapFill, n = 0) {
|
|
105
|
+
let generateCardsResp = yield new generate_cards_1.GenerateCards(this.openAiService).generateCards(prompt !== null && prompt !== void 0 ? prompt : "", JSON.stringify(this.parsedContent) + additionalContent, isGapFill, this.parsedContent.taxonomy, n);
|
|
106
106
|
// let response = await this.openAiService?.sendRequest(prompt,this.parsedContent);
|
|
107
107
|
// response['type'] = 'card_gen';
|
|
108
108
|
return generateCardsResp;
|
|
@@ -114,8 +114,8 @@ class OnlyEverGenerator {
|
|
|
114
114
|
return response;
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
|
-
gapFill(
|
|
118
|
-
return __awaiter(this,
|
|
117
|
+
gapFill(factsMaps_1, aiCards_1) {
|
|
118
|
+
return __awaiter(this, arguments, void 0, function* (factsMaps, aiCards, n = 0) {
|
|
119
119
|
/// factsmap
|
|
120
120
|
/// {
|
|
121
121
|
/// remaining_facts: [],
|
|
@@ -126,7 +126,7 @@ class OnlyEverGenerator {
|
|
|
126
126
|
response = yield this.generateCard(this.promptForCardGen +
|
|
127
127
|
"Generate cards only suitable for the given remaining concepts and facts" +
|
|
128
128
|
JSON.stringify(factsMaps) +
|
|
129
|
-
"Exclude generating cards with content in the following", JSON.stringify(aiCards), true);
|
|
129
|
+
"Exclude generating cards with content in the following", JSON.stringify(aiCards), true, n);
|
|
130
130
|
return response;
|
|
131
131
|
});
|
|
132
132
|
}
|
|
@@ -15,20 +15,20 @@ class GenerateCards {
|
|
|
15
15
|
constructor(openAiService) {
|
|
16
16
|
this.openAiService = openAiService;
|
|
17
17
|
}
|
|
18
|
-
generateCards(
|
|
19
|
-
return __awaiter(this,
|
|
18
|
+
generateCards(prompt_1, parsedContent_1, isGapFill_1, taxonomy_1) {
|
|
19
|
+
return __awaiter(this, arguments, void 0, function* (prompt, parsedContent, isGapFill, taxonomy, n = 0) {
|
|
20
20
|
var _a, _b, _c, _d, _e;
|
|
21
21
|
let response = yield ((_a = this.openAiService) === null || _a === void 0 ? void 0 : _a.sendRequest(prompt, parsedContent));
|
|
22
|
+
var updatedNumber = n + 1;
|
|
22
23
|
// console.log("response to card generation ", response);
|
|
23
|
-
response["request_type"] =
|
|
24
|
-
type: "breadth",
|
|
25
|
-
sub_type: isGapFill ? "gap_fill" : "card_gen",
|
|
26
|
-
n: isGapFill ? 1 : 2,
|
|
27
|
-
bloom_level: 1,
|
|
28
|
-
};
|
|
24
|
+
// response["request_type"] = ;
|
|
29
25
|
response.metadata = {
|
|
30
26
|
req_time: (_b = response.generated_at) !== null && _b !== void 0 ? _b : new Date(),
|
|
31
|
-
req_type:
|
|
27
|
+
req_type: {
|
|
28
|
+
type: "depth",
|
|
29
|
+
n: updatedNumber,
|
|
30
|
+
bloom_level: 1,
|
|
31
|
+
},
|
|
32
32
|
req_tokens: (_c = response.usage_data) === null || _c === void 0 ? void 0 : _c.prompt_tokens,
|
|
33
33
|
res_tokens: (_d = response.usage_data) === null || _d === void 0 ? void 0 : _d.completion_tokens,
|
|
34
34
|
prompt_tokens_details: (_e = response.usage_data) === null || _e === void 0 ? void 0 : _e.prompt_tokens_details,
|
|
@@ -31,7 +31,10 @@ class GenerateTypology {
|
|
|
31
31
|
};
|
|
32
32
|
response.metadata = {
|
|
33
33
|
req_time: (_b = response.generated_at) !== null && _b !== void 0 ? _b : new Date(),
|
|
34
|
-
req_type:
|
|
34
|
+
req_type: {
|
|
35
|
+
type: "breadth",
|
|
36
|
+
n: 1,
|
|
37
|
+
},
|
|
35
38
|
req_tokens: (_c = response.usage_data) === null || _c === void 0 ? void 0 : _c.prompt_tokens,
|
|
36
39
|
res_tokens: (_d = response.usage_data) === null || _d === void 0 ? void 0 : _d.completion_tokens,
|
|
37
40
|
prompt_tokens_details: (_e = response.usage_data) === null || _e === void 0 ? void 0 : _e.prompt_tokens_details,
|
|
@@ -55,16 +58,29 @@ class GenerateTypology {
|
|
|
55
58
|
}
|
|
56
59
|
parseTypologyOnSuccess(responseData) {
|
|
57
60
|
responseData.metadata.status = "completed";
|
|
61
|
+
const facts = responseData.generated_content.facts.map((fact) => {
|
|
62
|
+
return {
|
|
63
|
+
concept_text: fact.fact_text,
|
|
64
|
+
reference: fact.reference,
|
|
65
|
+
type: "fact",
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
const concepts = responseData.generated_content.concepts.map((concept) => {
|
|
69
|
+
return {
|
|
70
|
+
concept_text: concept.concept_text,
|
|
71
|
+
reference: concept.reference,
|
|
72
|
+
type: "concept",
|
|
73
|
+
};
|
|
74
|
+
});
|
|
58
75
|
const generatedContent = responseData.generated_content;
|
|
59
76
|
return {
|
|
60
77
|
status_code: 200,
|
|
61
78
|
metadata: responseData.metadata,
|
|
62
79
|
field: this.parseFields(generatedContent.field),
|
|
63
|
-
concepts:
|
|
64
|
-
facts: generatedContent.facts,
|
|
80
|
+
concepts: [...concepts, ...facts],
|
|
65
81
|
generate_cards: generatedContent.generate_cards,
|
|
66
82
|
summary_cards: generatedContent.summary_cards,
|
|
67
|
-
type: responseData.type,
|
|
83
|
+
// type: responseData.type,
|
|
68
84
|
};
|
|
69
85
|
}
|
|
70
86
|
parseFields(fields) {
|
package/package.json
CHANGED
package/src/bootstrap/app.ts
CHANGED
|
@@ -97,7 +97,7 @@ export class OnlyEverGenerator {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
async _generationForGapFill(typologyData: any, cardGenData: any) {
|
|
100
|
+
async _generationForGapFill(typologyData: any, cardGenData: any,) {
|
|
101
101
|
let gapFill = gapFilling(typologyData, cardGenData);
|
|
102
102
|
let response: any;
|
|
103
103
|
if (
|
|
@@ -108,11 +108,12 @@ export class OnlyEverGenerator {
|
|
|
108
108
|
this.typologyResponse.concepts = gapFill.remainingConcepts;
|
|
109
109
|
response = await this.generateCard(
|
|
110
110
|
this.promptForCardGen +
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
"Generate cards only suitable for the given remaining concepts and facts" +
|
|
112
|
+
JSON.stringify(gapFill),
|
|
113
113
|
|
|
114
114
|
"",
|
|
115
|
-
true
|
|
115
|
+
true,
|
|
116
|
+
1,
|
|
116
117
|
);
|
|
117
118
|
}
|
|
118
119
|
return response;
|
|
@@ -121,7 +122,8 @@ export class OnlyEverGenerator {
|
|
|
121
122
|
async generateCard(
|
|
122
123
|
prompt: string,
|
|
123
124
|
additionalContent: string,
|
|
124
|
-
isGapFill: boolean
|
|
125
|
+
isGapFill: boolean,
|
|
126
|
+
n: number = 0,
|
|
125
127
|
) {
|
|
126
128
|
let generateCardsResp = await new GenerateCards(
|
|
127
129
|
this.openAiService
|
|
@@ -129,7 +131,7 @@ export class OnlyEverGenerator {
|
|
|
129
131
|
prompt ?? "",
|
|
130
132
|
JSON.stringify(this.parsedContent) + additionalContent,
|
|
131
133
|
isGapFill,
|
|
132
|
-
this.parsedContent.taxonomy
|
|
134
|
+
this.parsedContent.taxonomy, n,
|
|
133
135
|
);
|
|
134
136
|
|
|
135
137
|
// let response = await this.openAiService?.sendRequest(prompt,this.parsedContent);
|
|
@@ -147,7 +149,7 @@ export class OnlyEverGenerator {
|
|
|
147
149
|
return response;
|
|
148
150
|
}
|
|
149
151
|
|
|
150
|
-
async gapFill(factsMaps: any, aiCards: Array<any
|
|
152
|
+
async gapFill(factsMaps: any, aiCards: Array<any>, n: number = 0) {
|
|
151
153
|
/// factsmap
|
|
152
154
|
/// {
|
|
153
155
|
/// remaining_facts: [],
|
|
@@ -159,11 +161,12 @@ export class OnlyEverGenerator {
|
|
|
159
161
|
|
|
160
162
|
response = await this.generateCard(
|
|
161
163
|
this.promptForCardGen +
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
"Generate cards only suitable for the given remaining concepts and facts" +
|
|
165
|
+
JSON.stringify(factsMaps) +
|
|
166
|
+
"Exclude generating cards with content in the following",
|
|
165
167
|
JSON.stringify(aiCards),
|
|
166
|
-
true
|
|
168
|
+
true,
|
|
169
|
+
n,
|
|
167
170
|
);
|
|
168
171
|
|
|
169
172
|
return response;
|
|
@@ -12,19 +12,20 @@ export class GenerateCards {
|
|
|
12
12
|
prompt: string,
|
|
13
13
|
parsedContent: string,
|
|
14
14
|
isGapFill: boolean,
|
|
15
|
-
taxonomy: any
|
|
15
|
+
taxonomy: any,
|
|
16
|
+
n: number = 0,
|
|
16
17
|
) {
|
|
17
18
|
let response = await this.openAiService?.sendRequest(prompt, parsedContent);
|
|
19
|
+
var updatedNumber = n + 1;
|
|
18
20
|
// console.log("response to card generation ", response);
|
|
19
|
-
response["request_type"] =
|
|
20
|
-
type: "breadth",
|
|
21
|
-
sub_type: isGapFill ? "gap_fill" : "card_gen",
|
|
22
|
-
n: isGapFill ? 1 : 2,
|
|
23
|
-
bloom_level: 1,
|
|
24
|
-
};
|
|
21
|
+
// response["request_type"] = ;
|
|
25
22
|
response.metadata = {
|
|
26
23
|
req_time: response.generated_at ?? new Date(),
|
|
27
|
-
req_type:
|
|
24
|
+
req_type: {
|
|
25
|
+
type: "depth",
|
|
26
|
+
n: updatedNumber,
|
|
27
|
+
bloom_level: 1,
|
|
28
|
+
},
|
|
28
29
|
req_tokens: response.usage_data?.prompt_tokens,
|
|
29
30
|
res_tokens: response.usage_data?.completion_tokens,
|
|
30
31
|
prompt_tokens_details: response.usage_data?.prompt_tokens_details,
|
|
@@ -32,7 +32,10 @@ export class GenerateTypology {
|
|
|
32
32
|
};
|
|
33
33
|
response.metadata = {
|
|
34
34
|
req_time: response.generated_at ?? new Date(),
|
|
35
|
-
req_type:
|
|
35
|
+
req_type: {
|
|
36
|
+
type: "breadth",
|
|
37
|
+
n: 1,
|
|
38
|
+
},
|
|
36
39
|
req_tokens: response.usage_data?.prompt_tokens,
|
|
37
40
|
res_tokens: response.usage_data?.completion_tokens,
|
|
38
41
|
prompt_tokens_details: response.usage_data?.prompt_tokens_details,
|
|
@@ -54,16 +57,29 @@ export class GenerateTypology {
|
|
|
54
57
|
|
|
55
58
|
parseTypologyOnSuccess(responseData: any) {
|
|
56
59
|
responseData.metadata.status = "completed";
|
|
60
|
+
const facts = responseData.generated_content.facts.map((fact: any) => {
|
|
61
|
+
return {
|
|
62
|
+
concept_text: fact.fact_text,
|
|
63
|
+
reference: fact.reference,
|
|
64
|
+
type: "fact",
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
const concepts = responseData.generated_content.concepts.map((concept: any) => {
|
|
68
|
+
return {
|
|
69
|
+
concept_text: concept.concept_text,
|
|
70
|
+
reference: concept.reference,
|
|
71
|
+
type: "concept",
|
|
72
|
+
};
|
|
73
|
+
});
|
|
57
74
|
const generatedContent = responseData.generated_content;
|
|
58
75
|
return {
|
|
59
76
|
status_code: 200,
|
|
60
77
|
metadata: responseData.metadata,
|
|
61
78
|
field: this.parseFields(generatedContent.field),
|
|
62
|
-
concepts:
|
|
63
|
-
facts: generatedContent.facts,
|
|
79
|
+
concepts: [...concepts, ...facts],
|
|
64
80
|
generate_cards: generatedContent.generate_cards,
|
|
65
81
|
summary_cards: generatedContent.summary_cards,
|
|
66
|
-
type: responseData.type,
|
|
82
|
+
// type: responseData.type,
|
|
67
83
|
};
|
|
68
84
|
}
|
|
69
85
|
|