From 0c10365da1550f9140f5dd4bf9d0d8d58d46fe6b Mon Sep 17 00:00:00 2001 From: Om Raheja Date: Sat, 18 May 2024 13:44:53 -0400 Subject: [PATCH] added inference api --- static/index.html | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/static/index.html b/static/index.html index 16511a4..bed6771 100644 --- a/static/index.html +++ b/static/index.html @@ -128,27 +128,34 @@ } async function generateIngredients() { - // Get all input elements inside the div - const inputs = editableClassesDiv.querySelectorAll("input"); + // Get all input elements inside the div + const inputs = editableClassesDiv.querySelectorAll("input"); - // Initialize an empty string to hold the input values - let values = ""; + // Initialize an empty string to hold the input values + let values = ""; - // Check if there are any input elements - if (inputs.length === 0) { - return; // Exit the function silently if there are no input elements - } - - // Loop through the input elements and add their values to the string - inputs.forEach((input) => { - if (values !== "") { - values += ", "; + // Check if there are any input elements + if (inputs.length === 0) { + return; // Exit the function silently if there are no input elements } - values += input.value; - }); - // Alert the input values - alert(values); + // Loop through the input elements and add their values to the string + inputs.forEach((input) => { + if (values !== "") { + values += ", "; + } + values += input.value; + }); + + // Alert the input values + const output = await createInference(values); + + // Create a new div element to hold the output + const outputDiv = document.createElement("div"); + outputDiv.textContent = output; + + // Add the output div to the page + document.body.appendChild(outputDiv); }