Browse Source

add temperature config

lloydzhou 1 năm trước cách đây
mục cha
commit
b78e5db817
1 tập tin đã thay đổi với 10 bổ sung1 xóa
  1. 10 1
      app/components/realtime-chat/realtime-chat.tsx

+ 10 - 1
app/components/realtime-chat/realtime-chat.tsx

@@ -56,6 +56,7 @@ export function RealtimeChat({
   const [deployment, setDeployment] = useState("");
   const [useVAD, setUseVAD] = useState(true);
   const [voice, setVoice] = useState<Voice>("alloy");
+  const [temperature, setTemperature] = useState(0.9);
 
   const clientRef = useRef<RTClient | null>(null);
   const audioHandlerRef = useRef<AudioHandler | null>(null);
@@ -84,7 +85,7 @@ export function RealtimeChat({
           input_audio_transcription: { model: "whisper-1" },
           turn_detection: turnDetection,
           tools: [],
-          temperature: 0.9,
+          temperature,
           modalities,
         });
         startResponseListener();
@@ -282,6 +283,14 @@ export function RealtimeChat({
     [],
   );
 
+  // update session params
+  useEffect(() => {
+    clientRef.current?.configure({ voice });
+  }, [voice]);
+  useEffect(() => {
+    clientRef.current?.configure({ temperature });
+  }, [temperature]);
+
   const handleClose = async () => {
     onClose?.();
     if (isRecording) {