Spaces:
Running
Running
Update src/hooks/use-live-api.ts
Browse files
src/hooks/use-live-api.ts
CHANGED
|
@@ -34,15 +34,10 @@ export type UseLiveAPIResults = {
|
|
| 34 |
volume: number;
|
| 35 |
};
|
| 36 |
|
| 37 |
-
export type UseLiveAPIOptions = MultimodalLiveAPIClientConnection & {
|
| 38 |
-
initialConfig?: LiveConfig;
|
| 39 |
-
};
|
| 40 |
-
|
| 41 |
export function useLiveAPI({
|
| 42 |
url,
|
| 43 |
apiKey,
|
| 44 |
-
|
| 45 |
-
}: UseLiveAPIOptions): UseLiveAPIResults {
|
| 46 |
const client = useMemo(
|
| 47 |
() => new MultimodalLiveClient({ url, apiKey }),
|
| 48 |
[url, apiKey],
|
|
@@ -50,7 +45,7 @@ export function useLiveAPI({
|
|
| 50 |
const audioStreamerRef = useRef<AudioStreamer | null>(null);
|
| 51 |
|
| 52 |
const [connected, setConnected] = useState(false);
|
| 53 |
-
const [config, setConfig] = useState<LiveConfig>(
|
| 54 |
model: "models/gemini-2.0-flash-exp",
|
| 55 |
});
|
| 56 |
const [volume, setVolume] = useState(0);
|
|
@@ -95,6 +90,7 @@ export function useLiveAPI({
|
|
| 95 |
}, [client]);
|
| 96 |
|
| 97 |
const connect = useCallback(async () => {
|
|
|
|
| 98 |
if (!config) {
|
| 99 |
throw new Error("config has not been set");
|
| 100 |
}
|
|
|
|
| 34 |
volume: number;
|
| 35 |
};
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
export function useLiveAPI({
|
| 38 |
url,
|
| 39 |
apiKey,
|
| 40 |
+
}: MultimodalLiveAPIClientConnection): UseLiveAPIResults {
|
|
|
|
| 41 |
const client = useMemo(
|
| 42 |
() => new MultimodalLiveClient({ url, apiKey }),
|
| 43 |
[url, apiKey],
|
|
|
|
| 45 |
const audioStreamerRef = useRef<AudioStreamer | null>(null);
|
| 46 |
|
| 47 |
const [connected, setConnected] = useState(false);
|
| 48 |
+
const [config, setConfig] = useState<LiveConfig>({
|
| 49 |
model: "models/gemini-2.0-flash-exp",
|
| 50 |
});
|
| 51 |
const [volume, setVolume] = useState(0);
|
|
|
|
| 90 |
}, [client]);
|
| 91 |
|
| 92 |
const connect = useCallback(async () => {
|
| 93 |
+
console.log(config);
|
| 94 |
if (!config) {
|
| 95 |
throw new Error("config has not been set");
|
| 96 |
}
|