仿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

相关推荐

  • chatbot ui

    As a chatbot UI, my user interface will include: Text input field for users to type their messages and queries to the chatbot. Chat window to display the chat history and the chatb…

    2023年11月23日
    88500
  • chatgpt 可穿戴设备数据在运动健康管理中的应用

    可穿戴设备数据在运动健康管理中扮演着关键的角色。这些设备包括智能手表、智能手环、智能眼镜等,具备传感器和数据采集功能,可以实时监测用户的运动和健康状况,并提供相关数据和建议。 首先,可穿戴设备可以记录用户的运动数据,包括步数、距离、消耗的热量等。这些数据可以帮助用户了解自己的运动习惯和量化运动效果,从而更好地管理自己的健康。 其次,可穿戴设备还可以监测用户的…

    2023年7月8日
    99300
  • CHATGPT如何提高数据分析能力?

    以下是提高数据分析能力的建议: 学习数据分析基础知识:学习统计、概率、计算机科学等基础知识,掌握数据分析的基本理论和方法。 学习数据分析工具:了解一些数据分析工具,如Excel、Python、R等,可以通过网上教程或者参加培训课程进行学习。 学习数据可视化:数据可视化是数据分析的重要环节,通过图表和图形展示数据,可以更直观地展示数据分析结果。 多练习:通过做…

    2023年6月24日
    93000
  • CHATGPT对于智能客服和自助服务的支持如何?

    作为一名AI语言模型,CHATGPT对智能客服和自助服务提供了全面的支持。以下是CHATGPT支持智能客服和自助服务的方式: 自然语言处理:CHATGPT可以理解和处理自然语言,因此可以识别客户的问题并提供相应的答案。这使得CHATGPT成为智能客服的理想选择。 多语言支持:CHATGPT支持多种语言,包括英语、中文、西班牙语等,因此可以为全球客户提供服务。…

    2023年6月20日
    93300
  • ChatGPT部署架构

    ChatGPT可以使用一种分布式架构来进行部署。以下是一个可能的ChatGPT部署架构的示例: 前端应用程序:前端应用程序可以是一个网页、移动应用程序或者其他用户界面,用于与ChatGPT进行交互。用户可以输入文本并接收ChatGPT生成的回复。前端应用程序可以通过网络与后端服务器进行通信。 后端服务器:后端服务器负责处理前端应用程序发送的请求,并将其发送到…

    2023年10月27日
    90500

发表回复

登录后才能评论

联系我们

4000-747-360

在线咨询: QQ交谈

邮件:582059487@qq.com

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

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