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.
- package/dist/bootstrap/app.d.ts +6 -3
- package/dist/bootstrap/app.d.ts.map +1 -1
- package/dist/bootstrap/app.js +11 -17
- package/dist/bootstrap/app.js.map +1 -1
- package/dist/card_gen/generate_cards.d.ts +2 -3
- package/dist/card_gen/generate_cards.d.ts.map +1 -1
- package/dist/card_gen/generate_cards.js +22 -15
- package/dist/card_gen/generate_cards.js.map +1 -1
- package/dist/constants/prompt_data.d.ts +4 -4
- package/dist/constants/prompt_data.js +302 -302
- package/dist/constants/prompts/card_gen_prompt.js +160 -160
- package/dist/constants/prompts/typology_prompt.js +131 -131
- package/dist/constants/source_data.d.ts +171 -171
- package/dist/constants/source_data.js +973 -973
- package/dist/embedding_generation/local_consolidation.js +104 -104
- package/dist/helper/build_concept_facts_schema.d.ts +42 -42
- package/dist/helper/build_concept_facts_schema.js +44 -44
- package/dist/helper/qdrant_db_methods.d.ts.map +1 -1
- package/dist/helper/schema_helper/build_card_schema.d.ts +1 -9
- package/dist/helper/schema_helper/build_card_schema.d.ts.map +1 -1
- package/dist/helper/schema_helper/build_card_schema.js +47 -50
- package/dist/helper/schema_helper/build_card_schema.js.map +1 -1
- package/dist/helper/schema_helper/build_concept_facts_schema.d.ts +1 -1
- package/dist/helper/schema_helper/build_concept_facts_schema.d.ts.map +1 -1
- package/dist/helper/schema_helper/build_concept_facts_schema.js +20 -5
- package/dist/helper/schema_helper/build_concept_facts_schema.js.map +1 -1
- package/dist/helper/schema_helper/build_summary_schema.d.ts +1 -1
- package/dist/helper/schema_helper/build_summary_schema.d.ts.map +1 -1
- package/dist/helper/schema_helper/build_summary_schema.js +18 -7
- package/dist/helper/schema_helper/build_summary_schema.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/parse/response_format_card.d.ts +176 -176
- package/dist/parse/response_format_card.js +371 -371
- package/dist/parse/response_format_typology.d.ts +1 -1
- package/dist/parse/response_format_typology.js +46 -46
- package/dist/services/get_prompts.d.ts +8 -7
- package/dist/services/get_prompts.d.ts.map +1 -1
- package/dist/services/get_prompts.js +69 -21
- package/dist/services/get_prompts.js.map +1 -1
- package/dist/typology_gen/generate_concept_facts.d.ts +2 -3
- package/dist/typology_gen/generate_concept_facts.d.ts.map +1 -1
- package/dist/typology_gen/generate_concept_facts.js +25 -15
- package/dist/typology_gen/generate_concept_facts.js.map +1 -1
- package/dist/typology_gen/generate_typology.d.ts +2 -1
- package/dist/typology_gen/generate_typology.d.ts.map +1 -1
- package/dist/typology_gen/generate_typology.js +24 -13
- package/dist/typology_gen/generate_typology.js.map +1 -1
- package/dist/typology_gen/summarize.d.ts +2 -3
- package/dist/typology_gen/summarize.d.ts.map +1 -1
- package/dist/typology_gen/summarize.js +24 -13
- package/dist/typology_gen/summarize.js.map +1 -1
- package/package.json +39 -38
- package/src/bootstrap/app.ts +418 -416
- package/src/card_gen/generate_cards.ts +347 -345
- package/src/config.ts +11 -11
- package/src/constants/api_constants.ts +7 -7
- package/src/constants/prompts/card_gen_prompt.ts +164 -164
- package/src/constants/prompts/typology_prompt.ts +139 -139
- package/src/embedding_generation/consolidation/global_consolidation.ts +96 -96
- package/src/embedding_generation/consolidation/local_consolidation.ts +141 -141
- package/src/embedding_generation/consolidation/write_consolidated_data.ts +98 -98
- package/src/embedding_generation/generate_embeddings.ts +42 -42
- package/src/embedding_generation/parse_embedding_response.ts +31 -31
- package/src/enums/card_type_enum.ts +6 -6
- package/src/gap_fill/calculate_gap_fill.ts +50 -50
- package/src/helper/get_id_from_title.ts +33 -33
- package/src/helper/mongo_helper.ts +29 -29
- package/src/helper/openai_helper.ts +20 -20
- package/src/helper/qdrant_db_methods.ts +77 -77
- package/src/helper/schema_helper/build_card_schema.ts +74 -98
- package/src/helper/schema_helper/build_classify_summarize_schema.ts +43 -43
- package/src/helper/schema_helper/build_concept_facts_schema.ts +45 -31
- package/src/helper/schema_helper/build_summary_schema.ts +43 -32
- package/src/index.ts +71 -73
- package/src/logger.ts +65 -65
- package/src/parse/parse_card/parse_cloze_card.ts +146 -146
- package/src/parse/parse_card/parse_flash_cards.ts +42 -42
- package/src/parse/parse_card/parse_match_card.ts +104 -104
- package/src/parse/parse_card/parse_mcq_card.ts +114 -114
- package/src/parse/parse_card_response.ts +197 -197
- package/src/parse/parse_source_content.ts +212 -212
- package/src/services/get_prompts.ts +164 -112
- package/src/services/open_ai_service.ts +89 -89
- package/src/services/qdrant_service.ts +10 -10
- package/src/types/base_param_type.ts +13 -13
- package/src/types/mongo_concept_fact_type.ts +12 -12
- package/src/types/parsed_card_type.ts +39 -39
- package/src/types/raw_card_response_types/generated_card_response_type.ts +59 -59
- package/src/types/source_taxonomy_type.ts +24 -24
- package/src/typology-parsed-response.ts +1932 -1932
- package/src/typology_gen/generate_concept_facts.ts +180 -169
- package/src/typology_gen/generate_typology.ts +203 -189
- package/src/typology_gen/summarize.ts +176 -164
- package/src/utils/distributed_quote_restoration.ts +80 -80
- package/src/utils/generate_args.ts +29 -29
- package/src/utils/parse_openai_response.ts +19 -19
- package/src/utils/sanitize_strings.ts +65 -65
- package/tsconfig.json +16 -16
- package/dist/constants/default_generation_variables.d.ts +0 -3
- package/dist/constants/default_generation_variables.d.ts.map +0 -1
- package/dist/constants/default_generation_variables.js +0 -580
- package/dist/constants/default_generation_variables.js.map +0 -1
- package/dist/services/prompts_test.d.ts +0 -10
- package/dist/services/prompts_test.d.ts.map +0 -1
- package/dist/services/prompts_test.js +0 -227
- package/dist/services/prompts_test.js.map +0 -1
- package/dist/types/generation_variables_schema.d.ts +0 -14
- package/dist/types/generation_variables_schema.d.ts.map +0 -1
- package/dist/types/generation_variables_schema.js +0 -3
- package/dist/types/generation_variables_schema.js.map +0 -1
- package/dist/utils/test.d.ts +0 -2
- package/dist/utils/test.d.ts.map +0 -1
- package/dist/utils/test.js +0 -5
- package/dist/utils/test.js.map +0 -1
- package/src/constants/default_generation_variables.ts +0 -624
- package/src/types/generation_variables_schema.ts +0 -16
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { setUpMongoClient, ObjectId } from "../mongo_helper";
|
|
2
|
-
import { sanitizeStringsForSchema } from "../../utils/sanitize_strings";
|
|
3
|
-
|
|
4
|
-
// Function to populate enums in a parsed schema
|
|
5
|
-
export const buildClassifySummarizeSchema = async (headings: string[]) => {
|
|
6
|
-
const database = await setUpMongoClient();
|
|
7
|
-
const objectId = new ObjectId("6895ab99aa1cad73b0018060");
|
|
8
|
-
const schemaObj = await database.collection("_prompts").findOne({
|
|
9
|
-
_id: objectId,
|
|
10
|
-
});
|
|
11
|
-
if (!schemaObj) {
|
|
12
|
-
throw new Error("Schema not found");
|
|
13
|
-
}
|
|
14
|
-
const schema = schemaObj.schema;
|
|
15
|
-
if (!schema) {
|
|
16
|
-
throw new Error("Schema not found");
|
|
17
|
-
}
|
|
18
|
-
// Deep clone to avoid mutating the original
|
|
19
|
-
const populatedSchema = JSON.parse(schema);
|
|
20
|
-
|
|
21
|
-
// Sanitize headings to remove quotes for OpenAI structured outputs
|
|
22
|
-
const sanitizedStrings = sanitizeStringsForSchema(headings);
|
|
23
|
-
|
|
24
|
-
// Type-safe enum population for reference field in summary_cards
|
|
25
|
-
if (
|
|
26
|
-
populatedSchema.schema?.properties?.summary_cards?.items?.properties
|
|
27
|
-
?.reference?.enum
|
|
28
|
-
) {
|
|
29
|
-
populatedSchema.schema.properties.summary_cards.items.properties.reference.enum =
|
|
30
|
-
sanitizedStrings;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return populatedSchema;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// export const buildClassifySummarizeSchema = (headings: string[]) => {
|
|
37
|
-
// const schema = JSON.parse(JSON.stringify(baseClassifySummarizeSchema));
|
|
38
|
-
// // Populate the enum after schema creation
|
|
39
|
-
// (schema.schema.properties.summary_cards.items.properties.reference
|
|
40
|
-
// .enum as string[]) = headings;
|
|
41
|
-
|
|
42
|
-
// return schema;
|
|
43
|
-
// };
|
|
1
|
+
import { setUpMongoClient, ObjectId } from "../mongo_helper";
|
|
2
|
+
import { sanitizeStringsForSchema } from "../../utils/sanitize_strings";
|
|
3
|
+
|
|
4
|
+
// Function to populate enums in a parsed schema
|
|
5
|
+
export const buildClassifySummarizeSchema = async (headings: string[]) => {
|
|
6
|
+
const database = await setUpMongoClient();
|
|
7
|
+
const objectId = new ObjectId("6895ab99aa1cad73b0018060");
|
|
8
|
+
const schemaObj = await database.collection("_prompts").findOne({
|
|
9
|
+
_id: objectId,
|
|
10
|
+
});
|
|
11
|
+
if (!schemaObj) {
|
|
12
|
+
throw new Error("Schema not found");
|
|
13
|
+
}
|
|
14
|
+
const schema = schemaObj.schema;
|
|
15
|
+
if (!schema) {
|
|
16
|
+
throw new Error("Schema not found");
|
|
17
|
+
}
|
|
18
|
+
// Deep clone to avoid mutating the original
|
|
19
|
+
const populatedSchema = JSON.parse(schema);
|
|
20
|
+
|
|
21
|
+
// Sanitize headings to remove quotes for OpenAI structured outputs
|
|
22
|
+
const sanitizedStrings = sanitizeStringsForSchema(headings);
|
|
23
|
+
|
|
24
|
+
// Type-safe enum population for reference field in summary_cards
|
|
25
|
+
if (
|
|
26
|
+
populatedSchema.schema?.properties?.summary_cards?.items?.properties
|
|
27
|
+
?.reference?.enum
|
|
28
|
+
) {
|
|
29
|
+
populatedSchema.schema.properties.summary_cards.items.properties.reference.enum =
|
|
30
|
+
sanitizedStrings;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return populatedSchema;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// export const buildClassifySummarizeSchema = (headings: string[]) => {
|
|
37
|
+
// const schema = JSON.parse(JSON.stringify(baseClassifySummarizeSchema));
|
|
38
|
+
// // Populate the enum after schema creation
|
|
39
|
+
// (schema.schema.properties.summary_cards.items.properties.reference
|
|
40
|
+
// .enum as string[]) = headings;
|
|
41
|
+
|
|
42
|
+
// return schema;
|
|
43
|
+
// };
|
|
@@ -1,31 +1,45 @@
|
|
|
1
|
-
import { ObjectId } from "mongodb";
|
|
2
|
-
import { setUpMongoClient } from "../mongo_helper";
|
|
3
|
-
import { sanitizeStringsForSchema } from "../../utils/sanitize_strings";
|
|
4
|
-
|
|
5
|
-
// Function to populate enums in a parsed schema
|
|
6
|
-
export async function buildConceptFactSchema(
|
|
7
|
-
headings: string[],
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import { ObjectId } from "mongodb";
|
|
2
|
+
import { setUpMongoClient } from "../mongo_helper";
|
|
3
|
+
import { sanitizeStringsForSchema } from "../../utils/sanitize_strings";
|
|
4
|
+
|
|
5
|
+
// Function to populate enums in a parsed schema
|
|
6
|
+
export async function buildConceptFactSchema(
|
|
7
|
+
headings: string[],
|
|
8
|
+
name: string = "concept_fact_gen_schema",
|
|
9
|
+
strict: boolean = true
|
|
10
|
+
) {
|
|
11
|
+
const database = await setUpMongoClient();
|
|
12
|
+
const objectId = new ObjectId("6895ac4baa1cad73b0018061");
|
|
13
|
+
const schemaObj = await database.collection("_prompts").findOne({
|
|
14
|
+
_id: objectId,
|
|
15
|
+
});
|
|
16
|
+
if (!schemaObj) {
|
|
17
|
+
throw new Error("Schema not found");
|
|
18
|
+
}
|
|
19
|
+
const schema = schemaObj.schema;
|
|
20
|
+
if (!schema) {
|
|
21
|
+
throw new Error("Schema not found");
|
|
22
|
+
}
|
|
23
|
+
// Deep clone to avoid mutating the original
|
|
24
|
+
const populatedSchema = JSON.parse(schema);
|
|
25
|
+
|
|
26
|
+
// Update name and strict mode
|
|
27
|
+
populatedSchema.name = name;
|
|
28
|
+
populatedSchema.strict = strict;
|
|
29
|
+
|
|
30
|
+
const allowedRefs = [...headings, ""];
|
|
31
|
+
|
|
32
|
+
// Sanitize headings to remove quotes for OpenAI structured outputs
|
|
33
|
+
const sanitizedStrings = sanitizeStringsForSchema(allowedRefs);
|
|
34
|
+
|
|
35
|
+
// Type-safe enum population for reference field
|
|
36
|
+
if (
|
|
37
|
+
populatedSchema.schema?.properties?.concepts_facts?.items?.properties
|
|
38
|
+
?.reference?.enum
|
|
39
|
+
) {
|
|
40
|
+
populatedSchema.schema.properties.concepts_facts.items.properties.reference.enum =
|
|
41
|
+
sanitizedStrings;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return populatedSchema;
|
|
45
|
+
}
|
|
@@ -1,32 +1,43 @@
|
|
|
1
|
-
import { sanitizeStringsForSchema } from "../../utils/sanitize_strings";
|
|
2
|
-
import { setUpMongoClient, ObjectId } from "../mongo_helper";
|
|
3
|
-
|
|
4
|
-
// Function to populate enums in a parsed schema
|
|
5
|
-
export async function buildSummarySchema(
|
|
6
|
-
headings: string[],
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
import { sanitizeStringsForSchema } from "../../utils/sanitize_strings";
|
|
2
|
+
import { setUpMongoClient, ObjectId } from "../mongo_helper";
|
|
3
|
+
|
|
4
|
+
// Function to populate enums in a parsed schema
|
|
5
|
+
export async function buildSummarySchema(
|
|
6
|
+
headings: string[],
|
|
7
|
+
name: string = "summary_cards",
|
|
8
|
+
strict: boolean = true
|
|
9
|
+
) {
|
|
10
|
+
const database = await setUpMongoClient();
|
|
11
|
+
const objectId = new ObjectId("690ae043116a8c929f3a4cd5");
|
|
12
|
+
const schemaObj = await database.collection("_prompts").findOne({
|
|
13
|
+
_id: objectId,
|
|
14
|
+
});
|
|
15
|
+
if (!schemaObj) {
|
|
16
|
+
throw new Error("Schema not found");
|
|
17
|
+
}
|
|
18
|
+
const schema = schemaObj.schema;
|
|
19
|
+
if (!schema) {
|
|
20
|
+
throw new Error("Schema not found");
|
|
21
|
+
}
|
|
22
|
+
// Deep clone to avoid mutating the original
|
|
23
|
+
const populatedSchema = JSON.parse(schema);
|
|
24
|
+
|
|
25
|
+
// Update name and strict mode
|
|
26
|
+
populatedSchema.name = name;
|
|
27
|
+
populatedSchema.strict = strict;
|
|
28
|
+
|
|
29
|
+
// Sanitize headings to remove quotes for OpenAI structured outputs
|
|
30
|
+
const sanitizedStrings = sanitizeStringsForSchema(headings);
|
|
31
|
+
|
|
32
|
+
// Type-safe enum population for reference field in summary_cards items
|
|
33
|
+
// This populates the enum for cards 2-N (takeaway cards)
|
|
34
|
+
if (
|
|
35
|
+
populatedSchema.schema?.properties?.summary_cards?.items?.properties
|
|
36
|
+
?.reference?.enum
|
|
37
|
+
) {
|
|
38
|
+
populatedSchema.schema.properties.summary_cards.items.properties.reference.enum =
|
|
39
|
+
sanitizedStrings;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return populatedSchema;
|
|
43
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,73 +1,71 @@
|
|
|
1
|
-
import express from "express";
|
|
2
|
-
import { OnlyEverGenerator } from "./bootstrap/app";
|
|
3
|
-
import { ObjectId } from "mongodb";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
// const
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
// .
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
// const
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
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
|
-
// "
|
|
63
|
-
// "
|
|
64
|
-
//
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
//
|
|
72
|
-
// console.log("Server is running on port 3000");
|
|
73
|
-
// });
|
|
1
|
+
import express from "express";
|
|
2
|
+
import { OnlyEverGenerator } from "./bootstrap/app";
|
|
3
|
+
import { ObjectId } from "mongodb";
|
|
4
|
+
// import { database, setUp } from "./helper/mongo_helper";
|
|
5
|
+
|
|
6
|
+
export { OnlyEverGenerator };
|
|
7
|
+
|
|
8
|
+
// const app = express();
|
|
9
|
+
|
|
10
|
+
// app.get("/generate", async (req, res) => {
|
|
11
|
+
// const source = new ObjectId("692837542bd1597ff832d383");
|
|
12
|
+
// setUp();
|
|
13
|
+
// const openAiKey = process.env.OPEN_AI_KEY;
|
|
14
|
+
// const document = await database
|
|
15
|
+
// .collection("_source")
|
|
16
|
+
// .findOne({ _id: source });
|
|
17
|
+
// if (!document) {
|
|
18
|
+
// return res.status(404).json({ error: "Source not found" });
|
|
19
|
+
// }
|
|
20
|
+
// const promptIdForClassify =
|
|
21
|
+
// "pmpt_687a8872d1c8819088a9cdc97dcb688b0893663621695594";
|
|
22
|
+
// const promptIdForConceptFacts =
|
|
23
|
+
// "pmpt_687aa547f99c8193b99467ca53630c2607f5a8caf451e7e8";
|
|
24
|
+
// const promptIdForCardGeneration =
|
|
25
|
+
// "pmpt_688118a923e4819098176a13a2f401920d2ea17d881cc6c6";
|
|
26
|
+
// const promptIdForMissingConceptsFacts =
|
|
27
|
+
// "pmpt_687ab50298dc8194b214804999d23df10e03b855371691f9";
|
|
28
|
+
// const promptIdForSummarize =
|
|
29
|
+
// "pmpt_6902c30a973481968395935cc6dfa78605f50d2b01d4afbd";
|
|
30
|
+
// // const generationCurriculum = process.env.GENERATION_CURRICULUM;
|
|
31
|
+
// const n = process.env.N;
|
|
32
|
+
// const generationContent = {
|
|
33
|
+
// content: {
|
|
34
|
+
// source_id: document.source_id,
|
|
35
|
+
// title: document.title,
|
|
36
|
+
// headings: document.headings,
|
|
37
|
+
// content: document.content,
|
|
38
|
+
// fields: [],
|
|
39
|
+
// taxonomy: {
|
|
40
|
+
// concepts_facts: document.concepts_facts ?? [],
|
|
41
|
+
// fields: document.fields ?? [],
|
|
42
|
+
// summary_cards: document.summary_cards ?? [],
|
|
43
|
+
// learn_value: document.learn_value,
|
|
44
|
+
// },
|
|
45
|
+
// type: document.type,
|
|
46
|
+
// },
|
|
47
|
+
// };
|
|
48
|
+
// const generator = new OnlyEverGenerator(
|
|
49
|
+
// openAiKey ?? "",
|
|
50
|
+
// "gpt-4o-mini",
|
|
51
|
+
// generationContent,
|
|
52
|
+
// promptIdForClassify ?? "",
|
|
53
|
+
// promptIdForConceptFacts ?? "",
|
|
54
|
+
// promptIdForCardGeneration ?? "",
|
|
55
|
+
// promptIdForSummarize ?? "",
|
|
56
|
+
// false,
|
|
57
|
+
// 1
|
|
58
|
+
// );
|
|
59
|
+
// const response = await generator.generate(true, true, [
|
|
60
|
+
// "cloze",
|
|
61
|
+
// "mcq",
|
|
62
|
+
// "flash",
|
|
63
|
+
// "match",
|
|
64
|
+
// ]);
|
|
65
|
+
// console.log("Close");
|
|
66
|
+
// res.json(response);
|
|
67
|
+
// });
|
|
68
|
+
|
|
69
|
+
// app.listen(3000, () => {
|
|
70
|
+
// console.log("Server is running on port 3000");
|
|
71
|
+
// });
|
package/src/logger.ts
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
/// this method will call out atlas function and will write to a doc, incase of any errors:
|
|
2
|
-
/// this is only for developmemt use
|
|
3
|
-
|
|
4
|
-
import axios from "axios";
|
|
5
|
-
import { setUpMongoClient } from "./helper/mongo_helper";
|
|
6
|
-
|
|
7
|
-
type log_type = {
|
|
8
|
-
flow: string;
|
|
9
|
-
data: any;
|
|
10
|
-
error: string;
|
|
11
|
-
timestamp: Date;
|
|
12
|
-
source_id: string;
|
|
13
|
-
type: {
|
|
14
|
-
request_type: string;
|
|
15
|
-
n: number;
|
|
16
|
-
card_types?: string;
|
|
17
|
-
bloom_level?: number;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export class ParsingError extends Error {
|
|
22
|
-
public response: any;
|
|
23
|
-
constructor(message: string, response: any) {
|
|
24
|
-
super(message); // Pass message to the Error constructor
|
|
25
|
-
this.name = "ParsingError"; // Set a custom name
|
|
26
|
-
this.response = response; // Set the response
|
|
27
|
-
Object.setPrototypeOf(this, new.target.prototype); // Fix prototype chain
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class ErrorLogger {
|
|
32
|
-
data: any;
|
|
33
|
-
constructor(data: any) {
|
|
34
|
-
this.data = data;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async log() {
|
|
38
|
-
try {
|
|
39
|
-
let response = await axios.post(
|
|
40
|
-
"https://us-east-1.aws.data.mongodb-api.com/app/oe-phase1-tkmsy/endpoint/oe_gen_logger",
|
|
41
|
-
{
|
|
42
|
-
data: this.data,
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
headers: {
|
|
46
|
-
"Content-Type": ["application/json"],
|
|
47
|
-
},
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
return response;
|
|
51
|
-
} catch (e) {
|
|
52
|
-
console.log(e);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
export async function log_error(error: log_type) {
|
|
57
|
-
try {
|
|
58
|
-
const database = await setUpMongoClient();
|
|
59
|
-
const db = database.collection("_generation_log");
|
|
60
|
-
const result = await db.insertOne(error);
|
|
61
|
-
return result;
|
|
62
|
-
} catch (e) {
|
|
63
|
-
console.log(e);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
1
|
+
/// this method will call out atlas function and will write to a doc, incase of any errors:
|
|
2
|
+
/// this is only for developmemt use
|
|
3
|
+
|
|
4
|
+
import axios from "axios";
|
|
5
|
+
import { setUpMongoClient } from "./helper/mongo_helper";
|
|
6
|
+
|
|
7
|
+
type log_type = {
|
|
8
|
+
flow: string;
|
|
9
|
+
data: any;
|
|
10
|
+
error: string;
|
|
11
|
+
timestamp: Date;
|
|
12
|
+
source_id: string;
|
|
13
|
+
type: {
|
|
14
|
+
request_type: string;
|
|
15
|
+
n: number;
|
|
16
|
+
card_types?: string;
|
|
17
|
+
bloom_level?: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export class ParsingError extends Error {
|
|
22
|
+
public response: any;
|
|
23
|
+
constructor(message: string, response: any) {
|
|
24
|
+
super(message); // Pass message to the Error constructor
|
|
25
|
+
this.name = "ParsingError"; // Set a custom name
|
|
26
|
+
this.response = response; // Set the response
|
|
27
|
+
Object.setPrototypeOf(this, new.target.prototype); // Fix prototype chain
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class ErrorLogger {
|
|
32
|
+
data: any;
|
|
33
|
+
constructor(data: any) {
|
|
34
|
+
this.data = data;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async log() {
|
|
38
|
+
try {
|
|
39
|
+
let response = await axios.post(
|
|
40
|
+
"https://us-east-1.aws.data.mongodb-api.com/app/oe-phase1-tkmsy/endpoint/oe_gen_logger",
|
|
41
|
+
{
|
|
42
|
+
data: this.data,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
headers: {
|
|
46
|
+
"Content-Type": ["application/json"],
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
return response;
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.log(e);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export async function log_error(error: log_type) {
|
|
57
|
+
try {
|
|
58
|
+
const database = await setUpMongoClient();
|
|
59
|
+
const db = database.collection("_generation_log");
|
|
60
|
+
const result = await db.insertOne(error);
|
|
61
|
+
return result;
|
|
62
|
+
} catch (e) {
|
|
63
|
+
console.log(e);
|
|
64
|
+
}
|
|
65
|
+
}
|