仿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/

Like (0)
luotuoemo的头像luotuoemo
Previous 2023年11月12日 上午8:25
Next 2023年11月13日 上午10:25

相关推荐

  • chatgpt如何改成中文

    要将ChatGPT改为中文,需要进行以下步骤: 数据收集:收集用于训练ChatGPT模型的中文对话数据。可以使用公开可用的聊天数据集,或者自己创建一个对话数据集。 数据预处理:对收集的中文对话数据进行预处理,包括分词、去除停用词、标记化等。可以使用开源的中文NLP工具,如jieba分词库。 构建训练集:将预处理后的中文对话数据转换为模型可以接受的格式,通常是…

    2023年7月28日
    72700
  • get智能写作

    “智能写作”是一种利用人工智能和自然语言处理技术来辅助或自动执行写作任务的方法。它可以包括以下功能和应用场景: 文章生成:智能写作工具可以根据用户提供的关键词或主题,自动生成文章。它基于大量的语料库和算法,可以快速生成高质量的文章,节省用户的时间和精力。 文字修订:智能写作工具可以提供文字修订和修改建议。它可以检测并纠正拼写、语法和标…

    2023年12月28日
    36800
  • CHATGPT在政府和公共服务领域的应用前景如何?

    作为一个人工智能的聊天机器人,CHATGPT在政府和公共服务领域有许多潜在的应用前景。 首先,CHATGPT可以用于智能客服或问答系统,在政府机构和公共服务领域中提供快速、高效、准确的信息和支持。例如,CHATGPT可以回答公民关于政策、程序和服务的常见问题,帮助他们更好地了解政府机构和公共服务的作用和实施。 其次,CHATGPT可以用于自然语言处理和文本分…

    2023年6月17日
    39400
  • chatgpt中文提示语模版

    下面是一些ChatGPT用于中文对话的提示语模板: 问候和介绍: 你好,我是ChatGPT,有什么我可以帮助您的吗? 您好!我是ChatGPT,我可以回答您的问题和提供信息。 嗨!我是ChatGPT,有什么我可以为您做的? 请提出问题: 请问您有什么问题需要我回答吗? 您需要关于某个特定主题的信息吗?请告诉我您的问题。 有什么我可以为您解答的问题吗? 提供帮…

    2023年8月2日
    33900
  • chat gpt 在生活中的应用

    GPT(生成对抗网络)在生活中有许多应用,以下是其中一些常见的应用领域: 聊天机器人:GPT可以用于创建智能聊天机器人,能够与用户进行自然语言对话,回答问题、提供建议等。这种应用对于客户服务、技术支持和信息查询等方面非常有用。 内容生成:GPT可以用于自动化生成文章、新闻报道、广告文案等文本内容。它可以根据输入的提示或要求生成与之相关的内容,帮助作者提供创作…

    2023年8月30日
    30300

发表回复

Please Login to Comment

联系我们

4000-747-360

在线咨询: QQ交谈

邮件:582059487@qq.com

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

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