仿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的头像luotuoemo
上一篇 2023年11月12日 上午8:25
下一篇 2023年11月13日 上午10:25

相关推荐

  • chart gpt

    chart gpt is a language model developed by OpenAI. It is part of the GPT (Generative Pre-trained Transformer) series of models and is specifically designed for generating charts, g…

    2024年1月10日
    17700
  • CHATGPT如何提高光电子技术发展效果?

    加强研究和开发:CHATGPT可以增加研究和开发投入,加速光电子技术的发展。为此,CHATGPT可以与大型企业和研究机构合作,共同研究光电子技术的应用和发展,推动技术在各行各业的应用。 支持技术转化:CHATGPT可以为光电子技术的转化提供支持,帮助企业和研究机构将研究成果转化为实际的产品和服务。为此,CHATGPT可以提供资金、设备和技术支持,以促进光电子…

    2023年6月24日
    10700
  • chatgpt使用网页

    要使用chatGPT,您可以通过以下方式在网页上使用它: 打开OpenAI的网站(https://www.openai.com/)。 在导航栏中选择“Products”(产品)。 在产品页面上找到chatGPT(它可能被称为GPT-3.5-turbo)并点击进入。 点击“Get started”(开始使用)按钮。 如果您还没有OpenAI帐户,请创建一个。如…

    2023年7月21日
    10200
  • chatGTP注册教程

    要注册ChatGPT,您需要遵循以下步骤: 访问OpenAI网站并登录到您的帐户。 登录后,导航到“产品”或“模型”页面。 在模型页面上,您会看到ChatGPT模型的相关信息。如果您尚未获得访问权限,可能需要加入等候列表或参与早期访问计划。按照指示操作以获得访问权限。 如果您已获得访问权限,则可以点击“开始使用”或类似的按钮开始注册ChatGPT。 在注册页…

    2023年11月28日
    16900
  • chatgpt训练一次的成本

    训练一次ChatGPT的成本可以有很多方面的考虑,包括但不限于以下几个方面: 计算资源成本:训练一个大型的语言模型需要大量的计算资源,包括高性能的GPU或TPU服务器,以及大规模的分布式训练和优化。 数据成本:训练语言模型需要大量的数据,这些数据可以是从互联网上爬取的文本数据,也可以是通过人工标注或者其他方式获得的数据,获取和准备这些数据的成本是不可忽视的。…

    2023年8月16日
    10500

发表回复

登录后才能评论

联系我们

4000-747-360

在线咨询: QQ交谈

邮件:582059487@qq.com

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

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