Skip to content

Commit

Permalink
add temperature config
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydzhou committed Nov 7, 2024
1 parent 46c469b commit b78e5db
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/components/realtime-chat/realtime-chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -84,7 +85,7 @@ export function RealtimeChat({
input_audio_transcription: { model: "whisper-1" },
turn_detection: turnDetection,
tools: [],
temperature: 0.9,
temperature,
modalities,
});
startResponseListener();
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b78e5db

Please sign in to comment.