both openai and gemini working well
This commit is contained in:
parent
1de375492c
commit
bcce78b273
3 changed files with 23 additions and 43 deletions
|
|
@ -43,6 +43,19 @@ wss.on("connection", async (ws: WSWebSocket, payload: IPayload) => {
|
||||||
const systemPrompt = createSystemPrompt(chatHistory, payload);
|
const systemPrompt = createSystemPrompt(chatHistory, payload);
|
||||||
|
|
||||||
const provider = user.personality?.provider;
|
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) {
|
switch (provider) {
|
||||||
case "openai":
|
case "openai":
|
||||||
await connectToOpenAI(
|
await connectToOpenAI(
|
||||||
|
|
|
||||||
|
|
@ -19,28 +19,7 @@ export const connectToGemini = async (
|
||||||
systemPrompt: string,
|
systemPrompt: string,
|
||||||
) => {
|
) => {
|
||||||
const { user, supabase } = payload;
|
const { user, supabase } = payload;
|
||||||
const { oai_voice, pitch_factor } = user.personality ?? {
|
const { oai_voice } = user.personality ?? { oai_voice: "Sadachbia" };
|
||||||
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,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(`Connecting with Gemini key "${geminiApiKey.slice(0, 3)}..."`);
|
console.log(`Connecting with Gemini key "${geminiApiKey.slice(0, 3)}..."`);
|
||||||
|
|
||||||
|
|
@ -60,7 +39,7 @@ export const connectToGemini = async (
|
||||||
realtimeInputConfig: {
|
realtimeInputConfig: {
|
||||||
automaticActivityDetection: {
|
automaticActivityDetection: {
|
||||||
disabled: false, // Keep VAD enabled
|
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
|
silenceDurationMs: 100, // How much silence before considering speech ended
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -104,14 +83,14 @@ export const connectToGemini = async (
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.serverContent.turnComplete) {
|
// if (message.serverContent.turnComplete) {
|
||||||
ws.send(
|
// ws.send(
|
||||||
JSON.stringify({
|
// JSON.stringify({
|
||||||
type: "server",
|
// type: "server",
|
||||||
msg: "AUDIO.COMMITTED",
|
// msg: "AUDIO.COMMITTED",
|
||||||
}),
|
// }),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return turns;
|
return turns;
|
||||||
|
|
|
||||||
|
|
@ -41,18 +41,6 @@ export const connectToOpenAI = async (
|
||||||
) => {
|
) => {
|
||||||
const { user, supabase } = payload;
|
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 currentItemId: string | null = null;
|
||||||
let currentCallId: string | null = null;
|
let currentCallId: string | null = null;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue