aringad commited on
Commit
0d4d60e
·
verified ·
1 Parent(s): 69bb670

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +19 -1
index.html CHANGED
@@ -20,6 +20,10 @@
20
  <h2>Generated Text:</h2>
21
  <p id="generatedText"></p>
22
  </div>
 
 
 
 
23
  </div>
24
 
25
  <script>
@@ -31,12 +35,17 @@
31
  generateText(prompt);
32
  }
33
  });
 
34
  function generateText(prompt) {
35
  const apiUrl = 'https://aringad-test.hf.space/run';
36
  const requestData = {
37
  prompt: prompt,
38
  model: 'OpenBuddy/openbuddy-llama3-8b-v21.1-8k'
39
  };
 
 
 
 
40
  fetch(apiUrl, {
41
  method: 'POST',
42
  headers: {
@@ -44,14 +53,23 @@
44
  },
45
  body: JSON.stringify(requestData)
46
  })
47
- .then(response => response.json())
 
 
 
 
 
48
  .then(data => {
 
 
49
  const generatedText = data.output;
50
  document.getElementById('generatedText').textContent = generatedText;
51
  document.getElementById('resultContainer').style.display = 'block';
52
  })
53
  .catch(error => {
54
  console.error('Error:', error);
 
 
55
  alert('An error occurred while generating text.');
56
  });
57
  }
 
20
  <h2>Generated Text:</h2>
21
  <p id="generatedText"></p>
22
  </div>
23
+ <div id="debugContainer">
24
+ <h2>Debug Information:</h2>
25
+ <pre id="debugOutput"></pre>
26
+ </div>
27
  </div>
28
 
29
  <script>
 
35
  generateText(prompt);
36
  }
37
  });
38
+
39
  function generateText(prompt) {
40
  const apiUrl = 'https://aringad-test.hf.space/run';
41
  const requestData = {
42
  prompt: prompt,
43
  model: 'OpenBuddy/openbuddy-llama3-8b-v21.1-8k'
44
  };
45
+
46
+ // Display request data in the debug output
47
+ document.getElementById('debugOutput').textContent = 'Request Data:\n' + JSON.stringify(requestData, null, 2);
48
+
49
  fetch(apiUrl, {
50
  method: 'POST',
51
  headers: {
 
53
  },
54
  body: JSON.stringify(requestData)
55
  })
56
+ .then(response => {
57
+ // Display response status and headers in the debug output
58
+ document.getElementById('debugOutput').textContent += '\n\nResponse Status: ' + response.status;
59
+ document.getElementById('debugOutput').textContent += '\nResponse Headers:\n' + JSON.stringify(Object.fromEntries(response.headers), null, 2);
60
+ return response.json();
61
+ })
62
  .then(data => {
63
+ // Display response data in the debug output
64
+ document.getElementById('debugOutput').textContent += '\n\nResponse Data:\n' + JSON.stringify(data, null, 2);
65
  const generatedText = data.output;
66
  document.getElementById('generatedText').textContent = generatedText;
67
  document.getElementById('resultContainer').style.display = 'block';
68
  })
69
  .catch(error => {
70
  console.error('Error:', error);
71
+ // Display error in the debug output
72
+ document.getElementById('debugOutput').textContent += '\n\nError:\n' + error.message;
73
  alert('An error occurred while generating text.');
74
  });
75
  }