From 6ebf2b59401186e3889622fe49cca58d681ffa97 Mon Sep 17 00:00:00 2001 From: Dustin Loring Date: Fri, 20 Dec 2024 16:46:51 -0500 Subject: [PATCH] feat: added a check for api keys and baseURL's if the provider is Ollama, LM Studio or OpenAI Like it will require a baseURL the others require an API key --- app/components/chat/BaseChat.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/components/chat/BaseChat.tsx b/app/components/chat/BaseChat.tsx index 5db66537c..8facf24ad 100644 --- a/app/components/chat/BaseChat.tsx +++ b/app/components/chat/BaseChat.tsx @@ -210,6 +210,25 @@ export const BaseChat = React.forwardRef( const handleSendMessage = (event: React.UIEvent, messageInput?: string) => { if (sendMessage) { + // Check if provider exists and is not experimental + if (provider) { + const isExperimental = ['Ollama', 'LMStudio', 'OpenAILike'].includes(provider.name); + + if (isExperimental) { + // For experimental providers, check if base URL is set + if (!provider.settings?.baseUrl) { + toast.error(`Please set a base URL for ${provider.name} in the model settings`); + return; + } + } else { + // For non-experimental providers, check if API key is set + if (!apiKeys[provider.name]) { + toast.error(`Please set an API key for ${provider.name} in the model settings`); + return; + } + } + } + sendMessage(event, messageInput); if (recognition) {