From 75250f3a5f798a433a616b4f2ff5f3c471e7159a Mon Sep 17 00:00:00 2001 From: Danny Avila <110412045+danny-avila@users.noreply.github.com> Date: Wed, 5 Jul 2023 09:18:45 -0400 Subject: [PATCH] Fix: Azure "user_provided" Frontend Credentials and Save Last Selected Bing Settings (#587) * fix(Messages.jsx): fix
tag warning * fix(NewConversationMenu): update localStorage with lastBingSettings when endpoint is 'bingAI' fix(getDefaultConversation): retrieve lastBingSettings from localStorage and use it to set default values for jailbreak and toneStyle when endpoint is 'bingAI' feat(settings.spec.js): add test to check if the active class is set on the selected endpoint in the settings menu * fix(BingAIOptions): add data-testid to BingAIOptions SelectDropDown component fix(settings.spec.js): update test to include additional steps for testing settings persistence * fix(azure): support user_provided credentials from client --- api/server/routes/ask/openAI.js | 2 +- .../components/Input/BingAIOptions/index.jsx | 1 + .../Input/NewConversationMenu/index.jsx | 9 ++++ .../components/Input/SetTokenDialog/index.jsx | 20 ++++---- client/src/components/Messages/index.jsx | 4 +- client/src/utils/getDefaultConversation.js | 6 ++- e2e/specs/settings.spec.js | 49 +++++++++++++++++++ 7 files changed, 76 insertions(+), 15 deletions(-) create mode 100644 e2e/specs/settings.spec.js diff --git a/api/server/routes/ask/openAI.js b/api/server/routes/ask/openAI.js index ae597a7bb..e123f462f 100644 --- a/api/server/routes/ask/openAI.js +++ b/api/server/routes/ask/openAI.js @@ -141,7 +141,7 @@ const ask = async ({ text, endpointOption, parentMessageId = null, endpoint, con let oaiApiKey = req.body?.token ?? process.env.OPENAI_API_KEY; if (process.env.AZURE_API_KEY && endpoint === 'azureOpenAI') { - clientOptions.azure = getAzureCredentials(); + clientOptions.azure = JSON.parse(req.body?.token) ?? getAzureCredentials(); // clientOptions.reverseProxyUrl = process.env.AZURE_REVERSE_PROXY ?? genAzureChatCompletion({ ...clientOptions.azure }); oaiApiKey = clientOptions.azure.azureOpenAIApiKey; } diff --git a/client/src/components/Input/BingAIOptions/index.jsx b/client/src/components/Input/BingAIOptions/index.jsx index 3237e8ef8..e1944af8b 100644 --- a/client/src/components/Input/BingAIOptions/index.jsx +++ b/client/src/components/Input/BingAIOptions/index.jsx @@ -61,6 +61,7 @@ function BingAIOptions({ show }) {