only_ever_generator 0.7.8 → 0.7.9

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 (145) hide show
  1. package/dist/bootstrap/app.d.ts +96 -0
  2. package/dist/bootstrap/app.js +42 -48
  3. package/dist/bootstrap/app.js.map +1 -0
  4. package/dist/card_gen/generate_cards.d.ts +7 -0
  5. package/dist/card_gen/generate_cards.js +32 -24
  6. package/dist/card_gen/generate_cards.js.map +1 -0
  7. package/dist/config.d.ts +7 -0
  8. package/dist/config.js +3 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/constants/api_constants.d.ts +2 -0
  11. package/dist/constants/api_constants.js +5 -0
  12. package/dist/constants/api_constants.js.map +1 -0
  13. package/dist/constants/prompt_data.d.ts +4 -0
  14. package/dist/constants/prompt_data.js +1 -0
  15. package/dist/constants/prompt_data.js.map +1 -0
  16. package/dist/constants/prompts/card_gen_prompt.d.ts +1 -0
  17. package/dist/constants/prompts/card_gen_prompt.js +1 -0
  18. package/dist/constants/prompts/card_gen_prompt.js.map +1 -0
  19. package/dist/constants/prompts/typology_prompt.d.ts +1 -0
  20. package/dist/constants/prompts/typology_prompt.js +1 -0
  21. package/dist/constants/prompts/typology_prompt.js.map +1 -0
  22. package/dist/constants/source_data.d.ts +171 -0
  23. package/dist/constants/source_data.js +2 -1
  24. package/dist/constants/source_data.js.map +1 -0
  25. package/dist/embedding_generation/consolidation/global_consolidation.d.ts +32 -0
  26. package/dist/embedding_generation/consolidation/global_consolidation.js +76 -0
  27. package/dist/embedding_generation/consolidation/global_consolidation.js.map +1 -0
  28. package/dist/embedding_generation/consolidation/local_consolidation.d.ts +38 -0
  29. package/dist/embedding_generation/consolidation/local_consolidation.js +105 -0
  30. package/dist/embedding_generation/consolidation/local_consolidation.js.map +1 -0
  31. package/dist/embedding_generation/consolidation/write_consolidated_data.d.ts +45 -0
  32. package/dist/embedding_generation/consolidation/write_consolidated_data.js +69 -0
  33. package/dist/embedding_generation/consolidation/write_consolidated_data.js.map +1 -0
  34. package/dist/embedding_generation/generate_embeddings.d.ts +27 -0
  35. package/dist/embedding_generation/generate_embeddings.js +54 -0
  36. package/dist/embedding_generation/generate_embeddings.js.map +1 -0
  37. package/dist/embedding_generation/parse_embedding_response.d.ts +25 -0
  38. package/dist/embedding_generation/parse_embedding_response.js +29 -0
  39. package/dist/embedding_generation/parse_embedding_response.js.map +1 -0
  40. package/dist/enums/card_type_enum.d.ts +6 -0
  41. package/dist/enums/card_type_enum.js +11 -0
  42. package/dist/enums/card_type_enum.js.map +1 -0
  43. package/dist/gap_fill/calculate_gap_fill.d.ts +4 -0
  44. package/dist/gap_fill/calculate_gap_fill.js +3 -5
  45. package/dist/gap_fill/calculate_gap_fill.js.map +1 -0
  46. package/dist/helper/qdrant_db_methods.d.ts +39 -0
  47. package/dist/helper/qdrant_db_methods.js +63 -0
  48. package/dist/helper/qdrant_db_methods.js.map +1 -0
  49. package/dist/index.d.ts +1 -0
  50. package/dist/index.js +88 -49
  51. package/dist/index.js.map +1 -0
  52. package/dist/logger.d.ts +5 -0
  53. package/dist/logger.js +1 -0
  54. package/dist/logger.js.map +1 -0
  55. package/dist/parse/parse_card/parse_cloze_card.d.ts +16 -0
  56. package/dist/parse/parse_card/parse_cloze_card.js +3 -2
  57. package/dist/parse/parse_card/parse_cloze_card.js.map +1 -0
  58. package/dist/parse/parse_card/parse_flash_cards.d.ts +25 -0
  59. package/dist/parse/parse_card/parse_flash_cards.js +4 -3
  60. package/dist/parse/parse_card/parse_flash_cards.js.map +1 -0
  61. package/dist/parse/parse_card/parse_match_card.d.ts +22 -0
  62. package/dist/parse/parse_card/parse_match_card.js +3 -3
  63. package/dist/parse/parse_card/parse_match_card.js.map +1 -0
  64. package/dist/parse/parse_card/parse_mcq_card.d.ts +30 -0
  65. package/dist/parse/parse_card/parse_mcq_card.js +3 -2
  66. package/dist/parse/parse_card/parse_mcq_card.js.map +1 -0
  67. package/dist/parse/parse_card_response.d.ts +19 -0
  68. package/dist/parse/parse_card_response.js +62 -28
  69. package/dist/parse/parse_card_response.js.map +1 -0
  70. package/dist/parse/parse_source_content.d.ts +25 -0
  71. package/dist/parse/parse_source_content.js +1 -0
  72. package/dist/parse/parse_source_content.js.map +1 -0
  73. package/dist/parse/response_format_card.d.ts +176 -0
  74. package/dist/parse/response_format_card.js +1 -0
  75. package/dist/parse/response_format_card.js.map +1 -0
  76. package/dist/parse/response_format_typology.d.ts +1 -0
  77. package/dist/parse/response_format_typology.js +1 -0
  78. package/dist/parse/response_format_typology.js.map +1 -0
  79. package/dist/services/open_ai_service.d.ts +15 -0
  80. package/dist/services/open_ai_service.js +29 -0
  81. package/dist/services/open_ai_service.js.map +1 -0
  82. package/dist/services/qdrant_service.d.ts +3 -0
  83. package/dist/services/qdrant_service.js +14 -0
  84. package/dist/services/qdrant_service.js.map +1 -0
  85. package/dist/types/base_param_type.d.ts +15 -0
  86. package/dist/types/base_param_type.js +3 -0
  87. package/dist/types/base_param_type.js.map +1 -0
  88. package/dist/types/mongo_concept_fact_type.d.ts +11 -0
  89. package/dist/types/mongo_concept_fact_type.js +3 -0
  90. package/dist/types/mongo_concept_fact_type.js.map +1 -0
  91. package/dist/types/parsed_card_type.d.ts +11 -0
  92. package/dist/types/parsed_card_type.js +30 -0
  93. package/dist/types/parsed_card_type.js.map +1 -0
  94. package/dist/types/raw_card_response_types/generated_card_response_type.d.ts +39 -0
  95. package/dist/types/raw_card_response_types/generated_card_response_type.js +8 -0
  96. package/dist/types/raw_card_response_types/generated_card_response_type.js.map +1 -0
  97. package/dist/types/source_taxonomy_type.d.ts +14 -0
  98. package/dist/types/source_taxonomy_type.js +3 -0
  99. package/dist/types/source_taxonomy_type.js.map +1 -0
  100. package/dist/typology_gen/generate_typology.d.ts +28 -0
  101. package/dist/typology_gen/generate_typology.js +12 -11
  102. package/dist/typology_gen/generate_typology.js.map +1 -0
  103. package/dist/utils/generate_args.d.ts +7 -0
  104. package/dist/utils/generate_args.js +1 -0
  105. package/dist/utils/generate_args.js.map +1 -0
  106. package/dist/utils/parse_openai_response.d.ts +10 -0
  107. package/dist/utils/parse_openai_response.js +1 -0
  108. package/dist/utils/parse_openai_response.js.map +1 -0
  109. package/package.json +17 -14
  110. package/src/bootstrap/app.ts +84 -71
  111. package/src/card_gen/generate_cards.ts +40 -29
  112. package/src/config.ts +2 -0
  113. package/src/constants/api_constants.ts +4 -0
  114. package/src/constants/prompts/card_gen_prompt.ts +1 -1
  115. package/src/embedding_generation/consolidation/global_consolidation.ts +94 -0
  116. package/src/embedding_generation/consolidation/local_consolidation.ts +141 -0
  117. package/src/embedding_generation/consolidation/write_consolidated_data.ts +98 -0
  118. package/src/embedding_generation/generate_embeddings.ts +41 -0
  119. package/src/embedding_generation/parse_embedding_response.ts +31 -0
  120. package/src/enums/card_type_enum.ts +6 -0
  121. package/src/gap_fill/calculate_gap_fill.ts +42 -45
  122. package/src/helper/qdrant_db_methods.ts +77 -0
  123. package/src/parse/parse_card/parse_cloze_card.ts +11 -3
  124. package/src/parse/parse_card/parse_flash_cards.ts +12 -4
  125. package/src/parse/parse_card/parse_match_card.ts +10 -4
  126. package/src/parse/parse_card/parse_mcq_card.ts +11 -3
  127. package/src/parse/parse_card_response.ts +94 -31
  128. package/src/parse/parse_source_content.ts +9 -1
  129. package/src/services/open_ai_service.ts +33 -1
  130. package/src/services/qdrant_service.ts +10 -0
  131. package/src/types/base_param_type.ts +16 -0
  132. package/src/types/mongo_concept_fact_type.ts +12 -0
  133. package/src/types/parsed_card_type.ts +39 -0
  134. package/src/types/raw_card_response_types/generated_card_response_type.ts +61 -0
  135. package/src/types/source_taxonomy_type.ts +17 -0
  136. package/src/typology_gen/generate_typology.ts +13 -12
  137. package/tsconfig.json +6 -3
  138. package/.env.example +0 -1
  139. package/prompts.json +0 -23
  140. package/readme.md +0 -35
  141. package/src/constants/prompt_data.ts +0 -301
  142. package/src/constants/source_data.ts +0 -1036
  143. package/src/index.ts +0 -72
  144. package/src/parse/response_format_card.ts +0 -386
  145. package/src/parse/response_format_typology.ts +0 -44
@@ -3,33 +3,83 @@ import { ParseClozeCard } from "./parse_card/parse_cloze_card";
3
3
  import { ParseFlashCard } from "./parse_card/parse_flash_cards";
4
4
  import { ParseMatchCard } from "./parse_card/parse_match_card";
5
5
  import { ParseMcqCard } from "./parse_card/parse_mcq_card";
6
-
6
+ import {
7
+ GeneratedCardResponseType,
8
+ RawClozeCardResponseType,
9
+ RawFlashCardResponseType,
10
+ RawMatchCardResponseType,
11
+ RawMcqCardResponseType,
12
+ RawTestCardResponseType,
13
+ } from "../types/raw_card_response_types/generated_card_response_type";
14
+ import { SourceTaxonomy } from "../types/source_taxonomy_type";
15
+ import { MongoConceptFactCards } from "../types/mongo_concept_fact_type";
16
+ import { ParsedCardType } from "../types/parsed_card_type";
7
17
  export class ParseCardResponse {
8
- parse(generatedData: any, isGapFill: boolean, sourceTaxonomy: any) {
18
+ parse(
19
+ generatedData: GeneratedCardResponseType,
20
+ isGapFill: boolean,
21
+ sourceTaxonomy: SourceTaxonomy,
22
+ bloom_level: number
23
+ ) {
9
24
  let usage_data = generatedData.metadata;
10
25
  try {
11
- const cardData = [];
26
+ const cardData: ParsedCardType[] = [];
12
27
  const unparsedTestCards = generatedData.generated_content.test_cards;
13
- const type = generatedData.type;
28
+
14
29
  if (unparsedTestCards !== undefined && unparsedTestCards.length != 0) {
15
30
  for (let elem of unparsedTestCards) {
31
+ elem.bloom_level = bloom_level;
32
+ const concepts = elem.concepts.map((e: any) => {
33
+ return {
34
+ text: e,
35
+ type: "concept",
36
+ };
37
+ });
38
+ const facts = elem.facts.map((e: any) => {
39
+ return {
40
+ text: e,
41
+ type: "fact",
42
+ };
43
+ });
44
+ const concepts_facts = [...concepts, ...facts];
45
+ const managedCardConcepts = this._mapIdToConcepts(
46
+ concepts_facts,
47
+ sourceTaxonomy.concepts_facts
48
+ );
49
+
16
50
  if (elem.type == "flash") {
17
- const flashCard = new ParseFlashCard().parse(elem);
51
+ const flashCard = new ParseFlashCard().parse({
52
+ card_content: elem.card_content as RawFlashCardResponseType,
53
+ type: elem.type,
54
+ concepts_facts: managedCardConcepts,
55
+ bloom_level: elem.bloom_level,
56
+ });
18
57
  if (flashCard != null && flashCard) {
19
58
  flashCard.heading = this._getCardReference(
20
59
  flashCard,
21
60
  sourceTaxonomy
22
61
  );
62
+
23
63
  cardData.push(flashCard);
24
64
  }
25
65
  } else if (elem.type == "mcq") {
26
- const mcqCard = new ParseMcqCard().parse(elem);
66
+ const mcqCard = new ParseMcqCard().parse({
67
+ card_content: elem.card_content as RawMcqCardResponseType,
68
+ type: elem.type,
69
+ concepts_facts: managedCardConcepts,
70
+ bloom_level: elem.bloom_level,
71
+ });
27
72
  if (mcqCard != null && mcqCard) {
28
73
  mcqCard.heading = this._getCardReference(mcqCard, sourceTaxonomy);
29
74
  cardData.push(mcqCard);
30
75
  }
31
76
  } else if (elem.type == "cloze") {
32
- const clozeCard = new ParseClozeCard().parse(elem);
77
+ const clozeCard = new ParseClozeCard().parse({
78
+ card_content: elem.card_content as RawClozeCardResponseType,
79
+ type: elem.type,
80
+ concepts_facts: managedCardConcepts,
81
+ bloom_level: elem.bloom_level,
82
+ });
33
83
  if (clozeCard && clozeCard != null) {
34
84
  clozeCard.heading = this._getCardReference(
35
85
  clozeCard,
@@ -38,7 +88,12 @@ export class ParseCardResponse {
38
88
  cardData.push(clozeCard);
39
89
  }
40
90
  } else if (elem.type == "match") {
41
- const matchCard = new ParseMatchCard().parse(elem);
91
+ const matchCard = new ParseMatchCard().parse({
92
+ card_content: elem.card_content as RawMatchCardResponseType,
93
+ type: elem.type,
94
+ concepts_facts: managedCardConcepts,
95
+ bloom_level: elem.bloom_level,
96
+ });
42
97
  if (matchCard && matchCard != null) {
43
98
  matchCard.heading = this._getCardReference(
44
99
  matchCard,
@@ -60,41 +115,27 @@ export class ParseCardResponse {
60
115
  return {
61
116
  status_code: cardData.length == 0 ? 400 : 200,
62
117
  metadata: usage_data,
63
- type: type,
64
- missing_concepts: [],
65
- missing_facts: [],
118
+ type: "card_gen",
119
+
66
120
  cards_data: cardData,
67
121
  };
68
122
  } catch (e: any) {
69
- new ErrorLogger({
70
- type: "card_parsing",
71
- data: e.message,
72
- response: generatedData,
73
- }).log();
74
123
  return {
75
124
  status_code: 500,
76
125
  metadata: usage_data,
77
- type: generatedData.type,
126
+ type: "card_gen",
78
127
  };
79
128
  }
80
129
  }
81
130
 
82
131
  _getCardReference(generatedCardData: any, sourceTaxonomy: any) {
83
- const cardConcepts = generatedCardData.concepts ?? [];
84
- const cardFacts = generatedCardData.facts ?? [];
85
- const combinedCardFactsAndConcepts = [...cardConcepts, ...cardFacts];
86
-
87
- const sourceConcepts = sourceTaxonomy.concepts ?? [];
88
-
89
- const mappedSourceConcepts = sourceConcepts.map((elem: any) => {
90
- return {
91
- text: elem.concept_text,
92
- reference: elem.reference,
93
- };
94
- });
132
+ const cardConcepts = (generatedCardData.concepts ?? []).map(
133
+ (e: any) => e.text
134
+ );
95
135
 
96
- const firstMatchedConcept = sourceConcepts.find((elem: any) =>
97
- combinedCardFactsAndConcepts.includes(elem.text)
136
+ const sourceConceptsFacts = sourceTaxonomy.concepts_facts ?? [];
137
+ const firstMatchedConcept = sourceConceptsFacts.find((elem: any) =>
138
+ cardConcepts.includes(elem.text)
98
139
  );
99
140
 
100
141
  if (firstMatchedConcept) {
@@ -103,4 +144,26 @@ export class ParseCardResponse {
103
144
  return "";
104
145
  }
105
146
  }
147
+
148
+ _mapIdToConcepts(
149
+ cardConcepts: any[],
150
+ sourceConceptsFacts: any[]
151
+ ): MongoConceptFactCards[] {
152
+ // const cardData = cardC
153
+ const managedCardConcepts = [];
154
+ for (const cardConcept of cardConcepts) {
155
+ const matchedConcept = sourceConceptsFacts.find(
156
+ (e: any) =>
157
+ e.text.toLowerCase().trim() == cardConcept.text.toLowerCase().trim()
158
+ );
159
+ if (matchedConcept) {
160
+ managedCardConcepts.push({
161
+ id: matchedConcept.id,
162
+ text: matchedConcept.text,
163
+ type: matchedConcept.type,
164
+ });
165
+ }
166
+ }
167
+ return managedCardConcepts;
168
+ }
106
169
  }
@@ -1,3 +1,5 @@
1
+ import { SourceTaxonomy } from "../types/source_taxonomy_type";
2
+
1
3
  export class ParseSourceContent {
2
4
  public content: any;
3
5
  /// Format of Content
@@ -25,7 +27,13 @@ export class ParseSourceContent {
25
27
  this.content = sourceContent;
26
28
  }
27
29
 
28
- parseData() {
30
+ parseData(): {
31
+ type: string;
32
+ title: string;
33
+ content: any[];
34
+ headings: string[];
35
+ taxonomy: SourceTaxonomy;
36
+ } {
29
37
  let sourceType = this.content.type;
30
38
  let afterSanitized;
31
39
  if (sourceType == "video") {
@@ -3,7 +3,10 @@ import {
3
3
  parseOpenAiFailureResponse,
4
4
  parseOpenAiSuccessResponse,
5
5
  } from "../utils/parse_openai_response";
6
- import { openAiEndPoint } from "../constants/api_constants";
6
+ import {
7
+ openAiEmbeddingEndPoint,
8
+ openAiEndPoint,
9
+ } from "../constants/api_constants";
7
10
 
8
11
  export class OpenAiService {
9
12
  public api_key: string;
@@ -53,4 +56,33 @@ export class OpenAiService {
53
56
  return parseOpenAiFailureResponse(err.response);
54
57
  }
55
58
  }
59
+
60
+ async sendEmbeddingRequest(texts: string[]) {
61
+ try {
62
+ const url = openAiEmbeddingEndPoint();
63
+ let response = await axios.post(
64
+ url,
65
+ {
66
+ model: "text-embedding-3-large",
67
+ input: texts,
68
+ dimensions: 512,
69
+ },
70
+ {
71
+ headers: {
72
+ Authorization: "Bearer " + this.api_key,
73
+ "Content-Type": ["application/json"],
74
+ },
75
+ }
76
+ );
77
+ return {
78
+ status_code: 200,
79
+ data: response.data,
80
+ };
81
+ } catch (err: any) {
82
+ return {
83
+ status_code: err.response.status ?? 500,
84
+ message: err.message,
85
+ };
86
+ }
87
+ }
56
88
  }
@@ -0,0 +1,10 @@
1
+ import { QdrantClient } from "@qdrant/js-client-rest";
2
+ import config from "../config";
3
+
4
+ // or connect to Qdrant Cloud
5
+ const qdrantClient = new QdrantClient({
6
+ url: config.qdrantUrl,
7
+ apiKey: config.qdrantApiKey,
8
+ });
9
+
10
+ export default qdrantClient;
@@ -0,0 +1,16 @@
1
+ import { SourceTaxonomy } from "./source_taxonomy_type";
2
+
3
+ export type BaseParamType = {
4
+ prompt: {
5
+ typology: string;
6
+ card_generation: string;
7
+ };
8
+ content: {
9
+ title: string;
10
+ headings: string[];
11
+ content: any[];
12
+ fields: string[];
13
+ taxonomy?: SourceTaxonomy;
14
+ type: string;
15
+ };
16
+ };
@@ -0,0 +1,12 @@
1
+ export type MongoConceptFactSource = {
2
+ text: string;
3
+ type: "concept" | "fact";
4
+ reference: string;
5
+ id: string;
6
+ };
7
+
8
+ export type MongoConceptFactCards = {
9
+ text: string;
10
+ type: "concept" | "fact";
11
+ id: string;
12
+ };
@@ -0,0 +1,39 @@
1
+ export type ParsedCardType = {
2
+ type: {
3
+ category: string;
4
+ sub_type: string;
5
+ };
6
+ heading: string;
7
+ displayTitle: string;
8
+ content: any;
9
+ explanation?: string;
10
+ bloom_level?: number;
11
+ };
12
+
13
+ // {
14
+ // "type": {
15
+ // "category": "learning",
16
+ // "sub_type": "cloze"
17
+ // },
18
+ // "heading": "",
19
+ // "displayTitle": "Ink is a medium that consists of colorants and other {{components}}. ---- components, elements, substances",
20
+ // "content": {
21
+ // "question": "Ink is a medium that consists of colorants and other {{c0:components}}.",
22
+ // "options": [
23
+ // {
24
+ // "option": "components",
25
+ // "cloze": "c0"
26
+ // },
27
+ // {
28
+ // "option": "elements",
29
+ // "cloze": "null"
30
+ // },
31
+ // {
32
+ // "option": "substances",
33
+ // "cloze": "null"
34
+ // }
35
+ // ]
36
+ // },
37
+ // "explanation": "Ink contains various components that include colorants, solvents, and additives which determine its properties.",
38
+ // "bloom_level": 1
39
+ // },
@@ -0,0 +1,61 @@
1
+ import { CardTypeEnum } from "../../enums/card_type_enum";
2
+
3
+ export type GeneratedCardResponseType = {
4
+ metadata: any;
5
+ generated_content: {
6
+ test_cards: RawTestCardResponseType[];
7
+ };
8
+ status_code: number;
9
+ usage_data: any;
10
+ generated_at: Date;
11
+ };
12
+
13
+ export type RawTestCardResponseType = {
14
+ type: string;
15
+ // type:
16
+ // | CardTypeEnum.FLASH
17
+ // | CardTypeEnum.MATCH
18
+ // | CardTypeEnum.MCQ
19
+ // | CardTypeEnum.CLOZE;
20
+ card_content:
21
+ | RawFlashCardResponseType
22
+ | RawMatchCardResponseType
23
+ | RawClozeCardResponseType
24
+ | RawMcqCardResponseType;
25
+ concepts: string[];
26
+ facts: string[];
27
+ bloom_level: number;
28
+ };
29
+
30
+ export type RawFlashCardResponseType = {
31
+ front: string;
32
+ back: string;
33
+ explanation?: string;
34
+ };
35
+
36
+ export type RawMatchCardResponseType = {
37
+ left_item: string;
38
+ right_item: string;
39
+ }[];
40
+
41
+ export type RawClozeCardResponseType = {
42
+ correct_options: string[];
43
+ incorrect_options: string[];
44
+ prompt: string;
45
+ explanation?: string;
46
+ };
47
+
48
+ export type RawMcqCardResponseType = {
49
+ prompt: string;
50
+ explanation?: string;
51
+ choices: {
52
+ choice: string;
53
+ is_correct: boolean;
54
+ }[];
55
+ };
56
+
57
+ //
58
+ // flash : 1
59
+ // cloze 0,
60
+ // match 2
61
+ // mcq 3
@@ -0,0 +1,17 @@
1
+ export type SourceTaxonomy = {
2
+ concepts_facts: {
3
+ text: string;
4
+ type: string;
5
+ /// will only be present temporarily and wont be stored in database
6
+ embedding?: number[];
7
+ reference: string;
8
+ }[];
9
+ fields: string[];
10
+
11
+ /// will only be present temporarily and wont be stored in database
12
+ metadata?: any[];
13
+ generate_cards: {
14
+ state: boolean;
15
+ reason: string;
16
+ };
17
+ };
@@ -1,5 +1,5 @@
1
1
  import { OpenAiService } from "../services/open_ai_service";
2
- import { returnTypologyData } from "../parse/response_format_typology";
2
+
3
3
  import { ErrorLogger } from "../logger";
4
4
 
5
5
  export class GenerateTypology {
@@ -57,26 +57,27 @@ export class GenerateTypology {
57
57
 
58
58
  parseTypologyOnSuccess(responseData: any) {
59
59
  responseData.metadata.status = "completed";
60
- const facts = responseData.generated_content.facts.map((fact: any) => {
60
+ const generatedContent = responseData.generated_content;
61
+ const concepts = generatedContent.concepts.map((e: any) => {
61
62
  return {
62
- concept_text: fact.fact_text,
63
- reference: fact.reference,
64
- type: "fact",
63
+ text: e.concept_text,
64
+ type: "concept",
65
+ reference: e.reference,
65
66
  };
66
67
  });
67
- const concepts = responseData.generated_content.concepts.map((concept: any) => {
68
+ const facts = generatedContent.facts.map((e: any) => {
68
69
  return {
69
- concept_text: concept.concept_text,
70
- reference: concept.reference,
71
- type: "concept",
70
+ text: e.fact_text,
71
+ type: "fact",
72
+ reference: e.reference,
72
73
  };
73
74
  });
74
- const generatedContent = responseData.generated_content;
75
+
75
76
  return {
76
77
  status_code: 200,
77
- metadata: responseData.metadata,
78
+ metadata: [responseData.metadata],
78
79
  field: this.parseFields(generatedContent.field),
79
- concepts: [...concepts, ...facts],
80
+ concepts_facts: [...concepts, ...facts],
80
81
  generate_cards: generatedContent.generate_cards,
81
82
  summary_cards: generatedContent.summary_cards,
82
83
  // type: responseData.type,
package/tsconfig.json CHANGED
@@ -5,8 +5,11 @@
5
5
  "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
6
6
  "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
7
7
  "strict": true,
8
+ "declaration": true,
8
9
  "rootDir": "./src",
9
- "outDir": "./dist" /* Enable all strict type-checking options. */
10
+ "outDir": "./dist", /* Enable all strict type-checking options. */
11
+ "sourceMap": true
10
12
  },
11
- "exclude": ["./src/*/*.d.ts"]
12
- }
13
+ "include": ["src/**/*"],
14
+ "exclude": ["node_modules", "**/*.test.ts"]
15
+ }
package/.env.example DELETED
@@ -1 +0,0 @@
1
- OPEN_AI_KEY= 'open ai key'
package/prompts.json DELETED
@@ -1,23 +0,0 @@
1
- [
2
- {
3
- "generation_for":"card",
4
- "type": "role",
5
- "prompt": "As a dedicated assistant at a learning company, your role is to create test cards based on the provided content. The purpose of these cards is to help learners master and understand the concepts and facts presented to you."
6
- },
7
- {
8
- "generation_for":"card",
9
- "type": "inputs",
10
- "prompt": "You will be provided with the following: \n 1. Title of the source \n 2. The content \n 3. The field of knowledge it belongs to \n 4. Key concepts in the source \n 5. Important facts in the source"
11
- },
12
- {
13
- "generation_for":"card",
14
- "type" :"steps",
15
- "prompt": "**Follow these steps:** \n 1. Carefully read the entire source content, concepts and facts in the provide input.\n 2. Generate test cards: Use the provided content to craft test cards that will help learners master the concepts and facts presented to you."
16
- },
17
- {
18
- "generation_for": "card",
19
- "type": "schema",
20
- "prompt": "**Format your response in the following JSON format:** json { \"test_cards\": [ { \"type\": \"{card_type}\", \"card_content\": \"{content}\", \"concepts\": [\"concept1\", \"concept2\", \"...\"], \"facts\": [\"fact1\", \"fact2\", \"...\"] }, {... as many cards as possible} ] }"
21
-
22
- }
23
- ]
package/readme.md DELETED
@@ -1,35 +0,0 @@
1
- This is a NPM package that handles the all the ai generation for _source on OnlyEver.
2
- The Generation includes, Knowledge Taxonomy , Summary and Test Cards data for the _source.
3
-
4
- The class [OnlyEverGenerator] is the Entry point for the generation module it has two required fields,
5
- [api_key] which is open ai token
6
- [model] open ai model : 'gpt-3.5-turbo-1106'
7
- [content] source content : Array<BaseBlocks>
8
-
9
- The [OnlyEverGenerator] currently exposes a main method, [generate] which handles all types of generation and takes a Param
10
- ```
11
- generate(generate_typology = false,generate_card = false) method takes two args, generate_typology and generate_cards, which are both boolean.
12
- For Eg:
13
- let oeGenerator = new OnlyEverGenerator(
14
- api_key,
15
- model,
16
- [Block1,Block2,Block3], // oe content model
17
- );
18
-
19
-
20
- let responsesArray = await oeGenerator.generate(true,true);
21
-
22
-
23
- Exposed a new method ```gapFill``` from OnlyEverGenerator
24
-
25
-
26
- async gapFill(factsMaps: any, aiCards: Array<any>) {}
27
- /// factsmap
28
- /// {
29
- /// remaining_facts: [],
30
- /// remaining_concepts: [],
31
- //}
32
-
33
- /// aicards is array of ai cards
34
-
35
- ```