only_ever_generator 8.4.6 → 8.4.8

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 (118) hide show
  1. package/dist/bootstrap/app.d.ts +6 -3
  2. package/dist/bootstrap/app.d.ts.map +1 -1
  3. package/dist/bootstrap/app.js +11 -17
  4. package/dist/bootstrap/app.js.map +1 -1
  5. package/dist/card_gen/generate_cards.d.ts +2 -3
  6. package/dist/card_gen/generate_cards.d.ts.map +1 -1
  7. package/dist/card_gen/generate_cards.js +22 -15
  8. package/dist/card_gen/generate_cards.js.map +1 -1
  9. package/dist/constants/prompt_data.d.ts +4 -4
  10. package/dist/constants/prompt_data.js +302 -302
  11. package/dist/constants/prompts/card_gen_prompt.js +160 -160
  12. package/dist/constants/prompts/typology_prompt.js +131 -131
  13. package/dist/constants/source_data.d.ts +171 -171
  14. package/dist/constants/source_data.js +973 -973
  15. package/dist/embedding_generation/local_consolidation.js +104 -104
  16. package/dist/helper/build_concept_facts_schema.d.ts +42 -42
  17. package/dist/helper/build_concept_facts_schema.js +44 -44
  18. package/dist/helper/qdrant_db_methods.d.ts.map +1 -1
  19. package/dist/helper/schema_helper/build_card_schema.d.ts +1 -9
  20. package/dist/helper/schema_helper/build_card_schema.d.ts.map +1 -1
  21. package/dist/helper/schema_helper/build_card_schema.js +47 -50
  22. package/dist/helper/schema_helper/build_card_schema.js.map +1 -1
  23. package/dist/helper/schema_helper/build_concept_facts_schema.d.ts +1 -1
  24. package/dist/helper/schema_helper/build_concept_facts_schema.d.ts.map +1 -1
  25. package/dist/helper/schema_helper/build_concept_facts_schema.js +20 -5
  26. package/dist/helper/schema_helper/build_concept_facts_schema.js.map +1 -1
  27. package/dist/helper/schema_helper/build_summary_schema.d.ts +1 -1
  28. package/dist/helper/schema_helper/build_summary_schema.d.ts.map +1 -1
  29. package/dist/helper/schema_helper/build_summary_schema.js +18 -7
  30. package/dist/helper/schema_helper/build_summary_schema.js.map +1 -1
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +5 -5
  33. package/dist/index.js.map +1 -1
  34. package/dist/parse/response_format_card.d.ts +176 -176
  35. package/dist/parse/response_format_card.js +371 -371
  36. package/dist/parse/response_format_typology.d.ts +1 -1
  37. package/dist/parse/response_format_typology.js +46 -46
  38. package/dist/services/get_prompts.d.ts +8 -7
  39. package/dist/services/get_prompts.d.ts.map +1 -1
  40. package/dist/services/get_prompts.js +69 -21
  41. package/dist/services/get_prompts.js.map +1 -1
  42. package/dist/typology_gen/generate_concept_facts.d.ts +2 -3
  43. package/dist/typology_gen/generate_concept_facts.d.ts.map +1 -1
  44. package/dist/typology_gen/generate_concept_facts.js +25 -15
  45. package/dist/typology_gen/generate_concept_facts.js.map +1 -1
  46. package/dist/typology_gen/generate_typology.d.ts +2 -1
  47. package/dist/typology_gen/generate_typology.d.ts.map +1 -1
  48. package/dist/typology_gen/generate_typology.js +24 -13
  49. package/dist/typology_gen/generate_typology.js.map +1 -1
  50. package/dist/typology_gen/summarize.d.ts +2 -3
  51. package/dist/typology_gen/summarize.d.ts.map +1 -1
  52. package/dist/typology_gen/summarize.js +24 -13
  53. package/dist/typology_gen/summarize.js.map +1 -1
  54. package/package.json +39 -38
  55. package/src/bootstrap/app.ts +418 -416
  56. package/src/card_gen/generate_cards.ts +347 -345
  57. package/src/config.ts +11 -11
  58. package/src/constants/api_constants.ts +7 -7
  59. package/src/constants/prompts/card_gen_prompt.ts +164 -164
  60. package/src/constants/prompts/typology_prompt.ts +139 -139
  61. package/src/embedding_generation/consolidation/global_consolidation.ts +96 -96
  62. package/src/embedding_generation/consolidation/local_consolidation.ts +141 -141
  63. package/src/embedding_generation/consolidation/write_consolidated_data.ts +98 -98
  64. package/src/embedding_generation/generate_embeddings.ts +42 -42
  65. package/src/embedding_generation/parse_embedding_response.ts +31 -31
  66. package/src/enums/card_type_enum.ts +6 -6
  67. package/src/gap_fill/calculate_gap_fill.ts +50 -50
  68. package/src/helper/get_id_from_title.ts +33 -33
  69. package/src/helper/mongo_helper.ts +29 -29
  70. package/src/helper/openai_helper.ts +20 -20
  71. package/src/helper/qdrant_db_methods.ts +77 -77
  72. package/src/helper/schema_helper/build_card_schema.ts +74 -98
  73. package/src/helper/schema_helper/build_classify_summarize_schema.ts +43 -43
  74. package/src/helper/schema_helper/build_concept_facts_schema.ts +45 -31
  75. package/src/helper/schema_helper/build_summary_schema.ts +43 -32
  76. package/src/index.ts +71 -73
  77. package/src/logger.ts +65 -65
  78. package/src/parse/parse_card/parse_cloze_card.ts +146 -146
  79. package/src/parse/parse_card/parse_flash_cards.ts +42 -42
  80. package/src/parse/parse_card/parse_match_card.ts +104 -104
  81. package/src/parse/parse_card/parse_mcq_card.ts +114 -114
  82. package/src/parse/parse_card_response.ts +197 -197
  83. package/src/parse/parse_source_content.ts +212 -212
  84. package/src/services/get_prompts.ts +164 -112
  85. package/src/services/open_ai_service.ts +89 -89
  86. package/src/services/qdrant_service.ts +10 -10
  87. package/src/types/base_param_type.ts +13 -13
  88. package/src/types/mongo_concept_fact_type.ts +12 -12
  89. package/src/types/parsed_card_type.ts +39 -39
  90. package/src/types/raw_card_response_types/generated_card_response_type.ts +59 -59
  91. package/src/types/source_taxonomy_type.ts +24 -24
  92. package/src/typology-parsed-response.ts +1932 -1932
  93. package/src/typology_gen/generate_concept_facts.ts +180 -169
  94. package/src/typology_gen/generate_typology.ts +203 -189
  95. package/src/typology_gen/summarize.ts +176 -164
  96. package/src/utils/distributed_quote_restoration.ts +80 -80
  97. package/src/utils/generate_args.ts +29 -29
  98. package/src/utils/parse_openai_response.ts +19 -19
  99. package/src/utils/sanitize_strings.ts +65 -65
  100. package/tsconfig.json +16 -16
  101. package/dist/constants/default_generation_variables.d.ts +0 -3
  102. package/dist/constants/default_generation_variables.d.ts.map +0 -1
  103. package/dist/constants/default_generation_variables.js +0 -580
  104. package/dist/constants/default_generation_variables.js.map +0 -1
  105. package/dist/services/prompts_test.d.ts +0 -10
  106. package/dist/services/prompts_test.d.ts.map +0 -1
  107. package/dist/services/prompts_test.js +0 -227
  108. package/dist/services/prompts_test.js.map +0 -1
  109. package/dist/types/generation_variables_schema.d.ts +0 -14
  110. package/dist/types/generation_variables_schema.d.ts.map +0 -1
  111. package/dist/types/generation_variables_schema.js +0 -3
  112. package/dist/types/generation_variables_schema.js.map +0 -1
  113. package/dist/utils/test.d.ts +0 -2
  114. package/dist/utils/test.d.ts.map +0 -1
  115. package/dist/utils/test.js +0 -5
  116. package/dist/utils/test.js.map +0 -1
  117. package/src/constants/default_generation_variables.ts +0 -624
  118. package/src/types/generation_variables_schema.ts +0 -16
@@ -1,164 +1,176 @@
1
- import { OpenAIHelper } from "../helper/openai_helper";
2
- import { OpenAiService } from "../services/open_ai_service";
3
- import { log_error, ParsingError } from "../logger";
4
- import { restoreQuotesInString } from "../utils/sanitize_strings";
5
- import { buildSummarySchema } from "../helper/schema_helper/build_summary_schema";
6
- import { GenerationVariablesSchema } from "../types/generation_variables_schema";
7
- import { promptIds } from "../services/get_prompts";
8
-
9
- export class GenerateSummaryCards {
10
- public openAiService: OpenAiService;
11
- public openAIHelper: OpenAIHelper;
12
- public sourceId: string;
13
- public generationCurriculum: boolean;
14
- public generationVariablesSchema: GenerationVariablesSchema;
15
- public content: {
16
- title: string;
17
- h1_headings?: string[];
18
- timecodes?: string[];
19
- content: any[];
20
- };
21
- public type: string = "";
22
- constructor(
23
- openAiService: OpenAiService,
24
- sourceId: string,
25
- content: {
26
- title: string;
27
- h1_headings?: string[];
28
- timecodes?: string[];
29
- content: any[];
30
- },
31
- type: string,
32
- generationCurriculum: boolean,
33
- generationVariablesSchema: GenerationVariablesSchema
34
- ) {
35
- this.openAiService = openAiService;
36
- this.openAIHelper = new OpenAIHelper(this.openAiService.api_key);
37
- this.content = content;
38
- this.type = type;
39
- this.sourceId = sourceId;
40
- this.generationCurriculum = generationCurriculum;
41
- this.generationVariablesSchema = generationVariablesSchema;
42
- }
43
-
44
- async generate() {
45
- try {
46
- const headings =
47
- this.type === "text"
48
- ? this.content.h1_headings || [""]
49
- : this.content.timecodes || [""];
50
- const schema = await buildSummarySchema(
51
- headings.length > 0 ? headings : [""],
52
- this.generationVariablesSchema.output_schema.summary
53
- );
54
- // const schema = this.generationVariablesSchema.output_schema.summary;
55
- const openAiResponse: any =
56
- await this.openAIHelper.openAI.responses.create({
57
- prompt: {
58
- id: promptIds.summarize,
59
- variables: {
60
- heading_type: this.type == "video" ? "timecode" : "h1 heading",
61
- },
62
- },
63
- max_output_tokens: 30000,
64
- input: [
65
- {
66
- role: "user",
67
- content: [
68
- {
69
- type: "input_text",
70
- text: JSON.stringify(this.content),
71
- },
72
- ],
73
- },
74
- ],
75
- store: true,
76
- text: {
77
- format: {
78
- type: "json_schema",
79
- name: schema.name,
80
- strict: schema.strict,
81
- schema: schema.schema,
82
- },
83
- },
84
- });
85
- if (!openAiResponse) {
86
- await log_error({
87
- flow: "manual_generation",
88
- data: openAiResponse,
89
- error: "empty_openai_response",
90
- timestamp: new Date(),
91
- source_id: this.sourceId,
92
- type: {
93
- request_type: "summary_cards",
94
- n: 1,
95
- },
96
- });
97
- return;
98
- }
99
-
100
- openAiResponse.metadata = {
101
- req_time: openAiResponse.created ?? new Date(),
102
- req_type: {
103
- type: "breadth",
104
- sub_type: "summary_cards",
105
- n: 1,
106
- },
107
- req_tokens: openAiResponse.usage?.input_tokens ?? 0,
108
- res_tokens: openAiResponse.usage?.output_tokens ?? 0,
109
- prompt: {
110
- id: openAiResponse.prompt.id,
111
- version: openAiResponse.prompt.version,
112
- },
113
- // prompt_tokens_details: openAiResponse.usage?.,
114
- model: this.openAiService.model,
115
- usage: openAiResponse.usage,
116
- status: "completed",
117
- };
118
- const summaryCards = this.parseJson(openAiResponse);
119
-
120
- return {
121
- summary_cards: summaryCards,
122
- metadata: openAiResponse.metadata,
123
- };
124
- } catch (error) {
125
- console.log(error);
126
- await log_error({
127
- flow: this.generationCurriculum
128
- ? "curriculum_manual_generation"
129
- : "manual_generation",
130
- data: error,
131
- timestamp: new Date(),
132
- error: "error_in_summary_cards_generation",
133
- source_id: this.sourceId,
134
- type: {
135
- request_type: "summary_cards",
136
- n: 1,
137
- },
138
- });
139
- return {
140
- summary_cards: [],
141
- metadata: {},
142
- };
143
- }
144
- }
145
-
146
- parseJson(response: any) {
147
- try {
148
- const summaryCards = JSON.parse(response.output_text).summary_cards;
149
- if (summaryCards) {
150
- return summaryCards.map((item: any) => {
151
- return {
152
- ...item,
153
- reference: restoreQuotesInString(item.reference),
154
- };
155
- });
156
- }
157
- } catch (e) {
158
- throw new ParsingError(
159
- "Something went wrong in parsing the json",
160
- response
161
- );
162
- }
163
- }
164
- }
1
+ import { OpenAIHelper } from "../helper/openai_helper";
2
+ import { OpenAiService } from "../services/open_ai_service";
3
+ import { log_error, ParsingError } from "../logger";
4
+ import { restoreQuotesInString } from "../utils/sanitize_strings";
5
+ import { buildSummarySchema } from "../helper/schema_helper/build_summary_schema";
6
+ import { jsonrepair } from "jsonrepair";
7
+
8
+ export class GenerateSummaryCards {
9
+ public openAiService: OpenAiService;
10
+ public openAIHelper: OpenAIHelper;
11
+ public sourceId: string;
12
+ public generationCurriculum: boolean;
13
+ public content: {
14
+ title: string;
15
+ h1_headings?: string[];
16
+ timecodes?: string[];
17
+ content: any[];
18
+ };
19
+ public type: string = "";
20
+ public promptIdForSummaryCards: string;
21
+ constructor(
22
+ openAiService: OpenAiService,
23
+ sourceId: string,
24
+ content: {
25
+ title: string;
26
+ h1_headings?: string[];
27
+ timecodes?: string[];
28
+ content: any[];
29
+ },
30
+ type: string,
31
+ promptIdForSummaryCards: string,
32
+ generationCurriculum: boolean
33
+ ) {
34
+ this.openAiService = openAiService;
35
+ this.openAIHelper = new OpenAIHelper(this.openAiService.api_key);
36
+ this.content = content;
37
+ this.promptIdForSummaryCards = promptIdForSummaryCards;
38
+ this.type = type;
39
+ this.sourceId = sourceId;
40
+ this.generationCurriculum = generationCurriculum;
41
+ }
42
+
43
+ async generate() {
44
+ try {
45
+ const headings =
46
+ this.type === "text"
47
+ ? this.content.h1_headings || [""]
48
+ : this.content.timecodes || [""];
49
+ const schema = await buildSummarySchema(
50
+ headings.length > 0 ? headings : [""],
51
+ "summary_cards",
52
+ true
53
+ );
54
+ const openAiResponse: any =
55
+ await this.openAIHelper.openAI.responses.create({
56
+ prompt: {
57
+ id: this.promptIdForSummaryCards,
58
+ variables: {
59
+ heading_type: this.type == "video" ? "timecode" : "h1 heading",
60
+ },
61
+ },
62
+ max_output_tokens: 30000,
63
+ input: [
64
+ {
65
+ role: "user",
66
+ content: [
67
+ {
68
+ type: "input_text",
69
+ text: JSON.stringify(this.content),
70
+ },
71
+ ],
72
+ },
73
+ ],
74
+ store: true,
75
+ text: {
76
+ format: {
77
+ type: "json_schema",
78
+ name: schema.name,
79
+ strict: schema.strict,
80
+ schema: schema.schema,
81
+ },
82
+ },
83
+ });
84
+ if (!openAiResponse) {
85
+ await log_error({
86
+ flow: "manual_generation",
87
+ data: openAiResponse,
88
+ error: "empty_openai_response",
89
+ timestamp: new Date(),
90
+ source_id: this.sourceId,
91
+ type: {
92
+ request_type: "summary_cards",
93
+ n: 1,
94
+ },
95
+ });
96
+ return;
97
+ }
98
+
99
+ openAiResponse.metadata = {
100
+ req_time: openAiResponse.created ?? new Date(),
101
+ req_type: {
102
+ type: "breadth",
103
+ sub_type: "summary_cards",
104
+ n: 1,
105
+ },
106
+ req_tokens: openAiResponse.usage?.input_tokens ?? 0,
107
+ res_tokens: openAiResponse.usage?.output_tokens ?? 0,
108
+ prompt: {
109
+ id: openAiResponse.prompt.id,
110
+ version: openAiResponse.prompt.version,
111
+ },
112
+ // prompt_tokens_details: openAiResponse.usage?.,
113
+ model: this.openAiService.model,
114
+ usage: openAiResponse.usage,
115
+ status: "completed",
116
+ };
117
+ const summaryCards = this.parseJson(openAiResponse);
118
+
119
+ return {
120
+ summary_cards: summaryCards,
121
+ metadata: openAiResponse.metadata,
122
+ };
123
+ } catch (error) {
124
+ console.log(error);
125
+ await log_error({
126
+ flow: this.generationCurriculum
127
+ ? "curriculum_manual_generation"
128
+ : "manual_generation",
129
+ data: error,
130
+ timestamp: new Date(),
131
+ error: "error_in_summary_cards_generation",
132
+ source_id: this.sourceId,
133
+ type: {
134
+ request_type: "summary_cards",
135
+ n: 1,
136
+ },
137
+ });
138
+ return {
139
+ summary_cards: [],
140
+ metadata: {},
141
+ };
142
+ }
143
+ }
144
+
145
+ parseJson(response: any) {
146
+ let parsedJson: any;
147
+
148
+ try {
149
+ parsedJson = JSON.parse(response.output_text);
150
+ } catch (e) {
151
+ // If original JSON parse fails, attempt to repair and parse
152
+ try {
153
+ const repairedJson = jsonrepair(response.output_text);
154
+ parsedJson = JSON.parse(repairedJson);
155
+ } catch (repairError) {
156
+ // If repair also fails, throw exception
157
+ throw new ParsingError(
158
+ "Something went wrong in repairing the json",
159
+ response
160
+ );
161
+ }
162
+ }
163
+
164
+ // Process the parsed content (same flow for both original and repaired JSON)
165
+ const summaryCards = parsedJson.summary_cards;
166
+ if (summaryCards) {
167
+ return summaryCards.map((item: any) => {
168
+ return {
169
+ ...item,
170
+ reference: restoreQuotesInString(item.reference),
171
+ };
172
+ });
173
+ }
174
+ return [];
175
+ }
176
+ }
@@ -1,80 +1,80 @@
1
- /**
2
- * Utility for restoring quotes in OpenAI responses across distributed Lambda functions
3
- * This works without requiring original context from the API call Lambda
4
- */
5
-
6
- import { restoreQuotesInObject } from "./sanitize_strings";
7
-
8
- /**
9
- * Restores quotes in any OpenAI response structure
10
- * Can be used in a parsing Lambda that receives the response from an API call Lambda
11
- * @param openAiResponse - The complete OpenAI response object
12
- * @returns Response with quotes restored in all string fields
13
- */
14
- export function restoreQuotesInOpenAiResponse(openAiResponse: any): any {
15
- if (!openAiResponse) {
16
- return openAiResponse;
17
- }
18
-
19
- // Create a deep copy to avoid mutating the original
20
- const restoredResponse = JSON.parse(JSON.stringify(openAiResponse));
21
-
22
- // Restore quotes in the main output/content
23
- if (restoredResponse.output) {
24
- restoredResponse.output = restoreQuotesInObject(restoredResponse.output);
25
- }
26
-
27
- // Handle different response formats
28
- if (
29
- restoredResponse.choices &&
30
- restoredResponse.choices[0]?.message?.content
31
- ) {
32
- try {
33
- const content = JSON.parse(restoredResponse.choices[0].message.content);
34
- restoredResponse.choices[0].message.content = JSON.stringify(
35
- restoreQuotesInObject(content)
36
- );
37
- } catch (error) {
38
- // If content is not JSON, restore quotes directly
39
- restoredResponse.choices[0].message.content = restoreQuotesInObject(
40
- restoredResponse.choices[0].message.content
41
- );
42
- }
43
- }
44
-
45
- // Handle any other potential content fields
46
- if (restoredResponse.content) {
47
- restoredResponse.content = restoreQuotesInObject(restoredResponse.content);
48
- }
49
-
50
- if (restoredResponse.generated_content) {
51
- restoredResponse.generated_content = restoreQuotesInObject(
52
- restoredResponse.generated_content
53
- );
54
- }
55
-
56
- return restoredResponse;
57
- }
58
-
59
- /**
60
- * Restores quotes in a parsed response object (after JSON parsing)
61
- * Use this when you have already parsed the OpenAI response JSON
62
- * @param parsedResponse - The parsed response object
63
- * @returns Response with quotes restored
64
- */
65
- export function restoreQuotesInParsedResponse(parsedResponse: any): any {
66
- return restoreQuotesInObject(parsedResponse);
67
- }
68
-
69
- /**
70
- * Example usage in a parsing Lambda function:
71
- *
72
- * // Receiving response from API call Lambda
73
- * const openAiResponse = event.openAiResponse;
74
- *
75
- * // Restore quotes without needing original mapping
76
- * const restoredResponse = restoreQuotesInOpenAiResponse(openAiResponse);
77
- *
78
- * // Now process the response with original quotes restored
79
- * const processedData = processResponse(restoredResponse);
80
- */
1
+ /**
2
+ * Utility for restoring quotes in OpenAI responses across distributed Lambda functions
3
+ * This works without requiring original context from the API call Lambda
4
+ */
5
+
6
+ import { restoreQuotesInObject } from "./sanitize_strings";
7
+
8
+ /**
9
+ * Restores quotes in any OpenAI response structure
10
+ * Can be used in a parsing Lambda that receives the response from an API call Lambda
11
+ * @param openAiResponse - The complete OpenAI response object
12
+ * @returns Response with quotes restored in all string fields
13
+ */
14
+ export function restoreQuotesInOpenAiResponse(openAiResponse: any): any {
15
+ if (!openAiResponse) {
16
+ return openAiResponse;
17
+ }
18
+
19
+ // Create a deep copy to avoid mutating the original
20
+ const restoredResponse = JSON.parse(JSON.stringify(openAiResponse));
21
+
22
+ // Restore quotes in the main output/content
23
+ if (restoredResponse.output) {
24
+ restoredResponse.output = restoreQuotesInObject(restoredResponse.output);
25
+ }
26
+
27
+ // Handle different response formats
28
+ if (
29
+ restoredResponse.choices &&
30
+ restoredResponse.choices[0]?.message?.content
31
+ ) {
32
+ try {
33
+ const content = JSON.parse(restoredResponse.choices[0].message.content);
34
+ restoredResponse.choices[0].message.content = JSON.stringify(
35
+ restoreQuotesInObject(content)
36
+ );
37
+ } catch (error) {
38
+ // If content is not JSON, restore quotes directly
39
+ restoredResponse.choices[0].message.content = restoreQuotesInObject(
40
+ restoredResponse.choices[0].message.content
41
+ );
42
+ }
43
+ }
44
+
45
+ // Handle any other potential content fields
46
+ if (restoredResponse.content) {
47
+ restoredResponse.content = restoreQuotesInObject(restoredResponse.content);
48
+ }
49
+
50
+ if (restoredResponse.generated_content) {
51
+ restoredResponse.generated_content = restoreQuotesInObject(
52
+ restoredResponse.generated_content
53
+ );
54
+ }
55
+
56
+ return restoredResponse;
57
+ }
58
+
59
+ /**
60
+ * Restores quotes in a parsed response object (after JSON parsing)
61
+ * Use this when you have already parsed the OpenAI response JSON
62
+ * @param parsedResponse - The parsed response object
63
+ * @returns Response with quotes restored
64
+ */
65
+ export function restoreQuotesInParsedResponse(parsedResponse: any): any {
66
+ return restoreQuotesInObject(parsedResponse);
67
+ }
68
+
69
+ /**
70
+ * Example usage in a parsing Lambda function:
71
+ *
72
+ * // Receiving response from API call Lambda
73
+ * const openAiResponse = event.openAiResponse;
74
+ *
75
+ * // Restore quotes without needing original mapping
76
+ * const restoredResponse = restoreQuotesInOpenAiResponse(openAiResponse);
77
+ *
78
+ * // Now process the response with original quotes restored
79
+ * const processedData = processResponse(restoredResponse);
80
+ */
@@ -1,29 +1,29 @@
1
- export class GenerateArgs {
2
- public generate_card: boolean = false;
3
- public generate_typology: boolean = false;
4
- public generate_summary: boolean = false;
5
-
6
- constructor(
7
- generate_card: boolean,
8
- generate_typology: boolean,
9
- generate_summary: boolean
10
- ) {
11
- this.generate_card = generate_card;
12
- this.generate_typology = generate_typology;
13
- this.generate_summary = generate_summary;
14
- }
15
-
16
- getWhatNeedsToBeGenerated() {
17
- let returnData = [];
18
- if (this.generate_typology == true) {
19
- returnData.push("generate_tyopology");
20
- }
21
- if (this.generate_summary == true) {
22
- returnData.push("generate_summary");
23
- }
24
- if (this.generate_card == true) {
25
- returnData.push("generate_card");
26
- }
27
- return returnData;
28
- }
29
- }
1
+ export class GenerateArgs {
2
+ public generate_card: boolean = false;
3
+ public generate_typology: boolean = false;
4
+ public generate_summary: boolean = false;
5
+
6
+ constructor(
7
+ generate_card: boolean,
8
+ generate_typology: boolean,
9
+ generate_summary: boolean
10
+ ) {
11
+ this.generate_card = generate_card;
12
+ this.generate_typology = generate_typology;
13
+ this.generate_summary = generate_summary;
14
+ }
15
+
16
+ getWhatNeedsToBeGenerated() {
17
+ let returnData = [];
18
+ if (this.generate_typology == true) {
19
+ returnData.push("generate_tyopology");
20
+ }
21
+ if (this.generate_summary == true) {
22
+ returnData.push("generate_summary");
23
+ }
24
+ if (this.generate_card == true) {
25
+ returnData.push("generate_card");
26
+ }
27
+ return returnData;
28
+ }
29
+ }
@@ -1,19 +1,19 @@
1
- export function parseOpenAiSuccessResponse(responseData: any) {
2
- let choices = JSON.parse(responseData.choices[0].message.content);
3
- let usuage = responseData.usage;
4
- let createdTime = responseData.created;
5
- return {
6
- status_code: 200,
7
- usage_data: usuage,
8
- generated_content: choices,
9
- generated_at: new Date(createdTime * 1000),
10
- };
11
- }
12
-
13
- export function parseOpenAiFailureResponse(errorResponse: any) {
14
- // let statusCode =
15
- return {
16
- status_code: errorResponse.status,
17
- message: errorResponse.data?.error?.code,
18
- };
19
- }
1
+ export function parseOpenAiSuccessResponse(responseData: any) {
2
+ let choices = JSON.parse(responseData.choices[0].message.content);
3
+ let usuage = responseData.usage;
4
+ let createdTime = responseData.created;
5
+ return {
6
+ status_code: 200,
7
+ usage_data: usuage,
8
+ generated_content: choices,
9
+ generated_at: new Date(createdTime * 1000),
10
+ };
11
+ }
12
+
13
+ export function parseOpenAiFailureResponse(errorResponse: any) {
14
+ // let statusCode =
15
+ return {
16
+ status_code: errorResponse.status,
17
+ message: errorResponse.data?.error?.code,
18
+ };
19
+ }