turn chunk.choices.map((choice) => choice.delta.content).join("\n");
  }

  // Initialize when document is loaded
  document.addEventListener("DOMContentLoaded", () => {
    initializeVisualization();
    simulation.on("tick", ticked);
    startListening();

    // Expose functions to window for debugging/demonstration
    window.addNode = addNode;
    window.linkNodes = linkNodes;
  });

  // Start listening for events
  async function startListening() {
    try {
      const listenerId = "<<listener_id>>"