diff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.py index d2f2dbc4c..511e5a940 100644 --- a/litellm/proxy/management_endpoints/key_management_endpoints.py +++ b/litellm/proxy/management_endpoints/key_management_endpoints.py @@ -160,7 +160,10 @@ def key_generation_check( """ Check if admin has restricted key creation to certain roles for teams or individuals """ - if litellm.key_generation_settings is None: + if ( + litellm.key_generation_settings is None + or user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value + ): return True ## check if key is for team or individual diff --git a/ui/litellm-dashboard/src/components/create_key_button.tsx b/ui/litellm-dashboard/src/components/create_key_button.tsx index 424a3b167..4f771b111 100644 --- a/ui/litellm-dashboard/src/components/create_key_button.tsx +++ b/ui/litellm-dashboard/src/components/create_key_button.tsx @@ -40,6 +40,31 @@ interface CreateKeyProps { setData: React.Dispatch>; } +const getPredefinedTags = (data: any[] | null) => { + let allTags = []; + + console.log("data:", JSON.stringify(data)); + + if (data) { + for (let key of data) { + if (key["metadata"] && key["metadata"]["tags"]) { + allTags.push(...key["metadata"]["tags"]); + } + } + } + + // Deduplicate using Set + const uniqueTags = Array.from(new Set(allTags)).map(tag => ({ + value: tag, + label: tag, + })); + + + console.log("uniqueTags:", uniqueTags); + return uniqueTags; +} + + const CreateKey: React.FC = ({ userID, team, @@ -55,6 +80,8 @@ const CreateKey: React.FC = ({ const [userModels, setUserModels] = useState([]); const [modelsToPick, setModelsToPick] = useState([]); const [keyOwner, setKeyOwner] = useState("you"); + const [predefinedTags, setPredefinedTags] = useState(getPredefinedTags(data)); + const handleOk = () => { setIsModalVisible(false); @@ -361,7 +388,7 @@ const CreateKey: React.FC = ({ style={{ width: '100%' }} placeholder="Enter tags" tokenSeparators={[',']} - open={false} + options={predefinedTags} />