Skip to content

Complete UI SDK in React ​

Applies to HENGSHI SENSE 7.0. Load the deployment's hengshi-copilot@VERSION.js (see Getting the SDK files and version for the version lookup), create an instance after mounting a React container, and destroy it on unmount. The SDK includes its UI; do not import an internal package as a public npm dependency.

Load the script and complete authentication/CORS and UI SDK configuration first.

jsx
import { useEffect, useRef } from 'react';

export function DataAgent() {
  const container = useRef(null);
  useEffect(() => {
    const copilot = new window.Copilot(container.current, {
      baseUrl: 'https://analytics.example.com',
      locale: 'en-US',
      userConfig: { dataSources: [{ dataAppId: 251, datasetId: 1 }] },
      style: { right: 20, bottom: 20, width: 440, height: 640 },
    });
    return () => copilot.destroy();
  }, []);
  return <div ref={container} />;
}

Use update() for SPA configuration changes instead of recreating instances when configuration object identity changes. An existing conversation's scope remains fixed; create a new conversation. Use the data client SDK for a fully custom React UI.

User Manual for Hengshi Analysis Platform