Spaces:
Running
Running
Update src/contexts/AppContext.tsx
Browse files
src/contexts/AppContext.tsx
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
// src/contexts/AppContext.tsx
|
2 |
import React, { createContext, FC, ReactNode, useContext, useEffect, useState, useCallback } from "react";
|
3 |
import { useLiveAPI, type UseLiveAPIResults } from "../hooks/use-live-api";
|
4 |
import { LiveConfig } from "../multimodal-live-types";
|
@@ -40,12 +40,14 @@ export const AppProvider: FC<{ children: ReactNode; initialConfig?: LiveConfig;
|
|
40 |
const finalInstruction = `${BASE_INSTRUCTION}\n\n${selectedPersonality === 'custom' ? customDetail : personalityInstruction}`;
|
41 |
|
42 |
const newConfig: LiveConfig = {
|
43 |
-
|
|
|
44 |
tools: [{ googleSearch: {} }],
|
45 |
generationConfig: { responseModalities: "audio" },
|
46 |
systemInstruction: { parts: [{ text: finalInstruction.trim() }] },
|
47 |
};
|
48 |
liveAPI.setConfig(newConfig);
|
|
|
49 |
}, [selectedPersonality, customUserName, customInstructions, personalityInstructions, liveAPI.setConfig, initialConfig]);
|
50 |
|
51 |
useEffect(() => {
|
|
|
1 |
+
// src/contexts/AppContext.tsx (نسخه نهایی و تصحیح شده)
|
2 |
import React, { createContext, FC, ReactNode, useContext, useEffect, useState, useCallback } from "react";
|
3 |
import { useLiveAPI, type UseLiveAPIResults } from "../hooks/use-live-api";
|
4 |
import { LiveConfig } from "../multimodal-live-types";
|
|
|
40 |
const finalInstruction = `${BASE_INSTRUCTION}\n\n${selectedPersonality === 'custom' ? customDetail : personalityInstruction}`;
|
41 |
|
42 |
const newConfig: LiveConfig = {
|
43 |
+
// ✅ رفع خطا: مدل را به صورت صریح تعریف میکنیم
|
44 |
+
model: initialConfig?.model || "models/gemini-2.0-flash-exp",
|
45 |
tools: [{ googleSearch: {} }],
|
46 |
generationConfig: { responseModalities: "audio" },
|
47 |
systemInstruction: { parts: [{ text: finalInstruction.trim() }] },
|
48 |
};
|
49 |
liveAPI.setConfig(newConfig);
|
50 |
+
|
51 |
}, [selectedPersonality, customUserName, customInstructions, personalityInstructions, liveAPI.setConfig, initialConfig]);
|
52 |
|
53 |
useEffect(() => {
|