From 3347a58e11e1865454dca79fd9dd9502d3cfc340 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Mon, 10 Jun 2024 15:48:36 -0700 Subject: [PATCH] ui - chat ui fix --- .../src/components/chat_ui.tsx | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/ui/litellm-dashboard/src/components/chat_ui.tsx b/ui/litellm-dashboard/src/components/chat_ui.tsx index 407e33dca..d96db60c4 100644 --- a/ui/litellm-dashboard/src/components/chat_ui.tsx +++ b/ui/litellm-dashboard/src/components/chat_ui.tsx @@ -119,9 +119,24 @@ const ChatUI: React.FC = ({ // Now, 'options' contains the list you wanted console.log(options); // You can log it to verify the list - - // setModelInfo(options) should be inside the if block to avoid setting it when no data is available - setModelInfo(options); + + // if options.length > 0, only store unique values + if (options.length > 0) { + const uniqueModels = Array.from(new Set(options)); + + console.log("Unique models:", uniqueModels); + + // sort uniqueModels alphabetically + uniqueModels.sort((a: any, b: any) => a.label.localeCompare(b.label)); + + + console.log("Model info:", modelInfo); + + // setModelInfo(options) should be inside the if block to avoid setting it when no data is available + setModelInfo(uniqueModels); + } + + setSelectedModel(fetchedAvailableModels.data[0].id); } } catch (error) {