only_ever_generator 0.2.7 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bootstrap/app.js +1 -1
- package/dist/card_gen/generate_cards.js +2 -1
- package/dist/constants/prompt_data.js +273 -273
- package/dist/constants/prompts/card_gen_prompt.js +287 -282
- package/dist/constants/prompts/typology_prompt.js +94 -100
- package/dist/constants/source_data.js +883 -7
- package/dist/index.js +1 -1
- package/dist/parse/parse_source_content.js +0 -7
- package/package.json +33 -33
- package/readme.md +23 -23
- package/src/bootstrap/app.ts +150 -154
- package/src/card_gen/generate_cards.ts +251 -251
- package/src/config.ts +6 -6
- package/src/constants/api_constants.ts +2 -2
- package/src/constants/prompt_data.ts +296 -296
- package/src/constants/prompts/card_gen_prompt.ts +372 -372
- package/src/constants/prompts/typology_prompt.ts +196 -202
- package/src/constants/source_data.ts +915 -47
- package/src/gap_fill/calculate_gap_fill.ts +52 -52
- package/src/index.ts +61 -61
- package/src/logger.ts +30 -30
- package/src/parse/parse_card_response.ts +289 -289
- package/src/parse/parse_source_content.ts +88 -94
- package/src/parse/response_format_card.ts +210 -210
- package/src/parse/response_format_typology.ts +43 -43
- package/src/services/open_ai_service.ts +55 -55
- package/src/typology_gen/generate_typology.ts +71 -71
- package/src/utils/generate_args.ts +28 -28
- package/src/utils/parse_openai_response.ts +20 -20
- package/tsconfig.json +12 -12
- package/dist/class/parse/parse_source_content.js +0 -62
- package/dist/class/services/open_ai_service.js +0 -25
- package/dist/parse_response/parse_card_response.js +0 -288
- package/dist/parse_response/response_format_card.js +0 -210
- package/dist/parse_response/response_format_typology.js +0 -47
- package/dist/service/open_ai_request.js +0 -57
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
function isEmpty(obj: object): boolean {
|
|
2
|
-
return Object.keys(obj).length === 0;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export function gapFilling(typologyResponse: any, cardgenResponse : any) {
|
|
7
|
-
let allConcepts: string[] = [];
|
|
8
|
-
let allFacts: string[] = [];
|
|
9
|
-
let generatedConceptsList: string[] = [];
|
|
10
|
-
let generatedFactsList: string[] = [];
|
|
11
|
-
let remainingConcepts: string[] = [];
|
|
12
|
-
let remainingFacts: string[] = [];
|
|
13
|
-
if (!isEmpty(typologyResponse)) {
|
|
14
|
-
allConcepts.push(...(typologyResponse.concepts ?? []));
|
|
15
|
-
allFacts.push(...(typologyResponse?.facts ?? []));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (!isEmpty(cardgenResponse)) {
|
|
19
|
-
allConcepts.push(...(cardgenResponse.missing_concepts ?? []));
|
|
20
|
-
allFacts.push(...(cardgenResponse.missing_facts ?? []));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if(cardgenResponse.cards_data !== undefined && cardgenResponse.cards_data.length != 0) {
|
|
24
|
-
for (let card of cardgenResponse.cards_data) {
|
|
25
|
-
if (card.concepts.length != 0) {
|
|
26
|
-
generatedConceptsList.push(...card.concepts);
|
|
27
|
-
}
|
|
28
|
-
if (card.facts.length != 0) {
|
|
29
|
-
generatedFactsList.push(...card.facts);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
let generatedConceptsSet = Array.from(new Set(generatedConceptsList));
|
|
34
|
-
let generatedFactsSet = Array.from(new Set(generatedFactsList));
|
|
35
|
-
|
|
36
|
-
remainingConcepts = allConcepts.filter(
|
|
37
|
-
(item) => !generatedConceptsSet.includes(item)
|
|
38
|
-
);
|
|
39
|
-
remainingFacts = allFacts.filter(
|
|
40
|
-
(item) => !generatedFactsSet.includes(item)
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
// allConcepts: allConcepts,
|
|
47
|
-
// allFacts: allFacts,
|
|
48
|
-
// generatedConcepts: generatedConceptsSet,
|
|
49
|
-
// generatedFacts: generatedFactsSet,
|
|
50
|
-
remainingConcepts: remainingConcepts,
|
|
51
|
-
remainingFacts: remainingFacts,
|
|
52
|
-
};
|
|
1
|
+
function isEmpty(obj: object): boolean {
|
|
2
|
+
return Object.keys(obj).length === 0;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export function gapFilling(typologyResponse: any, cardgenResponse : any) {
|
|
7
|
+
let allConcepts: string[] = [];
|
|
8
|
+
let allFacts: string[] = [];
|
|
9
|
+
let generatedConceptsList: string[] = [];
|
|
10
|
+
let generatedFactsList: string[] = [];
|
|
11
|
+
let remainingConcepts: string[] = [];
|
|
12
|
+
let remainingFacts: string[] = [];
|
|
13
|
+
if (!isEmpty(typologyResponse)) {
|
|
14
|
+
allConcepts.push(...(typologyResponse.concepts ?? []));
|
|
15
|
+
allFacts.push(...(typologyResponse?.facts ?? []));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!isEmpty(cardgenResponse)) {
|
|
19
|
+
allConcepts.push(...(cardgenResponse.missing_concepts ?? []));
|
|
20
|
+
allFacts.push(...(cardgenResponse.missing_facts ?? []));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if(cardgenResponse.cards_data !== undefined && cardgenResponse.cards_data.length != 0) {
|
|
24
|
+
for (let card of cardgenResponse.cards_data) {
|
|
25
|
+
if (card.concepts.length != 0) {
|
|
26
|
+
generatedConceptsList.push(...card.concepts);
|
|
27
|
+
}
|
|
28
|
+
if (card.facts.length != 0) {
|
|
29
|
+
generatedFactsList.push(...card.facts);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let generatedConceptsSet = Array.from(new Set(generatedConceptsList));
|
|
34
|
+
let generatedFactsSet = Array.from(new Set(generatedFactsList));
|
|
35
|
+
|
|
36
|
+
remainingConcepts = allConcepts.filter(
|
|
37
|
+
(item) => !generatedConceptsSet.includes(item)
|
|
38
|
+
);
|
|
39
|
+
remainingFacts = allFacts.filter(
|
|
40
|
+
(item) => !generatedFactsSet.includes(item)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
// allConcepts: allConcepts,
|
|
47
|
+
// allFacts: allFacts,
|
|
48
|
+
// generatedConcepts: generatedConceptsSet,
|
|
49
|
+
// generatedFacts: generatedFactsSet,
|
|
50
|
+
remainingConcepts: remainingConcepts,
|
|
51
|
+
remainingFacts: remainingFacts,
|
|
52
|
+
};
|
|
53
53
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
// import express from "express";
|
|
2
|
-
// import {
|
|
3
|
-
// returnSourceData,
|
|
4
|
-
// } from "./constants/source_data";
|
|
5
|
-
// import config from "./config";
|
|
6
|
-
// const app = express();
|
|
7
|
-
// const port = 3000;
|
|
8
|
-
|
|
9
|
-
import { OnlyEverGenerator } from "./bootstrap/app";
|
|
10
|
-
//import { returnPromptData } from "./constants/prompt_data";
|
|
11
|
-
|
|
12
|
-
/// While Publishing the package , and using this code as a separate npm module
|
|
13
|
-
/// uncomment the below line and comment all the others, expect the import of OnlyEverGenerator
|
|
14
|
-
export {OnlyEverGenerator};
|
|
15
|
-
|
|
16
|
-
//. All the Codes Below uses express and are strictly for development purpose, while publishing the package, comment everything
|
|
17
|
-
//below this line
|
|
18
|
-
// let oeGen = new OnlyEverGenerator(config.openAIKey, "gpt-3.5-turbo-1106", {
|
|
19
|
-
// prompt: returnPromptData(),
|
|
20
|
-
// content: returnSourceData(),
|
|
21
|
-
// });
|
|
22
|
-
// app.get("/", async (req, res) => {
|
|
23
|
-
// // let data = oeGen.returnParsedContent();
|
|
24
|
-
// // let parsedData = parseResponse()
|
|
25
|
-
// let cardPrompt = "";
|
|
26
|
-
|
|
27
|
-
// res.send(cardPrompt);
|
|
28
|
-
// });
|
|
29
|
-
|
|
30
|
-
// app.get("/openAI", async (req, res) => {
|
|
31
|
-
// // let prompt = returnPromt();
|
|
32
|
-
// // let prompt = returnCardGenPrompt();
|
|
33
|
-
// // let content = returnSourceData().toString()
|
|
34
|
-
// // let headings = returnHeadings();
|
|
35
|
-
// // // let aiRequest = await openAIRequest(prompt,content);
|
|
36
|
-
// // let aiRequest = await oeGen.generateCard(prompt,content, false);
|
|
37
|
-
// // res.send(aiRequest);
|
|
38
|
-
// });
|
|
39
|
-
|
|
40
|
-
// app.get("/typology", async (req, res) => {
|
|
41
|
-
// {
|
|
42
|
-
// // let typologyPrompt = returnTypologyPrompt();
|
|
43
|
-
// // let cardPrompt = returnCardGenPrompt();
|
|
44
|
-
// // let args = new GenerateArgs(
|
|
45
|
-
// // true,
|
|
46
|
-
// // true,
|
|
47
|
-
// // false,
|
|
48
|
-
// // {
|
|
49
|
-
// // typology_prompt: typologyPrompt,
|
|
50
|
-
// // card_gen_prompt: cardPrompt,
|
|
51
|
-
// // summary_prompt: "",
|
|
52
|
-
// // }
|
|
53
|
-
// // )
|
|
54
|
-
// let typologyRequest = await oeGen.generate(
|
|
55
|
-
// res.send(typologyRequest);
|
|
56
|
-
// }
|
|
57
|
-
// });
|
|
58
|
-
|
|
59
|
-
// app.listen(port, () => {
|
|
60
|
-
// console.log(`Example app listening at http://localhost:${port}`);
|
|
61
|
-
// });
|
|
1
|
+
// import express from "express";
|
|
2
|
+
// import {
|
|
3
|
+
// returnSourceData,
|
|
4
|
+
// } from "./constants/source_data";
|
|
5
|
+
// import config from "./config";
|
|
6
|
+
// const app = express();
|
|
7
|
+
// const port = 3000;
|
|
8
|
+
|
|
9
|
+
import { OnlyEverGenerator } from "./bootstrap/app";
|
|
10
|
+
// import { returnPromptData } from "./constants/prompt_data";
|
|
11
|
+
|
|
12
|
+
/// While Publishing the package , and using this code as a separate npm module
|
|
13
|
+
/// uncomment the below line and comment all the others, expect the import of OnlyEverGenerator
|
|
14
|
+
export {OnlyEverGenerator};
|
|
15
|
+
|
|
16
|
+
//. All the Codes Below uses express and are strictly for development purpose, while publishing the package, comment everything
|
|
17
|
+
//below this line
|
|
18
|
+
// let oeGen = new OnlyEverGenerator(config.openAIKey, "gpt-3.5-turbo-1106", {
|
|
19
|
+
// prompt: returnPromptData(),
|
|
20
|
+
// content: returnSourceData(),
|
|
21
|
+
// });
|
|
22
|
+
// app.get("/", async (req, res) => {
|
|
23
|
+
// // let data = oeGen.returnParsedContent();
|
|
24
|
+
// // let parsedData = parseResponse()
|
|
25
|
+
// let cardPrompt = "";
|
|
26
|
+
|
|
27
|
+
// res.send(cardPrompt);
|
|
28
|
+
// });
|
|
29
|
+
|
|
30
|
+
// app.get("/openAI", async (req, res) => {
|
|
31
|
+
// // let prompt = returnPromt();
|
|
32
|
+
// // let prompt = returnCardGenPrompt();
|
|
33
|
+
// // let content = returnSourceData().toString()
|
|
34
|
+
// // let headings = returnHeadings();
|
|
35
|
+
// // // let aiRequest = await openAIRequest(prompt,content);
|
|
36
|
+
// // let aiRequest = await oeGen.generateCard(prompt,content, false);
|
|
37
|
+
// // res.send(aiRequest);
|
|
38
|
+
// });
|
|
39
|
+
|
|
40
|
+
// app.get("/typology", async (req, res) => {
|
|
41
|
+
// {
|
|
42
|
+
// // let typologyPrompt = returnTypologyPrompt();
|
|
43
|
+
// // let cardPrompt = returnCardGenPrompt();
|
|
44
|
+
// // let args = new GenerateArgs(
|
|
45
|
+
// // true,
|
|
46
|
+
// // true,
|
|
47
|
+
// // false,
|
|
48
|
+
// // {
|
|
49
|
+
// // typology_prompt: typologyPrompt,
|
|
50
|
+
// // card_gen_prompt: cardPrompt,
|
|
51
|
+
// // summary_prompt: "",
|
|
52
|
+
// // }
|
|
53
|
+
// // )
|
|
54
|
+
// let typologyRequest = await oeGen.generate(false, true);
|
|
55
|
+
// res.send(typologyRequest);
|
|
56
|
+
// }
|
|
57
|
+
// });
|
|
58
|
+
|
|
59
|
+
// app.listen(port, () => {
|
|
60
|
+
// console.log(`Example app listening at http://localhost:${port}`);
|
|
61
|
+
// });
|
package/src/logger.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
/// this method will call out atlas function and will write to a doc, incase of any errors:
|
|
2
|
-
/// this is only for developmemt use
|
|
3
|
-
|
|
4
|
-
import axios from "axios";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export class ErrorLogger{
|
|
8
|
-
data: any;
|
|
9
|
-
constructor(data: any){
|
|
10
|
-
this.data = data;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async log() {
|
|
14
|
-
try{
|
|
15
|
-
let response = await axios.post(
|
|
16
|
-
'https://us-east-1.aws.data.mongodb-api.com/app/oe-phase1-tkmsy/endpoint/oe_gen_logger',
|
|
17
|
-
{
|
|
18
|
-
data: this.data,
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
headers : {
|
|
22
|
-
"Content-Type" : ['application/json']
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
);
|
|
27
|
-
return response;}catch(e){
|
|
28
|
-
console.log(e)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
/// this method will call out atlas function and will write to a doc, incase of any errors:
|
|
2
|
+
/// this is only for developmemt use
|
|
3
|
+
|
|
4
|
+
import axios from "axios";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export class ErrorLogger{
|
|
8
|
+
data: any;
|
|
9
|
+
constructor(data: any){
|
|
10
|
+
this.data = data;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async log() {
|
|
14
|
+
try{
|
|
15
|
+
let response = await axios.post(
|
|
16
|
+
'https://us-east-1.aws.data.mongodb-api.com/app/oe-phase1-tkmsy/endpoint/oe_gen_logger',
|
|
17
|
+
{
|
|
18
|
+
data: this.data,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
headers : {
|
|
22
|
+
"Content-Type" : ['application/json']
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
);
|
|
27
|
+
return response;}catch(e){
|
|
28
|
+
console.log(e)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
31
|
}
|