-
Notifications
You must be signed in to change notification settings - Fork 0
/
chatgpt2.js
73 lines (58 loc) · 1.81 KB
/
chatgpt2.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
// const { Configuration, OpenAIApi } = require("openai");
// const configiration = new Configuration({
// organization: 'org-0uaQLaArF3m5pgctUePtq5OR',
// apiKey: '',
// });
// console.log('<<--- Hello Node.js ---->>');
// console.log('*- openai api tutorial...');
// const openai = new OpenAIApi(configiration);
// const runPrompt = async () => {
// const response = await openai.createCompletion({
// model: "text-davinci-003",
// prompt: "what is your name?",
// max_tokens: 300,
// temperature: 0.2,
// });
// console.log('- completion:\n' + response.data.choices[0].text);
// console.log('\n- total tokens: ' + response.data.usage.total_tokens);
// console.log('*- completion ended...');
// }
// //runPrompt();
// const runGPT35 = async (prompt) => {
// const response = await openai.createChatCompletion({
// model: "gpt-3.5-turbo",
// messages: [{ role: "user", content: prompt }],
// });
// console.log(response.data.choices[0].message.content);
// };
// runGPT35("너 이름이 뭐야");
// const healthData = {
// hungry_time: 7,
// sleep_time: 8,
// calorie_intake: 100,
// steps: 6000,
// water_intake: 0.5
// };
// // 가중치 설정
// const weights = {
// hungry_time: 10,
// sleep_time: 10,
// calorie_intake: 40,
// steps: 30,
// water_intake: 10
// };
// const targets = {
// hungry_time: 16,
// sleep_time: 8,
// calorie_intake: 1500,
// steps: 6000,
// water_intake: 2
// };
// // 각 요소에 가중치를 곱하여 점수 계산
// let healthScore = 0;
// for (const key in healthData) {
// healthScore += (healthData[key] / targets[key]) * weights[key];
// }
// // 100점 만점으로 스케일링
// healthScore = Math.min(100, healthScore);
// console.log(`건강점수: ${healthScore.toFixed(2)}`);