only_ever_generator 2.0.3 → 2.0.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.d.ts +1 -1
- package/dist/bootstrap/app.d.ts.map +1 -1
- package/dist/bootstrap/app.js +17 -16
- package/dist/bootstrap/app.js.map +1 -1
- package/dist/card_gen/generate_cards.d.ts +10 -2
- package/dist/card_gen/generate_cards.d.ts.map +1 -1
- package/dist/card_gen/generate_cards.js +38 -11
- package/dist/card_gen/generate_cards.js.map +1 -1
- package/dist/helper/build_concept_facts_schema.d.ts +43 -0
- package/dist/helper/build_concept_facts_schema.d.ts.map +1 -0
- package/dist/helper/build_concept_facts_schema.js +45 -0
- package/dist/helper/build_concept_facts_schema.js.map +1 -0
- package/dist/helper/schema_helper/build_concept_facts_schema.d.ts +43 -0
- package/dist/helper/schema_helper/build_concept_facts_schema.d.ts.map +1 -0
- package/dist/helper/schema_helper/build_concept_facts_schema.js +45 -0
- package/dist/helper/schema_helper/build_concept_facts_schema.js.map +1 -0
- package/dist/parse/parse_card_response.d.ts +1 -1
- package/dist/parse/parse_card_response.d.ts.map +1 -1
- package/dist/parse/parse_card_response.js +2 -4
- package/dist/parse/parse_card_response.js.map +1 -1
- package/dist/typology_gen/generate_concept_facts.d.ts +10 -2
- package/dist/typology_gen/generate_concept_facts.d.ts.map +1 -1
- package/dist/typology_gen/generate_concept_facts.js +11 -7
- package/dist/typology_gen/generate_concept_facts.js.map +1 -1
- package/dist/typology_gen/generate_typology.d.ts.map +1 -1
- package/dist/typology_gen/generate_typology.js +1 -6
- package/dist/typology_gen/generate_typology.js.map +1 -1
- package/package.json +1 -1
- package/src/bootstrap/app.ts +17 -30
- package/src/card_gen/generate_cards.ts +47 -14
- package/src/helper/schema_helper/build_concept_facts_schema.ts +89 -0
- package/src/parse/parse_card_response.ts +1 -4
- package/src/typology_gen/generate_concept_facts.ts +26 -9
- package/src/typology_gen/generate_typology.ts +3 -7
package/dist/bootstrap/app.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export declare class OnlyEverGenerator {
|
|
|
35
35
|
});
|
|
36
36
|
generate(generate_typology?: boolean, generate_card?: boolean): Promise<Array<any>>;
|
|
37
37
|
shouldTheCardBeGeneratedAfterTypologyResponse(): boolean;
|
|
38
|
-
generateCard(
|
|
38
|
+
generateCard(n?: number): Promise<any>;
|
|
39
39
|
generateTypology(): Promise<any>;
|
|
40
40
|
generateConceptFacts(): Promise<any>;
|
|
41
41
|
generateEmbeddings(typologyResponse: any): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/bootstrap/app.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAO5D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAK/D,qBAAa,iBAAiB;IACrB,OAAO,EAAE,MAAM,CAAM;IACrB,aAAa,EAAE,aAAa,CAAC;IAGpC,aAAa,CAAC,EAAE;QACd,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,OAAO,EAAE,GAAG,EAAE,CAAC;QACf,QAAQ,EAAE,cAAc,CAAC;QACzB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;KACd,CAAa;IACd,iBAAiB,EAAE,MAAM,CAAM;IAC/B,gBAAgB,EAAE,MAAM,CAAM;IAC9B,gBAAgB,EAAE;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB,CAGC;IACF,qBAAqB,EAAE;QACrB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB,CAGC;IACF,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAM;IACnC,gBAAgB,CAAC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
111
111
|
},
|
|
112
112
|
};
|
|
113
|
-
this.cardgenResponse = yield this.generateCard(
|
|
113
|
+
this.cardgenResponse = yield this.generateCard(0);
|
|
114
114
|
responseToReturn.push({
|
|
115
115
|
type: "card_gen",
|
|
116
116
|
data: this.cardgenResponse,
|
|
@@ -129,27 +129,28 @@ class OnlyEverGenerator {
|
|
|
129
129
|
return false;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
generateCard(
|
|
133
|
-
return __awaiter(this, arguments, void 0, function* (
|
|
134
|
-
|
|
132
|
+
generateCard() {
|
|
133
|
+
return __awaiter(this, arguments, void 0, function* (n = 0) {
|
|
134
|
+
var _a, _b, _c;
|
|
135
|
+
const content = {
|
|
136
|
+
title: (_a = this.parsedContent) === null || _a === void 0 ? void 0 : _a.title,
|
|
137
|
+
concepts_facts: (_b = this.typologyResponse) === null || _b === void 0 ? void 0 : _b.concepts_facts,
|
|
138
|
+
content: (_c = this.parsedContent) === null || _c === void 0 ? void 0 : _c.content,
|
|
139
|
+
};
|
|
140
|
+
let generateCardsResp = yield new generate_cards_1.GenerateCards(this.openAiService, JSON.stringify(content), this.parsedContent.taxonomy).generateCards(n);
|
|
135
141
|
return generateCardsResp;
|
|
136
142
|
});
|
|
137
143
|
}
|
|
138
144
|
generateTypology() {
|
|
139
145
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
-
var _a, _b, _c, _d, _e
|
|
146
|
+
var _a, _b, _c, _d, _e;
|
|
141
147
|
const content = {
|
|
142
148
|
title: (_a = this.parsedContent) === null || _a === void 0 ? void 0 : _a.title,
|
|
143
149
|
headings: (_b = this.parsedContent) === null || _b === void 0 ? void 0 : _b.headings,
|
|
144
150
|
content: (_c = this.parsedContent) === null || _c === void 0 ? void 0 : _c.content,
|
|
145
151
|
};
|
|
146
|
-
console.log(content);
|
|
147
|
-
console.log(this.expectedFields);
|
|
148
|
-
console.log(this.promptForSummary);
|
|
149
|
-
console.log((_d = this.parsedContent) === null || _d === void 0 ? void 0 : _d.type);
|
|
150
|
-
console.log(this.openAiService);
|
|
151
152
|
try {
|
|
152
|
-
let response = yield new generate_typology_1.GenerateTypology(this.openAiService, (
|
|
153
|
+
let response = yield new generate_typology_1.GenerateTypology(this.openAiService, (_e = (_d = this.parsedContent) === null || _d === void 0 ? void 0 : _d.type) !== null && _e !== void 0 ? _e : "text", JSON.stringify(content), this.expectedFields, this.promptForSummary).generate();
|
|
153
154
|
return response;
|
|
154
155
|
}
|
|
155
156
|
catch (error) {
|
|
@@ -159,13 +160,13 @@ class OnlyEverGenerator {
|
|
|
159
160
|
}
|
|
160
161
|
generateConceptFacts() {
|
|
161
162
|
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
var _a, _b, _c, _d, _e;
|
|
163
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
163
164
|
const content = {
|
|
164
|
-
title: (_a = this.parsedContent) === null || _a === void 0 ? void 0 : _a.title,
|
|
165
|
-
headings: (
|
|
166
|
-
content: (
|
|
165
|
+
title: (_b = (_a = this.parsedContent) === null || _a === void 0 ? void 0 : _a.title) !== null && _b !== void 0 ? _b : "",
|
|
166
|
+
headings: (_d = (_c = this.parsedContent) === null || _c === void 0 ? void 0 : _c.headings) !== null && _d !== void 0 ? _d : [],
|
|
167
|
+
content: (_f = (_e = this.parsedContent) === null || _e === void 0 ? void 0 : _e.content) !== null && _f !== void 0 ? _f : [],
|
|
167
168
|
};
|
|
168
|
-
let response = yield new generate_concept_facts_1.GenerateConceptFacts(this.openAiService,
|
|
169
|
+
let response = yield new generate_concept_facts_1.GenerateConceptFacts(this.openAiService, content, (_h = (_g = this.parsedContent) === null || _g === void 0 ? void 0 : _g.type) !== null && _h !== void 0 ? _h : "text", this.promptForConceptFacts).generate();
|
|
169
170
|
return response;
|
|
170
171
|
});
|
|
171
172
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/bootstrap/app.ts"],"names":[],"mappings":";;;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AQ,EACR,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,GAAG,CACjB,CAAC;YAEF,OAAO,UAAU,CAAC;QACpB,CAAC;KAAA;CACF;AAvPD,8CAuPC"}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import { OpenAIHelper } from "../helper/openai_helper";
|
|
1
2
|
import { OpenAiService } from "../services/open_ai_service";
|
|
2
3
|
import { SourceTaxonomy } from "../types/source_taxonomy_type";
|
|
3
4
|
export declare class GenerateCards {
|
|
4
5
|
openAiService: OpenAiService;
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
content: string;
|
|
7
|
+
taxonomy: SourceTaxonomy;
|
|
8
|
+
openAIHelper: OpenAIHelper;
|
|
9
|
+
promptForCardsGeneration: {
|
|
10
|
+
promptId: string;
|
|
11
|
+
version: string;
|
|
12
|
+
};
|
|
13
|
+
constructor(openAiService: OpenAiService, content: string, taxonomy: SourceTaxonomy);
|
|
14
|
+
generateCards(n?: number): Promise<any>;
|
|
7
15
|
}
|
|
8
16
|
//# sourceMappingURL=generate_cards.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_cards.d.ts","sourceRoot":"","sources":["../../src/card_gen/generate_cards.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate_cards.d.ts","sourceRoot":"","sources":["../../src/card_gen/generate_cards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,qBAAa,aAAa;IACxB,aAAa,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,cAAc,CAAC;IAChC,YAAY,EAAE,YAAY,CAAC;IAC3B,wBAAwB,EAAE;QACxB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB,CAGC;gBAEA,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,cAAc;IAapB,aAAa,CAAC,CAAC,GAAE,MAAU;CA6ElC"}
|
|
@@ -10,28 +10,55 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.GenerateCards = void 0;
|
|
13
|
+
const openai_helper_1 = require("../helper/openai_helper");
|
|
13
14
|
const logger_1 = require("../logger");
|
|
14
15
|
const parse_card_response_1 = require("../parse/parse_card_response");
|
|
15
16
|
class GenerateCards {
|
|
16
|
-
constructor(openAiService) {
|
|
17
|
+
constructor(openAiService, content, taxonomy) {
|
|
18
|
+
this.promptForCardsGeneration = {
|
|
19
|
+
promptId: "",
|
|
20
|
+
version: "",
|
|
21
|
+
};
|
|
17
22
|
this.openAiService = openAiService;
|
|
23
|
+
this.openAIHelper = new openai_helper_1.OpenAIHelper(this.openAiService.api_key, this.openAiService.model, this.promptForCardsGeneration.promptId, this.promptForCardsGeneration.version);
|
|
24
|
+
this.content = content;
|
|
25
|
+
this.taxonomy = taxonomy;
|
|
18
26
|
}
|
|
19
|
-
generateCards(
|
|
20
|
-
return __awaiter(this, arguments, void 0, function* (
|
|
21
|
-
var _a, _b, _c, _d, _e
|
|
27
|
+
generateCards() {
|
|
28
|
+
return __awaiter(this, arguments, void 0, function* (n = 0) {
|
|
29
|
+
var _a, _b, _c, _d, _e;
|
|
22
30
|
try {
|
|
23
|
-
let response = yield
|
|
31
|
+
let response = yield this.openAIHelper.openAI.responses.create({
|
|
32
|
+
model: this.openAIHelper.model,
|
|
33
|
+
prompt: {
|
|
34
|
+
id: this.promptForCardsGeneration.promptId,
|
|
35
|
+
version: this.promptForCardsGeneration.version,
|
|
36
|
+
variables: {
|
|
37
|
+
bloom_level: "1",
|
|
38
|
+
card_types: "MCQ,Cloze,Match,Flash",
|
|
39
|
+
bloom_instructions: "",
|
|
40
|
+
card_instructions: "",
|
|
41
|
+
card_examples: "",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
input: this.content,
|
|
45
|
+
store: false,
|
|
46
|
+
});
|
|
47
|
+
// let response = await this.openAiService?.sendRequest(
|
|
48
|
+
// prompt,
|
|
49
|
+
// parsedContent
|
|
50
|
+
// );
|
|
24
51
|
var updatedNumber = n + 1;
|
|
25
52
|
response.metadata = {
|
|
26
|
-
req_time: (
|
|
53
|
+
req_time: (_a = response.generated_at) !== null && _a !== void 0 ? _a : new Date(),
|
|
27
54
|
req_type: {
|
|
28
55
|
type: "depth",
|
|
29
56
|
n: updatedNumber,
|
|
30
57
|
bloom_level: 1,
|
|
31
58
|
},
|
|
32
|
-
req_tokens: (
|
|
33
|
-
res_tokens: (
|
|
34
|
-
prompt_tokens_details: (
|
|
59
|
+
req_tokens: (_b = response.usage_data) === null || _b === void 0 ? void 0 : _b.prompt_tokens,
|
|
60
|
+
res_tokens: (_c = response.usage_data) === null || _c === void 0 ? void 0 : _c.completion_tokens,
|
|
61
|
+
prompt_tokens_details: (_d = response.usage_data) === null || _d === void 0 ? void 0 : _d.prompt_tokens_details,
|
|
35
62
|
model: this.openAiService.model,
|
|
36
63
|
};
|
|
37
64
|
if (response.status_code == 200) {
|
|
@@ -40,7 +67,7 @@ class GenerateCards {
|
|
|
40
67
|
const generated_data = {
|
|
41
68
|
metadata: response.metadata,
|
|
42
69
|
generated_content: {
|
|
43
|
-
test_cards: ((
|
|
70
|
+
test_cards: ((_e = response.generated_content.test_cards) !== null && _e !== void 0 ? _e : []).map((card) => {
|
|
44
71
|
var _a, _b, _c;
|
|
45
72
|
return {
|
|
46
73
|
type: card.type,
|
|
@@ -55,7 +82,7 @@ class GenerateCards {
|
|
|
55
82
|
generated_at: response.generated_at,
|
|
56
83
|
status_code: response.status_code,
|
|
57
84
|
};
|
|
58
|
-
let parseCard = new parse_card_response_1.ParseCardResponse().parse(generated_data,
|
|
85
|
+
let parseCard = new parse_card_response_1.ParseCardResponse().parse(generated_data, this.taxonomy, 1);
|
|
59
86
|
return parseCard;
|
|
60
87
|
}
|
|
61
88
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_cards.js","sourceRoot":"","sources":["../../src/card_gen/generate_cards.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAwC;AACxC,sEAAiE;AAKjE,MAAa,aAAa;
|
|
1
|
+
{"version":3,"file":"generate_cards.js","sourceRoot":"","sources":["../../src/card_gen/generate_cards.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAuD;AACvD,sCAAwC;AACxC,sEAAiE;AAKjE,MAAa,aAAa;IAYxB,YACE,aAA4B,EAC5B,OAAe,EACf,QAAwB;QAV1B,6BAAwB,GAGpB;YACF,QAAQ,EAAE,EAAE;YACZ,OAAO,EAAE,EAAE;SACZ,CAAC;QAMA,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,YAAY,GAAG,IAAI,4BAAY,CAClC,IAAI,CAAC,aAAa,CAAC,OAAO,EAC1B,IAAI,CAAC,aAAa,CAAC,KAAK,EACxB,IAAI,CAAC,wBAAwB,CAAC,QAAQ,EACtC,IAAI,CAAC,wBAAwB,CAAC,OAAO,CACtC,CAAC;QACF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEK,aAAa;6DAAC,IAAY,CAAC;;YAC/B,IAAI,CAAC;gBACH,IAAI,QAAQ,GAAQ,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;oBAClE,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK;oBAC9B,MAAM,EAAE;wBACN,EAAE,EAAE,IAAI,CAAC,wBAAwB,CAAC,QAAQ;wBAC1C,OAAO,EAAE,IAAI,CAA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,EAAE,IAAI,CAAC,YAAY;oCAC/B,QAAQ,EAAE,MAAA,IAAI,CAAC,QAAQ,mCAAI,EAAE;oCAC7B,KAAK,EAAE,MAAA,IAAI,CAAC,KAAK,mCAAI,EAAE;oCACvB,WAAW,EAAE,MAAA,IAAI,CAAC,WAAW,mCAAI,CAAC;iCACnC,CAAC;4BACJ,CAAC,CACF;yBACF;wBACD,UAAU,EAAE,QAAQ,CAAC,UAAU;wBAC/B,YAAY,EAAE,QAAQ,CAAC,YAAY;wBACnC,WAAW,EAAE,QAAQ,CAAC,WAAW;qBAClC,CAAC;oBACF,IAAI,SAAS,GAAG,IAAI,uCAAiB,EAAE,CAAC,KAAK,CAC3C,cAAc,EACd,IAAI,CAAC,QAAQ,EACb,CAAC,CACF,CAAC;oBACF,OAAO,SAAS,CAAC;gBACnB,CAAC;qBAAM,CAAC;oBACN,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC;oBACpC,QAAQ,CAAC,QAAQ,CAAC,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC;oBACjD,OAAO,QAAQ,CAAC;gBAClB,CAAC;YACH,CAAC;YAAC,OAAO,CAAM,EAAE,CAAC;gBAChB,IAAI,oBAAW,CAAC;oBACd,IAAI,EAAE,iBAAiB;oBACvB,IAAI,EAAE,CAAC,CAAC,OAAO;iBAChB,CAAC,CAAC,GAAG,EAAE,CAAC;YACX,CAAC;QACH,CAAC;KAAA;CACF;AAzGD,sCAyGC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
type ConceptFactType = "concept" | "fact";
|
|
2
|
+
interface ConceptFactSchemaItem {
|
|
3
|
+
text: {
|
|
4
|
+
type: "string";
|
|
5
|
+
minLength: number;
|
|
6
|
+
maxLength: number;
|
|
7
|
+
description: string;
|
|
8
|
+
};
|
|
9
|
+
type: {
|
|
10
|
+
type: "string";
|
|
11
|
+
enum: ConceptFactType[];
|
|
12
|
+
description: string;
|
|
13
|
+
};
|
|
14
|
+
reference: {
|
|
15
|
+
type: "string";
|
|
16
|
+
enum: string[];
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
interface Schema {
|
|
21
|
+
name: string;
|
|
22
|
+
strict: boolean;
|
|
23
|
+
schema: {
|
|
24
|
+
type: "object";
|
|
25
|
+
properties: {
|
|
26
|
+
concepts_facts: {
|
|
27
|
+
type: "array";
|
|
28
|
+
minItems: number;
|
|
29
|
+
items: {
|
|
30
|
+
type: "object";
|
|
31
|
+
properties: ConceptFactSchemaItem;
|
|
32
|
+
required: ["text", "type", "reference"];
|
|
33
|
+
additionalProperties: false;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
required: ["concepts_facts"];
|
|
38
|
+
additionalProperties: false;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export declare function buildConceptFactSchema(headings: string[], name?: string, strict?: boolean): Schema;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=build_concept_facts_schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_concept_facts_schema.d.ts","sourceRoot":"","sources":["../../src/helper/build_concept_facts_schema.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG,SAAS,GAAG,MAAM,CAAC;AAE1C,UAAU,qBAAqB;IAC7B,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ,CAAC;QACf,IAAI,EAAE,eAAe,EAAE,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,SAAS,EAAE;QACT,IAAI,EAAE,QAAQ,CAAC;QACf,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,UAAU,MAAM;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE;YACV,cAAc,EAAE;gBACd,IAAI,EAAE,OAAO,CAAC;gBACd,QAAQ,EAAE,MAAM,CAAC;gBACjB,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ,CAAC;oBACf,UAAU,EAAE,qBAAqB,CAAC;oBAClC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;oBACxC,oBAAoB,EAAE,KAAK,CAAC;iBAC7B,CAAC;aACH,CAAC;SACH,CAAC;QACF,QAAQ,EAAE,CAAC,gBAAgB,CAAC,CAAC;QAC7B,oBAAoB,EAAE,KAAK,CAAC;KAC7B,CAAC;CACH;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAAE,EAClB,IAAI,GAAE,MAAkC,EACxC,MAAM,GAAE,OAAe,GACtB,MAAM,CAyCR"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildConceptFactSchema = buildConceptFactSchema;
|
|
4
|
+
function buildConceptFactSchema(headings, name = "concept_fact_gen_schema", strict = false) {
|
|
5
|
+
const allowedRefs = [...headings, ""];
|
|
6
|
+
return {
|
|
7
|
+
name,
|
|
8
|
+
strict,
|
|
9
|
+
schema: {
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {
|
|
12
|
+
concepts_facts: {
|
|
13
|
+
type: "array",
|
|
14
|
+
minItems: 1,
|
|
15
|
+
items: {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
text: {
|
|
19
|
+
type: "string",
|
|
20
|
+
minLength: 80,
|
|
21
|
+
maxLength: 280,
|
|
22
|
+
description: "Noun phrase or declarative fact (80–280 chars).",
|
|
23
|
+
},
|
|
24
|
+
type: {
|
|
25
|
+
type: "string",
|
|
26
|
+
enum: ["concept", "fact"],
|
|
27
|
+
description: "“concept” vs “fact”.",
|
|
28
|
+
},
|
|
29
|
+
reference: {
|
|
30
|
+
type: "string",
|
|
31
|
+
enum: allowedRefs,
|
|
32
|
+
description: "Exact heading or empty string.",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
required: ["text", "type", "reference"],
|
|
36
|
+
additionalProperties: false,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
required: ["concepts_facts"],
|
|
41
|
+
additionalProperties: false,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=build_concept_facts_schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_concept_facts_schema.js","sourceRoot":"","sources":["../../src/helper/build_concept_facts_schema.ts"],"names":[],"mappings":";;AA2CA,wDA6CC;AA7CD,SAAgB,sBAAsB,CACpC,QAAkB,EAClB,OAAe,yBAAyB,EACxC,SAAkB,KAAK;IAEvB,MAAM,WAAW,GAAG,CAAC,GAAG,QAAQ,EAAE,EAAE,CAAC,CAAC;IAEtC,OAAO;QACL,IAAI;QACJ,MAAM;QACN,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,cAAc,EAAE;oBACd,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,CAAC;oBACX,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE;4BACV,IAAI,EAAE;gCACJ,IAAI,EAAE,QAAQ;gCACd,SAAS,EAAE,EAAE;gCACb,SAAS,EAAE,GAAG;gCACd,WAAW,EAAE,iDAAiD;6BAC/D;4BACD,IAAI,EAAE;gCACJ,IAAI,EAAE,QAAQ;gCACd,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;gCACzB,WAAW,EAAE,sBAAsB;6BACpC;4BACD,SAAS,EAAE;gCACT,IAAI,EAAE,QAAQ;gCACd,IAAI,EAAE,WAAW;gCACjB,WAAW,EAAE,gCAAgC;6BAC9C;yBACF;wBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC;wBACvC,oBAAoB,EAAE,KAAK;qBAC5B;iBACF;aACF;YACD,QAAQ,EAAE,CAAC,gBAAgB,CAAC;YAC5B,oBAAoB,EAAE,KAAK;SAC5B;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
type ConceptFactType = "concept" | "fact";
|
|
2
|
+
interface ConceptFactSchemaItem {
|
|
3
|
+
text: {
|
|
4
|
+
type: "string";
|
|
5
|
+
minLength: number;
|
|
6
|
+
maxLength: number;
|
|
7
|
+
description: string;
|
|
8
|
+
};
|
|
9
|
+
type: {
|
|
10
|
+
type: "string";
|
|
11
|
+
enum: ConceptFactType[];
|
|
12
|
+
description: string;
|
|
13
|
+
};
|
|
14
|
+
reference: {
|
|
15
|
+
type: "string";
|
|
16
|
+
enum: string[];
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
interface Schema {
|
|
21
|
+
name: string;
|
|
22
|
+
strict: boolean;
|
|
23
|
+
schema: {
|
|
24
|
+
type: "object";
|
|
25
|
+
properties: {
|
|
26
|
+
concepts_facts: {
|
|
27
|
+
type: "array";
|
|
28
|
+
minItems: number;
|
|
29
|
+
items: {
|
|
30
|
+
type: "object";
|
|
31
|
+
properties: ConceptFactSchemaItem;
|
|
32
|
+
required: ["text", "type", "reference"];
|
|
33
|
+
additionalProperties: false;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
required: ["concepts_facts"];
|
|
38
|
+
additionalProperties: false;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export declare function buildConceptFactSchema(headings: string[], name?: string, strict?: boolean): Schema;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=build_concept_facts_schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_concept_facts_schema.d.ts","sourceRoot":"","sources":["../../../src/helper/schema_helper/build_concept_facts_schema.ts"],"names":[],"mappings":"AAAA,KAAK,eAAe,GAAG,SAAS,GAAG,MAAM,CAAC;AAE1C,UAAU,qBAAqB;IAC7B,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ,CAAC;QACf,IAAI,EAAE,eAAe,EAAE,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,SAAS,EAAE;QACT,IAAI,EAAE,QAAQ,CAAC;QACf,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,UAAU,MAAM;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE;YACV,cAAc,EAAE;gBACd,IAAI,EAAE,OAAO,CAAC;gBACd,QAAQ,EAAE,MAAM,CAAC;gBACjB,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ,CAAC;oBACf,UAAU,EAAE,qBAAqB,CAAC;oBAClC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;oBACxC,oBAAoB,EAAE,KAAK,CAAC;iBAC7B,CAAC;aACH,CAAC;SACH,CAAC;QACF,QAAQ,EAAE,CAAC,gBAAgB,CAAC,CAAC;QAC7B,oBAAoB,EAAE,KAAK,CAAC;KAC7B,CAAC;CACH;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAAE,EAClB,IAAI,GAAE,MAAkC,EACxC,MAAM,GAAE,OAAe,GACtB,MAAM,CAyCR"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildConceptFactSchema = buildConceptFactSchema;
|
|
4
|
+
function buildConceptFactSchema(headings, name = "concept_fact_gen_schema", strict = false) {
|
|
5
|
+
const allowedRefs = [...headings, ""];
|
|
6
|
+
return {
|
|
7
|
+
name,
|
|
8
|
+
strict,
|
|
9
|
+
schema: {
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: {
|
|
12
|
+
concepts_facts: {
|
|
13
|
+
type: "array",
|
|
14
|
+
minItems: 1,
|
|
15
|
+
items: {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
text: {
|
|
19
|
+
type: "string",
|
|
20
|
+
minLength: 80,
|
|
21
|
+
maxLength: 280,
|
|
22
|
+
description: "Noun phrase or declarative fact (80–280 chars).",
|
|
23
|
+
},
|
|
24
|
+
type: {
|
|
25
|
+
type: "string",
|
|
26
|
+
enum: ["concept", "fact"],
|
|
27
|
+
description: "“concept” vs “fact”.",
|
|
28
|
+
},
|
|
29
|
+
reference: {
|
|
30
|
+
type: "string",
|
|
31
|
+
enum: allowedRefs,
|
|
32
|
+
description: "Exact heading or empty string.",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
required: ["text", "type", "reference"],
|
|
36
|
+
additionalProperties: false,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
required: ["concepts_facts"],
|
|
41
|
+
additionalProperties: false,
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=build_concept_facts_schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_concept_facts_schema.js","sourceRoot":"","sources":["../../../src/helper/schema_helper/build_concept_facts_schema.ts"],"names":[],"mappings":";;AA2CA,wDA6CC;AA7CD,SAAgB,sBAAsB,CACpC,QAAkB,EAClB,OAAe,yBAAyB,EACxC,SAAkB,KAAK;IAEvB,MAAM,WAAW,GAAG,CAAC,GAAG,QAAQ,EAAE,EAAE,CAAC,CAAC;IAEtC,OAAO;QACL,IAAI;QACJ,MAAM;QACN,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,cAAc,EAAE;oBACd,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,CAAC;oBACX,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE;4BACV,IAAI,EAAE;gCACJ,IAAI,EAAE,QAAQ;gCACd,SAAS,EAAE,EAAE;gCACb,SAAS,EAAE,GAAG;gCACd,WAAW,EAAE,iDAAiD;6BAC/D;4BACD,IAAI,EAAE;gCACJ,IAAI,EAAE,QAAQ;gCACd,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;gCACzB,WAAW,EAAE,sBAAsB;6BACpC;4BACD,SAAS,EAAE;gCACT,IAAI,EAAE,QAAQ;gCACd,IAAI,EAAE,WAAW;gCACjB,WAAW,EAAE,gCAAgC;6BAC9C;yBACF;wBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC;wBACvC,oBAAoB,EAAE,KAAK;qBAC5B;iBACF;aACF;YACD,QAAQ,EAAE,CAAC,gBAAgB,CAAC;YAC5B,oBAAoB,EAAE,KAAK;SAC5B;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { SourceTaxonomy } from "../types/source_taxonomy_type";
|
|
|
3
3
|
import { MongoConceptFactCards } from "../types/mongo_concept_fact_type";
|
|
4
4
|
import { ParsedCardType } from "../types/parsed_card_type";
|
|
5
5
|
export declare class ParseCardResponse {
|
|
6
|
-
parse(generatedData: GeneratedCardResponseType,
|
|
6
|
+
parse(generatedData: GeneratedCardResponseType, sourceTaxonomy: SourceTaxonomy, bloom_level: number): Promise<{
|
|
7
7
|
status_code: number;
|
|
8
8
|
metadata: any;
|
|
9
9
|
type: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse_card_response.d.ts","sourceRoot":"","sources":["../../src/parse/parse_card_response.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,yBAAyB,EAM1B,MAAM,+DAA+D,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EACL,qBAAqB,EAEtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,qBAAa,iBAAiB;IACtB,KAAK,CACT,aAAa,EAAE,yBAAyB,EACxC,
|
|
1
|
+
{"version":3,"file":"parse_card_response.d.ts","sourceRoot":"","sources":["../../src/parse/parse_card_response.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,yBAAyB,EAM1B,MAAM,+DAA+D,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EACL,qBAAqB,EAEtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,qBAAa,iBAAiB;IACtB,KAAK,CACT,aAAa,EAAE,yBAAyB,EACxC,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,MAAM;;;;;;;;;;;IAmHrB,UAAU,CAAC,iBAAiB,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG;IAStD,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG;IAmBhD,gBAAgB,CACd,YAAY,EAAE,GAAG,EAAE,EACnB,mBAAmB,EAAE,GAAG,EAAE,GACzB,qBAAqB,EAAE;CAkB3B"}
|
|
@@ -16,7 +16,7 @@ const parse_flash_cards_1 = require("./parse_card/parse_flash_cards");
|
|
|
16
16
|
const parse_match_card_1 = require("./parse_card/parse_match_card");
|
|
17
17
|
const parse_mcq_card_1 = require("./parse_card/parse_mcq_card");
|
|
18
18
|
class ParseCardResponse {
|
|
19
|
-
parse(generatedData,
|
|
19
|
+
parse(generatedData, sourceTaxonomy, bloom_level) {
|
|
20
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
21
|
var _a, _b;
|
|
22
22
|
let usage_data = generatedData.metadata;
|
|
@@ -91,9 +91,7 @@ class ParseCardResponse {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
|
-
|
|
95
|
-
usage_data.status = "failed";
|
|
96
|
-
}
|
|
94
|
+
usage_data.status = "failed";
|
|
97
95
|
}
|
|
98
96
|
if (cardData.length == 0) {
|
|
99
97
|
usage_data.status = "failed";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse_card_response.js","sourceRoot":"","sources":["../../src/parse/parse_card_response.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAwC;AACxC,oEAA+D;AAC/D,sEAAgE;AAChE,oEAA+D;AAC/D,gEAA2D;AAe3D,MAAa,iBAAiB;IACtB,KAAK,CACT,aAAwC,EACxC,
|
|
1
|
+
{"version":3,"file":"parse_card_response.js","sourceRoot":"","sources":["../../src/parse/parse_card_response.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAwC;AACxC,oEAA+D;AAC/D,sEAAgE;AAChE,oEAA+D;AAC/D,gEAA2D;AAe3D,MAAa,iBAAiB;IACtB,KAAK,CACT,aAAwC,EACxC,cAA8B,EAC9B,WAAmB;;;YAEnB,IAAI,UAAU,GAAG,aAAa,CAAC,QAAQ,CAAC;YACxC,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAqB,EAAE,CAAC;gBACtC,MAAM,iBAAiB,GAAG,aAAa,CAAC,iBAAiB,CAAC,UAAU,CAAC;gBAErE,IAAI,iBAAiB,KAAK,SAAS,IAAI,iBAAiB,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;oBACr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AAC,IAAI;iBAC1B,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QACD,OAAO,mBAAmB,CAAC;IAC7B,CAAC;CACF;AAxKD,8CAwKC"}
|
|
@@ -3,13 +3,21 @@ import { OpenAiService } from "../services/open_ai_service";
|
|
|
3
3
|
export declare class GenerateConceptFacts {
|
|
4
4
|
openAiService: OpenAiService;
|
|
5
5
|
openAIHelper: OpenAIHelper;
|
|
6
|
-
content:
|
|
6
|
+
content: {
|
|
7
|
+
title: string;
|
|
8
|
+
headings: string[];
|
|
9
|
+
content: any[];
|
|
10
|
+
};
|
|
7
11
|
type: string;
|
|
8
12
|
promptForConceptFacts: {
|
|
9
13
|
promptId: string;
|
|
10
14
|
version: string;
|
|
11
15
|
};
|
|
12
|
-
constructor(openAiService: OpenAiService, content:
|
|
16
|
+
constructor(openAiService: OpenAiService, content: {
|
|
17
|
+
title: string;
|
|
18
|
+
headings: string[];
|
|
19
|
+
content: any[];
|
|
20
|
+
}, type: string, promptForConceptFacts: {
|
|
13
21
|
promptId: string;
|
|
14
22
|
version: string;
|
|
15
23
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_concept_facts.d.ts","sourceRoot":"","sources":["../../src/typology_gen/generate_concept_facts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate_concept_facts.d.ts","sourceRoot":"","sources":["../../src/typology_gen/generate_concept_facts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,qBAAa,oBAAoB;IACxB,aAAa,EAAE,aAAa,CAAC;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE;QACd,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,OAAO,EAAE,GAAG,EAAE,CAAC;KAChB,CAAC;IACK,IAAI,EAAE,MAAM,CAAM;IAClB,qBAAqB,EAAE;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB,CAGC;gBAEA,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,OAAO,EAAE,GAAG,EAAE,CAAC;KAChB,EACD,IAAI,EAAE,MAAM,EACZ,qBAAqB,EAAE;QACrB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB;IAcG,QAAQ;CAiCf"}
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.GenerateConceptFacts = void 0;
|
|
13
|
+
const build_concept_facts_schema_1 = require("../helper/schema_helper/build_concept_facts_schema");
|
|
13
14
|
const openai_helper_1 = require("../helper/openai_helper");
|
|
14
15
|
class GenerateConceptFacts {
|
|
15
16
|
constructor(openAiService, content, type, promptForConceptFacts) {
|
|
@@ -26,11 +27,8 @@ class GenerateConceptFacts {
|
|
|
26
27
|
}
|
|
27
28
|
generate() {
|
|
28
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
console.log(this.promptForConceptFacts);
|
|
30
|
-
console.log(this.type == "video" ? "timecode" : "h1 heading");
|
|
31
|
-
console.log(this.content);
|
|
32
|
-
console.log(this.openAIHelper.model);
|
|
33
30
|
try {
|
|
31
|
+
const schema = (0, build_concept_facts_schema_1.buildConceptFactSchema)(this.content.headings, "concept_fact_gen_schema", true);
|
|
34
32
|
const openAiResponse = yield this.openAIHelper.openAI.responses.create({
|
|
35
33
|
model: this.openAIHelper.model,
|
|
36
34
|
prompt: {
|
|
@@ -40,11 +38,17 @@ class GenerateConceptFacts {
|
|
|
40
38
|
heading_type: this.type == "video" ? "timecode" : "h1 heading",
|
|
41
39
|
},
|
|
42
40
|
},
|
|
43
|
-
input: this.content,
|
|
41
|
+
input: JSON.stringify(this.content),
|
|
44
42
|
store: false,
|
|
43
|
+
text: {
|
|
44
|
+
format: {
|
|
45
|
+
type: "json_schema",
|
|
46
|
+
name: schema.name,
|
|
47
|
+
strict: schema.strict,
|
|
48
|
+
schema: schema.schema,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
45
51
|
});
|
|
46
|
-
console.log(openAiResponse);
|
|
47
|
-
console.log(openAiResponse.output_text);
|
|
48
52
|
return JSON.parse(openAiResponse.output_text);
|
|
49
53
|
}
|
|
50
54
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_concept_facts.js","sourceRoot":"","sources":["../../src/typology_gen/generate_concept_facts.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAuD;AAGvD,MAAa,oBAAoB;
|
|
1
|
+
{"version":3,"file":"generate_concept_facts.js","sourceRoot":"","sources":["../../src/typology_gen/generate_concept_facts.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mGAA4F;AAC5F,2DAAuD;AAGvD,MAAa,oBAAoB;IAgB/B,YACE,aAA4B,EAC5B,OAIC,EACD,IAAY,EACZ,qBAGC;QAnBI,SAAI,GAAW,EAAE,CAAC;QAClB,0BAAqB,GAGxB;YACF,QAAQ,EAAE,EAAE;YACZ,OAAO,EAAE,EAAE;SACZ,CAAC;QAcA,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,YAAY,GAAG,IAAI,4BAAY,CAClC,IAAI,CAAC,aAAa,CAAC,OAAO,EAC1B,IAAI,CAAC,aAAa,CAAC,KAAK,EACxB,IAAI,CAAC,qBAAqB,CAAC,QAAQ,EACnC,IAAI,CAAC,qBAAqB,CAAC,OAAO,CACnC,CAAC;QACF,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC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AQ3B,sBAAsB,CAAC,YAAY,EAAE,GAAG;;;;CAQ/C"}
|
|
@@ -32,7 +32,6 @@ class GenerateTypology {
|
|
|
32
32
|
try {
|
|
33
33
|
// Use OpenAI Responses API
|
|
34
34
|
const openAIHelper = new openai_helper_1.OpenAIHelper(this.openAiService.api_key, this.openAiService.model, this.promptForTypology.promptId, this.promptForTypology.version);
|
|
35
|
-
console.log(openAIHelper);
|
|
36
35
|
const openAiResponse = yield openAIHelper.openAI.responses.create({
|
|
37
36
|
model: openAIHelper.model,
|
|
38
37
|
prompt: {
|
|
@@ -45,11 +44,6 @@ class GenerateTypology {
|
|
|
45
44
|
input: this.content,
|
|
46
45
|
store: false,
|
|
47
46
|
});
|
|
48
|
-
console.log(openAiResponse);
|
|
49
|
-
// const response = await this.openAiService?.sendRequest(
|
|
50
|
-
// this.prompt,
|
|
51
|
-
// this.content
|
|
52
|
-
// );
|
|
53
47
|
openAiResponse["request_type"] = {
|
|
54
48
|
type: "breadth",
|
|
55
49
|
n: 1,
|
|
@@ -77,6 +71,7 @@ class GenerateTypology {
|
|
|
77
71
|
}
|
|
78
72
|
}
|
|
79
73
|
catch (e) {
|
|
74
|
+
console.log(e);
|
|
80
75
|
yield new logger_1.ErrorLogger({
|
|
81
76
|
type: "typology_parsing",
|
|
82
77
|
data: e.message,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_typology.js","sourceRoot":"","sources":["../../src/typology_gen/generate_typology.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"generate_typology.js","sourceRoot":"","sources":["../../src/typology_gen/generate_typology.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAkE;AAClE,sCAAwC;AAGxC,MAAa,gBAAgB;IAY3B,YACE,aAA4B,EAC5B,IAAY,EACZ,OAAe,EACf,eAA8B,EAC9B,iBAGC;QAlBI,SAAI,GAAW,EAAE,CAAC;QAClB,YAAO,GAAW,EAAE,CAAC;QACr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CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC;YAE/C,cAAc,EAAE,gBAAgB,CAAC,WAAW;YAC5C,aAAa,EAAE,gBAAgB,CAAC,aAAa;YAC7C,2BAA2B;SAC5B,CAAC;IACJ,CAAC;IAED,WAAW,CAAC,MAAqB;QAC/B,MAAM,SAAS,GAAG,CAAC,eAAe,EAAE,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;QACzE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;YAC9C,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI;YACxB,SAAS,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;SAC7D,CAAC,CAAC,CAAC;IACN,CAAC;IAEK,sBAAsB,CAAC,YAAiB;;YAC5C,YAAY,CAAC,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC;YAExC,OAAO;gBACL,WAAW,EAAE,YAAY,CAAC,WAAW;gBACrC,QAAQ,EAAE,YAAY,CAAC,QAAQ;aAChC,CAAC;QACJ,CAAC;KAAA;CACF;AAtHD,4CAsHC"}
|
package/package.json
CHANGED
package/src/bootstrap/app.ts
CHANGED
|
@@ -149,11 +149,7 @@ export class OnlyEverGenerator {
|
|
|
149
149
|
reason: "",
|
|
150
150
|
},
|
|
151
151
|
};
|
|
152
|
-
this.cardgenResponse = await this.generateCard(
|
|
153
|
-
this.promptForCardGen,
|
|
154
|
-
JSON.stringify(this.typologyResponse),
|
|
155
|
-
false
|
|
156
|
-
);
|
|
152
|
+
this.cardgenResponse = await this.generateCard(0);
|
|
157
153
|
responseToReturn.push({
|
|
158
154
|
type: "card_gen",
|
|
159
155
|
data: this.cardgenResponse,
|
|
@@ -171,21 +167,17 @@ export class OnlyEverGenerator {
|
|
|
171
167
|
}
|
|
172
168
|
}
|
|
173
169
|
|
|
174
|
-
async generateCard(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
170
|
+
async generateCard(n: number = 0) {
|
|
171
|
+
const content = {
|
|
172
|
+
title: this.parsedContent?.title,
|
|
173
|
+
concepts_facts: this.typologyResponse?.concepts_facts,
|
|
174
|
+
content: this.parsedContent?.content,
|
|
175
|
+
};
|
|
180
176
|
let generateCardsResp = await new GenerateCards(
|
|
181
|
-
this.openAiService
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
isGapFill,
|
|
186
|
-
this.parsedContent!.taxonomy,
|
|
187
|
-
n
|
|
188
|
-
);
|
|
177
|
+
this.openAiService,
|
|
178
|
+
JSON.stringify(content),
|
|
179
|
+
this.parsedContent!.taxonomy
|
|
180
|
+
).generateCards(n);
|
|
189
181
|
return generateCardsResp;
|
|
190
182
|
}
|
|
191
183
|
|
|
@@ -195,15 +187,10 @@ export class OnlyEverGenerator {
|
|
|
195
187
|
headings: this.parsedContent?.headings,
|
|
196
188
|
content: this.parsedContent?.content,
|
|
197
189
|
};
|
|
198
|
-
console.log(content);
|
|
199
|
-
console.log(this.expectedFields);
|
|
200
|
-
console.log(this.promptForSummary);
|
|
201
|
-
console.log(this.parsedContent?.type);
|
|
202
|
-
console.log(this.openAiService);
|
|
203
190
|
try {
|
|
204
191
|
let response = await new GenerateTypology(
|
|
205
192
|
this.openAiService,
|
|
206
|
-
this.parsedContent?.type ?? "
|
|
193
|
+
this.parsedContent?.type ?? "text",
|
|
207
194
|
JSON.stringify(content),
|
|
208
195
|
this.expectedFields,
|
|
209
196
|
this.promptForSummary
|
|
@@ -216,14 +203,14 @@ export class OnlyEverGenerator {
|
|
|
216
203
|
|
|
217
204
|
async generateConceptFacts() {
|
|
218
205
|
const content = {
|
|
219
|
-
title: this.parsedContent?.title,
|
|
220
|
-
headings: this.parsedContent?.headings,
|
|
221
|
-
content: this.parsedContent?.content,
|
|
206
|
+
title: this.parsedContent?.title ?? "",
|
|
207
|
+
headings: this.parsedContent?.headings ?? [],
|
|
208
|
+
content: this.parsedContent?.content ?? [],
|
|
222
209
|
};
|
|
223
210
|
let response = await new GenerateConceptFacts(
|
|
224
211
|
this.openAiService,
|
|
225
|
-
|
|
226
|
-
this.parsedContent?.type ?? "
|
|
212
|
+
content,
|
|
213
|
+
this.parsedContent?.type ?? "text",
|
|
227
214
|
this.promptForConceptFacts
|
|
228
215
|
).generate();
|
|
229
216
|
return response;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OpenAIHelper } from "../helper/openai_helper";
|
|
1
2
|
import { ErrorLogger } from "../logger";
|
|
2
3
|
import { ParseCardResponse } from "../parse/parse_card_response";
|
|
3
4
|
import { OpenAiService } from "../services/open_ai_service";
|
|
@@ -6,22 +7,55 @@ import { SourceTaxonomy } from "../types/source_taxonomy_type";
|
|
|
6
7
|
|
|
7
8
|
export class GenerateCards {
|
|
8
9
|
openAiService: OpenAiService;
|
|
9
|
-
|
|
10
|
+
public content: string;
|
|
11
|
+
public taxonomy: SourceTaxonomy;
|
|
12
|
+
openAIHelper: OpenAIHelper;
|
|
13
|
+
promptForCardsGeneration: {
|
|
14
|
+
promptId: string;
|
|
15
|
+
version: string;
|
|
16
|
+
} = {
|
|
17
|
+
promptId: "",
|
|
18
|
+
version: "",
|
|
19
|
+
};
|
|
20
|
+
constructor(
|
|
21
|
+
openAiService: OpenAiService,
|
|
22
|
+
content: string,
|
|
23
|
+
taxonomy: SourceTaxonomy
|
|
24
|
+
) {
|
|
10
25
|
this.openAiService = openAiService;
|
|
26
|
+
this.openAIHelper = new OpenAIHelper(
|
|
27
|
+
this.openAiService.api_key,
|
|
28
|
+
this.openAiService.model,
|
|
29
|
+
this.promptForCardsGeneration.promptId,
|
|
30
|
+
this.promptForCardsGeneration.version
|
|
31
|
+
);
|
|
32
|
+
this.content = content;
|
|
33
|
+
this.taxonomy = taxonomy;
|
|
11
34
|
}
|
|
12
35
|
|
|
13
|
-
async generateCards(
|
|
14
|
-
prompt: string,
|
|
15
|
-
parsedContent: string,
|
|
16
|
-
isGapFill: boolean,
|
|
17
|
-
taxonomy: SourceTaxonomy,
|
|
18
|
-
n: number = 0
|
|
19
|
-
) {
|
|
36
|
+
async generateCards(n: number = 0) {
|
|
20
37
|
try {
|
|
21
|
-
let response = await this.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
38
|
+
let response: any = await this.openAIHelper.openAI.responses.create({
|
|
39
|
+
model: this.openAIHelper.model,
|
|
40
|
+
prompt: {
|
|
41
|
+
id: this.promptForCardsGeneration.promptId,
|
|
42
|
+
version: this.promptForCardsGeneration.version,
|
|
43
|
+
variables: {
|
|
44
|
+
bloom_level: "1",
|
|
45
|
+
card_types: "MCQ,Cloze,Match,Flash",
|
|
46
|
+
bloom_instructions: "",
|
|
47
|
+
card_instructions: "",
|
|
48
|
+
card_examples: "",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
input: this.content,
|
|
53
|
+
store: false,
|
|
54
|
+
});
|
|
55
|
+
// let response = await this.openAiService?.sendRequest(
|
|
56
|
+
// prompt,
|
|
57
|
+
// parsedContent
|
|
58
|
+
// );
|
|
25
59
|
var updatedNumber = n + 1;
|
|
26
60
|
response.metadata = {
|
|
27
61
|
req_time: response.generated_at ?? new Date(),
|
|
@@ -60,8 +94,7 @@ export class GenerateCards {
|
|
|
60
94
|
};
|
|
61
95
|
let parseCard = new ParseCardResponse().parse(
|
|
62
96
|
generated_data,
|
|
63
|
-
|
|
64
|
-
taxonomy,
|
|
97
|
+
this.taxonomy,
|
|
65
98
|
1
|
|
66
99
|
);
|
|
67
100
|
return parseCard;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
type ConceptFactType = "concept" | "fact";
|
|
2
|
+
|
|
3
|
+
interface ConceptFactSchemaItem {
|
|
4
|
+
text: {
|
|
5
|
+
type: "string";
|
|
6
|
+
minLength: number;
|
|
7
|
+
maxLength: number;
|
|
8
|
+
description: string;
|
|
9
|
+
};
|
|
10
|
+
type: {
|
|
11
|
+
type: "string";
|
|
12
|
+
enum: ConceptFactType[];
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
15
|
+
reference: {
|
|
16
|
+
type: "string";
|
|
17
|
+
enum: string[];
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface Schema {
|
|
23
|
+
name: string;
|
|
24
|
+
strict: boolean;
|
|
25
|
+
schema: {
|
|
26
|
+
type: "object";
|
|
27
|
+
properties: {
|
|
28
|
+
concepts_facts: {
|
|
29
|
+
type: "array";
|
|
30
|
+
minItems: number;
|
|
31
|
+
items: {
|
|
32
|
+
type: "object";
|
|
33
|
+
properties: ConceptFactSchemaItem;
|
|
34
|
+
required: ["text", "type", "reference"];
|
|
35
|
+
additionalProperties: false;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
required: ["concepts_facts"];
|
|
40
|
+
additionalProperties: false;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function buildConceptFactSchema(
|
|
45
|
+
headings: string[],
|
|
46
|
+
name: string = "concept_fact_gen_schema",
|
|
47
|
+
strict: boolean = false
|
|
48
|
+
): Schema {
|
|
49
|
+
const allowedRefs = [...headings, ""];
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
name,
|
|
53
|
+
strict,
|
|
54
|
+
schema: {
|
|
55
|
+
type: "object",
|
|
56
|
+
properties: {
|
|
57
|
+
concepts_facts: {
|
|
58
|
+
type: "array",
|
|
59
|
+
minItems: 1,
|
|
60
|
+
items: {
|
|
61
|
+
type: "object",
|
|
62
|
+
properties: {
|
|
63
|
+
text: {
|
|
64
|
+
type: "string",
|
|
65
|
+
minLength: 80,
|
|
66
|
+
maxLength: 280,
|
|
67
|
+
description: "Noun phrase or declarative fact (80–280 chars).",
|
|
68
|
+
},
|
|
69
|
+
type: {
|
|
70
|
+
type: "string",
|
|
71
|
+
enum: ["concept", "fact"],
|
|
72
|
+
description: "“concept” vs “fact”.",
|
|
73
|
+
},
|
|
74
|
+
reference: {
|
|
75
|
+
type: "string",
|
|
76
|
+
enum: allowedRefs,
|
|
77
|
+
description: "Exact heading or empty string.",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
required: ["text", "type", "reference"],
|
|
81
|
+
additionalProperties: false,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
required: ["concepts_facts"],
|
|
86
|
+
additionalProperties: false,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -20,7 +20,6 @@ import { ParsedCardType } from "../types/parsed_card_type";
|
|
|
20
20
|
export class ParseCardResponse {
|
|
21
21
|
async parse(
|
|
22
22
|
generatedData: GeneratedCardResponseType,
|
|
23
|
-
isGapFill: boolean,
|
|
24
23
|
sourceTaxonomy: SourceTaxonomy,
|
|
25
24
|
bloom_level: number
|
|
26
25
|
) {
|
|
@@ -107,9 +106,7 @@ export class ParseCardResponse {
|
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
} else {
|
|
110
|
-
|
|
111
|
-
usage_data.status = "failed";
|
|
112
|
-
}
|
|
109
|
+
usage_data.status = "failed";
|
|
113
110
|
}
|
|
114
111
|
if (cardData.length == 0) {
|
|
115
112
|
usage_data.status = "failed";
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
import { buildConceptFactSchema } from "../helper/schema_helper/build_concept_facts_schema";
|
|
1
2
|
import { OpenAIHelper } from "../helper/openai_helper";
|
|
2
3
|
import { OpenAiService } from "../services/open_ai_service";
|
|
3
4
|
|
|
4
5
|
export class GenerateConceptFacts {
|
|
5
6
|
public openAiService: OpenAiService;
|
|
6
7
|
public openAIHelper: OpenAIHelper;
|
|
7
|
-
public content:
|
|
8
|
+
public content: {
|
|
9
|
+
title: string;
|
|
10
|
+
headings: string[];
|
|
11
|
+
content: any[];
|
|
12
|
+
};
|
|
8
13
|
public type: string = "";
|
|
9
14
|
public promptForConceptFacts: {
|
|
10
15
|
promptId: string;
|
|
@@ -15,7 +20,11 @@ export class GenerateConceptFacts {
|
|
|
15
20
|
};
|
|
16
21
|
constructor(
|
|
17
22
|
openAiService: OpenAiService,
|
|
18
|
-
content:
|
|
23
|
+
content: {
|
|
24
|
+
title: string;
|
|
25
|
+
headings: string[];
|
|
26
|
+
content: any[];
|
|
27
|
+
},
|
|
19
28
|
type: string,
|
|
20
29
|
promptForConceptFacts: {
|
|
21
30
|
promptId: string;
|
|
@@ -35,11 +44,12 @@ export class GenerateConceptFacts {
|
|
|
35
44
|
}
|
|
36
45
|
|
|
37
46
|
async generate() {
|
|
38
|
-
console.log(this.promptForConceptFacts);
|
|
39
|
-
console.log(this.type == "video" ? "timecode" : "h1 heading");
|
|
40
|
-
console.log(this.content);
|
|
41
|
-
console.log(this.openAIHelper.model);
|
|
42
47
|
try {
|
|
48
|
+
const schema = buildConceptFactSchema(
|
|
49
|
+
this.content.headings,
|
|
50
|
+
"concept_fact_gen_schema",
|
|
51
|
+
true
|
|
52
|
+
);
|
|
43
53
|
const openAiResponse = await this.openAIHelper.openAI.responses.create({
|
|
44
54
|
model: this.openAIHelper.model,
|
|
45
55
|
prompt: {
|
|
@@ -49,11 +59,18 @@ export class GenerateConceptFacts {
|
|
|
49
59
|
heading_type: this.type == "video" ? "timecode" : "h1 heading",
|
|
50
60
|
},
|
|
51
61
|
},
|
|
52
|
-
input: this.content,
|
|
62
|
+
input: JSON.stringify(this.content),
|
|
53
63
|
store: false,
|
|
64
|
+
text: {
|
|
65
|
+
format: {
|
|
66
|
+
type: "json_schema",
|
|
67
|
+
name: schema.name,
|
|
68
|
+
strict: schema.strict,
|
|
69
|
+
schema: schema.schema,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
54
72
|
});
|
|
55
|
-
|
|
56
|
-
console.log(openAiResponse.output_text);
|
|
73
|
+
|
|
57
74
|
return JSON.parse(openAiResponse.output_text);
|
|
58
75
|
} catch (error) {
|
|
59
76
|
console.log(error);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OpenAIHelper } from "../helper/openai_helper";
|
|
1
|
+
import { getOpenAI, OpenAIHelper } from "../helper/openai_helper";
|
|
2
2
|
import { ErrorLogger } from "../logger";
|
|
3
3
|
import { OpenAiService } from "../services/open_ai_service";
|
|
4
4
|
|
|
@@ -41,7 +41,7 @@ export class GenerateTypology {
|
|
|
41
41
|
this.promptForTypology.promptId,
|
|
42
42
|
this.promptForTypology.version
|
|
43
43
|
);
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
const openAiResponse: any = await openAIHelper.openAI.responses.create({
|
|
46
46
|
model: openAIHelper.model,
|
|
47
47
|
prompt: {
|
|
@@ -54,12 +54,7 @@ export class GenerateTypology {
|
|
|
54
54
|
input: this.content,
|
|
55
55
|
store: false,
|
|
56
56
|
});
|
|
57
|
-
console.log(openAiResponse);
|
|
58
57
|
|
|
59
|
-
// const response = await this.openAiService?.sendRequest(
|
|
60
|
-
// this.prompt,
|
|
61
|
-
// this.content
|
|
62
|
-
// );
|
|
63
58
|
openAiResponse["request_type"] = {
|
|
64
59
|
type: "breadth",
|
|
65
60
|
n: 1,
|
|
@@ -86,6 +81,7 @@ export class GenerateTypology {
|
|
|
86
81
|
return openAiResponse;
|
|
87
82
|
}
|
|
88
83
|
} catch (e: any) {
|
|
84
|
+
console.log(e);
|
|
89
85
|
await new ErrorLogger({
|
|
90
86
|
type: "typology_parsing",
|
|
91
87
|
data: e.message,
|