Merge pull request #4108 from BerriAI/litellm_ui_fix_show_unique_model_names

ui - Fix Test Key dropdown
This commit is contained in:
Ishaan Jaff 2024-06-10 20:08:43 -07:00 committed by GitHub
commit 8d18583c67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -120,8 +120,23 @@ const ChatUI: React.FC<ChatUIProps> = ({
// Now, 'options' contains the list you wanted // Now, 'options' contains the list you wanted
console.log(options); // You can log it to verify the list console.log(options); // You can log it to verify the list
// 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(options) should be inside the if block to avoid setting it when no data is available
setModelInfo(options); setModelInfo(uniqueModels);
}
setSelectedModel(fetchedAvailableModels.data[0].id); setSelectedModel(fetchedAvailableModels.data[0].id);
} }
} catch (error) { } catch (error) {