From 9582603c89bead1cf99782fbf76136a3b54c7504 Mon Sep 17 00:00:00 2001 From: tegnike Date: Thu, 17 Oct 2024 13:21:28 +0200 Subject: [PATCH 1/4] =?UTF-8?q?Realtime=20API=E3=81=AEURL=E3=82=92https=3D?= =?UTF-8?q?>wss=E3=81=AB=E5=A4=89=E6=9B=B4=EF=BC=88=E4=BB=8A=E3=81=BE?= =?UTF-8?q?=E3=81=A7https=E3=81=A7=E5=8B=95=E3=81=84=E3=81=A6=E3=81=9F?= =?UTF-8?q?=E7=90=86=E7=94=B1=E3=81=AF=E4=B8=8D=E6=98=8E=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/settings/modelProvider.tsx | 2 +- src/components/useRealtimeAPI.tsx | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/components/settings/modelProvider.tsx b/src/components/settings/modelProvider.tsx index 4d92172..faedd7f 100644 --- a/src/components/settings/modelProvider.tsx +++ b/src/components/settings/modelProvider.tsx @@ -319,7 +319,7 @@ const ModelProvider = () => { https://RESOURCE_NAME.openai.azure.com/openai/deployments/DEPLOYMENT_NAME/chat/completions?api-version=API_VERSION
Realtime API ex. - https://RESOURCE_NAME.openai.azure.com/openai/realtime?api-version=API_VERSION&deployment=DEPLOYMENT_NAME + wss://RESOURCE_NAME.openai.azure.com/openai/realtime?api-version=API_VERSION&deployment=DEPLOYMENT_NAME { 'openai-beta.realtime-v1', ]) } else if (ss.selectAIService === 'azure') { - const url = - `${ss.azureEndpoint}&api-key=${ss.azureKey}` || - `${process.env.AZURE_ENDPOINT}&api-key=${ss.azureKey}` || - '' + const url = `${ss.azureEndpoint}&api-key=${ss.azureKey}` ws = new WebSocket(url, []) } else { return null From 1620eb6c2a2c85e66b2439b649a901e5b1f5fdf9 Mon Sep 17 00:00:00 2001 From: tegnike Date: Fri, 18 Oct 2024 09:51:38 +0200 Subject: [PATCH 2/4] =?UTF-8?q?=E3=83=95=E3=83=AD=E3=83=B3=E3=83=88?= =?UTF-8?q?=E5=81=B4=E3=81=A7API=E3=82=AD=E3=83=BC=E3=81=8C=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=81=A8=E3=83=AA=E3=82=AF=E3=82=A8=E3=82=B9=E3=83=88=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E3=81=AB=E3=81=AA=E3=82=8B=E4=B8=8D=E5=85=B7?= =?UTF-8?q?=E5=90=88=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/chat/vercelAIChat.ts | 6 ------ src/features/slide/slideAIHelpers.ts | 6 ------ 2 files changed, 12 deletions(-) diff --git a/src/features/chat/vercelAIChat.ts b/src/features/chat/vercelAIChat.ts index 4359e7c..a84d31b 100644 --- a/src/features/chat/vercelAIChat.ts +++ b/src/features/chat/vercelAIChat.ts @@ -16,12 +16,6 @@ const getAIConfig = () => { const apiKeyName = `${aiService}Key` as const const apiKey = ss[apiKeyName] - if (!apiKey) { - throw new Error( - `API key for ${aiService} is missing. Unable to proceed with the AI service.` - ) - } - return { aiApiKey: apiKey, selectAIService: aiService, diff --git a/src/features/slide/slideAIHelpers.ts b/src/features/slide/slideAIHelpers.ts index 51e7f15..7a3b41a 100644 --- a/src/features/slide/slideAIHelpers.ts +++ b/src/features/slide/slideAIHelpers.ts @@ -19,12 +19,6 @@ export const judgeSlide = async ( const apiKeyName = `${aiService}Key` as const const apiKey = ss[apiKeyName] - if (!apiKey) { - throw new Error( - `API key for ${aiService} is missing. Unable to proceed with the AI service.` - ) - } - const systemMessage = ` You are an AI tasked with determining whether a user's comment is a question about a given script document and supplementary text, and if so, which page of the document is most relevant to the question. Follow these instructions carefully: From 4cc11591972d818ddb430eead798e91217b8ce49 Mon Sep 17 00:00:00 2001 From: tegnike Date: Fri, 18 Oct 2024 10:16:40 +0200 Subject: [PATCH 3/4] =?UTF-8?q?AI=E3=82=B5=E3=83=BC=E3=83=93=E3=82=B9?= =?UTF-8?q?=E3=81=8COpenAI/Azure=E3=81=A7=E3=81=AA=E3=81=91=E3=82=8C?= =?UTF-8?q?=E3=81=B0RealtimeAPI=E3=83=A2=E3=83=BC=E3=83=89=E3=82=92?= =?UTF-8?q?=E3=82=AA=E3=83=95=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/settings/modelProvider.tsx | 4 ++++ src/features/stores/settings.ts | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/settings/modelProvider.tsx b/src/components/settings/modelProvider.tsx index faedd7f..e8f955e 100644 --- a/src/components/settings/modelProvider.tsx +++ b/src/components/settings/modelProvider.tsx @@ -68,6 +68,10 @@ const ModelProvider = () => { isPlaying: false, }) } + + if (newService !== 'openai' && newService !== 'azure') { + settingsStore.setState({ realtimeAPIMode: false }) + } }, [] ) diff --git a/src/features/stores/settings.ts b/src/features/stores/settings.ts index 51be9c8..df92020 100644 --- a/src/features/stores/settings.ts +++ b/src/features/stores/settings.ts @@ -177,7 +177,12 @@ const settingsStore = create()( process.env.NEXT_PUBLIC_CHANGE_ENGLISH_TO_JAPANESE === 'true', showControlPanel: process.env.NEXT_PUBLIC_SHOW_CONTROL_PANEL !== 'false', webSocketMode: process.env.NEXT_PUBLIC_WEB_SOCKET_MODE === 'true', - realtimeAPIMode: process.env.NEXT_PUBLIC_REALTIME_API_MODE === 'true', + realtimeAPIMode: + (process.env.NEXT_PUBLIC_REALTIME_API_MODE === 'true' && + ['openai', 'azure'].includes( + process.env.NEXT_PUBLIC_SELECT_AI_SERVICE as AIService + )) || + false, slideMode: process.env.NEXT_PUBLIC_SLIDE_MODE === 'true', messageReceiverEnabled: false, clientId: '', From 9f4f343acc38c0619369705a22e594729373b004 Mon Sep 17 00:00:00 2001 From: tegnike Date: Fri, 18 Oct 2024 10:17:57 +0200 Subject: [PATCH 4/4] =?UTF-8?q?Realtime=20API=E3=83=A2=E3=83=BC=E3=83=89?= =?UTF-8?q?=E3=81=A7=E3=81=AF=E3=83=86=E3=82=AD=E3=82=B9=E3=83=88=E9=80=81?= =?UTF-8?q?=E4=BF=A1=E3=82=92=E9=9D=9E=E6=B4=BB=E6=80=A7=E3=81=AB=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/messageInput.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/messageInput.tsx b/src/components/messageInput.tsx index d5c7dc2..18447c3 100644 --- a/src/components/messageInput.tsx +++ b/src/components/messageInput.tsx @@ -108,7 +108,7 @@ export const MessageInput = ({ iconName="24/Send" className="bg-secondary hover:bg-secondary-hover active:bg-secondary-press disabled:bg-secondary-disabled" isProcessing={chatProcessing} - disabled={chatProcessing || !userMessage} + disabled={chatProcessing || !userMessage || realtimeAPIMode} onClick={onClickSendButton} />