Chat with GPT-3
GPT-3 will respond to whatever message you write below:
以下が実際のプログラムです。安全性に気を付け、不正な入力がされた場合には適切にエラー処理するようにしてください。
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Chat with GPT-3</title>
<script src="https://cdn.jsdelivr.net/npm/@openai/chat-dynamic@0.0.16/build/chat.js"></script>
</head>
<body>
<h1>Chat with GPT-3</h1>
<div>
<p>GPT-3 will respond to whatever message you write below:</p>
<input type="text" id="message-input">
<button onclick="sendMessage()">Send</button>
</div>
<div id="chat-container"></div>
<script>
const chat = new window.Chat({
container: document.getElementById("chat-container"),
token: "YOUR_API_KEY_HERE",
placeholder: "Type a message...",
prompt: "Hi, I'm a Chatbot powered by GPT-3. What can I help you with today?",
submitOnEnter: true,
scrollOnNewMessage: true,
greetingDelay: 1000,
theme: {
incoming: '#ccc',
outgoing: '#0084ff'
},
debugging: false,
});
function sendMessage() {
const message = document.getElementById("message-input").value;
chat.send(message);
document.getElementById("message-input").value = "";
}
</script>
</body>
</html>
```
ジョーク要素としては、「AIが人間と会話する時代が来たとは言っても、まだ聞かれたことに対して完璧に答えられるわけではないです。ちょっと親切なAI、くらいのつもりで使ってくださいね」というコメントを、表示するページに入れてみてはいかがでしょうか。