HAMZA OUBAHIM commited on
Commit
5d15a57
1 Parent(s): ee08f89

adding api required

Browse files
Files changed (1) hide show
  1. index.html +14 -7
index.html CHANGED
@@ -45,6 +45,7 @@
45
  : 'w-full md:w-6/6'">
46
  <div x-show="openModal" class="bg-gray-400 p-6 rounded-lg shadow-md w-full md:w-1/2 lg:w-1/3">
47
  <h2 class="text-lg font-semibold mb-4">Choose Model</h2>
 
48
  <div class="space-y-4">
49
  <button
50
  @click="selectModel('mistralai/Mistral-7B-Instruct-v0.1', 'https://mistral.ai/news/announcing-mistral-7b')"
@@ -103,7 +104,10 @@
103
  <textarea id="prompt-input" rows="4"
104
  class="w-full border-0 bg-slate-50 px-0 text-base text-slate-900 focus:outline-none "
105
  placeholder="Describe your web app" required></textarea>
 
106
  </div>
 
 
107
  <div class="ml-2 flex items-center py-2">
108
  <div>
109
  <button type="submit"
@@ -159,6 +163,8 @@
159
  </button>
160
  </div>
161
  </form>
 
 
162
 
163
  </div>
164
 
@@ -289,16 +295,17 @@
289
  }
290
  this.loading = !this.loading;
291
  const userPrompt = document.getElementById('prompt-input').value;
292
-
293
  const htmlFormatPrompt = `Generate HTML code with proper formatting: ${userPrompt}`;
294
  try {
295
  const response = await axios.post(`https://api-inference.huggingface.co/models/${this.selectedModel}`, {
296
- inputs: htmlFormatPrompt,
297
- }, {
298
- headers: {
299
- 'Authorization': 'Bearer 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',
300
- },
301
- });
 
302
  let extractedCode = '';
303
 
304
  try {
 
45
  : 'w-full md:w-6/6'">
46
  <div x-show="openModal" class="bg-gray-400 p-6 rounded-lg shadow-md w-full md:w-1/2 lg:w-1/3">
47
  <h2 class="text-lg font-semibold mb-4">Choose Model</h2>
48
+ <input type="text">
49
  <div class="space-y-4">
50
  <button
51
  @click="selectModel('mistralai/Mistral-7B-Instruct-v0.1', 'https://mistral.ai/news/announcing-mistral-7b')"
 
104
  <textarea id="prompt-input" rows="4"
105
  class="w-full border-0 bg-slate-50 px-0 text-base text-slate-900 focus:outline-none "
106
  placeholder="Describe your web app" required></textarea>
107
+
108
  </div>
109
+ <label for="api-token" class="sr-only">API Token:</label>
110
+ <input class="rounded-lg border border-slate-300 bg-slate-50 w-[90%] px-2 py-2" type="text" id="api-token" placeholder="Enter your huggingface API" required>
111
  <div class="ml-2 flex items-center py-2">
112
  <div>
113
  <button type="submit"
 
163
  </button>
164
  </div>
165
  </form>
166
+
167
+
168
 
169
  </div>
170
 
 
295
  }
296
  this.loading = !this.loading;
297
  const userPrompt = document.getElementById('prompt-input').value;
298
+ const apiToken = document.getElementById('api-token').value;
299
  const htmlFormatPrompt = `Generate HTML code with proper formatting: ${userPrompt}`;
300
  try {
301
  const response = await axios.post(`https://api-inference.huggingface.co/models/${this.selectedModel}`, {
302
+ inputs: htmlFormatPrompt,
303
+ }, {
304
+ headers: {
305
+ 'Authorization': `Bearer ${apiToken}`,
306
+ },
307
+ });
308
+
309
  let extractedCode = '';
310
 
311
  try {