mpociot / chatgpt-vscode

A VSCode extension that allows you to use ChatGPT
4.98k stars 362 forks source link

Requesting HTML content often renders the requested html in the chat window instead of giving me the HTML code that I can copy #52

Open funinvegas opened 1 year ago

funinvegas commented 1 year ago

I'm able to work around by asking for the contents of the body tag, but if chatGPT renders a full HTML file it will occasionally render in place instead.

I reproduced by selecting all of my HTML in a file (below) and asking it to add fields.


<html>
  <head>
    <meta charset="UTF-8">
    <title>ChatGPT Prompt</title>
    <link rel="stylesheet" type="text/css" href="style.css">
  </head>
  <body>
    <h1>ChatGPT Prompt</h1>
    <div style="display: flex;">
      <div style="flex: 1; margin-right: 20px;">
        <h3>Column 1</h3>
        <form>
          <label for="prompt1">Enter your prompt:</label><br>
          <textarea id="prompt1" name="prompt1" rows="4" cols="50"></textarea><br><br>
          <button type="button" onclick="generateResponse(1)">Submit</button><br><br>
          <label for="response1">ChatGPT Response:</label><br>
          <textarea id="response1" name="response1" rows="8" cols="50" style="height: 300px;"></textarea>
        </form>
      </div>
      <div style="flex: 1; margin-right: 20px;">
        <h3>Column 2</h3>
        <form>
          <label for="prompt2">Enter your prompt:</label><br>
          <textarea id="prompt2" name="prompt2" rows=\"4" cols="50"></textarea><br><br>
          <button type="button" onclick="generateResponse(2)">Submit</button><br><br>
          <label for="response2">ChatGPT Response:</label><br>
          <textarea id="response2" name="response2" rows="8" cols="50" style="height: 300px;"></textarea>
        </form>
      </div>
      <div style="flex: 1;">
        <h3>Column 3</h3>
        <form>
          <label for="prompt3">Enter your prompt:</label><br>
          <textarea id="prompt3" name="prompt3" rows="4" cols="50"></textarea><br><br>
          <button type="button" onclick="generateResponse(3)">Submit</button><br><br>
          <label for="response3">ChatGPT Response:</label><br>
          <textarea id="response3" name="response3" rows="8" cols="50" style="height: 300px;"></textarea>
        </form>
      </div>
    </div>
    <script>
      async function generateResponse(column) {
        const input = document.getElementById(`prompt${column}`).value;
        const response = await fetch(`/prompt?prompt=${encodeURI(input)}`);
        const result = await response.text();
        document.getElementById(`response${column}`).value = result;
      }
    </script>
  </body>
</html>```