import { fetchGitHubFile, getOpenAIResponse } from 'backend/openai'; // Adjust the path to the backend file if necessary $w.onReady(function () { // Add a click event handler to the button $w('#askButton').onClick(async () => { const question = $w('#questionInput').value; if (question.trim() !== '') { try { const answer = await handleQuestionInput(question); // Display the answer in a text element on the page $w('#answerText').text = `Answer: ${answer}`; } catch (error) { console.error('Error:', error); $w('#answerText').text = 'Error answering the question. Please try again.'; } } else { $w('#answerText').text = 'Please enter a question.'; } }); }); // Function to handle user input and get the OpenAI response export async function handleQuestionInput(question) { try { const fileContent = await fetchGitHubFile(); const response = await getOpenAIResponse(question, fileContent); // The answer will be in the 'response.data' object. You can access it using response.data.answer. return response.data.answer; } catch (error) { console.error('Error answering the question:', error); throw error; } }
top of page

Grade Calculator

Online Organic Chemistry Tool for Structures

Scholarship Opportunities: Jack Kent Cooke Foundation

bottom of page