Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/api/chat/openai-realtime/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function POST(request: NextRequest) {
return new Response("Unauthorized", { status: 401 });
}

const { voice, mentions, agentId } = (await request.json()) as {
const { model, voice, mentions, agentId } = (await request.json()) as {
model: string;
voice: string;
agentId?: string;
Expand Down Expand Up @@ -102,7 +102,7 @@ export async function POST(request: NextRequest) {
},

body: JSON.stringify({
model: "gpt-4o-realtime-preview",
model: model || "gpt-4o-realtime-preview",
voice: voice || "alloy",
input_audio_transcription: {
model: "whisper-1",
Expand Down
3 changes: 2 additions & 1 deletion src/app/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ const initialState: AppState = {
options: {
provider: "openai",
providerOptions: {
model: OPENAI_VOICE["Alloy"],
voice: OPENAI_VOICE.Alloy,
model: "gpt-4o-realtime-preview",
},
},
},
Expand Down
57 changes: 55 additions & 2 deletions src/components/chat-bot-voice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
MessageSquareMoreIcon,
WrenchIcon,
ChevronRight,
BrainCircuitIcon,
} from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { toast } from "sonner";
Expand Down Expand Up @@ -67,6 +68,12 @@ const prependTools: EnabledTools[] = [
},
];

export const OPENAI_REALTIME_MODELS = {
"GPT-4o Realtime": "gpt-4o-realtime-preview",
"GPT Realtime": "gpt-realtime",
"GPT Realtime Mini": "gpt-realtime-mini",
} as const;

export function ChatBotVoice() {
const t = useTranslations("Chat");
const [
Expand Down Expand Up @@ -358,13 +365,57 @@ export function ChatBotVoice() {
align="start"
>
<DropdownMenuGroup className="cursor-pointer">
<DropdownMenuSub>
<DropdownMenuSubTrigger
className="flex items-center gap-2 cursor-pointer"
icon=""
>
<BrainCircuitIcon className="size-3.5" />
Model
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
{Object.entries(OPENAI_REALTIME_MODELS).map(
([key, value]) => (
<DropdownMenuItem
className="cursor-pointer flex items-center justify-between"
onClick={() =>
appStoreMutate({
voiceChat: {
...voiceChat,
options: {
...voiceChat.options,
providerOptions: {
...voiceChat.options
.providerOptions,
model: value,
},
},
},
})
}
key={key}
>
{key}

{value ===
voiceChat.options.providerOptions
?.model && (
<CheckIcon className="size-3.5" />
)}
</DropdownMenuItem>
),
)}
</DropdownMenuSubContent>
</DropdownMenuPortal>
</DropdownMenuSub>
<DropdownMenuSub>
<DropdownMenuSubTrigger
className="flex items-center gap-2 cursor-pointer"
icon=""
>
<OpenAIIcon className="size-3.5 stroke-none fill-foreground" />
Open AI
Voice
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
Expand All @@ -377,8 +428,10 @@ export function ChatBotVoice() {
voiceChat: {
...voiceChat,
options: {
provider: "openai",
...voiceChat.options,
providerOptions: {
...voiceChat.options
.providerOptions,
voice: value,
},
},
Expand Down