Hiyve Components - v1.0.0
    Preparing search index...

    Function useIntelligenceStream

    • Hook for real-time AI coaching intelligence.

      Subscribes to the intelligence slice of the HiyveStore and provides actions to enable/disable coaching, update coaching data, and dismiss hints.

      Returns {
          allHints: CoachingHint[];
          coachingEnabled: boolean;
          coachingVariant: CoachingVariant;
          currentTopic: string | null;
          disableCoaching: () => void;
          dismissHint: (hintId: string) => void;
          enableCoaching: (variant?: CoachingVariant) => void;
          hints: CoachingHint[];
          isActive: boolean;
          talkRatio: { listening: number; speaking: number };
          topicShifts: TopicShift[];
          updateCoachingData: (
              data: {
                  currentTopic?: string;
                  hints?: CoachingHint[];
                  talkRatio?: { listening: number; speaking: number };
                  topicShifts?: TopicShift[];
              },
          ) => void;
      }

      • allHints: CoachingHint[]
      • coachingEnabled: boolean
      • coachingVariant: CoachingVariant
      • currentTopic: string | null
      • disableCoaching: () => void
      • dismissHint: (hintId: string) => void
      • enableCoaching: (variant?: CoachingVariant) => void
      • hints: CoachingHint[]
      • isActive: boolean
      • talkRatio: { listening: number; speaking: number }
      • topicShifts: TopicShift[]
      • updateCoachingData: (
            data: {
                currentTopic?: string;
                hints?: CoachingHint[];
                talkRatio?: { listening: number; speaking: number };
                topicShifts?: TopicShift[];
            },
        ) => void

      The polling of the coaching endpoint should be handled externally (e.g., by the CoachingOverlay component or consumer code) which calls updateCoachingData() with the response.

      function CoachingPanel() {
      const {
      isActive,
      coachingEnabled,
      hints,
      talkRatio,
      currentTopic,
      enableCoaching,
      disableCoaching,
      dismissHint,
      } = useIntelligenceStream();

      return (
      <div>
      <button onClick={() => enableCoaching('sales')}>
      {coachingEnabled ? 'Disable' : 'Enable'} Coaching
      </button>
      {isActive && (
      <>
      <p>Topic: {currentTopic}</p>
      <p>Ratio: {talkRatio.speaking}% / {talkRatio.listening}%</p>
      {hints.map(h => (
      <div key={h.id}>
      {h.text}
      <button onClick={() => dismissHint(h.id)}>Dismiss</button>
      </div>
      ))}
      </>
      )}
      </div>
      );
      }