only_ever_generator 8.1.2 → 8.1.4
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/index.js +32 -50
- package/dist/index.js.map +1 -1
- package/dist/typology_gen/generate_typology.d.ts.map +1 -1
- package/dist/typology_gen/generate_typology.js +27 -21
- package/dist/typology_gen/generate_typology.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +35 -35
- package/src/typology_gen/generate_typology.ts +27 -23
package/dist/index.js
CHANGED
|
@@ -1,57 +1,39 @@
|
|
|
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
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.OnlyEverGenerator = void 0;
|
|
16
|
-
const mongodb_1 = require("mongodb");
|
|
17
4
|
const app_1 = require("./bootstrap/app");
|
|
18
5
|
Object.defineProperty(exports, "OnlyEverGenerator", { enumerable: true, get: function () { return app_1.OnlyEverGenerator; } });
|
|
19
|
-
const open_ai_service_1 = require("./services/open_ai_service");
|
|
20
|
-
const summarize_1 = require("./typology_gen/summarize");
|
|
21
|
-
const mongo_helper_1 = require("./helper/mongo_helper");
|
|
22
|
-
// import { LocalConsolidation } from "./embedding_generation/consolidation/local_consolidation";
|
|
23
|
-
// import { embeddingsResp } from "./typology-parsed-response";
|
|
24
|
-
// import { GlobalConsolidation } from "./embedding_generation/consolidation/global_consolidation";
|
|
25
|
-
// import { ParseEmbeddingResponse } from "./embedding_generation/parse_embedding_response";
|
|
26
|
-
// import { OpenAIHelper } from "./helper/openai_helper";
|
|
27
|
-
// import { GenerateTypology } from "./typology_gen/generate_typology";
|
|
28
|
-
// import { OpenAiService } from "./services/open_ai_service";
|
|
29
|
-
// import { GenerateConceptFacts } from "./typology_gen/generate_concept_facts";
|
|
30
|
-
// import { BaseParamType } from "./types/base_param_type";
|
|
31
|
-
// import dotenv from "dotenv";
|
|
32
|
-
const express_1 = __importDefault(require("express"));
|
|
33
|
-
const app = (0, express_1.default)();
|
|
34
|
-
const port = 3000;
|
|
35
6
|
// dotenv.config();
|
|
36
|
-
app.listen(port, () => {
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
app.get("/summarize", (req, res) =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
7
|
+
// app.listen(port, () => {
|
|
8
|
+
// console.log(`Server is running on port ${port}`);
|
|
9
|
+
// });
|
|
10
|
+
// app.get("/summarize", async (req, res) => {
|
|
11
|
+
// setUp();
|
|
12
|
+
// const promptIdForSummaryCards =
|
|
13
|
+
// "pmpt_6902c30a973481968395935cc6dfa78605f50d2b01d4afbd";
|
|
14
|
+
// const sourceId = "68b114dac849a25097ed1778";
|
|
15
|
+
// const source = await database
|
|
16
|
+
// .collection("_source")
|
|
17
|
+
// .findOne({ _id: new ObjectId(sourceId) });
|
|
18
|
+
// const content = {
|
|
19
|
+
// title: source?.title,
|
|
20
|
+
// h1_headings: source?.headings,
|
|
21
|
+
// content: source?.content,
|
|
22
|
+
// };
|
|
23
|
+
// const openAiService = new OpenAiService(
|
|
24
|
+
// process.env.OPEN_AI_KEY || "",
|
|
25
|
+
// "gpt-5-mini"
|
|
26
|
+
// );
|
|
27
|
+
// const summarize = new GenerateSummaryCards(
|
|
28
|
+
// openAiService,
|
|
29
|
+
// sourceId,
|
|
30
|
+
// content,
|
|
31
|
+
// "text",
|
|
32
|
+
// promptIdForSummaryCards,
|
|
33
|
+
// false
|
|
34
|
+
// );
|
|
35
|
+
// const summaryCards = await summarize.generate();
|
|
36
|
+
// console.log(summaryCards);
|
|
37
|
+
// res.json(summaryCards);
|
|
38
|
+
// });
|
|
57
39
|
//# 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":";;;AACA,yCAAoD;AAyB3C,kGAzBA,uBAAiB,OAyBA;AAC1B,mBAAmB;AAEnB,2BAA2B;AAC3B,sDAAsD;AACtD,MAAM;AAEN,8CAA8C;AAC9C,aAAa;AACb,oCAAoC;AACpC,+DAA+D;AAC/D,iDAAiD;AACjD,kCAAkC;AAClC,6BAA6B;AAC7B,iDAAiD;AACjD,sBAAsB;AACtB,4BAA4B;AAC5B,qCAAqC;AACrC,gCAAgC;AAChC,OAAO;AACP,6CAA6C;AAC7C,qCAAqC;AACrC,mBAAmB;AACnB,OAAO;AACP,gDAAgD;AAChD,qBAAqB;AACrB,gBAAgB;AAChB,eAAe;AACf,cAAc;AACd,+BAA+B;AAC/B,YAAY;AACZ,OAAO;AACP,qDAAqD;AACrD,+BAA+B;AAC/B,4BAA4B;AAC5B,MAAM"}
|
|
@@ -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;IA4Gd,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) {
|
|
@@ -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,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE,CACzD,IAAI,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,CAC9B,CAAC;QACF,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAC/C,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,CAAC;IACK,QAAQ;;;YACZ,IAAI,CAAC;gBACH,mBAAmB;gBACnB,yBAAyB;gBACzB,uCAAuC;gBACvC,0CAA0C;gBAC1C,2BAA2B;gBAC3B,sEAAsE;gBACtE,0CAA0C;gBAC1C,KAAK;gBACL,MAAM,YAAY,GAAG,IAAI,4BAAY,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;gBAElE,MAAM,cAAc,GAAQ,MAAM,YAAY,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X,MAAM,IAAI,qBAAY,CACpB,0CAA0C,EAC1C,QAAQ,CACT,CAAC;QACJ,CAAC;IACH,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;AA1MD,4CA0MC"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -13,9 +13,9 @@ import { database, setUp } from "./helper/mongo_helper";
|
|
|
13
13
|
// import { GenerateConceptFacts } from "./typology_gen/generate_concept_facts";
|
|
14
14
|
// import { BaseParamType } from "./types/base_param_type";
|
|
15
15
|
// import dotenv from "dotenv";
|
|
16
|
-
import express from "express";
|
|
17
|
-
const app = express();
|
|
18
|
-
const port = 3000;
|
|
16
|
+
// import express from "express";
|
|
17
|
+
// const app = express();
|
|
18
|
+
// const port = 3000;
|
|
19
19
|
|
|
20
20
|
// // import { OnlyEverGenerator } from "./bootstrap/app";
|
|
21
21
|
// import { database, ObjectId, setUp } from "./helper/mongo_helper";
|
|
@@ -27,36 +27,36 @@ const port = 3000;
|
|
|
27
27
|
export { OnlyEverGenerator };
|
|
28
28
|
// dotenv.config();
|
|
29
29
|
|
|
30
|
-
app.listen(port, () => {
|
|
31
|
-
|
|
32
|
-
});
|
|
30
|
+
// app.listen(port, () => {
|
|
31
|
+
// console.log(`Server is running on port ${port}`);
|
|
32
|
+
// });
|
|
33
33
|
|
|
34
|
-
app.get("/summarize", async (req, res) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
34
|
+
// app.get("/summarize", async (req, res) => {
|
|
35
|
+
// setUp();
|
|
36
|
+
// const promptIdForSummaryCards =
|
|
37
|
+
// "pmpt_6902c30a973481968395935cc6dfa78605f50d2b01d4afbd";
|
|
38
|
+
// const sourceId = "68b114dac849a25097ed1778";
|
|
39
|
+
// const source = await database
|
|
40
|
+
// .collection("_source")
|
|
41
|
+
// .findOne({ _id: new ObjectId(sourceId) });
|
|
42
|
+
// const content = {
|
|
43
|
+
// title: source?.title,
|
|
44
|
+
// h1_headings: source?.headings,
|
|
45
|
+
// content: source?.content,
|
|
46
|
+
// };
|
|
47
|
+
// const openAiService = new OpenAiService(
|
|
48
|
+
// process.env.OPEN_AI_KEY || "",
|
|
49
|
+
// "gpt-5-mini"
|
|
50
|
+
// );
|
|
51
|
+
// const summarize = new GenerateSummaryCards(
|
|
52
|
+
// openAiService,
|
|
53
|
+
// sourceId,
|
|
54
|
+
// content,
|
|
55
|
+
// "text",
|
|
56
|
+
// promptIdForSummaryCards,
|
|
57
|
+
// false
|
|
58
|
+
// );
|
|
59
|
+
// const summaryCards = await summarize.generate();
|
|
60
|
+
// console.log(summaryCards);
|
|
61
|
+
// res.json(summaryCards);
|
|
62
|
+
// });
|
|
@@ -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) {
|