Spaces:
Running
Running
Update src/contexts/LiveAPIContext.tsx
Browse files
src/contexts/LiveAPIContext.tsx
CHANGED
|
@@ -17,20 +17,29 @@
|
|
| 17 |
import { createContext, FC, type ReactNode, useContext } from "react";
|
| 18 |
import { useLiveAPI, type UseLiveAPIResults } from "../hooks/use-live-api";
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
const LiveAPIContext = createContext<UseLiveAPIResults | undefined>(undefined);
|
| 21 |
|
| 22 |
export type LiveAPIProviderProps = {
|
| 23 |
children: ReactNode;
|
| 24 |
url?: string;
|
|
|
|
| 25 |
};
|
| 26 |
|
| 27 |
export const LiveAPIProvider: FC<LiveAPIProviderProps> = ({
|
| 28 |
url = process.env.NODE_ENV === 'development'
|
| 29 |
? `${window.location.protocol === 'https:' ? 'wss:' : 'ws:'}//localhost:3001/ws`
|
| 30 |
: `${window.location.protocol === 'https:' ? 'wss:' : 'ws:'}//${window.location.host}/ws`,
|
|
|
|
| 31 |
children,
|
| 32 |
}) => {
|
| 33 |
-
const liveAPI = useLiveAPI({ url });
|
| 34 |
|
| 35 |
return (
|
| 36 |
<LiveAPIContext.Provider value={liveAPI}>
|
|
@@ -47,4 +56,4 @@ export const useLiveAPIContext = () => {
|
|
| 47 |
}
|
| 48 |
console.log('✅ LiveAPIContext successfully retrieved');
|
| 49 |
return context;
|
| 50 |
-
};
|
|
|
|
| 17 |
import { createContext, FC, type ReactNode, useContext } from "react";
|
| 18 |
import { useLiveAPI, type UseLiveAPIResults } from "../hooks/use-live-api";
|
| 19 |
|
| 20 |
+
export type LiveConfig = {
|
| 21 |
+
model?: string;
|
| 22 |
+
systemInstruction?: {
|
| 23 |
+
parts: Array<{ text: string }>;
|
| 24 |
+
};
|
| 25 |
+
};
|
| 26 |
+
|
| 27 |
const LiveAPIContext = createContext<UseLiveAPIResults | undefined>(undefined);
|
| 28 |
|
| 29 |
export type LiveAPIProviderProps = {
|
| 30 |
children: ReactNode;
|
| 31 |
url?: string;
|
| 32 |
+
initialConfig?: LiveConfig;
|
| 33 |
};
|
| 34 |
|
| 35 |
export const LiveAPIProvider: FC<LiveAPIProviderProps> = ({
|
| 36 |
url = process.env.NODE_ENV === 'development'
|
| 37 |
? `${window.location.protocol === 'https:' ? 'wss:' : 'ws:'}//localhost:3001/ws`
|
| 38 |
: `${window.location.protocol === 'https:' ? 'wss:' : 'ws:'}//${window.location.host}/ws`,
|
| 39 |
+
initialConfig,
|
| 40 |
children,
|
| 41 |
}) => {
|
| 42 |
+
const liveAPI = useLiveAPI({ url, initialConfig });
|
| 43 |
|
| 44 |
return (
|
| 45 |
<LiveAPIContext.Provider value={liveAPI}>
|
|
|
|
| 56 |
}
|
| 57 |
console.log('✅ LiveAPIContext successfully retrieved');
|
| 58 |
return context;
|
| 59 |
+
};
|