仿chatgpt网页源码

<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ChatGPT</title>
<style>
    body {
        font-family: Arial, sans-serif;
        margin: 0;
        padding: 0;
        background-color: #f4f4f4;
    }
    .container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 20px;
    }
    .chat-container {
        background-color: #fff;
        border-radius: 5px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        padding: 20px;
    }
    .chat-bubble {
        background-color: #f0f0f0;
        padding: 10px 15px;
        margin-bottom: 10px;
        border-radius: 5px;
    }
    .user-bubble {
        background-color: #c3e1fc;
        text-align: right;
    }
    input[type="text"] {
        width: calc(100% - 50px);
        padding: 10px;
        border: 1px solid #ccc;
        border-radius: 5px;
        margin-right: 10px;
    }
    input[type="submit"] {
        padding: 10px 20px;
        background-color: #007bff;
        color: #fff;
        border: none;
        border-radius: 5px;
        cursor: pointer;
    }
</style>

</head>
<body>

<div class="container">
    <h1>ChatGPT</h1>
    <div class="chat-container">
        <div class="chat-bubble user-bubble">
            Hi there, how can I help you today?
        </div>
        <div class="chat-bubble">
            Well, I'm looking for some information on AI chatbots.
        </div>
    </div>
    <form id="chat-form">
        <input type="text" id="user-input" placeholder="Type your message...">
        <input type="submit" value="Send">
    </form>
</div>

<script>
    document.getElementById('chat-form').addEventListener('submit', function(e) {
        e.preventDefault();
        var userInput = document.getElementById('user-input').value;
        var userBubble = document.createElement('div');
        userBubble.classList.add('chat-bubble', 'user-bubble');
        userBubble.textContent = userInput;
        document.querySelector('.chat-container').appendChild(userBubble);
        document.getElementById('user-input').value = '';

        // Make a request to the ChatGPT API to get the response
        fetch('https://api.chatgpt.com/chat', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({ message: userInput })
        })
        .then(response => response.json())
        .then(data => {
            var chatBubble = document.createElement('div');
            chatBubble.classList.add('chat-bubble');
            chatBubble.textContent = data.message;
            document.querySelector('.chat-container').appendChild(chatBubble);
        });
    });
</script>

</body>
</html>

<!DOCTYPE html>
<html>
<head>
<title>ChatGPT</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="chat-container">

<div class="chat-log" id="chat-log">
  <div class="chat-message">
    <div class="sender">ChatGPT</div>
    <div class="message">Hello there! How can I help you today?</div>
  </div>
</div>
<div class="chat-input">
  <input type="text" id="user-input" placeholder="Type your message...">
  <button id="send-button">Send</button>
</div>

</div>

<script>

const chatLog = document.getElementById('chat-log');
const userInput = document.getElementById('user-input');
const sendButton = document.getElementById('send-button');

sendButton.addEventListener('click', () => {
  const userMessage = userInput.value;
  const userChatMessage = document.createElement('div');
  userChatMessage.classList.add('chat-message');
  userChatMessage.innerHTML = `
    <div class="sender">You</div>
    <div class="message">${userMessage}</div>
  `;
  chatLog.appendChild(userChatMessage);

  // Call ChatGPT API to get response
  fetch('https://api.chatgpt.com/ask', {
    method: 'POST',
    body: JSON.stringify({ message: userMessage }),
    headers: {
      'Content-Type': 'application/json'
    }
  })
  .then(response => response.json())
  .then(data => {
    const { message } = data;
    const chatGPTMessage = document.createElement('div');
    chatGPTMessage.classList.add('chat-message');
    chatGPTMessage.innerHTML = `
      <div class="sender">ChatGPT</div>
      <div class="message">${message}</div>
    `;
    chatLog.appendChild(chatGPTMessage);
  })
});

</script>
</body>
</html>

仿chatgpt网页源码 发布者:luotuoemo,转转请注明出处:https://www.chatairc.com/34664/

(0)
luotuoemo's avatarluotuoemo
上一篇 2023年11月12日 上午8:25
下一篇 2023年11月13日 上午10:25

相关推荐

  • 如何搭建chatgpt的虚拟人

    要搭建ChatGPT的虚拟人,可以按照以下步骤进行: 数据收集和准备:收集和整理与虚拟人相关的数据,包括对话文本和相关背景知识。数据准备是训练ChatGPT模型的基础。 模型训练:使用OpenAI的GPT训练框架,如OpenAI Gym或OpenAI Baselines,根据收集到的数据对ChatGPT进行训练。这通常需要使用大量的计算资源和时间。 虚拟人设…

    2023年8月1日
    75600
  • chatgpt引发的人工智能的故事

    人工智能的故事可以追溯到20世纪50年代,当时科学家们开始探索如何创建可以像人类一样思考和学习的机器。经过几十年的发展,人工智能技术逐渐成熟,并开始在各个领域得到应用。 其中,ChatGPT是一个受到广泛关注的人工智能项目。它是由OpenAI团队开发的,旨在通过使用大规模的语言模型,让机器能够产生自然而流畅的对话。ChatGPT的训练过程非常复杂,使用了大量…

    2023年8月7日
    71200
  • chatgpt 插件系统的上线

    感谢您关注ChatGPT插件系统的上线!我们非常高兴地宣布,我们已经成功推出了ChatGPT插件系统。 ChatGPT插件系统旨在为用户提供更多个性化和定制化的聊天体验。这一系统允许开发人员和社区成员创建自己的插件,以增强ChatGPT的功能和功能。 通过插件系统,您可以根据自己的需求和喜好添加各种功能,例如自动翻译、实时信息检索、特定领域知识等等。这些插件…

    2023年8月31日
    65500
  • 如何用chatgpt做ppt

    要使用ChatGPT制作PPT,可以按照以下步骤进行操作: 确定PPT主题和内容:首先,确定你要制作PPT的主题和内容。明确你想要在PPT中传达的信息和展示的内容。 收集素材和资料:收集与你主题相关的素材和资料,例如图片、图表、数据等。确保这些素材能够支持你的讲述和展示。 创建PPT的框架:在PPT软件中创建一个新的幻灯片,设定好布局和主题样式。根据你的主题…

    2023年9月15日
    77000
  • gptchat写论文

    抱歉,我无法为您编写论文。我是GPT-3,一个语言模型,我可以回答一些问题并提供一些信息和建议,但我不能代替您进行学术写作。写论文需要深入的研究、分析和对特定领域的专业知识。我建议您自己进行研究,收集相关资料,并尝试提纲或草稿,然后逐步完善您的论文。如果您需要帮助,我可以提供一些指导和建议。 当使用GPT-3来帮助写论文时,以下是一些建议和步骤: 确定论文的…

    2023年9月11日
    73300

发表回复

登录后才能评论

联系我们

4000-747-360

在线咨询: QQ交谈

邮件:582059487@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
国内Chat Ai版本直接使用:https://chat.chatairc.com/