only_ever_generator 8.1.3 → 8.1.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_typology.d.ts","sourceRoot":"","sources":["../../src/typology_gen/generate_typology.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAQ5D,qBAAa,gBAAgB;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAM;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,OAAO,EAAE;QACd,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,EAAE,GAAG,EAAE,CAAC;KAChB,CAAC;IACK,mBAAmB,EAAE,MAAM,CAAC;IACnC,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAE5B,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,EAAE,GAAG,EAAE,CAAC;KAChB,EACD,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,EAC9B,mBAAmB,EAAE,MAAM,EAC3B,oBAAoB,EAAE,OAAO;IAYzB,QAAQ;
|
|
1
|
+
{"version":3,"file":"generate_typology.d.ts","sourceRoot":"","sources":["../../src/typology_gen/generate_typology.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAQ5D,qBAAa,gBAAgB;IACpB,aAAa,EAAE,aAAa,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAM;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,OAAO,EAAE;QACd,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,EAAE,GAAG,EAAE,CAAC;KAChB,CAAC;IACK,mBAAmB,EAAE,MAAM,CAAC;IACnC,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAE5B,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,OAAO,EAAE,GAAG,EAAE,CAAC;KAChB,EACD,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,EAC9B,mBAAmB,EAAE,MAAM,EAC3B,oBAAoB,EAAE,OAAO;IAYzB,QAAQ;IA+Gd,sBAAsB,CAAC,YAAY,EAAE,GAAG;;;;;;;;;;IAgBxC,SAAS,CAAC,QAAQ,EAAE,GAAG;IAyBvB,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;;;;IAQ3B,sBAAsB,CAAC,YAAY,EAAE,GAAG;;;;CAQ/C"}
|
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.GenerateTypology = void 0;
|
|
13
13
|
const openai_helper_1 = require("../helper/openai_helper");
|
|
14
14
|
const logger_1 = require("../logger");
|
|
15
|
-
const build_classify_summarize_schema_1 = require("../helper/schema_helper/build_classify_summarize_schema");
|
|
16
15
|
const sanitize_strings_1 = require("../utils/sanitize_strings");
|
|
17
16
|
class GenerateTypology {
|
|
18
17
|
constructor(openAiService, type, sourceId, content, expected_fields, promptIdForTypology, generationCurriculum) {
|
|
@@ -29,37 +28,44 @@ class GenerateTypology {
|
|
|
29
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
30
29
|
var _a, _b, _c, _d, _e;
|
|
31
30
|
try {
|
|
32
|
-
const headings =
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
// const headings =
|
|
32
|
+
// this.type == "video"
|
|
33
|
+
// ? this.content.timecodes || [""]
|
|
34
|
+
// : this.content.h1_headings || [""];
|
|
35
35
|
// Use OpenAI Responses API
|
|
36
|
-
const classifySummarizeSchema =
|
|
36
|
+
// const classifySummarizeSchema = await buildClassifySummarizeSchema(
|
|
37
|
+
// headings.length > 0 ? headings : [""]
|
|
38
|
+
// );
|
|
37
39
|
const openAIHelper = new openai_helper_1.OpenAIHelper(this.openAiService.api_key);
|
|
38
40
|
const openAiResponse = yield openAIHelper.openAI.responses.create({
|
|
39
41
|
prompt: {
|
|
40
42
|
id: this.promptIdForTypology,
|
|
41
43
|
variables: {
|
|
42
44
|
heading_type: this.type == "video" ? "timecode" : "h1 heading",
|
|
45
|
+
source_title: this.content.title,
|
|
46
|
+
source_content: JSON.stringify(this.content.content),
|
|
47
|
+
source_headings: JSON.stringify(this.content.h1_headings || []),
|
|
43
48
|
},
|
|
49
|
+
version: "64",
|
|
44
50
|
},
|
|
45
51
|
max_output_tokens: 30000,
|
|
46
|
-
input: [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
],
|
|
52
|
+
// input: [
|
|
53
|
+
// {
|
|
54
|
+
// role: "user",
|
|
55
|
+
// content: [
|
|
56
|
+
// { type: "input_text", text: JSON.stringify(this.content) },
|
|
57
|
+
// ],
|
|
58
|
+
// },
|
|
59
|
+
// ],
|
|
54
60
|
store: true,
|
|
55
|
-
text: {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
61
|
+
// text: {
|
|
62
|
+
// format: {
|
|
63
|
+
// type: "json_schema",
|
|
64
|
+
// name: classifySummarizeSchema.name,
|
|
65
|
+
// strict: true,
|
|
66
|
+
// schema: classifySummarizeSchema.schema,
|
|
67
|
+
// },
|
|
68
|
+
// },
|
|
63
69
|
});
|
|
64
70
|
console.log(openAiResponse);
|
|
65
71
|
if (!openAiResponse) {
|
|
@@ -94,7 +100,10 @@ class GenerateTypology {
|
|
|
94
100
|
},
|
|
95
101
|
req_tokens: (_c = (_b = openAiResponse.usage) === null || _b === void 0 ? void 0 : _b.input_tokens) !== null && _c !== void 0 ? _c : 0,
|
|
96
102
|
res_tokens: (_e = (_d = openAiResponse.usage) === null || _d === void 0 ? void 0 : _d.output_tokens) !== null && _e !== void 0 ? _e : 0,
|
|
97
|
-
prompt:
|
|
103
|
+
prompt: {
|
|
104
|
+
id: openAiResponse.prompt.id,
|
|
105
|
+
version: openAiResponse.prompt.version,
|
|
106
|
+
},
|
|
98
107
|
// prompt_tokens_details: openAiResponse.usage?.,
|
|
99
108
|
model: openAiResponse.model,
|
|
100
109
|
usage: openAiResponse.usage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate_typology.js","sourceRoot":"","sources":["../../src/typology_gen/generate_typology.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,2DAAkE;AAClE,sCAAiE;
|
|
1
|
+
{"version":3,"file":"generate_typology.js","sourceRoot":"","sources":["../../src/typology_gen/generate_typology.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,2DAAkE;AAClE,sCAAiE;AAIjE,gEAGmC;AAEnC,MAAa,gBAAgB;IAa3B,YACE,aAA4B,EAC5B,IAAY,EACZ,QAAgB,EAChB,OAKC,EACD,eAA8B,EAC9B,mBAA2B,EAC3B,oBAA6B;QAvBxB,SAAI,GAAW,EAAE,CAAC;QAyBvB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,IAA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AAC,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;AA7MD,4CA6MC"}
|
package/package.json
CHANGED
|
@@ -48,14 +48,14 @@ export class GenerateTypology {
|
|
|
48
48
|
}
|
|
49
49
|
async generate() {
|
|
50
50
|
try {
|
|
51
|
-
const headings =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
// const headings =
|
|
52
|
+
// this.type == "video"
|
|
53
|
+
// ? this.content.timecodes || [""]
|
|
54
|
+
// : this.content.h1_headings || [""];
|
|
55
55
|
// Use OpenAI Responses API
|
|
56
|
-
const classifySummarizeSchema = await buildClassifySummarizeSchema(
|
|
57
|
-
|
|
58
|
-
);
|
|
56
|
+
// const classifySummarizeSchema = await buildClassifySummarizeSchema(
|
|
57
|
+
// headings.length > 0 ? headings : [""]
|
|
58
|
+
// );
|
|
59
59
|
const openAIHelper = new OpenAIHelper(this.openAiService.api_key);
|
|
60
60
|
|
|
61
61
|
const openAiResponse: any = await openAIHelper.openAI.responses.create({
|
|
@@ -63,26 +63,30 @@ export class GenerateTypology {
|
|
|
63
63
|
id: this.promptIdForTypology,
|
|
64
64
|
variables: {
|
|
65
65
|
heading_type: this.type == "video" ? "timecode" : "h1 heading",
|
|
66
|
+
source_title: this.content.title,
|
|
67
|
+
source_content: JSON.stringify(this.content.content),
|
|
68
|
+
source_headings: JSON.stringify(this.content.h1_headings || []),
|
|
66
69
|
},
|
|
70
|
+
version: "64",
|
|
67
71
|
},
|
|
68
72
|
max_output_tokens: 30000,
|
|
69
|
-
input: [
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
],
|
|
73
|
+
// input: [
|
|
74
|
+
// {
|
|
75
|
+
// role: "user",
|
|
76
|
+
// content: [
|
|
77
|
+
// { type: "input_text", text: JSON.stringify(this.content) },
|
|
78
|
+
// ],
|
|
79
|
+
// },
|
|
80
|
+
// ],
|
|
77
81
|
store: true,
|
|
78
|
-
text: {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
},
|
|
82
|
+
// text: {
|
|
83
|
+
// format: {
|
|
84
|
+
// type: "json_schema",
|
|
85
|
+
// name: classifySummarizeSchema.name,
|
|
86
|
+
// strict: true,
|
|
87
|
+
// schema: classifySummarizeSchema.schema,
|
|
88
|
+
// },
|
|
89
|
+
// },
|
|
86
90
|
});
|
|
87
91
|
console.log(openAiResponse);
|
|
88
92
|
if (!openAiResponse) {
|
|
@@ -119,7 +123,10 @@ export class GenerateTypology {
|
|
|
119
123
|
},
|
|
120
124
|
req_tokens: openAiResponse.usage?.input_tokens ?? 0,
|
|
121
125
|
res_tokens: openAiResponse.usage?.output_tokens ?? 0,
|
|
122
|
-
prompt:
|
|
126
|
+
prompt: {
|
|
127
|
+
id: openAiResponse.prompt.id,
|
|
128
|
+
version: openAiResponse.prompt.version,
|
|
129
|
+
},
|
|
123
130
|
// prompt_tokens_details: openAiResponse.usage?.,
|
|
124
131
|
model: openAiResponse.model,
|
|
125
132
|
usage: openAiResponse.usage,
|