@@ -11,7 +11,7 @@ const POINT_CLOUDS = {
1111} ;
1212
1313// Function to generate point cloud based on instruction
14- async function processInstruction ( ) {
14+ window . processInstruction = async function ( ) {
1515 const instruction = document . getElementById ( 'instruction' ) . value ;
1616 if ( ! instruction ) {
1717 alert ( 'Please enter an instruction' ) ;
@@ -55,12 +55,12 @@ async function processInstruction() {
5555 }
5656 } catch ( error ) {
5757 console . error ( 'Error:' , error ) ;
58- alert ( 'An error occurred while processing your request using the key: ' + OPENAI_API_KEY ) ;
58+ alert ( 'An error occurred while processing your request' ) ;
5959 } finally {
6060 // Hide loading spinner
6161 document . getElementById ( 'loading' ) . style . display = 'none' ;
6262 }
63- }
63+ } ;
6464
6565// Function to visualize point cloud using Plotly
6666function visualizePointCloud ( points ) {
@@ -181,8 +181,10 @@ function generatePyramid(numPoints) {
181181}
182182
183183// Add event listener for Enter key
184- document . getElementById ( 'instruction' ) . addEventListener ( 'keypress' , function ( e ) {
185- if ( e . key === 'Enter' ) {
186- processInstruction ( ) ;
187- }
184+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
185+ document . getElementById ( 'instruction' ) . addEventListener ( 'keypress' , function ( e ) {
186+ if ( e . key === 'Enter' ) {
187+ window . processInstruction ( ) ;
188+ }
189+ } ) ;
188190} ) ;
0 commit comments