only_ever_generator 1.0.7 → 1.0.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.
- package/dist/bootstrap/app.d.ts +29 -6
- package/dist/bootstrap/app.d.ts.map +1 -1
- package/dist/bootstrap/app.js +82 -19
- package/dist/bootstrap/app.js.map +1 -1
- package/dist/card_gen/generate_cards.d.ts +2 -1
- package/dist/card_gen/generate_cards.d.ts.map +1 -1
- package/dist/card_gen/generate_cards.js +21 -4
- package/dist/card_gen/generate_cards.js.map +1 -1
- package/dist/constants/prompt_data.d.ts +0 -1
- package/dist/constants/prompts/card_gen_prompt.js.map +1 -1
- package/dist/constants/source_data.d.ts +0 -2
- package/dist/constants/source_data.js +1 -1
- package/dist/constants/source_data.js.map +1 -1
- package/dist/embedding_generation/consolidation/global_consolidation.d.ts +1 -1
- package/dist/embedding_generation/consolidation/global_consolidation.d.ts.map +1 -1
- package/dist/embedding_generation/consolidation/global_consolidation.js +1 -1
- package/dist/embedding_generation/consolidation/global_consolidation.js.map +1 -1
- package/dist/embedding_generation/consolidation/local_consolidation.d.ts.map +1 -1
- package/dist/embedding_generation/local_consolidation.js +104 -0
- package/dist/enums/card_type_enum.d.ts +7 -0
- package/dist/enums/card_type_enum.d.ts.map +1 -0
- package/dist/enums/card_type_enum.js +11 -0
- package/dist/enums/card_type_enum.js.map +1 -0
- package/dist/helper/openai_helper.d.ts +12 -0
- package/dist/helper/openai_helper.d.ts.map +1 -0
- package/dist/helper/openai_helper.js +26 -0
- package/dist/helper/openai_helper.js.map +1 -0
- package/dist/helper/qdrant_db_methods.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +923 -87
- package/dist/index.js.map +1 -1
- package/dist/parse/parse_card/parse_cloze_card.d.ts +8 -1
- package/dist/parse/parse_card/parse_cloze_card.d.ts.map +1 -1
- package/dist/parse/parse_card/parse_cloze_card.js +2 -2
- package/dist/parse/parse_card/parse_cloze_card.js.map +1 -1
- package/dist/parse/parse_card/parse_flash_cards.d.ts +14 -7
- package/dist/parse/parse_card/parse_flash_cards.d.ts.map +1 -1
- package/dist/parse/parse_card/parse_flash_cards.js +3 -3
- package/dist/parse/parse_card/parse_flash_cards.js.map +1 -1
- package/dist/parse/parse_card/parse_match_card.d.ts +8 -1
- package/dist/parse/parse_card/parse_match_card.d.ts.map +1 -1
- package/dist/parse/parse_card/parse_match_card.js +2 -3
- package/dist/parse/parse_card/parse_match_card.js.map +1 -1
- package/dist/parse/parse_card/parse_mcq_card.d.ts +15 -8
- package/dist/parse/parse_card/parse_mcq_card.d.ts.map +1 -1
- package/dist/parse/parse_card/parse_mcq_card.js +2 -2
- package/dist/parse/parse_card/parse_mcq_card.js.map +1 -1
- package/dist/parse/parse_card_response.d.ts +12 -10
- package/dist/parse/parse_card_response.d.ts.map +1 -1
- package/dist/parse/parse_card_response.js +121 -54
- package/dist/parse/parse_card_response.js.map +1 -1
- package/dist/parse/parse_source_content.d.ts +7 -5
- package/dist/parse/parse_source_content.d.ts.map +1 -1
- package/dist/parse/parse_source_content.js +1 -0
- package/dist/parse/parse_source_content.js.map +1 -1
- package/dist/parse/response_format_card.d.ts +0 -1
- package/dist/parse/response_format_typology.d.ts +0 -1
- package/dist/types/base_param_type.d.ts +17 -0
- package/dist/types/base_param_type.d.ts.map +1 -0
- package/dist/types/base_param_type.js +3 -0
- package/dist/types/base_param_type.js.map +1 -0
- package/dist/types/mongo_concept_fact_type.d.ts +12 -0
- package/dist/types/mongo_concept_fact_type.d.ts.map +1 -0
- package/dist/types/mongo_concept_fact_type.js +3 -0
- package/dist/types/mongo_concept_fact_type.js.map +1 -0
- package/dist/types/parsed_card_type.d.ts +12 -0
- package/dist/types/parsed_card_type.d.ts.map +1 -0
- package/dist/types/parsed_card_type.js +30 -0
- package/dist/types/parsed_card_type.js.map +1 -0
- package/dist/types/raw_card_response_types/generated_card_response_type.d.ts +40 -0
- package/dist/types/raw_card_response_types/generated_card_response_type.d.ts.map +1 -0
- package/dist/types/raw_card_response_types/generated_card_response_type.js +8 -0
- package/dist/types/raw_card_response_types/generated_card_response_type.js.map +1 -0
- package/dist/types/source_taxonomy_type.d.ts +15 -0
- package/dist/types/source_taxonomy_type.d.ts.map +1 -0
- package/dist/types/source_taxonomy_type.js +3 -0
- package/dist/types/source_taxonomy_type.js.map +1 -0
- package/dist/typology_gen/generate_concept_facts.d.ts +18 -0
- package/dist/typology_gen/generate_concept_facts.d.ts.map +1 -0
- package/dist/typology_gen/generate_concept_facts.js +48 -0
- package/dist/typology_gen/generate_concept_facts.js.map +1 -0
- package/dist/typology_gen/generate_typology.d.ts +9 -3
- package/dist/typology_gen/generate_typology.d.ts.map +1 -1
- package/dist/typology_gen/generate_typology.js +43 -31
- package/dist/typology_gen/generate_typology.js.map +1 -1
- package/package.json +9 -9
- package/src/bootstrap/app.ts +129 -29
- package/src/card_gen/generate_cards.ts +27 -5
- package/src/constants/prompts/card_gen_prompt.ts +1 -1
- package/src/embedding_generation/consolidation/global_consolidation.ts +2 -2
- package/src/enums/card_type_enum.ts +6 -0
- package/src/helper/openai_helper.ts +31 -0
- package/src/index.ts +947 -101
- package/src/parse/parse_card/parse_cloze_card.ts +11 -3
- package/src/parse/parse_card/parse_flash_cards.ts +12 -4
- package/src/parse/parse_card/parse_match_card.ts +10 -4
- package/src/parse/parse_card/parse_mcq_card.ts +11 -3
- package/src/parse/parse_card_response.ts +94 -20
- package/src/parse/parse_source_content.ts +11 -1
- package/src/types/base_param_type.ts +17 -0
- package/src/types/mongo_concept_fact_type.ts +12 -0
- package/src/types/parsed_card_type.ts +39 -0
- package/src/types/raw_card_response_types/generated_card_response_type.ts +61 -0
- package/src/types/source_taxonomy_type.ts +17 -0
- package/src/typology_gen/generate_concept_facts.ts +54 -0
- package/src/typology_gen/generate_typology.ts +59 -36
- package/.env.example +0 -1
- package/dist/constants/prompt_data.d.ts.map +0 -1
- package/dist/constants/source_data.d.ts.map +0 -1
- package/dist/parse/response_format_card.d.ts.map +0 -1
- package/dist/parse/response_format_typology.d.ts.map +0 -1
- package/prompts.json +0 -23
- package/readme.md +0 -35
- package/src/constants/prompt_data.ts +0 -301
- package/src/constants/source_data.ts +0 -1036
- package/src/parse/response_format_card.ts +0 -386
- package/src/parse/response_format_typology.ts +0 -44
package/src/bootstrap/app.ts
CHANGED
|
@@ -7,28 +7,67 @@ import { GenerateEmbeddings } from "../embedding_generation/generate_embeddings"
|
|
|
7
7
|
import { LocalConsolidation } from "../embedding_generation/consolidation/local_consolidation";
|
|
8
8
|
import { GlobalConsolidation } from "../embedding_generation/consolidation/global_consolidation";
|
|
9
9
|
import { WriteConsolidatedData } from "../embedding_generation/consolidation/write_consolidated_data";
|
|
10
|
+
import { BaseParamType } from "../types/base_param_type";
|
|
11
|
+
import { SourceTaxonomy } from "../types/source_taxonomy_type";
|
|
12
|
+
import { MongoConceptFactSource } from "../types/mongo_concept_fact_type";
|
|
13
|
+
import { OpenAIHelper } from "../helper/openai_helper";
|
|
14
|
+
import { GenerateConceptFacts } from "../typology_gen/generate_concept_facts";
|
|
10
15
|
|
|
11
16
|
export class OnlyEverGenerator {
|
|
12
17
|
public api_key: string = "";
|
|
13
18
|
public openAiService: OpenAiService;
|
|
14
19
|
|
|
15
20
|
/// these fields will be populated inside the constructor
|
|
16
|
-
parsedContent
|
|
21
|
+
parsedContent?: {
|
|
22
|
+
title: string;
|
|
23
|
+
headings: string[];
|
|
24
|
+
content: any[];
|
|
25
|
+
taxonomy: SourceTaxonomy;
|
|
26
|
+
source_id: string;
|
|
27
|
+
type: string;
|
|
28
|
+
} = undefined;
|
|
17
29
|
promptForTypology: string = "";
|
|
18
30
|
promptForCardGen: string = "";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
31
|
+
promptForSummary: {
|
|
32
|
+
promptId: string;
|
|
33
|
+
version: string;
|
|
34
|
+
} = {
|
|
35
|
+
promptId: "",
|
|
36
|
+
version: "",
|
|
37
|
+
};
|
|
38
|
+
promptForConceptFacts: {
|
|
39
|
+
promptId: string;
|
|
40
|
+
version: string;
|
|
41
|
+
} = {
|
|
42
|
+
promptId: "",
|
|
43
|
+
version: "",
|
|
44
|
+
};
|
|
45
|
+
expectedFields: Array<string> = [];
|
|
46
|
+
typologyResponse?: any = undefined;
|
|
22
47
|
cardgenResponse: any = undefined;
|
|
23
48
|
summarizeResponse = {};
|
|
24
|
-
gapFillResponse: any = {};
|
|
25
49
|
|
|
26
|
-
constructor(
|
|
50
|
+
constructor(
|
|
51
|
+
apiKey: string,
|
|
52
|
+
model: string,
|
|
53
|
+
generationContent: BaseParamType,
|
|
54
|
+
promptForSummary: {
|
|
55
|
+
promptId: string;
|
|
56
|
+
version: string;
|
|
57
|
+
},
|
|
58
|
+
promptForConceptFacts: {
|
|
59
|
+
promptId: string;
|
|
60
|
+
version: string;
|
|
61
|
+
}
|
|
62
|
+
) {
|
|
63
|
+
this.promptForSummary = promptForSummary;
|
|
64
|
+
this.promptForConceptFacts = promptForConceptFacts;
|
|
27
65
|
this.api_key = apiKey;
|
|
28
66
|
this.openAiService = new OpenAiService(
|
|
29
67
|
apiKey,
|
|
30
68
|
model ?? "gpt-3.5-turbo-1106"
|
|
31
69
|
);
|
|
70
|
+
|
|
32
71
|
const parsedData = new ParseSourceContent(
|
|
33
72
|
generationContent.content
|
|
34
73
|
).parseData();
|
|
@@ -37,6 +76,8 @@ export class OnlyEverGenerator {
|
|
|
37
76
|
headings: parsedData.headings,
|
|
38
77
|
content: parsedData.content,
|
|
39
78
|
taxonomy: parsedData.taxonomy,
|
|
79
|
+
source_id: parsedData.source_id,
|
|
80
|
+
type: parsedData.type,
|
|
40
81
|
}),
|
|
41
82
|
(this.typologyResponse = generationContent.content.taxonomy);
|
|
42
83
|
|
|
@@ -54,26 +95,69 @@ export class OnlyEverGenerator {
|
|
|
54
95
|
const whatNeedsToBeGenerated = args.getWhatNeedsToBeGenerated();
|
|
55
96
|
for (let elem of whatNeedsToBeGenerated)
|
|
56
97
|
if (elem == "generate_tyopology") {
|
|
57
|
-
this.typologyResponse = await this.generateTypology(
|
|
58
|
-
|
|
59
|
-
);
|
|
98
|
+
this.typologyResponse = await this.generateTypology();
|
|
99
|
+
console.log("Typology generated");
|
|
100
|
+
console.log(this.typologyResponse);
|
|
60
101
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
102
|
+
if (this.typologyResponse?.status_code == 200) {
|
|
103
|
+
console.log("Concept facts generating");
|
|
104
|
+
const response = await this.generateConceptFacts();
|
|
105
|
+
this.typologyResponse.concepts_facts = response.concepts_facts;
|
|
106
|
+
console.log("Concept facts generated");
|
|
107
|
+
console.log(this.typologyResponse);
|
|
108
|
+
const embeddings = await this.generateEmbeddings(
|
|
109
|
+
this.typologyResponse
|
|
110
|
+
);
|
|
111
|
+
console.log("Embedding generated");
|
|
112
|
+
const localConsolidation = await this.localConsolidation(
|
|
113
|
+
embeddings.concepts_facts,
|
|
114
|
+
this.parsedContent!.title
|
|
115
|
+
);
|
|
116
|
+
console.log("Local consolidation done");
|
|
117
|
+
this.typologyResponse!.concepts_facts =
|
|
118
|
+
localConsolidation.sourceTaxonomyOps;
|
|
119
|
+
const globalConsolidation = await this.globalConsolidation(
|
|
120
|
+
localConsolidation.sourceTaxonomyOps,
|
|
121
|
+
this.parsedContent!.source_id,
|
|
122
|
+
0.8
|
|
123
|
+
);
|
|
124
|
+
console.log("Global consolidation done");
|
|
125
|
+
this.typologyResponse!.concepts_facts =
|
|
126
|
+
globalConsolidation.source_taxonomy;
|
|
127
|
+
this.typologyResponse!.metadata?.push(embeddings.metadata);
|
|
128
|
+
responseToReturn.push({
|
|
129
|
+
type: "typology",
|
|
130
|
+
data: this.typologyResponse,
|
|
131
|
+
qdrantOps: {
|
|
132
|
+
update: globalConsolidation.global_updates,
|
|
133
|
+
inserts: globalConsolidation.global_inserts,
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
} else {
|
|
137
|
+
responseToReturn.push({
|
|
138
|
+
type: "typology",
|
|
139
|
+
data: this.typologyResponse,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
65
142
|
} else if (elem == "generate_card") {
|
|
66
143
|
if (this.shouldTheCardBeGeneratedAfterTypologyResponse()) {
|
|
67
|
-
this.parsedContent
|
|
68
|
-
concepts_facts: this.typologyResponse
|
|
69
|
-
|
|
144
|
+
this.parsedContent!.taxonomy = {
|
|
145
|
+
concepts_facts: this.typologyResponse?.concepts_facts ?? [],
|
|
146
|
+
fields: this.expectedFields,
|
|
147
|
+
generate_cards: this.typologyResponse?.generate_cards ?? {
|
|
148
|
+
state: false,
|
|
149
|
+
reason: "",
|
|
150
|
+
},
|
|
70
151
|
};
|
|
71
152
|
this.cardgenResponse = await this.generateCard(
|
|
72
153
|
this.promptForCardGen,
|
|
73
154
|
JSON.stringify(this.typologyResponse),
|
|
74
155
|
false
|
|
75
156
|
);
|
|
76
|
-
responseToReturn.push(
|
|
157
|
+
responseToReturn.push({
|
|
158
|
+
type: "card_gen",
|
|
159
|
+
data: this.cardgenResponse,
|
|
160
|
+
});
|
|
77
161
|
}
|
|
78
162
|
}
|
|
79
163
|
return responseToReturn;
|
|
@@ -99,25 +183,46 @@ export class OnlyEverGenerator {
|
|
|
99
183
|
prompt ?? "",
|
|
100
184
|
JSON.stringify(this.parsedContent) + additionalContent,
|
|
101
185
|
isGapFill,
|
|
102
|
-
this.parsedContent
|
|
186
|
+
this.parsedContent!.taxonomy,
|
|
103
187
|
n
|
|
104
188
|
);
|
|
105
189
|
return generateCardsResp;
|
|
106
190
|
}
|
|
107
191
|
|
|
108
|
-
async generateTypology(
|
|
192
|
+
async generateTypology() {
|
|
193
|
+
const content = {
|
|
194
|
+
title: this.parsedContent?.title,
|
|
195
|
+
headings: this.parsedContent?.headings,
|
|
196
|
+
content: this.parsedContent?.content,
|
|
197
|
+
};
|
|
109
198
|
let response = await new GenerateTypology(
|
|
110
199
|
this.openAiService,
|
|
111
|
-
|
|
112
|
-
JSON.stringify(
|
|
113
|
-
this.expectedFields
|
|
200
|
+
this.parsedContent?.type ?? "wiki",
|
|
201
|
+
JSON.stringify(content),
|
|
202
|
+
this.expectedFields,
|
|
203
|
+
this.promptForSummary
|
|
204
|
+
).generate();
|
|
205
|
+
return response;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
async generateConceptFacts() {
|
|
209
|
+
const content = {
|
|
210
|
+
title: this.parsedContent?.title,
|
|
211
|
+
headings: this.parsedContent?.headings,
|
|
212
|
+
content: this.parsedContent?.content,
|
|
213
|
+
};
|
|
214
|
+
let response = await new GenerateConceptFacts(
|
|
215
|
+
this.openAiService,
|
|
216
|
+
JSON.stringify(content),
|
|
217
|
+
this.parsedContent?.type ?? "wiki",
|
|
218
|
+
this.promptForConceptFacts
|
|
114
219
|
).generate();
|
|
115
220
|
return response;
|
|
116
221
|
}
|
|
117
222
|
|
|
118
223
|
async generateEmbeddings(typologyResponse: any) {
|
|
119
224
|
const concepts_facts = typologyResponse.concepts_facts;
|
|
120
|
-
const texts = concepts_facts.map((e:
|
|
225
|
+
const texts = concepts_facts.map((e: MongoConceptFactSource) => e.text);
|
|
121
226
|
const embeddings = await new GenerateEmbeddings(
|
|
122
227
|
this.openAiService
|
|
123
228
|
).generateEmbeddings(concepts_facts);
|
|
@@ -156,12 +261,7 @@ export class OnlyEverGenerator {
|
|
|
156
261
|
sourceId,
|
|
157
262
|
threshold ?? 0.8
|
|
158
263
|
);
|
|
159
|
-
|
|
160
|
-
// new WriteConsolidatedData().writeConsolidatedData(
|
|
161
|
-
// embeddings,
|
|
162
|
-
// [],
|
|
163
|
-
// sourceId
|
|
164
|
-
// );
|
|
264
|
+
|
|
165
265
|
return embeddings;
|
|
166
266
|
}
|
|
167
267
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ErrorLogger } from "../logger";
|
|
2
2
|
import { ParseCardResponse } from "../parse/parse_card_response";
|
|
3
3
|
import { OpenAiService } from "../services/open_ai_service";
|
|
4
|
+
import { GeneratedCardResponseType } from "../types/raw_card_response_types/generated_card_response_type";
|
|
5
|
+
import { SourceTaxonomy } from "../types/source_taxonomy_type";
|
|
4
6
|
|
|
5
7
|
export class GenerateCards {
|
|
6
8
|
openAiService: OpenAiService;
|
|
@@ -12,7 +14,7 @@ export class GenerateCards {
|
|
|
12
14
|
prompt: string,
|
|
13
15
|
parsedContent: string,
|
|
14
16
|
isGapFill: boolean,
|
|
15
|
-
taxonomy:
|
|
17
|
+
taxonomy: SourceTaxonomy,
|
|
16
18
|
n: number = 0
|
|
17
19
|
) {
|
|
18
20
|
try {
|
|
@@ -21,8 +23,6 @@ export class GenerateCards {
|
|
|
21
23
|
parsedContent
|
|
22
24
|
);
|
|
23
25
|
var updatedNumber = n + 1;
|
|
24
|
-
// console.log("response to card generation ", response);
|
|
25
|
-
// response["request_type"] = ;
|
|
26
26
|
response.metadata = {
|
|
27
27
|
req_time: response.generated_at ?? new Date(),
|
|
28
28
|
req_type: {
|
|
@@ -35,12 +35,34 @@ export class GenerateCards {
|
|
|
35
35
|
prompt_tokens_details: response.usage_data?.prompt_tokens_details,
|
|
36
36
|
model: this.openAiService.model,
|
|
37
37
|
};
|
|
38
|
+
|
|
38
39
|
if (response.status_code == 200) {
|
|
39
40
|
response.metadata.status = "completed";
|
|
41
|
+
/// map response to generated_content
|
|
42
|
+
const generated_data: GeneratedCardResponseType = {
|
|
43
|
+
metadata: response.metadata,
|
|
44
|
+
generated_content: {
|
|
45
|
+
test_cards: (response.generated_content.test_cards ?? []).map(
|
|
46
|
+
(card: any) => {
|
|
47
|
+
return {
|
|
48
|
+
type: card.type,
|
|
49
|
+
card_content: card.card_content,
|
|
50
|
+
concepts: card.concepts ?? [],
|
|
51
|
+
facts: card.facts ?? [],
|
|
52
|
+
bloom_level: card.bloom_level ?? 1,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
},
|
|
57
|
+
usage_data: response.usage_data,
|
|
58
|
+
generated_at: response.generated_at,
|
|
59
|
+
status_code: response.status_code,
|
|
60
|
+
};
|
|
40
61
|
let parseCard = new ParseCardResponse().parse(
|
|
41
|
-
|
|
62
|
+
generated_data,
|
|
42
63
|
isGapFill,
|
|
43
|
-
taxonomy
|
|
64
|
+
taxonomy,
|
|
65
|
+
1
|
|
44
66
|
);
|
|
45
67
|
return parseCard;
|
|
46
68
|
} else {
|
|
@@ -160,5 +160,5 @@ Once you are done generating the test cards, review the full list of concepts an
|
|
|
160
160
|
Only stop generating test questions once you believe there is sufficient testing material for learners to fully understand the concepts and remember the facts. The same concept or fact can have multiple test cards, so continue creating test cards until you are confident that there are enough for learners to fully grasp the source material.
|
|
161
161
|
`;
|
|
162
162
|
export function returnCardGenPrompt() {
|
|
163
|
-
|
|
163
|
+
return promptString;
|
|
164
164
|
}
|
|
@@ -27,8 +27,8 @@ export class GlobalConsolidation {
|
|
|
27
27
|
|
|
28
28
|
const globalUpdatesOps: {
|
|
29
29
|
id: string;
|
|
30
|
-
vector: number[];
|
|
31
30
|
sourceIdToAdd: string;
|
|
31
|
+
vector: number[];
|
|
32
32
|
currentPayload: {
|
|
33
33
|
_sources: string[];
|
|
34
34
|
text: string;
|
|
@@ -73,8 +73,8 @@ export class GlobalConsolidation {
|
|
|
73
73
|
});
|
|
74
74
|
globalUpdatesOps.push({
|
|
75
75
|
id: consolidatedId.toString(),
|
|
76
|
-
vector: originalConcept.embedding,
|
|
77
76
|
sourceIdToAdd: sourceId,
|
|
77
|
+
vector: originalConcept.embedding,
|
|
78
78
|
currentPayload: {
|
|
79
79
|
// _sources: currentPayload['_sources'] ?? [],
|
|
80
80
|
_sources: (currentPayload?._sources ?? []) as string[],
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
|
|
3
|
+
export class OpenAIHelper {
|
|
4
|
+
public openAI: OpenAI;
|
|
5
|
+
public model: string;
|
|
6
|
+
public promptId: string;
|
|
7
|
+
public openAIKey: string;
|
|
8
|
+
public version: string;
|
|
9
|
+
constructor(
|
|
10
|
+
openAIKey: string,
|
|
11
|
+
model: string,
|
|
12
|
+
promptId: string,
|
|
13
|
+
version: string
|
|
14
|
+
) {
|
|
15
|
+
this.openAI = getOpenAI(openAIKey);
|
|
16
|
+
this.model = model;
|
|
17
|
+
this.promptId = promptId;
|
|
18
|
+
this.openAIKey = openAIKey;
|
|
19
|
+
this.version = version;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const getOpenAI = (openAIKey: string) => {
|
|
24
|
+
const openai = new OpenAI({
|
|
25
|
+
apiKey: openAIKey,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return openai;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { getOpenAI, OpenAI };
|