only_ever_generator 0.1.0 → 0.1.2
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 +8 -1
- package/dist/card_gen/generate_cards.js +2 -0
- package/dist/index.js +54 -49
- package/package.json +6 -5
- package/src/bootstrap/app.ts +7 -1
- package/src/card_gen/generate_cards.ts +2 -0
- package/src/index.ts +48 -48
package/dist/bootstrap/app.js
CHANGED
|
@@ -53,7 +53,14 @@ class OnlyEverGenerator {
|
|
|
53
53
|
responseToReturn.push(this.typologyResponse);
|
|
54
54
|
}
|
|
55
55
|
else if (elem == "generate_card") {
|
|
56
|
-
|
|
56
|
+
if (this.typologyResponse.generate_card) {
|
|
57
|
+
if (this.typologyResponse.generate_card.state == false) {
|
|
58
|
+
console.log('Cards Generation Not Required');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.cardgenResponse = yield this.generateCard((_b = args.prompts.card_gen_prompt) !== null && _b !== void 0 ? _b : "", this.parsedContent + JSON.stringify(this.typologyResponse), false);
|
|
63
|
+
}
|
|
57
64
|
responseToReturn.push(this.cardgenResponse);
|
|
58
65
|
}
|
|
59
66
|
if (this.cardgenResponse.status_code == 200) {
|
|
@@ -27,9 +27,11 @@ class GenerateCards {
|
|
|
27
27
|
"res_tokens": (_c = response.usage_data) === null || _c === void 0 ? void 0 : _c.completion_tokens,
|
|
28
28
|
};
|
|
29
29
|
if (response.status_code == 200) {
|
|
30
|
+
response.metadata.status = "completed";
|
|
30
31
|
return this.parse(response);
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
34
|
+
response.metadata.status = "failed";
|
|
33
35
|
return response;
|
|
34
36
|
}
|
|
35
37
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,54 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
10
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
|
|
15
|
+
const express_1 = __importDefault(require("express"));
|
|
16
|
+
const card_gen_prompt_1 = require("./constants/prompts/card_gen_prompt");
|
|
17
|
+
const typology_prompt_1 = require("./constants/prompts/typology_prompt");
|
|
18
|
+
const generate_args_1 = require("./utils/generate_args");
|
|
19
|
+
const source_data_1 = require("./constants/source_data");
|
|
20
|
+
const config_1 = __importDefault(require("./config"));
|
|
21
|
+
const app = (0, express_1.default)();
|
|
22
|
+
const port = 3000;
|
|
12
23
|
const app_1 = require("./bootstrap/app");
|
|
13
|
-
|
|
24
|
+
/// While Publishing the package , and using this code as a separate npm module
|
|
25
|
+
/// uncomment the below line and comment all the others, expect the import of OnlyEverGenerator
|
|
26
|
+
// export {OnlyEverGenerator};
|
|
14
27
|
/// All the Codes Below uses express and are strictly for development purpose, while publishing the package, comment everything
|
|
15
28
|
/// below this line
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// true
|
|
48
|
-
// );
|
|
49
|
-
// res.send(typologyRequest);
|
|
50
|
-
// }
|
|
51
|
-
// });
|
|
52
|
-
// app.listen(port, () => {
|
|
53
|
-
// console.log(`Example app listening at http://localhost:${port}`);
|
|
54
|
-
// });
|
|
29
|
+
let oeGen = new app_1.OnlyEverGenerator(config_1.default.openAIKey, "gpt-3.5-turbo-1106", (0, source_data_1.returnSourceData)(), (0, source_data_1.returnFields)());
|
|
30
|
+
app.get('/', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
let data = oeGen._returnParsedContent();
|
|
32
|
+
// let parsedData = parseResponse()
|
|
33
|
+
res.send(data);
|
|
34
|
+
}));
|
|
35
|
+
app.get('/openAI', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
// let prompt = returnPromt();
|
|
37
|
+
let prompt = (0, card_gen_prompt_1.returnCardGenPrompt)();
|
|
38
|
+
let content = (0, source_data_1.returnSourceData)().toString();
|
|
39
|
+
let headings = (0, source_data_1.returnHeadings)();
|
|
40
|
+
// let aiRequest = await openAIRequest(prompt,content);
|
|
41
|
+
let aiRequest = yield oeGen.generateCard(prompt, content, false);
|
|
42
|
+
res.send(aiRequest);
|
|
43
|
+
}));
|
|
44
|
+
app.get('/typology', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
{
|
|
46
|
+
let typologyPrompt = (0, typology_prompt_1.returnTypologyPrompt)();
|
|
47
|
+
let cardPrompt = (0, card_gen_prompt_1.returnCardGenPrompt)();
|
|
48
|
+
let args = new generate_args_1.GenerateArgs(true, true, false, {
|
|
49
|
+
typology_prompt: typologyPrompt,
|
|
50
|
+
card_gen_prompt: cardPrompt,
|
|
51
|
+
summary_prompt: "",
|
|
52
|
+
});
|
|
53
|
+
let typologyRequest = yield oeGen.generate(true, true);
|
|
54
|
+
res.send(typologyRequest);
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
app.listen(port, () => {
|
|
58
|
+
console.log(`Example app listening at http://localhost:${port}`);
|
|
59
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "only_ever_generator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "npm run build && nodemon dist/index.js",
|
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
"@types/node": "^20.14.2",
|
|
16
16
|
"nodemon": "^3.1.3",
|
|
17
17
|
"ts-node": "^10.9.2",
|
|
18
|
-
"typescript": "^5.4.5"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"axios": "^1.7.2",
|
|
18
|
+
"typescript": "^5.4.5",
|
|
22
19
|
"dotenv": "^16.4.5",
|
|
23
20
|
"express": "^4.19.2"
|
|
21
|
+
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"axios": "^1.7.2"
|
|
24
25
|
|
|
25
26
|
},
|
|
26
27
|
"eslintConfig": {
|
package/src/bootstrap/app.ts
CHANGED
|
@@ -58,11 +58,17 @@ export class OnlyEverGenerator {
|
|
|
58
58
|
);
|
|
59
59
|
responseToReturn.push(this.typologyResponse);
|
|
60
60
|
} else if (elem == "generate_card") {
|
|
61
|
+
if(this.typologyResponse.generate_card){
|
|
62
|
+
if(this.typologyResponse.generate_card.state == false){
|
|
63
|
+
console.log('Cards Generation Not Required');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}else{
|
|
61
67
|
this.cardgenResponse = await this.generateCard(
|
|
62
68
|
args.prompts.card_gen_prompt ?? "",
|
|
63
69
|
this.parsedContent + JSON.stringify(this.typologyResponse),
|
|
64
70
|
false
|
|
65
|
-
);
|
|
71
|
+
);}
|
|
66
72
|
responseToReturn.push(this.cardgenResponse);
|
|
67
73
|
}
|
|
68
74
|
if (this.cardgenResponse.status_code == 200) {
|
|
@@ -17,8 +17,10 @@ export class GenerateCards {
|
|
|
17
17
|
"res_tokens": response.usage_data?.completion_tokens,
|
|
18
18
|
};
|
|
19
19
|
if(response.status_code == 200){
|
|
20
|
+
response.metadata.status = "completed";
|
|
20
21
|
return this.parse(response);
|
|
21
22
|
} else {
|
|
23
|
+
response.metadata.status = "failed";
|
|
22
24
|
return response;
|
|
23
25
|
}
|
|
24
26
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import express from "express";
|
|
3
|
+
import { returnCardGenPrompt } from "./constants/prompts/card_gen_prompt";
|
|
4
|
+
import { returnTypologyPrompt } from "./constants/prompts/typology_prompt";
|
|
5
|
+
import { GenerateArgs } from "./utils/generate_args";
|
|
6
|
+
import { returnFields, returnHeadings, returnSourceData } from "./constants/source_data";
|
|
7
|
+
import config from "./config";
|
|
8
|
+
const app = express();
|
|
9
|
+
const port = 3000;
|
|
10
10
|
|
|
11
11
|
import { OnlyEverGenerator } from "./bootstrap/app";
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
/// While Publishing the package , and using this code as a separate npm module
|
|
15
15
|
/// uncomment the below line and comment all the others, expect the import of OnlyEverGenerator
|
|
16
|
-
export {OnlyEverGenerator};
|
|
16
|
+
// export {OnlyEverGenerator};
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
/// All the Codes Below uses express and are strictly for development purpose, while publishing the package, comment everything
|
|
22
22
|
/// below this line
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
let oeGen = new OnlyEverGenerator(config.openAIKey,"gpt-3.5-turbo-1106" ,returnSourceData(),returnFields())
|
|
24
|
+
app.get('/', async (req, res) => {
|
|
25
|
+
let data = oeGen._returnParsedContent();
|
|
26
|
+
// let parsedData = parseResponse()
|
|
27
|
+
res.send(data);
|
|
28
|
+
});
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
//
|
|
30
|
+
app.get('/openAI', async (req,res)=> {
|
|
31
|
+
// let prompt = returnPromt();
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
let prompt = returnCardGenPrompt();
|
|
34
|
+
let content = returnSourceData().toString()
|
|
35
|
+
let headings = returnHeadings();
|
|
36
|
+
// let aiRequest = await openAIRequest(prompt,content);
|
|
37
|
+
let aiRequest = await oeGen.generateCard(prompt,content, false);
|
|
38
|
+
res.send(aiRequest);
|
|
39
|
+
});
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
41
|
+
app.get('/typology', async(req,res)=>{
|
|
42
|
+
{
|
|
43
|
+
let typologyPrompt = returnTypologyPrompt();
|
|
44
|
+
let cardPrompt = returnCardGenPrompt();
|
|
45
|
+
let args = new GenerateArgs(
|
|
46
|
+
true,
|
|
47
|
+
true,
|
|
48
|
+
false,
|
|
49
|
+
{
|
|
50
|
+
typology_prompt: typologyPrompt,
|
|
51
|
+
card_gen_prompt: cardPrompt,
|
|
52
|
+
summary_prompt: "",
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
let typologyRequest = await oeGen.generate(
|
|
56
|
+
true,
|
|
57
|
+
true
|
|
58
|
+
);
|
|
59
|
+
res.send(typologyRequest);
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
app.listen(port, () => {
|
|
65
|
+
console.log(`Example app listening at http://localhost:${port}`);
|
|
66
|
+
});
|