From a1bc3f27b37e8c0d464f80ec38b8fb651aa7ff75 Mon Sep 17 00:00:00 2001 From: felri Date: Mon, 11 Dec 2023 12:52:19 -0300 Subject: [PATCH] Add logic to handle empty API key and create OpenAI instance --- src/components/FlowComponents/apiKey.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/FlowComponents/apiKey.jsx b/src/components/FlowComponents/apiKey.jsx index f4338bf..b37dc53 100644 --- a/src/components/FlowComponents/apiKey.jsx +++ b/src/components/FlowComponents/apiKey.jsx @@ -68,6 +68,15 @@ function ApiKeyNode({ id }) { const onChange = (e) => { setApiKey(e.target.value); + if (e.target.value.length === 0) { + store((state) => { + state.openAIInstance = null; + }); + } + + if (e.target.value.length > 0) { + createOpenAIInstance(); + } }; useEffect(() => {