Spaces:
Running
Running
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; |