仿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

相关推荐

  • 如何使用chat gpt

    要使用ChatGPT,您可以遵循以下步骤: 访问OpenAI的ChatGPT界面:https://beta.openai.com/signup/。请注意,ChatGPT目前仍处于测试阶段,您需要加入等待列表以获取访问权限。 一旦您获得访问权限,您将能够在界面上输入对话。在与ChatGPT进行对话之前,您需要提供一些初始消息来引导模型。您可以提供关于对话主题、…

    2023年8月3日
    71500
  • chatgpt没有美国手机号怎么办

    如果您没有美国手机号,您仍然可以使用ChatGPT进行聊天,但可能需要遵循以下步骤: 使用ChatGPT的某些功能可能需要进行身份验证,以确保用户的安全和合法性。通常,手机号是验证用户身份的一种方式。但是,具体要求可能因平台而异。 您可以尝试使用其他身份验证方式,例如电子邮件验证、社交媒体账号验证等。查看ChatGPT平台的注册或身份验证选项,了解是否存在其…

    2023年9月25日
    68100
  • chatgpt 大语言模型

    ChatGPT是一个由OpenAI开发的大型语言模型,它使用了大量的数据和深度学习技术,可以生成具有上下文和连贯性的文本回复。它被训练来理解和生成自然语言,可以用于回答问题、参与对话、生成文本和执行其他自然语言处理任务。 ChatGPT基于transformer架构,它将输入的文本序列编码成向量表示,并使用这些向量进行下一步的生成。它的训练数据包括网络上的大…

    2023年11月10日
    65100
  • 怎么才能用chatgpt

    要使用ChatGPT,您需要按照以下步骤进行操作: 访问OpenAI的网站:https://www.openai.com/ 如果您尚未创建OpenAI帐户,请按照指示创建一个帐户。 登录并从主页上选择”APIs”选项。 阅读相关文件,仔细查看ChatGPT的使用说明和限制条件。 如果您同意条件并且已经了解相关事项,请点击”…

    2023年12月18日
    55300
  • chatgpt注册好后如何聊天

    要开始与ChatGPT进行聊天,您可以使用OpenAI API来与模型进行交互。下面是一个示例代码,展示如何使用Python与ChatGPT进行对话: import openai # 设置OpenAI API凭证 openai.api_key = 'YOUR_API_KEY' # 定义对话的起始信息 def start_chat(): p…

    2023年11月6日
    60900

发表回复

登录后才能评论

联系我们

4000-747-360

在线咨询: QQ交谈

邮件:582059487@qq.com

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

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