only_ever_generator 4.0.1 → 4.0.3

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.
Files changed (32) hide show
  1. package/dist/bootstrap/app.js +12 -12
  2. package/dist/bootstrap/app.js.map +1 -1
  3. package/dist/helper/mongo_helper.d.ts +5 -0
  4. package/dist/helper/mongo_helper.d.ts.map +1 -0
  5. package/dist/helper/mongo_helper.js +12 -0
  6. package/dist/helper/mongo_helper.js.map +1 -0
  7. package/dist/helper/schema_helper/build_classify_summarize_schema.d.ts +1 -76
  8. package/dist/helper/schema_helper/build_classify_summarize_schema.d.ts.map +1 -1
  9. package/dist/helper/schema_helper/build_classify_summarize_schema.js +43 -93
  10. package/dist/helper/schema_helper/build_classify_summarize_schema.js.map +1 -1
  11. package/dist/helper/schema_helper/build_concept_facts_schema.d.ts +1 -42
  12. package/dist/helper/schema_helper/build_concept_facts_schema.d.ts.map +1 -1
  13. package/dist/helper/schema_helper/build_concept_facts_schema.js +40 -40
  14. package/dist/helper/schema_helper/build_concept_facts_schema.js.map +1 -1
  15. package/dist/index.d.ts +1 -2
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +1133 -1140
  18. package/dist/index.js.map +1 -1
  19. package/dist/typology_gen/generate_concept_facts.js +3 -3
  20. package/dist/typology_gen/generate_concept_facts.js.map +1 -1
  21. package/dist/typology_gen/generate_typology.d.ts +12 -2
  22. package/dist/typology_gen/generate_typology.d.ts.map +1 -1
  23. package/dist/typology_gen/generate_typology.js +9 -4
  24. package/dist/typology_gen/generate_typology.js.map +1 -1
  25. package/package.json +3 -2
  26. package/src/bootstrap/app.ts +8 -8
  27. package/src/helper/mongo_helper.ts +9 -0
  28. package/src/helper/schema_helper/build_classify_summarize_schema.ts +38 -98
  29. package/src/helper/schema_helper/build_concept_facts_schema.ts +35 -83
  30. package/src/index.ts +1150 -1147
  31. package/src/typology_gen/generate_concept_facts.ts +4 -4
  32. package/src/typology_gen/generate_typology.ts +23 -4
@@ -35,10 +35,10 @@ export class GenerateConceptFacts {
35
35
  try {
36
36
  const headings =
37
37
  this.type === "text"
38
- ? this.content.h1_headings || []
39
- : this.content.timecodes || [];
40
- const schema = buildConceptFactSchema(
41
- headings,
38
+ ? this.content.h1_headings || [""]
39
+ : this.content.timecodes || [""];
40
+ const schema = await buildConceptFactSchema(
41
+ headings.length > 0 ? headings : [""],
42
42
  "concept_fact_gen_schema",
43
43
  true
44
44
  );
@@ -3,18 +3,28 @@ import { getOpenAI, OpenAIHelper } from "../helper/openai_helper";
3
3
  import { ErrorLogger } from "../logger";
4
4
  import { OpenAiService } from "../services/open_ai_service";
5
5
  import { text } from "stream/consumers";
6
- import { classifySummarizeSchema } from "../helper/schema_helper/build_classify_summarize_schema";
6
+ import { buildClassifySummarizeSchema } from "../helper/schema_helper/build_classify_summarize_schema";
7
7
 
8
8
  export class GenerateTypology {
9
9
  public openAiService: OpenAiService;
10
10
  public type: string = "";
11
- public content: string = "";
11
+ public content: {
12
+ title: string;
13
+ h1_headings?: string[];
14
+ timecodes?: string[];
15
+ content: any[];
16
+ };
12
17
  public promptIdForTypology: string;
13
18
  expectedFields: Array<string>;
14
19
  constructor(
15
20
  openAiService: OpenAiService,
16
21
  type: string,
17
- content: string,
22
+ content: {
23
+ title: string;
24
+ h1_headings?: string[];
25
+ timecodes?: string[];
26
+ content: any[];
27
+ },
18
28
  expected_fields: Array<string>,
19
29
  promptIdForTypology: string
20
30
  ) {
@@ -28,7 +38,14 @@ export class GenerateTypology {
28
38
  }
29
39
  async generate() {
30
40
  try {
41
+ const headings =
42
+ this.type == "video"
43
+ ? this.content.timecodes || [""]
44
+ : this.content.h1_headings || [""];
31
45
  // Use OpenAI Responses API
46
+ const classifySummarizeSchema = await buildClassifySummarizeSchema(
47
+ headings.length > 0 ? headings : [""]
48
+ );
32
49
  const openAIHelper = new OpenAIHelper(this.openAiService.api_key);
33
50
 
34
51
  const openAiResponse: any = await openAIHelper.openAI.responses.create({
@@ -41,7 +58,9 @@ export class GenerateTypology {
41
58
  input: [
42
59
  {
43
60
  role: "user",
44
- content: [{ type: "input_text", text: this.content }],
61
+ content: [
62
+ { type: "input_text", text: JSON.stringify(this.content) },
63
+ ],
45
64
  },
46
65
  ],
47
66
  store: false,