only_ever_generator 1.0.3 → 1.0.5
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 +91 -0
- package/dist/bootstrap/app.d.ts.map +1 -0
- package/dist/bootstrap/app.js +120 -84
- package/dist/bootstrap/app.js.map +1 -0
- package/dist/card_gen/generate_cards.d.ts +7 -0
- package/dist/card_gen/generate_cards.d.ts.map +1 -0
- package/dist/card_gen/generate_cards.js +60 -0
- package/dist/card_gen/generate_cards.js.map +1 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +4 -1
- package/dist/config.js.map +1 -0
- package/dist/constants/api_constants.d.ts +3 -0
- package/dist/constants/api_constants.d.ts.map +1 -0
- package/dist/constants/api_constants.js +11 -0
- package/dist/constants/api_constants.js.map +1 -0
- package/dist/constants/prompt_data.d.ts +5 -0
- package/dist/constants/prompt_data.d.ts.map +1 -0
- package/dist/constants/prompt_data.js +303 -0
- package/dist/constants/prompt_data.js.map +1 -0
- package/dist/constants/prompts/card_gen_prompt.d.ts +2 -0
- package/dist/constants/prompts/card_gen_prompt.d.ts.map +1 -0
- package/dist/constants/prompts/card_gen_prompt.js +100 -203
- package/dist/constants/prompts/card_gen_prompt.js.map +1 -0
- package/dist/constants/prompts/typology_prompt.d.ts +2 -0
- package/dist/constants/prompts/typology_prompt.d.ts.map +1 -0
- package/dist/constants/prompts/typology_prompt.js +78 -34
- package/dist/constants/prompts/typology_prompt.js.map +1 -0
- package/dist/constants/source_data.d.ts +173 -0
- package/dist/constants/source_data.d.ts.map +1 -0
- package/dist/constants/source_data.js +962 -10
- package/dist/constants/source_data.js.map +1 -0
- package/dist/embedding_generation/consolidation/global_consolidation.d.ts +33 -0
- package/dist/embedding_generation/consolidation/global_consolidation.d.ts.map +1 -0
- package/dist/embedding_generation/consolidation/global_consolidation.js +76 -0
- package/dist/embedding_generation/consolidation/global_consolidation.js.map +1 -0
- package/dist/embedding_generation/consolidation/local_consolidation.d.ts +39 -0
- package/dist/embedding_generation/consolidation/local_consolidation.d.ts.map +1 -0
- package/dist/embedding_generation/consolidation/local_consolidation.js +105 -0
- package/dist/embedding_generation/consolidation/local_consolidation.js.map +1 -0
- package/dist/embedding_generation/consolidation/write_consolidated_data.d.ts +46 -0
- package/dist/embedding_generation/consolidation/write_consolidated_data.d.ts.map +1 -0
- package/dist/embedding_generation/consolidation/write_consolidated_data.js +69 -0
- package/dist/embedding_generation/consolidation/write_consolidated_data.js.map +1 -0
- package/dist/embedding_generation/generate_embeddings.d.ts +28 -0
- package/dist/embedding_generation/generate_embeddings.d.ts.map +1 -0
- package/dist/embedding_generation/generate_embeddings.js +54 -0
- package/dist/embedding_generation/generate_embeddings.js.map +1 -0
- package/dist/embedding_generation/parse_embedding_response.d.ts +26 -0
- package/dist/embedding_generation/parse_embedding_response.d.ts.map +1 -0
- package/dist/embedding_generation/parse_embedding_response.js +29 -0
- package/dist/embedding_generation/parse_embedding_response.js.map +1 -0
- package/dist/gap_fill/calculate_gap_fill.d.ts +5 -0
- package/dist/gap_fill/calculate_gap_fill.d.ts.map +1 -0
- package/dist/gap_fill/calculate_gap_fill.js +43 -0
- package/dist/gap_fill/calculate_gap_fill.js.map +1 -0
- package/dist/helper/qdrant_db_methods.d.ts +40 -0
- package/dist/helper/qdrant_db_methods.d.ts.map +1 -0
- package/dist/helper/qdrant_db_methods.js +63 -0
- package/dist/helper/qdrant_db_methods.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +86 -149
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +6 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +42 -0
- package/dist/logger.js.map +1 -0
- package/dist/parse/parse_card/parse_cloze_card.d.ts +10 -0
- package/dist/parse/parse_card/parse_cloze_card.d.ts.map +1 -0
- package/dist/parse/parse_card/parse_cloze_card.js +126 -0
- package/dist/parse/parse_card/parse_cloze_card.js.map +1 -0
- package/dist/parse/parse_card/parse_flash_cards.d.ts +19 -0
- package/dist/parse/parse_card/parse_flash_cards.d.ts.map +1 -0
- package/dist/parse/parse_card/parse_flash_cards.js +34 -0
- package/dist/parse/parse_card/parse_flash_cards.js.map +1 -0
- package/dist/parse/parse_card/parse_match_card.d.ts +16 -0
- package/dist/parse/parse_card/parse_match_card.d.ts.map +1 -0
- package/dist/parse/parse_card/parse_match_card.js +82 -0
- package/dist/parse/parse_card/parse_match_card.js.map +1 -0
- package/dist/parse/parse_card/parse_mcq_card.d.ts +24 -0
- package/dist/parse/parse_card/parse_mcq_card.d.ts.map +1 -0
- package/dist/parse/parse_card/parse_mcq_card.js +104 -0
- package/dist/parse/parse_card/parse_mcq_card.js.map +1 -0
- package/dist/parse/parse_card_response.d.ts +19 -0
- package/dist/parse/parse_card_response.d.ts.map +1 -0
- package/dist/parse/parse_card_response.js +100 -0
- package/dist/parse/parse_card_response.js.map +1 -0
- package/dist/parse/parse_source_content.d.ts +25 -0
- package/dist/parse/parse_source_content.d.ts.map +1 -0
- package/dist/parse/parse_source_content.js +186 -0
- package/dist/parse/parse_source_content.js.map +1 -0
- package/dist/parse/response_format_card.d.ts +177 -0
- package/dist/parse/response_format_card.d.ts.map +1 -0
- package/dist/parse/response_format_card.js +372 -0
- package/dist/parse/response_format_card.js.map +1 -0
- package/dist/parse/response_format_typology.d.ts +2 -0
- package/dist/parse/response_format_typology.d.ts.map +1 -0
- package/dist/{parse_response → parse}/response_format_typology.js +18 -18
- package/dist/parse/response_format_typology.js.map +1 -0
- package/dist/services/open_ai_service.d.ts +16 -0
- package/dist/services/open_ai_service.d.ts.map +1 -0
- package/dist/services/open_ai_service.js +92 -0
- package/dist/services/open_ai_service.js.map +1 -0
- package/dist/services/qdrant_service.d.ts +4 -0
- package/dist/services/qdrant_service.d.ts.map +1 -0
- package/dist/services/qdrant_service.js +14 -0
- package/dist/services/qdrant_service.js.map +1 -0
- package/dist/typology-parsed-response.d.ts +62 -0
- package/dist/typology-parsed-response.d.ts.map +1 -0
- package/dist/typology-parsed-response.js +1936 -0
- package/dist/typology-parsed-response.js.map +1 -0
- package/dist/typology_gen/generate_typology.d.ts +29 -0
- package/dist/typology_gen/generate_typology.d.ts.map +1 -0
- package/dist/typology_gen/generate_typology.js +92 -15
- package/dist/typology_gen/generate_typology.js.map +1 -0
- package/dist/utils/generate_args.d.ts +8 -0
- package/dist/utils/generate_args.d.ts.map +1 -0
- package/dist/utils/generate_args.js +28 -0
- package/dist/utils/generate_args.js.map +1 -0
- package/dist/utils/parse_openai_response.d.ts +11 -0
- package/dist/utils/parse_openai_response.d.ts.map +1 -0
- package/dist/utils/parse_openai_response.js +11 -10
- package/dist/utils/parse_openai_response.js.map +1 -0
- package/package.json +19 -7
- package/prompts.json +23 -0
- package/readme.md +16 -13
- package/src/bootstrap/app.ts +167 -107
- package/src/card_gen/generate_cards.ts +58 -0
- package/src/config.ts +5 -3
- package/src/constants/api_constants.ts +7 -0
- package/src/constants/prompt_data.ts +301 -0
- package/src/constants/prompts/card_gen_prompt.ts +101 -208
- package/src/constants/prompts/typology_prompt.ts +81 -33
- package/src/constants/source_data.ts +1029 -23
- package/src/embedding_generation/consolidation/global_consolidation.ts +94 -0
- package/src/embedding_generation/consolidation/local_consolidation.ts +141 -0
- package/src/embedding_generation/consolidation/write_consolidated_data.ts +98 -0
- package/src/embedding_generation/generate_embeddings.ts +41 -0
- package/src/embedding_generation/parse_embedding_response.ts +31 -0
- package/src/gap_fill/calculate_gap_fill.ts +50 -0
- package/src/helper/qdrant_db_methods.ts +77 -0
- package/src/index.ts +98 -164
- package/src/logger.ts +30 -0
- package/src/parse/parse_card/parse_cloze_card.ts +136 -0
- package/src/parse/parse_card/parse_flash_cards.ts +33 -0
- package/src/parse/parse_card/parse_match_card.ts +94 -0
- package/src/parse/parse_card/parse_mcq_card.ts +105 -0
- package/src/parse/parse_card_response.ts +117 -0
- package/src/parse/parse_source_content.ts +202 -0
- package/src/parse/response_format_card.ts +386 -0
- package/src/parse/response_format_typology.ts +44 -0
- package/src/services/open_ai_service.ts +88 -0
- package/src/services/qdrant_service.ts +10 -0
- package/src/typology-parsed-response.ts +1932 -0
- package/src/typology_gen/generate_typology.ts +101 -12
- package/src/utils/generate_args.ts +29 -0
- package/src/utils/parse_openai_response.ts +17 -19
- package/tsconfig.json +8 -3
- package/dist/class/parse/parse_source_content.js +0 -62
- package/dist/class/services/open_ai_service.js +0 -25
- package/dist/parse_response/response_format_card.js +0 -210
- package/dist/service/open_ai_request.js +0 -58
- package/src/class/parse/parse_source_content.ts +0 -71
- package/src/class/services/open_ai_service.ts +0 -18
- package/src/parse_response/response_format_card.ts +0 -211
- package/src/parse_response/response_format_typology.ts +0 -44
- package/src/service/open_ai_request.ts +0 -46
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const typologyResponse = {
|
|
2
|
+
usage_data: {
|
|
3
|
+
prompt_tokens: 11611,
|
|
4
|
+
completion_tokens: 441,
|
|
5
|
+
total_tokens: 12052,
|
|
6
|
+
},
|
|
7
|
+
generated_content: {
|
|
8
|
+
field: [
|
|
9
|
+
"Sciences",
|
|
10
|
+
"Technology & Engineering",
|
|
11
|
+
"Education, Learning & Personal Development",
|
|
12
|
+
],
|
|
13
|
+
concepts: [
|
|
14
|
+
"Electrolysis",
|
|
15
|
+
"Faraday's Laws of Electrolysis",
|
|
16
|
+
"Electrolytic Cell",
|
|
17
|
+
"Decomposition Potential",
|
|
18
|
+
"Oxidation and Reduction at the Electrodes",
|
|
19
|
+
"Electrolysis of Water",
|
|
20
|
+
"Electrolysis of Carbon Dioxide",
|
|
21
|
+
"Electrocrystallization",
|
|
22
|
+
],
|
|
23
|
+
facts: [
|
|
24
|
+
"Electrolysis is the passing of a direct electric current through an electrolyte producing chemical reactions at the electrodes and decomposition of the materials.",
|
|
25
|
+
"In electrolysis, the quantity of the products is proportional to the current, and when two or more electrolytic cells are connected in series to the same power source, the products produced in the cells are proportional to their equivalent weight.",
|
|
26
|
+
"The main components required to achieve electrolysis are an electrolyte, electrodes, and an external power source.",
|
|
27
|
+
"Faraday's laws of electrolysis detail the amount of the products of electrolysis is related to the number of electrons in the reaction at the electrodes.",
|
|
28
|
+
"Decomposition potential or decomposition voltage refers to the minimum voltage between anode and cathode of an electrolytic cell that is needed for electrolysis to occur.",
|
|
29
|
+
"The electrochemical reduction of carbon dioxide can produce value-added chemicals such as methane, ethylene, and ethanol.",
|
|
30
|
+
],
|
|
31
|
+
generate_cards: true,
|
|
32
|
+
summary_cards: [
|
|
33
|
+
"Electrolysis is the process of passing direct electric current through an electrolyte, resulting in chemical reactions and the decomposition of materials.",
|
|
34
|
+
"Faraday's laws of electrolysis determine the relationship between the amounts of products generated and the electrons involved in the reaction at the electrodes.",
|
|
35
|
+
"Decomposition potential is the minimum voltage required between anode and cathode for electrolysis to occur.",
|
|
36
|
+
"The electrochemical reduction of carbon dioxide is a potential method for producing valuable chemicals such as methane, ethylene, and ethanol.",
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
generated_at: "Tue, 20 Jan 1970 21:17:46 GMT",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export function returnTypologyData() {
|
|
43
|
+
return typologyResponse as any;
|
|
44
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import {
|
|
3
|
+
parseOpenAiFailureResponse,
|
|
4
|
+
parseOpenAiSuccessResponse,
|
|
5
|
+
} from "../utils/parse_openai_response";
|
|
6
|
+
import {
|
|
7
|
+
openAiEmbeddingEndPoint,
|
|
8
|
+
openAiEndPoint,
|
|
9
|
+
} from "../constants/api_constants";
|
|
10
|
+
|
|
11
|
+
export class OpenAiService {
|
|
12
|
+
public api_key: string;
|
|
13
|
+
public model: string;
|
|
14
|
+
|
|
15
|
+
constructor(apiKey: string, model: string) {
|
|
16
|
+
this.api_key = apiKey;
|
|
17
|
+
this.model = model;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async sendRequest(prompt: string, content: string) {
|
|
21
|
+
try {
|
|
22
|
+
let message = [
|
|
23
|
+
{
|
|
24
|
+
role: "system",
|
|
25
|
+
content: prompt,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
role: "user",
|
|
29
|
+
content: content,
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
const url = openAiEndPoint();
|
|
33
|
+
let response = await axios.post(
|
|
34
|
+
url,
|
|
35
|
+
{
|
|
36
|
+
model: this.model,
|
|
37
|
+
messages: message,
|
|
38
|
+
response_format: { type: "json_object" },
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
headers: {
|
|
42
|
+
Authorization: "Bearer " + this.api_key,
|
|
43
|
+
"Content-Type": ["application/json"],
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (response.status == 200) {
|
|
49
|
+
console.log("success");
|
|
50
|
+
return parseOpenAiSuccessResponse(response.data) as any;
|
|
51
|
+
} else {
|
|
52
|
+
console.log("failed");
|
|
53
|
+
return response.statusText as any;
|
|
54
|
+
}
|
|
55
|
+
} catch (err: any) {
|
|
56
|
+
return parseOpenAiFailureResponse(err.response);
|
|
57
|
+
}
|
|
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
|
+
}
|
|
88
|
+
}
|