both openai and gemini working well

This commit is contained in:
akdeb 2025-06-11 15:22:51 +01:00
parent 1de375492c
commit bcce78b273
3 changed files with 23 additions and 43 deletions

View file

@ -43,6 +43,19 @@ wss.on("connection", async (ws: WSWebSocket, payload: IPayload) => {
const systemPrompt = createSystemPrompt(chatHistory, payload);
const provider = user.personality?.provider;
// send user details to client
// when DEV_MODE is true, we send the default values 100, false, false
ws.send(
JSON.stringify({
type: "auth",
volume_control: user.device?.volume ?? 20,
is_ota: user.device?.is_ota ?? false,
is_reset: user.device?.is_reset ?? false,
pitch_factor: user.personality?.pitch_factor ?? 1,
}),
);
switch (provider) {
case "openai":
await connectToOpenAI(

View file

@ -19,28 +19,7 @@ export const connectToGemini = async (
systemPrompt: string,
) => {
const { user, supabase } = payload;
const { oai_voice, pitch_factor } = user.personality ?? {
oai_voice: "Sadachbia",
provider: "gemini",
pitch_factor: 1,
};
const { is_ota, is_reset, volume } = user.device ?? {
is_ota: false,
is_reset: false,
volume: 10,
};
// Send user details to client
ws.send(
JSON.stringify({
type: "auth",
volume_control: volume,
is_ota: is_ota,
is_reset: is_reset,
pitch_factor: pitch_factor,
}),
);
const { oai_voice } = user.personality ?? { oai_voice: "Sadachbia" };
console.log(`Connecting with Gemini key "${geminiApiKey.slice(0, 3)}..."`);
@ -60,7 +39,7 @@ export const connectToGemini = async (
realtimeInputConfig: {
automaticActivityDetection: {
disabled: false, // Keep VAD enabled
endOfSpeechSensitivity: EndSensitivity.END_SENSITIVITY_HIGH, // How sensitive to detect speech ending
endOfSpeechSensitivity: EndSensitivity.END_SENSITIVITY_LOW, // How sensitive to detect speech ending
silenceDurationMs: 100, // How much silence before considering speech ended
},
},
@ -104,14 +83,14 @@ export const connectToGemini = async (
done = true;
}
if (message.serverContent.turnComplete) {
ws.send(
JSON.stringify({
type: "server",
msg: "AUDIO.COMMITTED",
}),
);
}
// if (message.serverContent.turnComplete) {
// ws.send(
// JSON.stringify({
// type: "server",
// msg: "AUDIO.COMMITTED",
// }),
// );
// }
}
}
return turns;

View file

@ -41,18 +41,6 @@ export const connectToOpenAI = async (
) => {
const { user, supabase } = payload;
// send user details to client
// when DEV_MODE is true, we send the default values 100, false, false
ws.send(
JSON.stringify({
type: "auth",
volume_control: user.device?.volume ?? 20,
is_ota: user.device?.is_ota ?? false,
is_reset: user.device?.is_reset ?? false,
pitch_factor: user.personality?.pitch_factor ?? 1,
}),
);
let currentItemId: string | null = null;
let currentCallId: string | null = null;