only_ever_generator 8.0.7 → 8.0.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.d.ts +3 -2
- package/dist/bootstrap/app.d.ts.map +1 -1
- package/dist/bootstrap/app.js +4 -4
- package/dist/bootstrap/app.js.map +1 -1
- package/dist/card_gen/generate_cards.d.ts +12 -2
- package/dist/card_gen/generate_cards.d.ts.map +1 -1
- package/dist/card_gen/generate_cards.js +42 -6
- package/dist/card_gen/generate_cards.js.map +1 -1
- package/dist/helper/schema_helper/build_card_schema.d.ts +1 -1
- package/dist/helper/schema_helper/build_card_schema.d.ts.map +1 -1
- package/dist/helper/schema_helper/build_card_schema.js +34 -1
- package/dist/helper/schema_helper/build_card_schema.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +82 -65
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +2 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/services/get_prompts.d.ts +1 -1
- package/dist/services/get_prompts.d.ts.map +1 -1
- package/dist/services/get_prompts.js +16 -3
- package/dist/services/get_prompts.js.map +1 -1
- package/package.json +1 -1
- package/src/bootstrap/app.ts +14 -7
- package/src/card_gen/generate_cards.ts +65 -6
- package/src/helper/schema_helper/build_card_schema.ts +45 -1
- package/src/index.ts +89 -70
- package/src/logger.ts +2 -0
- package/src/services/get_prompts.ts +22 -3
package/dist/bootstrap/app.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GenerateCardsResponseList } from "../card_gen/generate_cards";
|
|
1
2
|
import { OpenAiService } from "../services/open_ai_service";
|
|
2
3
|
import { BaseParamType } from "../types/base_param_type";
|
|
3
4
|
import { SourceTaxonomy } from "../types/source_taxonomy_type";
|
|
@@ -26,7 +27,7 @@ export declare class OnlyEverGenerator {
|
|
|
26
27
|
};
|
|
27
28
|
expectedFields: Array<string>;
|
|
28
29
|
typologyResponse?: any;
|
|
29
|
-
cardgenResponse:
|
|
30
|
+
cardgenResponse: GenerateCardsResponseList;
|
|
30
31
|
summarizeResponse: {};
|
|
31
32
|
constructor(apiKey: string, model: string, generationContent: BaseParamType, promptIdForTypology: string, promptIdForConceptFacts: string, promptIdForCardsGeneration: string, generationVariables: {
|
|
32
33
|
bloom_instructions: string;
|
|
@@ -35,7 +36,7 @@ export declare class OnlyEverGenerator {
|
|
|
35
36
|
}, generationCurriculum: boolean, n: number | undefined);
|
|
36
37
|
generate(generate_typology?: boolean, generate_card?: boolean, card_generation_types?: string[]): Promise<Array<any>>;
|
|
37
38
|
shouldTheCardBeGeneratedAfterTypologyResponse(): boolean;
|
|
38
|
-
generateCard(n: number): Promise<
|
|
39
|
+
generateCard(n: number, card_generation_types: string[]): Promise<GenerateCardsResponseList>;
|
|
39
40
|
generateTypology(): Promise<any>;
|
|
40
41
|
generateConceptFacts(typologyResponse: any): Promise<{
|
|
41
42
|
concepts_facts: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/bootstrap/app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/bootstrap/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,EAC1B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAM5D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAI/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,EAA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AAgB,EAAE,GAAG;;;;IA0B1C,kBAAkB,CAAC,gBAAgB,EAAE,GAAG;;;;;;;;;;;;;;;;;;IASxC,kBAAkB,CACtB,cAAc,EAAE;QACd,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,EAAE,CAAC;KACrB,EAAE,EACH,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;;;;;;IASZ,mBAAmB,CACvB,cAAc,EAAE;QACd,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,EAAE,CAAC;KACrB,EAAE,EACH,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;CAUpB"}
|
package/dist/bootstrap/app.js
CHANGED
|
@@ -35,7 +35,7 @@ class OnlyEverGenerator {
|
|
|
35
35
|
};
|
|
36
36
|
this.expectedFields = [];
|
|
37
37
|
this.typologyResponse = undefined;
|
|
38
|
-
this.cardgenResponse =
|
|
38
|
+
this.cardgenResponse = [];
|
|
39
39
|
this.summarizeResponse = {};
|
|
40
40
|
this.promptIdForTypology = promptIdForTypology;
|
|
41
41
|
this.promptIdForConceptFacts = promptIdForConceptFacts;
|
|
@@ -122,7 +122,7 @@ class OnlyEverGenerator {
|
|
|
122
122
|
bloom_levels_reason: "",
|
|
123
123
|
},
|
|
124
124
|
};
|
|
125
|
-
this.cardgenResponse = yield this.generateCard(this.n);
|
|
125
|
+
this.cardgenResponse = yield this.generateCard(this.n, card_generation_types);
|
|
126
126
|
responseToReturn.push({
|
|
127
127
|
type: "card_gen",
|
|
128
128
|
data: this.cardgenResponse,
|
|
@@ -146,7 +146,7 @@ class OnlyEverGenerator {
|
|
|
146
146
|
return false;
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
generateCard(n) {
|
|
149
|
+
generateCard(n, card_generation_types) {
|
|
150
150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
151
|
var _a, _b, _c, _d, _e;
|
|
152
152
|
const content = {
|
|
@@ -154,7 +154,7 @@ class OnlyEverGenerator {
|
|
|
154
154
|
concepts_facts: (_b = this.typologyResponse) === null || _b === void 0 ? void 0 : _b.concepts_facts,
|
|
155
155
|
content: (_c = this.parsedContent) === null || _c === void 0 ? void 0 : _c.content,
|
|
156
156
|
};
|
|
157
|
-
let generateCardsResp = yield new generate_cards_1.GenerateCards(this.openAiService, (_e = (_d = this.parsedContent) === null || _d === void 0 ? void 0 : _d.source_id) !== null && _e !== void 0 ? _e : "", JSON.stringify(content), this.parsedContent.taxonomy, this.generationVariables, this.promptIdForCardsGeneration, this.generationCurriculum).generateCards(n);
|
|
157
|
+
let generateCardsResp = yield new generate_cards_1.GenerateCards(this.openAiService, (_e = (_d = this.parsedContent) === null || _d === void 0 ? void 0 : _d.source_id) !== null && _e !== void 0 ? _e : "", JSON.stringify(content), this.parsedContent.taxonomy, this.generationVariables, this.promptIdForCardsGeneration, this.generationCurriculum).generateCards(n, card_generation_types);
|
|
158
158
|
return generateCardsResp;
|
|
159
159
|
});
|
|
160
160
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/bootstrap/app.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/bootstrap/app.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAGoC;AACpC,wEAAmE;AACnE,iEAA4D;AAC5D,yEAAqE;AACrE,0DAAsD;AACtD,qFAAiF;AACjF,mGAA+F;AAC/F,qGAAiG;AAIjG,mFAA8E;AAE9E,MAAa,iBAAiB;IAkC5B,YACE,MAAc,EACd,KAAa,EACb,iBAAgC,EAChC,mBAA2B,EAC3B,uBAA+B,EA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C,OAAO,UAAU,CAAC;QACpB,CAAC;KAAA;IAEK,kBAAkB,CACtB,cAKG,EACH,QAAgB;;YAEhB,MAAM,UAAU,GAAG,IAAI,wCAAkB,EAAE,CAAC,WAAW,CACrD,cAAc,EACd,QAAQ,CACT,CAAC;YACF,OAAO,UAAU,CAAC;QACpB,CAAC;KAAA;IAEK,mBAAmB,CACvB,cAMG,EACH,QAAgB,EAChB,SAAiB;;YAEjB,MAAM,UAAU,GAAG,MAAM,IAAI,0CAAmB,EAAE,CAAC,WAAW,CAC5D,cAAc,EACd,QAAQ,EACR,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,GAAG,CACjB,CAAC;YAEF,OAAO,UAAU,CAAC;QACpB,CAAC;KAAA;CACF;AA/SD,8CA+SC"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { OpenAIHelper } from "../helper/openai_helper";
|
|
2
2
|
import { OpenAiService } from "../services/open_ai_service";
|
|
3
3
|
import { SourceTaxonomy } from "../types/source_taxonomy_type";
|
|
4
|
+
import { ParsedCardType } from "../types/parsed_card_type";
|
|
5
|
+
type GenerateCardsResponse = {
|
|
6
|
+
status_code: number;
|
|
7
|
+
metadata: any;
|
|
8
|
+
type: string;
|
|
9
|
+
cards_data?: ParsedCardType[];
|
|
10
|
+
};
|
|
11
|
+
export type GenerateCardsResponseList = (GenerateCardsResponse | undefined)[];
|
|
4
12
|
export declare class GenerateCards {
|
|
5
13
|
openAiService: OpenAiService;
|
|
6
14
|
content: string;
|
|
@@ -19,8 +27,10 @@ export declare class GenerateCards {
|
|
|
19
27
|
card_instructions: string;
|
|
20
28
|
card_examples: string;
|
|
21
29
|
}, promptIdForCardsGeneration: string, generationCurriculum: boolean);
|
|
22
|
-
openAIResponse(): Promise<any>;
|
|
23
|
-
generateCards(n: number): Promise<
|
|
30
|
+
openAIResponse(card_generation_types: string[]): Promise<any>;
|
|
31
|
+
generateCards(n: number, card_generation_types: string[]): Promise<GenerateCardsResponseList>;
|
|
32
|
+
generateCardsForType(n: number, card_generation_type: string): Promise<GenerateCardsResponse | undefined>;
|
|
24
33
|
parseJson(response: any): any;
|
|
25
34
|
}
|
|
35
|
+
export {};
|
|
26
36
|
//# 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":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAOvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;
|
|
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;AAOvD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,KAAK,qBAAqB,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;CAC/B,CAAC;AAGF,MAAM,MAAM,yBAAyB,GAAG,CAAC,qBAAqB,GAAG,SAAS,CAAC,EAAE,CAAC;AAE9E,qBAAa,aAAa;IACxB,aAAa,EAAE,aAAa,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,cAAc,CAAC;IACzB,mBAAmB,EAAE;QAC1B,kBAAkB,EAAE,MAAM,CAAC;QAC3B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,YAAY,EAAE,YAAY,CAAC;IACpB,0BAA0B,EAAE,MAAM,CAAC;IACnC,oBAAoB,EAAE,OAAO,CAAC;gBAEnC,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,cAAc,EACxB,mBAAmB,EAAE;QACnB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,iBAAiB,EAAE,MAAM,CAAC;QAC1B,aAAa,EAAE,MAAM,CAAC;KACvB,EACD,0BAA0B,EAAE,MAAM,EAClC,oBAAoB,EAAE,OAAO;IAYzB,cAAc,CAAC,qBAAqB,EAAE,MAAM,EAAE;IA8F9C,aAAa,CACjB,CAAC,EAAE,MAAM,EACT,qBAAqB,EAAE,MAAM,EAAE,GAC9B,OAAO,CAAC,yBAAyB,CAAC;IAwC/B,oBAAoB,CACxB,CAAC,EAAE,MAAM,EACT,oBAAoB,EAAE,MAAM,GAC3B,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IAqE7C,SAAS,CAAC,QAAQ,EAAE,GAAG;CAWxB"}
|
|
@@ -25,7 +25,7 @@ class GenerateCards {
|
|
|
25
25
|
this.promptIdForCardsGeneration = promptIdForCardsGeneration;
|
|
26
26
|
this.generationCurriculum = generationCurriculum;
|
|
27
27
|
}
|
|
28
|
-
openAIResponse() {
|
|
28
|
+
openAIResponse(card_generation_types) {
|
|
29
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
30
|
const concepts = this.taxonomy.concepts_facts
|
|
31
31
|
.filter((concept) => concept.type === "concept")
|
|
@@ -33,14 +33,14 @@ class GenerateCards {
|
|
|
33
33
|
const facts = this.taxonomy.concepts_facts
|
|
34
34
|
.filter((fact) => fact.type === "fact")
|
|
35
35
|
.map((fact) => fact.text);
|
|
36
|
-
const schema = yield (0, build_card_schema_1.buildCardSchema)(concepts, facts);
|
|
36
|
+
const schema = yield (0, build_card_schema_1.buildCardSchema)(concepts, facts, card_generation_types);
|
|
37
37
|
try {
|
|
38
38
|
let response = yield this.openAIHelper.openAI.responses.create({
|
|
39
39
|
prompt: {
|
|
40
40
|
id: this.promptIdForCardsGeneration,
|
|
41
41
|
variables: {
|
|
42
42
|
bloom_level: "1",
|
|
43
|
-
card_types: "
|
|
43
|
+
card_types: card_generation_types.join(","),
|
|
44
44
|
bloom_instructions: this.generationVariables.bloom_instructions,
|
|
45
45
|
card_instructions: this.generationVariables.card_instructions,
|
|
46
46
|
card_examples: this.generationVariables.card_examples,
|
|
@@ -116,21 +116,55 @@ class GenerateCards {
|
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
generateCards(n) {
|
|
119
|
+
generateCards(n, card_generation_types) {
|
|
120
120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
var _a, _b, _c, _d;
|
|
122
121
|
try {
|
|
123
122
|
// let response = await this.openAiService?.sendRequest(
|
|
124
123
|
// prompt,
|
|
125
124
|
// parsedContent
|
|
126
125
|
// );
|
|
127
126
|
console.log("generation started");
|
|
128
|
-
let
|
|
127
|
+
let responses = yield Promise.all(card_generation_types.map((card_generation_type) => __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
return yield this.generateCardsForType(n, card_generation_type);
|
|
129
|
+
})));
|
|
130
|
+
// Flatten all parsed cards from all responses
|
|
131
|
+
// const allParsedCards: AllParsedCards = [];
|
|
132
|
+
// for (const response of responses) {
|
|
133
|
+
// if (response && response.cards_data) {
|
|
134
|
+
// allParsedCards.push(...response.cards_data);
|
|
135
|
+
// }
|
|
136
|
+
// }
|
|
137
|
+
return responses;
|
|
138
|
+
}
|
|
139
|
+
catch (e) {
|
|
140
|
+
yield (0, logger_1.log_error)({
|
|
141
|
+
flow: this.generationCurriculum
|
|
142
|
+
? "curriculum_manual_generation"
|
|
143
|
+
: "manual_generation",
|
|
144
|
+
data: e,
|
|
145
|
+
timestamp: new Date(),
|
|
146
|
+
error: "error_in_card_generation",
|
|
147
|
+
source_id: this.sourceId,
|
|
148
|
+
type: {
|
|
149
|
+
request_type: "depth",
|
|
150
|
+
n: n,
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
generateCardsForType(n, card_generation_type) {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
var _a, _b, _c, _d;
|
|
160
|
+
try {
|
|
161
|
+
let response = yield this.openAIResponse([card_generation_type]);
|
|
129
162
|
response.metadata = {
|
|
130
163
|
req_time: (_a = response.generated_at) !== null && _a !== void 0 ? _a : new Date(),
|
|
131
164
|
req_type: {
|
|
132
165
|
type: "depth",
|
|
133
166
|
n: n,
|
|
167
|
+
card_types: card_generation_type,
|
|
134
168
|
bloom_level: 1,
|
|
135
169
|
},
|
|
136
170
|
req_tokens: (_b = response.usage_data) === null || _b === void 0 ? void 0 : _b.prompt_tokens,
|
|
@@ -182,6 +216,8 @@ class GenerateCards {
|
|
|
182
216
|
type: {
|
|
183
217
|
request_type: "depth",
|
|
184
218
|
n: n,
|
|
219
|
+
card_types: card_generation_type,
|
|
220
|
+
bloom_level: 1,
|
|
185
221
|
},
|
|
186
222
|
});
|
|
187
223
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_cards.js","sourceRoot":"","sources":["../../src/card_gen/generate_cards.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAuD;AACvD,iFAGmD;AACnD,sCAAiE;AACjE,sEAAiE;
|
|
1
|
+
{"version":3,"file":"generate_cards.js","sourceRoot":"","sources":["../../src/card_gen/generate_cards.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAuD;AACvD,iFAGmD;AACnD,sCAAiE;AACjE,sEAAiE;AAiBjE,MAAa,aAAa;IAaxB,YACE,aAA4B,EAC5B,QAAgB,EAChB,OAAe,EACf,QAAwB,EACxB,mBAIC,EACD,0BAAkC,EAClC,oBAA6B;QAE7B,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AA8B;wBAChC,CAAC,CAAC,mBAAmB;oBACvB,IAAI,EAAE,CAAC;oBACP,SAAS,EAAE,IAAI,IAAI,EAAE;oBACrB,KAAK,EAAE,0BAA0B;oBACjC,SAAS,EAAE,IAAI,CAAC,QAAQ;oBACxB,IAAI,EAAE;wBACJ,YAAY,EAAE,OAAO;wBACrB,CAAC,EAAE,CAAC;wBACJ,UAAU,EAAE,oBAAoB;wBAChC,WAAW,EAAE,CAAC;qBACf;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;KAAA;IAED,SAAS,CAAC,QAAa;QACrB,IAAI,CAAC;YACH,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC;YACnE,OAAO,cAAc,CAAC;QACxB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,qBAAY,CACpB,0CAA0C,EAC1C,QAAQ,CACT,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAhQD,sCAgQC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const buildCardSchema: (concepts: string[], facts: string[]) => Promise<any>;
|
|
1
|
+
export declare const buildCardSchema: (concepts: string[], facts: string[], card_generation_types: string[]) => Promise<any>;
|
|
2
2
|
export declare const cardSchema: (concepts: string[], facts: string[]) => {
|
|
3
3
|
type: string;
|
|
4
4
|
properties: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_card_schema.d.ts","sourceRoot":"","sources":["../../../src/helper/schema_helper/build_card_schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build_card_schema.d.ts","sourceRoot":"","sources":["../../../src/helper/schema_helper/build_card_schema.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAAE,EAClB,OAAO,MAAM,EAAE,EACf,uBAAuB,MAAM,EAAE,iBA+DhC,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,UAAU,MAAM,EAAE,EAAE,OAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiJ7D,CAAC"}
|
|
@@ -12,7 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.cardSchema = exports.buildCardSchema = void 0;
|
|
13
13
|
const sanitize_strings_1 = require("../../utils/sanitize_strings");
|
|
14
14
|
const mongo_helper_1 = require("../mongo_helper");
|
|
15
|
-
|
|
15
|
+
// flash:68ef4e1b5a123c94a835c6ab
|
|
16
|
+
// cloze:68ef4eb45a123c94a835c6ac
|
|
17
|
+
// mcq:68ef4f095a123c94a835c6ad
|
|
18
|
+
// match:68ef4fae5a123c94a835c6ae
|
|
19
|
+
const buildCardSchema = (concepts, facts, card_generation_types) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
20
|
(0, mongo_helper_1.setUp)();
|
|
17
21
|
const objectId = new mongo_helper_1.ObjectId("689c5cbd0d9d3bbda64b9584");
|
|
18
22
|
const schemaObj = yield mongo_helper_1.database.collection("_prompts").findOne({
|
|
@@ -27,12 +31,41 @@ const buildCardSchema = (concepts, facts) => __awaiter(void 0, void 0, void 0, f
|
|
|
27
31
|
}
|
|
28
32
|
const conceptsSanitized = (0, sanitize_strings_1.sanitizeStringsForSchema)(concepts);
|
|
29
33
|
const factsSanitized = (0, sanitize_strings_1.sanitizeStringsForSchema)(facts);
|
|
34
|
+
// Fetch individual card type schemas based on card_generation_types
|
|
35
|
+
const cardTypeObjectIds = {
|
|
36
|
+
flash: new mongo_helper_1.ObjectId("68ef4e1b5a123c94a835c6ab"),
|
|
37
|
+
cloze: new mongo_helper_1.ObjectId("68ef4eb45a123c94a835c6ac"),
|
|
38
|
+
mcq: new mongo_helper_1.ObjectId("68ef4f095a123c94a835c6ad"),
|
|
39
|
+
match: new mongo_helper_1.ObjectId("68ef4fae5a123c94a835c6ae"),
|
|
40
|
+
};
|
|
41
|
+
const cardTypeSchemas = {};
|
|
42
|
+
// Only fetch schemas for the requested card types
|
|
43
|
+
for (const cardType of card_generation_types) {
|
|
44
|
+
if (cardTypeObjectIds[cardType]) {
|
|
45
|
+
const cardSchemaObj = yield mongo_helper_1.database.collection("_prompts").findOne({
|
|
46
|
+
_id: cardTypeObjectIds[cardType],
|
|
47
|
+
});
|
|
48
|
+
if (cardSchemaObj && cardSchemaObj.schema) {
|
|
49
|
+
cardTypeSchemas[cardType] = JSON.parse(cardSchemaObj.schema);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
30
53
|
// Deep clone to avoid mutating the original
|
|
31
54
|
const populatedSchema = JSON.parse(schema);
|
|
32
55
|
populatedSchema.schema.properties.test_cards.items.properties.concepts.items.enum =
|
|
33
56
|
conceptsSanitized;
|
|
34
57
|
populatedSchema.schema.properties.test_cards.items.properties.facts.items.enum =
|
|
35
58
|
factsSanitized;
|
|
59
|
+
// Replace the type enum with the requested card generation types
|
|
60
|
+
populatedSchema.schema.properties.test_cards.items.properties.type.enum =
|
|
61
|
+
card_generation_types;
|
|
62
|
+
// Replace anyOf array with individual schemas based on card type
|
|
63
|
+
if (Object.keys(cardTypeSchemas).length > 0) {
|
|
64
|
+
populatedSchema.schema.properties.test_cards.items.properties.card_content =
|
|
65
|
+
{
|
|
66
|
+
anyOf: Object.values(cardTypeSchemas),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
36
69
|
console.log("Populated Schema", JSON.stringify(populatedSchema.schema.properties.test_cards.items, null, 2));
|
|
37
70
|
return populatedSchema;
|
|
38
71
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_card_schema.js","sourceRoot":"","sources":["../../../src/helper/schema_helper/build_card_schema.ts"],"names":[],"mappings":";;;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Y,CAAC;gDAClC,oBAAoB,EAAE,KAAK;6CAC5B;yCACF;wCACD,mDAAmD;qCACpD;oCACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;oCAC/B,oBAAoB,EAAE,KAAK;iCAC5B;6BACF;yBACF;wBACD,WAAW,EAAE;4BACX,IAAI,EAAE,QAAQ;4BACd,SAAS,EAAE,GAAG;4BACd,WAAW,EACT,8CAA8C;gCAC9C,2DAA2D;gCAC3D,0FAA0F;gCAC1F,oFAAoF;gCACpF,kFAAkF;yBACrF;wBACD,QAAQ,EAAE;4BACR,IAAI,EAAE,OAAO;4BACb,QAAQ,EAAE,CAAC;4BACX,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;yBAC1C;wBACD,KAAK,EAAE;4BACL,IAAI,EAAE,OAAO;4BACb,QAAQ,EAAE,CAAC;4BACX,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE;yBACvC;wBACD,eAAe,EAAE;4BACf,IAAI,EAAE,QAAQ;4BACd,SAAS,EAAE,GAAG;4BACd,WAAW,EACT,sFAAsF;yBACzF;qBACF;oBACD,QAAQ,EAAE;wBACR,MAAM;wBACN,cAAc;wBACd,UAAU;wBACV,OAAO;wBACP,iBAAiB;wBACjB,aAAa;qBACd;oBACD,oBAAoB,EAAE,KAAK;iBAC5B;aACF;SACF;QACD,QAAQ,EAAE,CAAC,YAAY,CAAC;QACxB,oBAAoB,EAAE,KAAK;KAC5B,CAAC;AACJ,CAAC,CAAC;AAjJW,QAAA,UAAU,cAiJrB"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAyBpD,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.OnlyEverGenerator = void 0;
|
|
4
13
|
const app_1 = require("./bootstrap/app");
|
|
5
14
|
Object.defineProperty(exports, "OnlyEverGenerator", { enumerable: true, get: function () { return app_1.OnlyEverGenerator; } });
|
|
15
|
+
const mongo_helper_1 = require("./helper/mongo_helper");
|
|
16
|
+
const get_prompts_1 = require("./services/get_prompts");
|
|
6
17
|
// dotenv.config();
|
|
18
|
+
// (async () => {
|
|
19
|
+
// setUp();
|
|
20
|
+
// const schema = await buildCardSchema(
|
|
21
|
+
// ["concept1", "concept2"],
|
|
22
|
+
// ["fact1", "fact2"],
|
|
23
|
+
// ["flash", "cloze"]
|
|
24
|
+
// );
|
|
25
|
+
// console.log(schema);
|
|
26
|
+
// })();
|
|
7
27
|
// app.get("/generate", async (req, res) => {
|
|
8
28
|
// try {
|
|
9
29
|
// const openAIKey =
|
|
@@ -79,69 +99,66 @@ Object.defineProperty(exports, "OnlyEverGenerator", { enumerable: true, get: fun
|
|
|
79
99
|
// app.listen(port, () => {
|
|
80
100
|
// console.log(`Server is running on port ${port}`);
|
|
81
101
|
// });
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
// const response = await onlyEverGenerator.generate(true, false);
|
|
145
|
-
// console.log(response);
|
|
146
|
-
// })();
|
|
102
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
103
|
+
var _a;
|
|
104
|
+
const promptForSummary = {
|
|
105
|
+
promptId: "pmpt_687a8872d1c8819088a9cdc97dcb688b0893663621695594",
|
|
106
|
+
// version: "13",
|
|
107
|
+
};
|
|
108
|
+
const promptForConceptFacts = {
|
|
109
|
+
promptId: "pmpt_687aa547f99c8193b99467ca53630c2607f5a8caf451e7e8",
|
|
110
|
+
// version: "6",
|
|
111
|
+
};
|
|
112
|
+
(0, mongo_helper_1.setUp)();
|
|
113
|
+
const source = yield mongo_helper_1.database.collection("_source").findOne({
|
|
114
|
+
_id: new mongo_helper_1.ObjectId("68b114d5c849a25097ec75bf"),
|
|
115
|
+
});
|
|
116
|
+
const contentForGen = {
|
|
117
|
+
prompt: {
|
|
118
|
+
typology: "",
|
|
119
|
+
card_generation: "",
|
|
120
|
+
},
|
|
121
|
+
content: {
|
|
122
|
+
source_id: ((_a = source === null || source === void 0 ? void 0 : source._id) === null || _a === void 0 ? void 0 : _a.toString()) || "",
|
|
123
|
+
title: (source === null || source === void 0 ? void 0 : source.title) || "",
|
|
124
|
+
type: (source === null || source === void 0 ? void 0 : source.source_type) || "",
|
|
125
|
+
headings: (source === null || source === void 0 ? void 0 : source.headings) || [],
|
|
126
|
+
content: (source === null || source === void 0 ? void 0 : source.content) || [],
|
|
127
|
+
fields: (source === null || source === void 0 ? void 0 : source.fields) || [],
|
|
128
|
+
taxonomy: (source === null || source === void 0 ? void 0 : source.learn_value)
|
|
129
|
+
? {
|
|
130
|
+
generate_cards: (source === null || source === void 0 ? void 0 : source.generate_cards) || {
|
|
131
|
+
state: false,
|
|
132
|
+
reason: "",
|
|
133
|
+
},
|
|
134
|
+
concepts_facts: (source === null || source === void 0 ? void 0 : source.concepts_facts) || [],
|
|
135
|
+
fields: (source === null || source === void 0 ? void 0 : source.fields) || [],
|
|
136
|
+
learn_value: (source === null || source === void 0 ? void 0 : source.learn_value) || {
|
|
137
|
+
value: 0,
|
|
138
|
+
reason: "",
|
|
139
|
+
bloom_levels: [],
|
|
140
|
+
bloom_levels_reason: "",
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
: undefined,
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
const prompts = yield (0, get_prompts_1.getPrompts)("text", ["flash", "cloze"]);
|
|
147
|
+
const bloomInstructions = prompts.bloom_instructions;
|
|
148
|
+
const cardInstructions = prompts.card_instructions;
|
|
149
|
+
const cardExamples = prompts.card_examples;
|
|
150
|
+
console.log("Initializing OnlyEverGenerator");
|
|
151
|
+
const onlyEverGenerator = new app_1.OnlyEverGenerator(process.env.OPEN_AI_KEY, "o4-mini", contentForGen, "pmpt_687a8872d1c8819088a9cdc97dcb688b0893663621695594", "pmpt_687aa547f99c8193b99467ca53630c2607f5a8caf451e7e8", "pmpt_688118a923e4819098176a13a2f401920d2ea17d881cc6c6", {
|
|
152
|
+
bloom_instructions: bloomInstructions,
|
|
153
|
+
card_instructions: cardInstructions,
|
|
154
|
+
card_examples: cardExamples,
|
|
155
|
+
}, false, 1);
|
|
156
|
+
const response = yield onlyEverGenerator.generate(true, true, [
|
|
157
|
+
"flash",
|
|
158
|
+
"cloze",
|
|
159
|
+
"mcq",
|
|
160
|
+
"match",
|
|
161
|
+
]);
|
|
162
|
+
console.log(response);
|
|
163
|
+
}))();
|
|
147
164
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAoD;AAyB3C,kGAzBA,uBAAiB,OAyBA;AAxB1B,wDAAkE;AAElE,wDAAoD;AAuBpD,mBAAmB;AAEnB,iBAAiB;AACjB,aAAa;AACb,0CAA0C;AAC1C,gCAAgC;AAChC,0BAA0B;AAC1B,yBAAyB;AACzB,OAAO;AACP,yBAAyB;AACzB,QAAQ;AAER,6CAA6C;AAC7C,UAAU;AACV,wBAAwB;AACxB,gLAAgL;AAChL,iCAAiC;AACjC,2EAA2E;AAC3E,0BAA0B;AAC1B,SAAS;AACT,sCAAsC;AACtC,2EAA2E;AAC3E,yBAAyB;AACzB,SAAS;AAET,eAAe;AAEf,oEAAoE;AACpE,uDAAuD;AACvD,UAAU;AAEV,8BAA8B;AAC9B,kBAAkB;AAClB,wBAAwB;AAC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,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IAC7D,MAAM,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IACrD,MAAM,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IACnD,MAAM,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAE3C,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAC9C,MAAM,iBAAiB,GAAG,IAAI,uBAAiB,CAC7C,OAAO,CAAC,GAAG,CAAC,WAAqB,EACjC,SAAS,EACT,aAAa,EAEb,uDAAuD,EACvD,uDAAuD,EACvD,uDAAuD,EACvD;QACE,kBAAkB,EAAE,iBAAiB;QACrC,iBAAiB,EAAE,gBAAgB;QACnC,aAAa,EAAE,YAAY;KAC5B,EACD,KAAK,EACL,CAAC,CACF,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE;QAC5D,OAAO;QACP,OAAO;QACP,KAAK;QACL,OAAO;KACR,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACxB,CAAC,CAAA,CAAC,EAAE,CAAC"}
|
package/dist/logger.d.ts
CHANGED
package/dist/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAMA,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE;QACJ,YAAY,EAAE,MAAM,CAAC;QACrB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAMA,KAAK,QAAQ,GAAG;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE;QACJ,YAAY,EAAE,MAAM,CAAC;QACrB,CAAC,EAAE,MAAM,CAAC;QACV,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH,CAAC;AAEF,qBAAa,YAAa,SAAQ,KAAK;IAC9B,QAAQ,EAAE,GAAG,CAAC;gBACT,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG;CAM3C;AAED,qBAAa,WAAW;IACtB,IAAI,EAAE,GAAG,CAAC;gBACE,IAAI,EAAE,GAAG;IAIf,GAAG;CAkBV;AACD,wBAAsB,SAAS,CAAC,KAAK,EAAE,QAAQ,mFAS9C"}
|
package/dist/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA,2FAA2F;AAC3F,oCAAoC;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA,2FAA2F;AAC3F,oCAAoC;;;;;;;;;;;;;;;AAsDpC,8BASC;AA7DD,kDAA0B;AAC1B,wDAAwD;AAgBxD,MAAa,YAAa,SAAQ,KAAK;IAErC,YAAY,OAAe,EAAE,QAAa;QACxC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wCAAwC;QACxD,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC,CAAC,oBAAoB;QAChD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC,mBAAmB;QAC7C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,sBAAsB;IAC3E,CAAC;CACF;AARD,oCAQC;AAED,MAAa,WAAW;IAEtB,YAAY,IAAS;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAEK,GAAG;;YACP,IAAI,CAAC;gBACH,IAAI,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC7B,uFAAuF,EACvF;oBACE,IAAI,EAAE,IAAI,CAAC,IAAI;iBAChB,EACD;oBACE,OAAO,EAAE;wBACP,cAAc,EAAE,CAAC,kBAAkB,CAAC;qBACrC;iBACF,CACF,CAAC;gBACF,OAAO,QAAQ,CAAC;YAClB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC;QACH,CAAC;KAAA;CACF;AAxBD,kCAwBC;AACD,SAAsB,SAAS,CAAC,KAAe;;QAC7C,IAAI,CAAC;YACH,IAAA,oBAAK,GAAE,CAAC;YACR,MAAM,EAAE,GAAG,uBAAQ,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;YAClD,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACzC,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_prompts.d.ts","sourceRoot":"","sources":["../../src/services/get_prompts.ts"],"names":[],"mappings":"AAuDA,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"get_prompts.d.ts","sourceRoot":"","sources":["../../src/services/get_prompts.ts"],"names":[],"mappings":"AAuDA,eAAO,MAAM,UAAU,GACrB,YAAY,MAAM,EAClB,oBAAoB,MAAM,EAAE;;;;;;;;;;;;EAyG7B,CAAC"}
|
|
@@ -59,15 +59,28 @@ const cardGenExamplesDocs = {
|
|
|
59
59
|
const bloomInstructionsDocs = {
|
|
60
60
|
bloom_1: "6780d21318f81be17e39f5b5",
|
|
61
61
|
};
|
|
62
|
-
const getPrompts = (sourceType) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
+
const getPrompts = (sourceType, cardGenerationType) => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
63
|
// const typologyDocs = JSON.parse(baseConfig.typologyPrompts);
|
|
64
64
|
// const cardGenerationDocs = JSON.parse(baseConfig.cardGenerationPrompts);
|
|
65
65
|
// const videoTypologyDocs = JSON.parse(baseConfig.videoTypologyPrompts);
|
|
66
66
|
const typologyObjectIds = Object.values(typologyDocs).map((e) => mongo_helper_1.ObjectId.createFromHexString(e.toString()));
|
|
67
67
|
const cardGenObjectIds = Object.values(cardGenDocs).map((e) => mongo_helper_1.ObjectId.createFromHexString(e));
|
|
68
68
|
const typologyVideoObjectIds = Object.values(videoTypologyDocs).map((e) => mongo_helper_1.ObjectId.createFromHexString(e));
|
|
69
|
-
|
|
70
|
-
const
|
|
69
|
+
// Filter card generation instructions and examples based on cardGenerationType array
|
|
70
|
+
const filteredCardGenInstructions = {};
|
|
71
|
+
const filteredCardGenExamples = {};
|
|
72
|
+
cardGenerationType.forEach((type) => {
|
|
73
|
+
if (cardGenInstructionsDocs[type]) {
|
|
74
|
+
filteredCardGenInstructions[type] =
|
|
75
|
+
cardGenInstructionsDocs[type];
|
|
76
|
+
}
|
|
77
|
+
if (cardGenExamplesDocs[type]) {
|
|
78
|
+
filteredCardGenExamples[type] =
|
|
79
|
+
cardGenExamplesDocs[type];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const cardGenInstructionsObjectIds = Object.values(filteredCardGenInstructions).map((e) => mongo_helper_1.ObjectId.createFromHexString(e));
|
|
83
|
+
const cardGenExamplesObjectIds = Object.values(filteredCardGenExamples).map((e) => mongo_helper_1.ObjectId.createFromHexString(e));
|
|
71
84
|
const bloomInstructionsObjectIds = Object.values(bloomInstructionsDocs).map((e) => mongo_helper_1.ObjectId.createFromHexString(e));
|
|
72
85
|
const typology = yield getPromptString(typologyObjectIds);
|
|
73
86
|
const card_generation = yield getPromptString(cardGenObjectIds);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_prompts.js","sourceRoot":"","sources":["../../src/services/get_prompts.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAA4D;AAC5D,MAAM,YAAY,GAAG;IACnB,IAAI,EAAE,0BAA0B;IAChC,KAAK,EAAE,0BAA0B;IACjC,KAAK,EAAE,0BAA0B;IACjC,MAAM,EAAE,0BAA0B;IAClC,MAAM,EAAE,0BAA0B;IAClC,QAAQ,EAAE,0BAA0B;IACpC,KAAK,EAAE,0BAA0B;IACjC,QAAQ,EAAE,0BAA0B;IACpC,SAAS,EAAE,0BAA0B;CACtC,CAAC;AAEF,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,0BAA0B;IAChC,MAAM,EAAE,0BAA0B;IAClC,KAAK,EAAE,0BAA0B;IACjC,MAAM,EAAE,0BAA0B;IAClC,KAAK,EAAE,0BAA0B;IACjC,KAAK,EAAE,0BAA0B;IACjC,KAAK,EAAE,0BAA0B;IACjC,GAAG,EAAE,0BAA0B;IAC/B,QAAQ,EAAE,0BAA0B;CACrC,CAAC;AAEF,MAAM,iBAAiB,GAAG;IACxB,IAAI,EAAE,0BAA0B;IAChC,MAAM,EAAE,0BAA0B;IAClC,KAAK,EAAE,0BAA0B;IACjC,MAAM,EAAE,0BAA0B;IAClC,MAAM,EAAE,0BAA0B;IAClC,QAAQ,EAAE,0BAA0B;IACpC,KAAK,EAAE,0BAA0B;IACjC,QAAQ,EAAE,0BAA0B;IACpC,SAAS,EAAE,0BAA0B;CACtC,CAAC;AAEF,MAAM,uBAAuB,GAAG;IAC9B,KAAK,EAAE,0BAA0B;IACjC,KAAK,EAAE,0BAA0B;IACjC,KAAK,EAAE,0BAA0B;IACjC,GAAG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EAAE,CAAC;QAChE,CAAC;KAAA;AACH,CAAC,CAAA,CAAC;AA3GW,QAAA,UAAU,cA2GrB"}
|
package/package.json
CHANGED
package/src/bootstrap/app.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
GenerateCards,
|
|
3
|
+
GenerateCardsResponseList,
|
|
4
|
+
} from "../card_gen/generate_cards";
|
|
2
5
|
import { ParseSourceContent } from "../parse/parse_source_content";
|
|
3
6
|
import { OpenAiService } from "../services/open_ai_service";
|
|
4
7
|
import { GenerateTypology } from "../typology_gen/generate_typology";
|
|
@@ -6,11 +9,9 @@ import { GenerateArgs } from "../utils/generate_args";
|
|
|
6
9
|
import { GenerateEmbeddings } from "../embedding_generation/generate_embeddings";
|
|
7
10
|
import { LocalConsolidation } from "../embedding_generation/consolidation/local_consolidation";
|
|
8
11
|
import { GlobalConsolidation } from "../embedding_generation/consolidation/global_consolidation";
|
|
9
|
-
import { WriteConsolidatedData } from "../embedding_generation/consolidation/write_consolidated_data";
|
|
10
12
|
import { BaseParamType } from "../types/base_param_type";
|
|
11
13
|
import { SourceTaxonomy } from "../types/source_taxonomy_type";
|
|
12
14
|
import { MongoConceptFactSource } from "../types/mongo_concept_fact_type";
|
|
13
|
-
import { OpenAIHelper } from "../helper/openai_helper";
|
|
14
15
|
import { GenerateConceptFacts } from "../typology_gen/generate_concept_facts";
|
|
15
16
|
|
|
16
17
|
export class OnlyEverGenerator {
|
|
@@ -44,7 +45,7 @@ export class OnlyEverGenerator {
|
|
|
44
45
|
};
|
|
45
46
|
expectedFields: Array<string> = [];
|
|
46
47
|
typologyResponse?: any = undefined;
|
|
47
|
-
cardgenResponse:
|
|
48
|
+
cardgenResponse: GenerateCardsResponseList = [];
|
|
48
49
|
summarizeResponse = {};
|
|
49
50
|
|
|
50
51
|
constructor(
|
|
@@ -171,7 +172,10 @@ export class OnlyEverGenerator {
|
|
|
171
172
|
bloom_levels_reason: "",
|
|
172
173
|
},
|
|
173
174
|
};
|
|
174
|
-
this.cardgenResponse = await this.generateCard(
|
|
175
|
+
this.cardgenResponse = await this.generateCard(
|
|
176
|
+
this.n,
|
|
177
|
+
card_generation_types
|
|
178
|
+
);
|
|
175
179
|
responseToReturn.push({
|
|
176
180
|
type: "card_gen",
|
|
177
181
|
data: this.cardgenResponse,
|
|
@@ -197,7 +201,10 @@ export class OnlyEverGenerator {
|
|
|
197
201
|
}
|
|
198
202
|
}
|
|
199
203
|
|
|
200
|
-
async generateCard(
|
|
204
|
+
async generateCard(
|
|
205
|
+
n: number,
|
|
206
|
+
card_generation_types: string[]
|
|
207
|
+
): Promise<GenerateCardsResponseList> {
|
|
201
208
|
const content = {
|
|
202
209
|
title: this.parsedContent?.title,
|
|
203
210
|
concepts_facts: this.typologyResponse?.concepts_facts,
|
|
@@ -211,7 +218,7 @@ export class OnlyEverGenerator {
|
|
|
211
218
|
this.generationVariables,
|
|
212
219
|
this.promptIdForCardsGeneration,
|
|
213
220
|
this.generationCurriculum
|
|
214
|
-
).generateCards(n);
|
|
221
|
+
).generateCards(n, card_generation_types);
|
|
215
222
|
return generateCardsResp;
|
|
216
223
|
}
|
|
217
224
|
|
|
@@ -8,6 +8,18 @@ import { ParseCardResponse } from "../parse/parse_card_response";
|
|
|
8
8
|
import { OpenAiService } from "../services/open_ai_service";
|
|
9
9
|
import { GeneratedCardResponseType } from "../types/raw_card_response_types/generated_card_response_type";
|
|
10
10
|
import { SourceTaxonomy } from "../types/source_taxonomy_type";
|
|
11
|
+
import { ParsedCardType } from "../types/parsed_card_type";
|
|
12
|
+
|
|
13
|
+
// Type for the response structure returned by generateCardsForType
|
|
14
|
+
type GenerateCardsResponse = {
|
|
15
|
+
status_code: number;
|
|
16
|
+
metadata: any;
|
|
17
|
+
type: string;
|
|
18
|
+
cards_data?: ParsedCardType[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Type for list/array of GenerateCardsResponse (including undefined)
|
|
22
|
+
export type GenerateCardsResponseList = (GenerateCardsResponse | undefined)[];
|
|
11
23
|
|
|
12
24
|
export class GenerateCards {
|
|
13
25
|
openAiService: OpenAiService;
|
|
@@ -45,21 +57,25 @@ export class GenerateCards {
|
|
|
45
57
|
this.generationCurriculum = generationCurriculum;
|
|
46
58
|
}
|
|
47
59
|
|
|
48
|
-
async openAIResponse() {
|
|
60
|
+
async openAIResponse(card_generation_types: string[]) {
|
|
49
61
|
const concepts = this.taxonomy.concepts_facts
|
|
50
62
|
.filter((concept) => concept.type === "concept")
|
|
51
63
|
.map((concept) => concept.text);
|
|
52
64
|
const facts = this.taxonomy.concepts_facts
|
|
53
65
|
.filter((fact) => fact.type === "fact")
|
|
54
66
|
.map((fact) => fact.text);
|
|
55
|
-
const schema = await buildCardSchema(
|
|
67
|
+
const schema = await buildCardSchema(
|
|
68
|
+
concepts,
|
|
69
|
+
facts,
|
|
70
|
+
card_generation_types
|
|
71
|
+
);
|
|
56
72
|
try {
|
|
57
73
|
let response: any = await this.openAIHelper.openAI.responses.create({
|
|
58
74
|
prompt: {
|
|
59
75
|
id: this.promptIdForCardsGeneration,
|
|
60
76
|
variables: {
|
|
61
77
|
bloom_level: "1",
|
|
62
|
-
card_types: "
|
|
78
|
+
card_types: card_generation_types.join(","),
|
|
63
79
|
bloom_instructions: this.generationVariables.bloom_instructions,
|
|
64
80
|
card_instructions: this.generationVariables.card_instructions,
|
|
65
81
|
card_examples: this.generationVariables.card_examples,
|
|
@@ -135,19 +151,61 @@ export class GenerateCards {
|
|
|
135
151
|
}
|
|
136
152
|
}
|
|
137
153
|
|
|
138
|
-
async generateCards(
|
|
154
|
+
async generateCards(
|
|
155
|
+
n: number,
|
|
156
|
+
card_generation_types: string[]
|
|
157
|
+
): Promise<GenerateCardsResponseList> {
|
|
139
158
|
try {
|
|
140
159
|
// let response = await this.openAiService?.sendRequest(
|
|
141
160
|
// prompt,
|
|
142
161
|
// parsedContent
|
|
143
162
|
// );
|
|
144
163
|
console.log("generation started");
|
|
145
|
-
let
|
|
164
|
+
let responses: GenerateCardsResponseList = await Promise.all(
|
|
165
|
+
card_generation_types.map(async (card_generation_type) => {
|
|
166
|
+
return await this.generateCardsForType(n, card_generation_type);
|
|
167
|
+
})
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
// Flatten all parsed cards from all responses
|
|
171
|
+
// const allParsedCards: AllParsedCards = [];
|
|
172
|
+
// for (const response of responses) {
|
|
173
|
+
// if (response && response.cards_data) {
|
|
174
|
+
// allParsedCards.push(...response.cards_data);
|
|
175
|
+
// }
|
|
176
|
+
// }
|
|
177
|
+
|
|
178
|
+
return responses;
|
|
179
|
+
} catch (e: any) {
|
|
180
|
+
await log_error({
|
|
181
|
+
flow: this.generationCurriculum
|
|
182
|
+
? "curriculum_manual_generation"
|
|
183
|
+
: "manual_generation",
|
|
184
|
+
data: e,
|
|
185
|
+
timestamp: new Date(),
|
|
186
|
+
error: "error_in_card_generation",
|
|
187
|
+
source_id: this.sourceId,
|
|
188
|
+
type: {
|
|
189
|
+
request_type: "depth",
|
|
190
|
+
n: n,
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
return [];
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async generateCardsForType(
|
|
198
|
+
n: number,
|
|
199
|
+
card_generation_type: string
|
|
200
|
+
): Promise<GenerateCardsResponse | undefined> {
|
|
201
|
+
try {
|
|
202
|
+
let response = await this.openAIResponse([card_generation_type]);
|
|
146
203
|
response.metadata = {
|
|
147
204
|
req_time: response.generated_at ?? new Date(),
|
|
148
205
|
req_type: {
|
|
149
206
|
type: "depth",
|
|
150
207
|
n: n,
|
|
208
|
+
card_types: card_generation_type,
|
|
151
209
|
bloom_level: 1,
|
|
152
210
|
},
|
|
153
211
|
req_tokens: response.usage_data?.prompt_tokens,
|
|
@@ -155,7 +213,6 @@ export class GenerateCards {
|
|
|
155
213
|
prompt_tokens_details: response.usage_data?.prompt_tokens_details,
|
|
156
214
|
model: response.model,
|
|
157
215
|
};
|
|
158
|
-
|
|
159
216
|
if (response.status == "completed") {
|
|
160
217
|
response.metadata.status = "completed";
|
|
161
218
|
/// map response to generated_content
|
|
@@ -202,6 +259,8 @@ export class GenerateCards {
|
|
|
202
259
|
type: {
|
|
203
260
|
request_type: "depth",
|
|
204
261
|
n: n,
|
|
262
|
+
card_types: card_generation_type,
|
|
263
|
+
bloom_level: 1,
|
|
205
264
|
},
|
|
206
265
|
});
|
|
207
266
|
}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { sanitizeStringsForSchema } from "../../utils/sanitize_strings";
|
|
2
2
|
import { database, ObjectId, setUp } from "../mongo_helper";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// flash:68ef4e1b5a123c94a835c6ab
|
|
5
|
+
// cloze:68ef4eb45a123c94a835c6ac
|
|
6
|
+
// mcq:68ef4f095a123c94a835c6ad
|
|
7
|
+
// match:68ef4fae5a123c94a835c6ae
|
|
8
|
+
export const buildCardSchema = async (
|
|
9
|
+
concepts: string[],
|
|
10
|
+
facts: string[],
|
|
11
|
+
card_generation_types: string[]
|
|
12
|
+
) => {
|
|
5
13
|
setUp();
|
|
6
14
|
const objectId = new ObjectId("689c5cbd0d9d3bbda64b9584");
|
|
7
15
|
const schemaObj = await database.collection("_prompts").findOne({
|
|
@@ -16,12 +24,48 @@ export const buildCardSchema = async (concepts: string[], facts: string[]) => {
|
|
|
16
24
|
}
|
|
17
25
|
const conceptsSanitized = sanitizeStringsForSchema(concepts);
|
|
18
26
|
const factsSanitized = sanitizeStringsForSchema(facts);
|
|
27
|
+
|
|
28
|
+
// Fetch individual card type schemas based on card_generation_types
|
|
29
|
+
const cardTypeObjectIds: { [key: string]: ObjectId } = {
|
|
30
|
+
flash: new ObjectId("68ef4e1b5a123c94a835c6ab"),
|
|
31
|
+
cloze: new ObjectId("68ef4eb45a123c94a835c6ac"),
|
|
32
|
+
mcq: new ObjectId("68ef4f095a123c94a835c6ad"),
|
|
33
|
+
match: new ObjectId("68ef4fae5a123c94a835c6ae"),
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const cardTypeSchemas: { [key: string]: any } = {};
|
|
37
|
+
|
|
38
|
+
// Only fetch schemas for the requested card types
|
|
39
|
+
for (const cardType of card_generation_types) {
|
|
40
|
+
if (cardTypeObjectIds[cardType]) {
|
|
41
|
+
const cardSchemaObj = await database.collection("_prompts").findOne({
|
|
42
|
+
_id: cardTypeObjectIds[cardType],
|
|
43
|
+
});
|
|
44
|
+
if (cardSchemaObj && cardSchemaObj.schema) {
|
|
45
|
+
cardTypeSchemas[cardType] = JSON.parse(cardSchemaObj.schema);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
19
50
|
// Deep clone to avoid mutating the original
|
|
20
51
|
const populatedSchema = JSON.parse(schema);
|
|
21
52
|
populatedSchema.schema.properties.test_cards.items.properties.concepts.items.enum =
|
|
22
53
|
conceptsSanitized;
|
|
23
54
|
populatedSchema.schema.properties.test_cards.items.properties.facts.items.enum =
|
|
24
55
|
factsSanitized;
|
|
56
|
+
|
|
57
|
+
// Replace the type enum with the requested card generation types
|
|
58
|
+
populatedSchema.schema.properties.test_cards.items.properties.type.enum =
|
|
59
|
+
card_generation_types;
|
|
60
|
+
|
|
61
|
+
// Replace anyOf array with individual schemas based on card type
|
|
62
|
+
if (Object.keys(cardTypeSchemas).length > 0) {
|
|
63
|
+
populatedSchema.schema.properties.test_cards.items.properties.card_content =
|
|
64
|
+
{
|
|
65
|
+
anyOf: Object.values(cardTypeSchemas),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
25
69
|
console.log(
|
|
26
70
|
"Populated Schema",
|
|
27
71
|
JSON.stringify(populatedSchema.schema.properties.test_cards.items, null, 2)
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { OnlyEverGenerator } from "./bootstrap/app";
|
|
2
|
+
import { database, ObjectId, setUp } from "./helper/mongo_helper";
|
|
3
|
+
import { buildCardSchema } from "./helper/schema_helper/build_card_schema";
|
|
4
|
+
import { getPrompts } from "./services/get_prompts";
|
|
2
5
|
// import { LocalConsolidation } from "./embedding_generation/consolidation/local_consolidation";
|
|
3
6
|
// import { embeddingsResp } from "./typology-parsed-response";
|
|
4
7
|
// import { GlobalConsolidation } from "./embedding_generation/consolidation/global_consolidation";
|
|
@@ -23,6 +26,16 @@ import { OnlyEverGenerator } from "./bootstrap/app";
|
|
|
23
26
|
export { OnlyEverGenerator };
|
|
24
27
|
// dotenv.config();
|
|
25
28
|
|
|
29
|
+
// (async () => {
|
|
30
|
+
// setUp();
|
|
31
|
+
// const schema = await buildCardSchema(
|
|
32
|
+
// ["concept1", "concept2"],
|
|
33
|
+
// ["fact1", "fact2"],
|
|
34
|
+
// ["flash", "cloze"]
|
|
35
|
+
// );
|
|
36
|
+
// console.log(schema);
|
|
37
|
+
// })();
|
|
38
|
+
|
|
26
39
|
// app.get("/generate", async (req, res) => {
|
|
27
40
|
// try {
|
|
28
41
|
// const openAIKey =
|
|
@@ -106,73 +119,79 @@ export { OnlyEverGenerator };
|
|
|
106
119
|
// console.log(`Server is running on port ${port}`);
|
|
107
120
|
// });
|
|
108
121
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
//
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
122
|
+
(async () => {
|
|
123
|
+
const promptForSummary = {
|
|
124
|
+
promptId: "pmpt_687a8872d1c8819088a9cdc97dcb688b0893663621695594",
|
|
125
|
+
// version: "13",
|
|
126
|
+
};
|
|
127
|
+
const promptForConceptFacts = {
|
|
128
|
+
promptId: "pmpt_687aa547f99c8193b99467ca53630c2607f5a8caf451e7e8",
|
|
129
|
+
// version: "6",
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
setUp();
|
|
133
|
+
|
|
134
|
+
const source = await database.collection("_source").findOne({
|
|
135
|
+
_id: new ObjectId("68b114d5c849a25097ec75bf"),
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const contentForGen = {
|
|
139
|
+
prompt: {
|
|
140
|
+
typology: "",
|
|
141
|
+
card_generation: "",
|
|
142
|
+
},
|
|
143
|
+
content: {
|
|
144
|
+
source_id: source?._id?.toString() || "",
|
|
145
|
+
title: source?.title || "",
|
|
146
|
+
type: source?.source_type || "",
|
|
147
|
+
headings: source?.headings || [],
|
|
148
|
+
content: source?.content || [],
|
|
149
|
+
fields: source?.fields || [],
|
|
150
|
+
taxonomy: source?.learn_value
|
|
151
|
+
? {
|
|
152
|
+
generate_cards: source?.generate_cards || {
|
|
153
|
+
state: false,
|
|
154
|
+
reason: "",
|
|
155
|
+
},
|
|
156
|
+
concepts_facts: source?.concepts_facts || [],
|
|
157
|
+
fields: source?.fields || [],
|
|
158
|
+
learn_value: source?.learn_value || {
|
|
159
|
+
value: 0,
|
|
160
|
+
reason: "",
|
|
161
|
+
bloom_levels: [],
|
|
162
|
+
bloom_levels_reason: "",
|
|
163
|
+
},
|
|
164
|
+
}
|
|
165
|
+
: undefined,
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
const prompts = await getPrompts("text", ["flash", "cloze"]);
|
|
169
|
+
const bloomInstructions = prompts.bloom_instructions;
|
|
170
|
+
const cardInstructions = prompts.card_instructions;
|
|
171
|
+
const cardExamples = prompts.card_examples;
|
|
172
|
+
|
|
173
|
+
console.log("Initializing OnlyEverGenerator");
|
|
174
|
+
const onlyEverGenerator = new OnlyEverGenerator(
|
|
175
|
+
process.env.OPEN_AI_KEY as string,
|
|
176
|
+
"o4-mini",
|
|
177
|
+
contentForGen,
|
|
178
|
+
|
|
179
|
+
"pmpt_687a8872d1c8819088a9cdc97dcb688b0893663621695594",
|
|
180
|
+
"pmpt_687aa547f99c8193b99467ca53630c2607f5a8caf451e7e8",
|
|
181
|
+
"pmpt_688118a923e4819098176a13a2f401920d2ea17d881cc6c6",
|
|
182
|
+
{
|
|
183
|
+
bloom_instructions: bloomInstructions,
|
|
184
|
+
card_instructions: cardInstructions,
|
|
185
|
+
card_examples: cardExamples,
|
|
186
|
+
},
|
|
187
|
+
false,
|
|
188
|
+
1
|
|
189
|
+
);
|
|
190
|
+
const response = await onlyEverGenerator.generate(true, true, [
|
|
191
|
+
"flash",
|
|
192
|
+
"cloze",
|
|
193
|
+
"mcq",
|
|
194
|
+
"match",
|
|
195
|
+
]);
|
|
196
|
+
console.log(response);
|
|
197
|
+
})();
|
package/src/logger.ts
CHANGED
|
@@ -53,7 +53,10 @@ const bloomInstructionsDocs = {
|
|
|
53
53
|
bloom_1: "6780d21318f81be17e39f5b5",
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
export const getPrompts = async (
|
|
56
|
+
export const getPrompts = async (
|
|
57
|
+
sourceType: string,
|
|
58
|
+
cardGenerationType: string[]
|
|
59
|
+
) => {
|
|
57
60
|
// const typologyDocs = JSON.parse(baseConfig.typologyPrompts);
|
|
58
61
|
// const cardGenerationDocs = JSON.parse(baseConfig.cardGenerationPrompts);
|
|
59
62
|
// const videoTypologyDocs = JSON.parse(baseConfig.videoTypologyPrompts);
|
|
@@ -66,10 +69,26 @@ export const getPrompts = async (sourceType: string) => {
|
|
|
66
69
|
const typologyVideoObjectIds = Object.values(videoTypologyDocs).map(
|
|
67
70
|
(e: any) => ObjectId.createFromHexString(e)
|
|
68
71
|
);
|
|
72
|
+
|
|
73
|
+
// Filter card generation instructions and examples based on cardGenerationType array
|
|
74
|
+
const filteredCardGenInstructions: Record<string, string> = {};
|
|
75
|
+
const filteredCardGenExamples: Record<string, string> = {};
|
|
76
|
+
|
|
77
|
+
cardGenerationType.forEach((type) => {
|
|
78
|
+
if (cardGenInstructionsDocs[type as keyof typeof cardGenInstructionsDocs]) {
|
|
79
|
+
filteredCardGenInstructions[type] =
|
|
80
|
+
cardGenInstructionsDocs[type as keyof typeof cardGenInstructionsDocs];
|
|
81
|
+
}
|
|
82
|
+
if (cardGenExamplesDocs[type as keyof typeof cardGenExamplesDocs]) {
|
|
83
|
+
filteredCardGenExamples[type] =
|
|
84
|
+
cardGenExamplesDocs[type as keyof typeof cardGenExamplesDocs];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
69
88
|
const cardGenInstructionsObjectIds = Object.values(
|
|
70
|
-
|
|
89
|
+
filteredCardGenInstructions
|
|
71
90
|
).map((e: any) => ObjectId.createFromHexString(e));
|
|
72
|
-
const cardGenExamplesObjectIds = Object.values(
|
|
91
|
+
const cardGenExamplesObjectIds = Object.values(filteredCardGenExamples).map(
|
|
73
92
|
(e: any) => ObjectId.createFromHexString(e)
|
|
74
93
|
);
|
|
75
94
|
const bloomInstructionsObjectIds = Object.values(bloomInstructionsDocs).map(
|