Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
2.8 kB
3
Indexable
Never
<html>
<head>
  <title>Investor Deck Summarizer</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js"></script>
</head>
<body>
  <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <div class="container-fluid">
      <a class="navbar-brand" href="#">Investor Deck Summarizer</a>
    </div>
  </nav>
  <div class="container my-4">
    <div class="row">
      <div class="col-md-6 mx-auto">
        <form id="upload-form" enctype="multipart/form-data">
          <div class="mb-3">
            <label for="pdf-file" class="form-label">Upload PDF File</label>
            <input class="form-control" type="file" id="pdf-file" name="pdf-file" accept="application/pdf" required>
          </div>
          <button type="submit" class="btn btn-primary">Summarize Deck</button>
        </form>
      </div>
    </div>
  </div>
  <div id="loading" class="container my-4 d-none">
    <div class="row">
      <div class="col-md-6 mx-auto text-center">
        <h4>Summarizing Deck...</h4>
        <div class="spinner-border" role="status">
          <span class="visually-hidden">Loading...</span>
        </div>
      </div>
    </div>
  </div>
  <div id="result" class="container my-4 d-none">
    <div class="row">
      <div class="col-md-6 mx-auto">
        <h4>Summary</h4>
        <p id="summary"></p>
      </div>
    </div>
  </div>
  <script>
    const form = document.querySelector('#upload-form');
    const loading = document.querySelector('#loading');
    const result = document.querySelector('#result');
    const summary = document.querySelector('#summary');

    form.addEventListener('submit', (e) => {
      e.preventDefault();
      const file = document.querySelector('#pdf-file').files[0];
      const formData = new FormData();
      formData.append('pdf', file);

      loading.classList.remove('d-none');
      result.classList.add('d-none');

      fetch('https://www.literallyanything.io/api/integrations/chatgpt', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          systemPrompt: 'Please summarize the contents of the investor deck.',
          prompts: [{ role: 'user', content: 'Summarize investor deck.' }]
        })
      })
        .then(response => response.json())
        .then(data => {
          summary.innerText = data.response;
          loading.classList.add('d-none');
          result.classList.remove('d-none');
        })
        .catch(error => console.error(error));
    });
  </script>
</body>
</html>