forked from Yarob50/ChatGPT-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (23 loc) · 737 Bytes
/
Copy pathscript.js
File metadata and controls
28 lines (23 loc) · 737 Bytes
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
document.getElementById("submit-btn").addEventListener("click", function () {
sendToChatGPT();
});
// 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
function sendToChatGPT() {
let value = document.getElementById("word-input").value;
let body = {
model: "gpt-3.5-turbo",
messages: [{ role: "user", content: value }],
tempreture: "1",
};
let headers = {
Authorization: "Bearer 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",
};
axios
.post("https://api.openai.com/v1/chat/completions", body, {
headers: headers,
})
.then((response) => {
let reply = response.data.choices[0].message.content;
document.getElementById("reply-content").textContent = reply;
});
}