Ezmary commited on
Commit
fc82e2c
·
verified ·
1 Parent(s): a9228b4

Update src/App.tsx

Browse files
Files changed (1) hide show
  1. src/App.tsx +5 -16
src/App.tsx CHANGED
@@ -2,15 +2,7 @@
2
 
3
  /**
4
  Copyright 2024 Google LLC
5
- Licensed under the Apache License, Version 2.0 (the "License");
6
- you may not use this file except in compliance with the License.
7
- You may obtain a copy of the License at
8
- http://www.apache.org/licenses/LICENSE-2.0
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
14
  */
15
 
16
  import React, { useEffect, useRef, useState } from "react";
@@ -24,7 +16,6 @@ import { LiveConfig } from "./multimodal-live-types";
24
  import LogoAnimation from "./components/logo-animation/LogoAnimation";
25
  import BackButton from "./components/back-button/BackButton";
26
 
27
- // *** NEW: دستورالعمل‌های جدید ربات ***
28
  const myCustomInstruction = `
29
  تو دستیار صوتی و تصویری پیشرفته از "اپلیکیشن هوش مصنوعی هوشان" هستی
30
  وظیفه اصلی تو کمک به کاربر است.
@@ -44,7 +35,7 @@ const myCustomInstruction = `
44
  `.trim();
45
 
46
  const initialAppConfig: LiveConfig = {
47
- model: "models/gemini-2.0-flash-exp", // یا مدل دیگری که استفاده می‌کنید
48
  systemInstruction: {
49
  parts: [{ text: myCustomInstruction }],
50
  },
@@ -57,7 +48,6 @@ const SvgReferenceMicrophoneIcon = () => (
57
  </svg>
58
  );
59
 
60
- // این کامپوننت داخلی برای مدیریت بهتر state ها و props ها است
61
  const AppCore: React.FC<{
62
  currentFacingMode: 'user' | 'environment';
63
  setCurrentFacingMode: React.Dispatch<React.SetStateAction<'user' | 'environment'>>;
@@ -107,7 +97,7 @@ const AppCore: React.FC<{
107
  </div>
108
  <div ref={notificationPopoverRef} id="notification-popover-wrapper" className="notification-popover-wrapper">
109
  <div id="notification-popover" className={cn("popover-content", { "open animate-popover-open-top-center": isNotificationOpen, "animate-popover-close-top-center": !isNotificationOpen && typeof document !== 'undefined' && document.getElementById('notification-popover')?.classList.contains('open'), })}>
110
- <div className="notification-popover-text-content">مدل‌های هوش مصنوعی می‌توانند اشتباه کنند، صحت اطلاعات مهم را بررسی کنید و از بیان اطلاعات حساس بپرهیزید.</div>
111
  </div>
112
  </div>
113
  <div className="media-area w-full flex flex-col items-center justify-center flex-grow relative">
@@ -121,7 +111,7 @@ const AppCore: React.FC<{
121
  <ControlTray
122
  videoRef={videoRef}
123
  supportsVideo={true}
124
- onVideoStreamChange={(stream) => { /* ... */ }}
125
  isAppMicActive={isMicActive}
126
  onAppMicToggle={setIsMicActive}
127
  isAppCamActive={isCamActive}
@@ -134,7 +124,6 @@ const AppCore: React.FC<{
134
  );
135
  };
136
 
137
-
138
  function App() {
139
  const [showIOSModal, setShowIOSModal] = useState(false);
140
  const [isAllowedOrigin, setIsAllowedOrigin] = useState<boolean | null>(null);
@@ -145,7 +134,7 @@ function App() {
145
 
146
  return (
147
  <LiveAPIProvider initialConfig={initialAppConfig}>
148
- <div className="w-full flex flex-col items-center justify-center min-h-screen text-foreground antialiased"> {/* این div والد اصلی است */}
149
  <AppCore currentFacingMode={currentFacingMode} setCurrentFacingMode={setCurrentFacingMode} />
150
  </div>
151
  <IOSModal isOpen={showIOSModal} onClose={() => setShowIOSModal(false)} />
 
2
 
3
  /**
4
  Copyright 2024 Google LLC
5
+ ... (لایسنس) ...
 
 
 
 
 
 
 
 
6
  */
7
 
8
  import React, { useEffect, useRef, useState } from "react";
 
16
  import LogoAnimation from "./components/logo-animation/LogoAnimation";
17
  import BackButton from "./components/back-button/BackButton";
18
 
 
19
  const myCustomInstruction = `
20
  تو دستیار صوتی و تصویری پیشرفته از "اپلیکیشن هوش مصنوعی هوشان" هستی
21
  وظیفه اصلی تو کمک به کاربر است.
 
35
  `.trim();
36
 
37
  const initialAppConfig: LiveConfig = {
38
+ model: "models/gemini-2.0-flash-exp",
39
  systemInstruction: {
40
  parts: [{ text: myCustomInstruction }],
41
  },
 
48
  </svg>
49
  );
50
 
 
51
  const AppCore: React.FC<{
52
  currentFacingMode: 'user' | 'environment';
53
  setCurrentFacingMode: React.Dispatch<React.SetStateAction<'user' | 'environment'>>;
 
97
  </div>
98
  <div ref={notificationPopoverRef} id="notification-popover-wrapper" className="notification-popover-wrapper">
99
  <div id="notification-popover" className={cn("popover-content", { "open animate-popover-open-top-center": isNotificationOpen, "animate-popover-close-top-center": !isNotificationOpen && typeof document !== 'undefined' && document.getElementById('notification-popover')?.classList.contains('open'), })}>
100
+ <div className="notification-popover-text-content">مدل‌های هوش مصنوعی می‌توانند اشتباه کنند، صحت اطلاعات مهم را بررسی کنید و از وارد کردن اطلاعات حساس بپرهیزید.</div>
101
  </div>
102
  </div>
103
  <div className="media-area w-full flex flex-col items-center justify-center flex-grow relative">
 
111
  <ControlTray
112
  videoRef={videoRef}
113
  supportsVideo={true}
114
+ onVideoStreamChange={(stream) => { if(videoRef.current && stream) videoRef.current.srcObject = stream; else if(videoRef.current) videoRef.current.srcObject = null; }} // ساده شده
115
  isAppMicActive={isMicActive}
116
  onAppMicToggle={setIsMicActive}
117
  isAppCamActive={isCamActive}
 
124
  );
125
  };
126
 
 
127
  function App() {
128
  const [showIOSModal, setShowIOSModal] = useState(false);
129
  const [isAllowedOrigin, setIsAllowedOrigin] = useState<boolean | null>(null);
 
134
 
135
  return (
136
  <LiveAPIProvider initialConfig={initialAppConfig}>
137
+ <div className="w-full flex flex-col items-center justify-center min-h-screen text-foreground antialiased">
138
  <AppCore currentFacingMode={currentFacingMode} setCurrentFacingMode={setCurrentFacingMode} />
139
  </div>
140
  <IOSModal isOpen={showIOSModal} onClose={() => setShowIOSModal(false)} />