仿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

相关推荐

  • gpt4取代

    GPT-4是OpenAI开发的自然语言处理模型,它是由前一代模型GPT-3的改进版本。GPT-4对于自然语言处理任务的性能和效率有了显著的提升。下面是一些可能会被GPT-4取代的应用和领域: 聊天机器人:GPT-4能够更加准确、流畅地理解和回应用户的问题和指令,使得聊天机器人的交互更加自然且智能化。 自动摘要和文档生成:GPT-4可以更好地理解和概括文本内容…

    2024年1月19日
    84800
  • gpt-5

    As of my knowledge, there is currently no GPT-5 model available. As of September 2022, the latest publicly available model is GPT-3, developed by OpenAI. GPT-3 is a powerful langua…

    2023年12月22日
    2.4K00
  • chatgpt 在数字出版中的应用

    数字出版在当今的出版行业中扮演着重要的角色。以下是数字出版在出版领域中的一些应用: 电子书籍:数字出版使得图书可以以电子格式呈现,读者可以通过电子阅读器、平板电脑、智能手机等设备来阅读电子书籍。这种形式的出版使得读者可以随时随地获取所需的书籍,并且能够调整字体大小、背景颜色等以适应个人阅读习惯。 数字杂志和报纸:许多传统杂志和报纸已经转向数字平台,以适应现代…

    2023年7月7日
    85700
  • chatgpt怎么安装

    要安装ChatGPT,您需要执行以下步骤: 首先,您需要将OpenAI的GPT代码库克隆到您的本地计算机上。在命令行中执行以下命令: git clone https://github.com/openai/chatgpt.git 接下来,进入克隆的代码库文件夹: cd chatgpt 创建并激活一个新的Python虚拟环境(可选,但强烈建议)。您可以使用co…

    2023年8月31日
    77300
  • CHATGPT对于不同领域的专业术语有了解吗?

    作为一个AI助手,CHATGPT可以回答许多不同领域的专业术语和知识。通过其先进的自然语言处理技术和大量的知识库,CHATGPT可以理解和回答许多不同领域的问题,包括医学、法律、科学、技术、金融、教育等等。 作为一个AI语言模型,CHATGPT 接触了大量的文本数据,对于各个领域的专业术语、行话有一定的了解。但是要想完全掌握某个领域的专业术语,还需要具备相应…

    2023年6月19日
    78400

发表回复

登录后才能评论

联系我们

4000-747-360

在线咨询: QQ交谈

邮件:582059487@qq.com

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

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