File size: 1,984 Bytes
d66b261
7f2a14a
 
 
 
 
 
 
 
76513b5
d66b261
7f2a14a
 
 
 
 
 
 
 
 
 
 
d66b261
8e783b9
 
d66b261
76513b5
 
 
 
 
 
 
7f2a14a
 
76513b5
7f2a14a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d66b261
7f2a14a
 
 
 
d66b261
 
 
7f2a14a
 
 
 
 
d66b261
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import React, { useEffect, useRef, useState } from "react";
import "./App.scss";
import { LiveAPIProvider } from "./contexts/LiveAPIContext";
import SidePanel from "./components/side-panel/SidePanel";
import { Altair } from "./components/altair/Altair";
import ControlTray from "./components/control-tray/ControlTray";
import { IOSModal } from "./components/ios-modal/IOSModal";
import { isIOS } from "./lib/platform";
import cn from "classnames";
import { LiveConfig } from "./multimodal-live-types";

function App() {
  const videoRef = useRef<HTMLVideoElement>(null);
  const [videoStream, setVideoStream] = useState<MediaStream | null>(null);
  const [showIOSModal, setShowIOSModal] = useState(false);

  useEffect(() => {
    if (isIOS()) {
      setShowIOSModal(true);
    }
  }, []);

  const myCustomInstruction = `
  // تو یک ربات شوخ طبع هستی که باید به زبان فارسی دقیق صحبت کنی
  `.trim();

  const initialAppConfig: LiveConfig = {
    model: "models/gemini-2.0-flash-exp",
    systemInstruction: {
      parts: [{ text: myCustomInstruction }]
    }
  };

  return (
    <div className="App">
      <LiveAPIProvider initialConfig={initialAppConfig}>
        <div className="streaming-console">
          <SidePanel />
          <main>
            <div className="main-app-area">
              <Altair />
              <video
                className={cn("stream", {
                  hidden: !videoRef.current || !videoStream,
                })}
                ref={videoRef}
                autoPlay
                playsInline
              />
            </div>
            <ControlTray
              videoRef={videoRef}
              supportsVideo={true}
              onVideoStreamChange={setVideoStream}
            />
          </main>
        </div>
      </LiveAPIProvider>

      <IOSModal
        isOpen={showIOSModal}
        onClose={() => setShowIOSModal(false)}
      />
    </div>
  );
}

export default App;