-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgpt_test2.js
452 lines (447 loc) · 14.8 KB
/
gpt_test2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
const {Configuration, OpenAIApi} = require('openai');
const secret = require("./config/secret");
const configuration = new Configuration({
organization: secret.openaiOrganization,
apiKey: secret.openaiSecret,
});
const openai = new OpenAIApi(configuration);
const temp = async function() {
const completion = await openai.createChatCompletion({
model: "gpt-3.5-turbo-16k",
messages: [
{role: "system", content: "You're a fitness trainer who recommends exercise routines."},
{role: "system", content: `
exerciseId-exerciseName-note(rep of unit),
1-Bench Press, 2-Incline Dumbbell Press, 3-Chest Press Machine, 4-Leg Extension, 5-Lat Pull down, 6-Barbell Row, 7-Deadlift, 8-Dumbbell Row,9-Dumbbell Fly, 10-Shoulder Press, 11-Side Lateral Raise, 12-Front Dumbbell Raise,13-Bent Over Lateral Raise, 14-Seated Row, 15-Leg Curl, 16-Leg Press, 17-Hip Thrust, 18-Hip Raise, 19-Chest Dips, 20-Pull Up, 21-Push Up, 22-Front Plank-(1sec), 23-Side Plank-(1sec), 24-Running-(100m), 25-Cycling-(100m)
Create a routine with these exercises
`
},
{role: "user", content: `
I am a male born in 2001, I am 174cm tall and weigh 62kg.
I think I can lift up to 60kg when I do bench press to the maximum.
I will do chest, back, shoulder, arm, core, lower body exercises at gym.
I'm going to exercise for a total of 7 days on Sunday and Monday, Tuesday, Wednesday, Thursday, Friday, Saturday.
`},
{role: "user", content:
`Please recommend 3 routines in various combinations.
Say only JSON Object format like
[
{
'Title': thisRoutineTitle
'dayOfWeek'(day of week name): {
'target': targetArea,
'content': [
{
'exerciseId': exerciseId,
'exerciseName': exerciseName,
'sets': numsOfSet(Only Int),
'reps': numsOfRep(Only Int),
'weights'(If exerciseId is between 19 and 25, that is, bare body exercise, get rid of this.): numsOfWeight(Only List(Integer as many as numsOfSet))
}
]
}
}(This object must include all requested days of the weeks. If the request is Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday, Then should be seven 'dayOfWeek's).
](This array must have three elements that are the number of branches of the routine example.)
In the case of planks, if 1 rep performs 1 second, that is, 10 seconds, using note(rep of unit), rep should be 10.
In the case of Running and Cycling, if 1 rep performs 100m, that is, 500m, using note(rep of unit), rep should be 5.
example
[
{
"Title": "Full Body Workout",
"Monday": {
"target": "Chest",
"content": [
{
"exerciseId": 1,
"exerciseName": "Bench Press",
"sets": 3,
"reps": 10,
"weights": [40, 40, 40]
},
{
"exerciseId": 9,
"exerciseName": "Dumbbell Fly",
"sets": 3,
"reps": 12,
"weights": [8, 8, 8]
}
]
},
"Tuesday": {
"target": "Back",
"content": [
{
"exerciseId": 6,
"exerciseName": "Barbell Row",
"sets": 3,
"reps": 10,
"weights": [30, 30, 30]
},
{
"exerciseId": 8,
"exerciseName": "Dumbbell Row",
"sets": 3,
"reps": 12,
"weights": [10, 10, 10]
}
]
},
"Wednesday": {
"target": "Shoulders",
"content": [
{
"exerciseId": 10,
"exerciseName": "Shoulder Press",
"sets": 3,
"reps": 10,
"weights": [20, 20, 20]
},
{
"exerciseId": 11,
"exerciseName": "Side Lateral Raise",
"sets": 3,
"reps": 12,
"weights": [5, 5, 5]
}
]
},
"Thursday": {
"target": "Arms",
"content": [
{
"exerciseId": 2,
"exerciseName": "Incline Dumbbell Press",
"sets": 3,
"reps": 10,
"weights": [15, 15, 15]
},
{
"exerciseId": 19,
"exerciseName": "Chest Dips",
"sets": 3,
"reps": 12
}
]
},
"Friday": {
"target": "Core",
"content": [
{
"exerciseId": 22,
"exerciseName": "Front Plank",
"sets": 3,
"reps": 10
},
{
"exerciseId": 23,
"exerciseName": "Side Plank",
"sets": 3,
"reps": 10
}
]
},
"Saturday": {
"target": "Lower Body",
"content": [
{
"exerciseId": 16,
"exerciseName": "Leg Press",
"sets": 3,
"reps": 10,
"weights": [80, 80, 80]
},
{
"exerciseId": 15,
"exerciseName": "Leg Curl",
"sets": 3,
"reps": 12,
"weights": [20, 20, 20]
}
]
},
"Sunday": {
"target": "Cardio",
"content": [
{
"exerciseId": 24,
"exerciseName": "Running",
"sets": 1,
"reps": 5
},
{
"exerciseId": 25,
"exerciseName": "Cycling",
"sets": 1,
"reps": 5
}
]
}
},
{
"Title": "Advanced Upper Body Workout",
"Monday": {
"target": "Chest",
"content": [
{
"exerciseId": 1,
"exerciseName": "Bench Press",
"sets": 4,
"reps": 8,
"weights": [50, 60, 70, 80]
},
{
"exerciseId": 3,
"exerciseName": "Chest Press Machine",
"sets": 4,
"reps": 10,
"weights": [40, 50, 60, 70]
}
]
},
"Tuesday": {
"target": "Back",
"content": [
{
"exerciseId": 6,
"exerciseName": "Barbell Row",
"sets": 4,
"reps": 8,
"weights": [40, 50, 60, 70]
},
{
"exerciseId": 5,
"exerciseName": "Lat Pulldown",
"sets": 4,
"reps": 10,
"weights": [40, 50, 60, 70]
}
]
},
"Wednesday": {
"target": "Shoulders",
"content": [
{
"exerciseId": 10,
"exerciseName": "Shoulder Press",
"sets": 4,
"reps": 8,
"weights": [30, 40, 50, 60]
},
{
"exerciseId": 12,
"exerciseName": "Front Dumbbell Raise",
"sets": 4,
"reps": 10,
"weights": [10, 15, 20, 25]
}
]
},
"Thursday": {
"target": "Arms",
"content": [
{
"exerciseId": 19,
"exerciseName": "Chest Dips",
"sets": 4,
"reps": 8
},
{
"exerciseId": 20,
"exerciseName": "Pull Ups",
"sets": 4,
"reps": 10
}
]
},
"Friday": {
"target": "Core",
"content": [
{
"exerciseId": 22,
"exerciseName": "Front Plank",
"sets": 4,
"reps": 20
},
{
"exerciseId": 23,
"exerciseName": "Side Plank",
"sets": 4,
"reps": 20
}
]
},
"Saturday": {
"target": "Lower Body",
"content": [
{
"exerciseId": 16,
"exerciseName": "Leg Press",
"sets": 4,
"reps": 8,
"weights": [100, 120, 140, 160]
},
{
"exerciseId": 17,
"exerciseName": "Hip Thrust",
"sets": 4,
"reps": 10,
"weights": [40, 60, 80, 100]
}
]
},
"Sunday": {
"target": "Cardio",
"content": [
{
"exerciseId": 24,
"exerciseName": "Running",
"sets": 1,
"reps": 6
},
{
"exerciseId": 25,
"exerciseName": "Cycling",
"sets": 1,
"reps": 6
}
]
}
},
{
"Title": "Advanced Full Body Workout",
"Monday": {
"target": "Chest",
"content": [
{
"exerciseId": 1,
"exerciseName": "Bench Press",
"sets": 4,
"reps": 8,
"weights": [50, 60, 70, 80]
},
{
"exerciseId": 3,
"exerciseName": "Chest Press Machine",
"sets": 4,
"reps": 10,
"weights": [40, 50, 60, 70]
}
]
},
"Tuesday": {
"target": "Back",
"content": [
{
"exerciseId": 6,
"exerciseName": "Barbell Row",
"sets": 4,
"reps": 8,
"weights": [40, 50, 60, 70]
},
{
"exerciseId": 5,
"exerciseName": "Lat Pulldown",
"sets": 4,
"reps": 10,
"weights": [40, 50, 60, 70]
}
]
},
"Wednesday": {
"target": "Shoulders",
"content": [
{
"exerciseId": 10,
"exerciseName": "Shoulder Press",
"sets": 4,
"reps": 8,
"weights": [30, 40, 50, 60]
},
{
"exerciseId": 12,
"exerciseName": "Front Dumbbell Raise",
"sets": 4,
"reps": 10,
"weights": [10, 15, 20, 25]
}
]
},
"Thursday": {
"target": "Arms",
"content": [
{
"exerciseId": 19,
"exerciseName": "Chest Dips",
"sets": 4,
"reps": 8
},
{
"exerciseId": 20,
"exerciseName": "Pull Ups",
"sets": 4,
"reps": 10
}
]
},
"Friday": {
"target": "Core",
"content": [
{
"exerciseId": 22,
"exerciseName": "Front Plank",
"sets": 4,
"reps": 20
},
{
"exerciseId": 23,
"exerciseName": "Side Plank",
"sets": 4,
"reps": 20
}
]
},
"Saturday": {
"target": "Lower Body",
"content": [
{
"exerciseId": 16,
"exerciseName": "Leg Press",
"sets": 4,
"reps": 8,
"weights": [100, 120, 140, 160]
},
{
"exerciseId": 17,
"exerciseName": "Hip Thrust",
"sets": 4,
"reps": 10,
"weights": [40, 60, 80, 100]
}
]
},
"Sunday": {
"target": "Cardio",
"content": [
{
"exerciseId": 24,
"exerciseName": "Running",
"sets": 1,
"reps": 6
},
{
"exerciseId": 25,
"exerciseName": "Cycling",
"sets": 1,
"reps": 6
}
]
}
}
]
Never Explain.
`}
],
});
console.log(JSON.parse(completion.data.choices[0].message.content));
};
temp();