only_ever_generator 0.2.7 → 0.2.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/card_gen/generate_cards.js +1 -0
- package/dist/constants/prompt_data.js +273 -273
- package/dist/constants/prompts/card_gen_prompt.js +180 -180
- package/dist/constants/prompts/typology_prompt.js +93 -93
- package/package.json +33 -33
- package/readme.md +23 -23
- package/src/bootstrap/app.ts +150 -154
- package/src/card_gen/generate_cards.ts +251 -251
- package/src/config.ts +6 -6
- package/src/constants/api_constants.ts +2 -2
- package/src/constants/prompt_data.ts +296 -296
- package/src/constants/prompts/card_gen_prompt.ts +372 -372
- package/src/constants/prompts/typology_prompt.ts +202 -202
- package/src/constants/source_data.ts +47 -47
- package/src/gap_fill/calculate_gap_fill.ts +52 -52
- package/src/index.ts +61 -61
- package/src/logger.ts +30 -30
- package/src/parse/parse_card_response.ts +289 -289
- package/src/parse/parse_source_content.ts +94 -94
- package/src/parse/response_format_card.ts +210 -210
- package/src/parse/response_format_typology.ts +43 -43
- package/src/services/open_ai_service.ts +55 -55
- package/src/typology_gen/generate_typology.ts +71 -71
- package/src/utils/generate_args.ts +28 -28
- package/src/utils/parse_openai_response.ts +20 -20
- package/tsconfig.json +12 -12
- package/dist/class/parse/parse_source_content.js +0 -62
- package/dist/class/services/open_ai_service.js +0 -25
- package/dist/parse_response/parse_card_response.js +0 -288
- package/dist/parse_response/response_format_card.js +0 -210
- package/dist/parse_response/response_format_typology.js +0 -47
- package/dist/service/open_ai_request.js +0 -57
|
@@ -1,251 +1,251 @@
|
|
|
1
|
-
import { ErrorLogger } from "../logger";
|
|
2
|
-
import { OpenAiService } from "../services/open_ai_service";
|
|
3
|
-
|
|
4
|
-
export class GenerateCards {
|
|
5
|
-
openAiService: OpenAiService;
|
|
6
|
-
constructor(openAiService: OpenAiService) {
|
|
7
|
-
this.openAiService = openAiService;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async generateCards(prompt: string, parsedContent: string, isGapFill: boolean) {
|
|
11
|
-
let response = await this.openAiService?.sendRequest(prompt, parsedContent);
|
|
12
|
-
// console.log("response to card generation ", response);
|
|
13
|
-
response["type"] = isGapFill ? "gap_fill":"card_gen";
|
|
14
|
-
response.metadata = {
|
|
15
|
-
"req_time": response.generated_at,
|
|
16
|
-
"req_type": response.type,
|
|
17
|
-
"req_tokens": response.usage_data?.prompt_tokens,
|
|
18
|
-
"res_tokens": response.usage_data?.completion_tokens,
|
|
19
|
-
// "created_at":response.created_at,
|
|
20
|
-
};
|
|
21
|
-
if(response.status_code == 200){
|
|
22
|
-
response.metadata.status = "completed";
|
|
23
|
-
//return response;
|
|
24
|
-
return this.parse(response, isGapFill);
|
|
25
|
-
} else {
|
|
26
|
-
response.metadata.status = "failed";
|
|
27
|
-
return response;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async parse(generatedData: any, isGapFill: boolean) {
|
|
32
|
-
try{
|
|
33
|
-
const cardData = [];
|
|
34
|
-
let usage_data = generatedData.metadata;
|
|
35
|
-
const status_code = generatedData.status_code;
|
|
36
|
-
const missing_concepts = generatedData.generated_content.missing_concepts;
|
|
37
|
-
const missing_facts = generatedData.generated_content.missing_facts;
|
|
38
|
-
const unparsedTestCards = generatedData.generated_content.test_cards;
|
|
39
|
-
const type = generatedData.type;
|
|
40
|
-
if(unparsedTestCards !== undefined && unparsedTestCards.length != 0) {
|
|
41
|
-
for (let elem of unparsedTestCards) {
|
|
42
|
-
if (elem.type == "flash") {
|
|
43
|
-
cardData.push(this.parseFlashCard(elem));
|
|
44
|
-
} else if (elem.type == "mcq") {
|
|
45
|
-
cardData.push(this.parseMcqCard(elem));
|
|
46
|
-
} else if (elem.type == "cloze") {
|
|
47
|
-
cardData.push(this.parseClozeCard(elem));
|
|
48
|
-
} else if (elem.type == "match") {
|
|
49
|
-
cardData.push(this.parseMatchCard(elem));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
if(!isGapFill) {
|
|
54
|
-
usage_data.status = "failed";
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
status_code: status_code,
|
|
62
|
-
metadata: usage_data,
|
|
63
|
-
type: type,
|
|
64
|
-
missing_concepts: missing_concepts,
|
|
65
|
-
missing_facts: missing_facts,
|
|
66
|
-
cards_data: cardData,
|
|
67
|
-
};
|
|
68
|
-
}catch (e:any){
|
|
69
|
-
await new ErrorLogger({
|
|
70
|
-
"type": 'card_parsing',
|
|
71
|
-
"data": e.message,
|
|
72
|
-
}).log();
|
|
73
|
-
return {
|
|
74
|
-
status_code: 500,
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
parseFlashCard(data: any) {
|
|
81
|
-
let displayTitle = this.generateFlashCardDisplayTitle(
|
|
82
|
-
data.card_content.front,
|
|
83
|
-
data.card_content.back
|
|
84
|
-
);
|
|
85
|
-
let flashCardData = {
|
|
86
|
-
type: {
|
|
87
|
-
category: 'learning',
|
|
88
|
-
sub_type: data.type,
|
|
89
|
-
},
|
|
90
|
-
heading: data.card_reference,
|
|
91
|
-
displayTitle: displayTitle,
|
|
92
|
-
content: {
|
|
93
|
-
front_content: data.card_content.front,
|
|
94
|
-
back_content: data.card_content.back,
|
|
95
|
-
},
|
|
96
|
-
concepts: data.concepts,
|
|
97
|
-
facts: data.facts,
|
|
98
|
-
bloomLevel: data.bloom_level,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
return flashCardData;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
generateFlashCardDisplayTitle(front: string, back: string) {
|
|
105
|
-
return `${front} ---- ${back}`;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
parseMcqCard(data: any) {
|
|
109
|
-
let mcqAnswers = [];
|
|
110
|
-
if(data.card_content.choices !== undefined && data.card_content.choices.length != 0) {
|
|
111
|
-
for (let choice of data.card_content.choices) {
|
|
112
|
-
let answer = {
|
|
113
|
-
answer: choice.choice,
|
|
114
|
-
is_correct: choice.is_correct,
|
|
115
|
-
};
|
|
116
|
-
mcqAnswers.push(answer);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
let displayTitle = this.generateMcqCardDisplayTitle(
|
|
121
|
-
data.card_content.prompt,
|
|
122
|
-
mcqAnswers
|
|
123
|
-
);
|
|
124
|
-
let mcqCard = {
|
|
125
|
-
type: {
|
|
126
|
-
category: 'learning',
|
|
127
|
-
sub_type: data.type,
|
|
128
|
-
},
|
|
129
|
-
heading: data.card_reference,
|
|
130
|
-
displayTitle: displayTitle,
|
|
131
|
-
content: {
|
|
132
|
-
question: data.card_content.prompt,
|
|
133
|
-
answers: mcqAnswers,
|
|
134
|
-
},
|
|
135
|
-
concepts: data.concepts,
|
|
136
|
-
facts: data.facts,
|
|
137
|
-
bloomLevel: data.bloom_level,
|
|
138
|
-
|
|
139
|
-
};
|
|
140
|
-
return mcqCard;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
generateMcqCardDisplayTitle(question: string, answers: any) {
|
|
144
|
-
let answersString = [];
|
|
145
|
-
if(answers.length != 0) {
|
|
146
|
-
for (let option of answers) {
|
|
147
|
-
let currentIndex = answers.indexOf(option) + 1;
|
|
148
|
-
let temp = `${currentIndex} . ${option.answer} `;
|
|
149
|
-
answersString.push(temp);
|
|
150
|
-
}
|
|
151
|
-
let resultString = answersString.join("");
|
|
152
|
-
let finalDisplayTitle = `${question} ---- ${resultString}`;
|
|
153
|
-
return finalDisplayTitle;
|
|
154
|
-
} else {
|
|
155
|
-
return question;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
parseClozeCard(data: any) {
|
|
161
|
-
let displayTitle = this.generateClozeCardDisplayTitle(
|
|
162
|
-
data.card_content.text,
|
|
163
|
-
data.card_content.options
|
|
164
|
-
);
|
|
165
|
-
let clozeCardData = {
|
|
166
|
-
type: {
|
|
167
|
-
category: 'learning',
|
|
168
|
-
sub_type: data.type,
|
|
169
|
-
},
|
|
170
|
-
heading: data.card_reference,
|
|
171
|
-
displayTitle: displayTitle,
|
|
172
|
-
content: {
|
|
173
|
-
question: data.card_content.text,
|
|
174
|
-
options: data.card_content.options,
|
|
175
|
-
},
|
|
176
|
-
concepts: data.concepts,
|
|
177
|
-
facts: data.facts,
|
|
178
|
-
bloomLevel: data.bloom_level,
|
|
179
|
-
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
return clozeCardData;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
generateClozeCardDisplayTitle(question: string, answers: Array<any>) {
|
|
186
|
-
let optionsString = '';
|
|
187
|
-
if(answers.length !== 0) {
|
|
188
|
-
optionsString = answers
|
|
189
|
-
.map((item: { option: any }) => {
|
|
190
|
-
if(item.option !== undefined) {
|
|
191
|
-
return item.option;
|
|
192
|
-
} else {
|
|
193
|
-
return '';
|
|
194
|
-
}
|
|
195
|
-
})
|
|
196
|
-
.join(", ");
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return `${question} ---- ${optionsString}`;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
parseMatchCard(cardData: any) {
|
|
203
|
-
let data = cardData.card_content;
|
|
204
|
-
const transformedData: { [key: string]: string[] } = {};
|
|
205
|
-
|
|
206
|
-
for (let key in data) {
|
|
207
|
-
if (data.hasOwnProperty(key)) {
|
|
208
|
-
transformedData[key] = [data[key]];
|
|
209
|
-
// let value = data[key].replace(/[\[\]]/g, '');
|
|
210
|
-
// let items = data[key].split(',').map((item: string) => item.trim());
|
|
211
|
-
// map.set(key, items);
|
|
212
|
-
// }
|
|
213
|
-
}
|
|
214
|
-
let displayTitle = this.generateMatchCardDisplayTitle(transformedData);
|
|
215
|
-
let matchCard = {
|
|
216
|
-
type: {
|
|
217
|
-
category: 'learning',
|
|
218
|
-
sub_type: data.type,
|
|
219
|
-
},
|
|
220
|
-
heading: cardData.card_reference,
|
|
221
|
-
content: transformedData,
|
|
222
|
-
// content: cardData.card_content,
|
|
223
|
-
displayTitle: displayTitle,
|
|
224
|
-
concepts: cardData.concepts,
|
|
225
|
-
facts: cardData.facts,
|
|
226
|
-
bloomLevel: cardData.bloom_level,
|
|
227
|
-
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
return matchCard;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
generateMatchCardDisplayTitle(answers: any) {
|
|
235
|
-
let titles: string[] = [];
|
|
236
|
-
let counter = 65;
|
|
237
|
-
for (let key in answers) {
|
|
238
|
-
if (answers.hasOwnProperty(key)) {
|
|
239
|
-
let value = answers[key];
|
|
240
|
-
// let items = value.split(',').map((item: string) => item.trim());
|
|
241
|
-
// items.forEach((item: any) => {
|
|
242
|
-
let letter = String.fromCharCode(counter);
|
|
243
|
-
titles.push(`${letter}. ${key} -- ${value}`);
|
|
244
|
-
counter++;
|
|
245
|
-
// });
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
let displayTitle = titles.join(",");
|
|
249
|
-
return displayTitle;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
1
|
+
import { ErrorLogger } from "../logger";
|
|
2
|
+
import { OpenAiService } from "../services/open_ai_service";
|
|
3
|
+
|
|
4
|
+
export class GenerateCards {
|
|
5
|
+
openAiService: OpenAiService;
|
|
6
|
+
constructor(openAiService: OpenAiService) {
|
|
7
|
+
this.openAiService = openAiService;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async generateCards(prompt: string, parsedContent: string, isGapFill: boolean) {
|
|
11
|
+
let response = await this.openAiService?.sendRequest(prompt, parsedContent);
|
|
12
|
+
// console.log("response to card generation ", response);
|
|
13
|
+
response["type"] = isGapFill ? "gap_fill":"card_gen";
|
|
14
|
+
response.metadata = {
|
|
15
|
+
"req_time": response.generated_at,
|
|
16
|
+
"req_type": response.type,
|
|
17
|
+
"req_tokens": response.usage_data?.prompt_tokens,
|
|
18
|
+
"res_tokens": response.usage_data?.completion_tokens,
|
|
19
|
+
// "created_at":response.created_at,
|
|
20
|
+
};
|
|
21
|
+
if(response.status_code == 200){
|
|
22
|
+
response.metadata.status = "completed";
|
|
23
|
+
//return response;
|
|
24
|
+
return this.parse(response, isGapFill);
|
|
25
|
+
} else {
|
|
26
|
+
response.metadata.status = "failed";
|
|
27
|
+
return response;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async parse(generatedData: any, isGapFill: boolean) {
|
|
32
|
+
try{
|
|
33
|
+
const cardData = [];
|
|
34
|
+
let usage_data = generatedData.metadata;
|
|
35
|
+
const status_code = generatedData.status_code;
|
|
36
|
+
const missing_concepts = generatedData.generated_content.missing_concepts;
|
|
37
|
+
const missing_facts = generatedData.generated_content.missing_facts;
|
|
38
|
+
const unparsedTestCards = generatedData.generated_content.test_cards;
|
|
39
|
+
const type = generatedData.type;
|
|
40
|
+
if(unparsedTestCards !== undefined && unparsedTestCards.length != 0) {
|
|
41
|
+
for (let elem of unparsedTestCards) {
|
|
42
|
+
if (elem.type == "flash") {
|
|
43
|
+
cardData.push(this.parseFlashCard(elem));
|
|
44
|
+
} else if (elem.type == "mcq") {
|
|
45
|
+
cardData.push(this.parseMcqCard(elem));
|
|
46
|
+
} else if (elem.type == "cloze") {
|
|
47
|
+
cardData.push(this.parseClozeCard(elem));
|
|
48
|
+
} else if (elem.type == "match") {
|
|
49
|
+
cardData.push(this.parseMatchCard(elem));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
if(!isGapFill) {
|
|
54
|
+
usage_data.status = "failed";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
status_code: status_code,
|
|
62
|
+
metadata: usage_data,
|
|
63
|
+
type: type,
|
|
64
|
+
missing_concepts: missing_concepts,
|
|
65
|
+
missing_facts: missing_facts,
|
|
66
|
+
cards_data: cardData,
|
|
67
|
+
};
|
|
68
|
+
}catch (e:any){
|
|
69
|
+
await new ErrorLogger({
|
|
70
|
+
"type": 'card_parsing',
|
|
71
|
+
"data": e.message,
|
|
72
|
+
}).log();
|
|
73
|
+
return {
|
|
74
|
+
status_code: 500,
|
|
75
|
+
type: 'card_gen',
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
parseFlashCard(data: any) {
|
|
81
|
+
let displayTitle = this.generateFlashCardDisplayTitle(
|
|
82
|
+
data.card_content.front,
|
|
83
|
+
data.card_content.back
|
|
84
|
+
);
|
|
85
|
+
let flashCardData = {
|
|
86
|
+
type: {
|
|
87
|
+
category: 'learning',
|
|
88
|
+
sub_type: data.type,
|
|
89
|
+
},
|
|
90
|
+
heading: data.card_reference,
|
|
91
|
+
displayTitle: displayTitle,
|
|
92
|
+
content: {
|
|
93
|
+
front_content: data.card_content.front,
|
|
94
|
+
back_content: data.card_content.back,
|
|
95
|
+
},
|
|
96
|
+
concepts: data.concepts,
|
|
97
|
+
facts: data.facts,
|
|
98
|
+
bloomLevel: data.bloom_level,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return flashCardData;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
generateFlashCardDisplayTitle(front: string, back: string) {
|
|
105
|
+
return `${front} ---- ${back}`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
parseMcqCard(data: any) {
|
|
109
|
+
let mcqAnswers = [];
|
|
110
|
+
if(data.card_content.choices !== undefined && data.card_content.choices.length != 0) {
|
|
111
|
+
for (let choice of data.card_content.choices) {
|
|
112
|
+
let answer = {
|
|
113
|
+
answer: choice.choice,
|
|
114
|
+
is_correct: choice.is_correct,
|
|
115
|
+
};
|
|
116
|
+
mcqAnswers.push(answer);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
let displayTitle = this.generateMcqCardDisplayTitle(
|
|
121
|
+
data.card_content.prompt,
|
|
122
|
+
mcqAnswers
|
|
123
|
+
);
|
|
124
|
+
let mcqCard = {
|
|
125
|
+
type: {
|
|
126
|
+
category: 'learning',
|
|
127
|
+
sub_type: data.type,
|
|
128
|
+
},
|
|
129
|
+
heading: data.card_reference,
|
|
130
|
+
displayTitle: displayTitle,
|
|
131
|
+
content: {
|
|
132
|
+
question: data.card_content.prompt,
|
|
133
|
+
answers: mcqAnswers,
|
|
134
|
+
},
|
|
135
|
+
concepts: data.concepts,
|
|
136
|
+
facts: data.facts,
|
|
137
|
+
bloomLevel: data.bloom_level,
|
|
138
|
+
|
|
139
|
+
};
|
|
140
|
+
return mcqCard;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
generateMcqCardDisplayTitle(question: string, answers: any) {
|
|
144
|
+
let answersString = [];
|
|
145
|
+
if(answers.length != 0) {
|
|
146
|
+
for (let option of answers) {
|
|
147
|
+
let currentIndex = answers.indexOf(option) + 1;
|
|
148
|
+
let temp = `${currentIndex} . ${option.answer} `;
|
|
149
|
+
answersString.push(temp);
|
|
150
|
+
}
|
|
151
|
+
let resultString = answersString.join("");
|
|
152
|
+
let finalDisplayTitle = `${question} ---- ${resultString}`;
|
|
153
|
+
return finalDisplayTitle;
|
|
154
|
+
} else {
|
|
155
|
+
return question;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
parseClozeCard(data: any) {
|
|
161
|
+
let displayTitle = this.generateClozeCardDisplayTitle(
|
|
162
|
+
data.card_content.text,
|
|
163
|
+
data.card_content.options
|
|
164
|
+
);
|
|
165
|
+
let clozeCardData = {
|
|
166
|
+
type: {
|
|
167
|
+
category: 'learning',
|
|
168
|
+
sub_type: data.type,
|
|
169
|
+
},
|
|
170
|
+
heading: data.card_reference,
|
|
171
|
+
displayTitle: displayTitle,
|
|
172
|
+
content: {
|
|
173
|
+
question: data.card_content.text,
|
|
174
|
+
options: data.card_content.options,
|
|
175
|
+
},
|
|
176
|
+
concepts: data.concepts,
|
|
177
|
+
facts: data.facts,
|
|
178
|
+
bloomLevel: data.bloom_level,
|
|
179
|
+
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
return clozeCardData;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
generateClozeCardDisplayTitle(question: string, answers: Array<any>) {
|
|
186
|
+
let optionsString = '';
|
|
187
|
+
if(answers.length !== 0) {
|
|
188
|
+
optionsString = answers
|
|
189
|
+
.map((item: { option: any }) => {
|
|
190
|
+
if(item.option !== undefined) {
|
|
191
|
+
return item.option;
|
|
192
|
+
} else {
|
|
193
|
+
return '';
|
|
194
|
+
}
|
|
195
|
+
})
|
|
196
|
+
.join(", ");
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return `${question} ---- ${optionsString}`;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
parseMatchCard(cardData: any) {
|
|
203
|
+
let data = cardData.card_content;
|
|
204
|
+
const transformedData: { [key: string]: string[] } = {};
|
|
205
|
+
|
|
206
|
+
for (let key in data) {
|
|
207
|
+
if (data.hasOwnProperty(key)) {
|
|
208
|
+
transformedData[key] = [data[key]];
|
|
209
|
+
// let value = data[key].replace(/[\[\]]/g, '');
|
|
210
|
+
// let items = data[key].split(',').map((item: string) => item.trim());
|
|
211
|
+
// map.set(key, items);
|
|
212
|
+
// }
|
|
213
|
+
}
|
|
214
|
+
let displayTitle = this.generateMatchCardDisplayTitle(transformedData);
|
|
215
|
+
let matchCard = {
|
|
216
|
+
type: {
|
|
217
|
+
category: 'learning',
|
|
218
|
+
sub_type: data.type,
|
|
219
|
+
},
|
|
220
|
+
heading: cardData.card_reference,
|
|
221
|
+
content: transformedData,
|
|
222
|
+
// content: cardData.card_content,
|
|
223
|
+
displayTitle: displayTitle,
|
|
224
|
+
concepts: cardData.concepts,
|
|
225
|
+
facts: cardData.facts,
|
|
226
|
+
bloomLevel: cardData.bloom_level,
|
|
227
|
+
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
return matchCard;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
generateMatchCardDisplayTitle(answers: any) {
|
|
235
|
+
let titles: string[] = [];
|
|
236
|
+
let counter = 65;
|
|
237
|
+
for (let key in answers) {
|
|
238
|
+
if (answers.hasOwnProperty(key)) {
|
|
239
|
+
let value = answers[key];
|
|
240
|
+
// let items = value.split(',').map((item: string) => item.trim());
|
|
241
|
+
// items.forEach((item: any) => {
|
|
242
|
+
let letter = String.fromCharCode(counter);
|
|
243
|
+
titles.push(`${letter}. ${key} -- ${value}`);
|
|
244
|
+
counter++;
|
|
245
|
+
// });
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
let displayTitle = titles.join(",");
|
|
249
|
+
return displayTitle;
|
|
250
|
+
}
|
|
251
|
+
}
|
package/src/config.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
|
|
3
|
-
const config = {
|
|
4
|
-
openAIKey : process.env.OPEN_AI_KEY as string
|
|
5
|
-
}
|
|
6
|
-
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
|
|
3
|
+
const config = {
|
|
4
|
+
openAIKey : process.env.OPEN_AI_KEY as string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
7
|
export default config;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function openAiEndPoint(){
|
|
2
|
-
return 'https://api.openai.com/v1/chat/completions';
|
|
1
|
+
export function openAiEndPoint(){
|
|
2
|
+
return 'https://api.openai.com/v1/chat/completions';
|
|
3
3
|
}
|