forked from phoenix/litellm-mirror
build(ui/): show created tags in dropdown
makes it easier for admin to add tags to keys
This commit is contained in:
parent
43e0b52f6f
commit
829199d538
2 changed files with 32 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -40,6 +40,31 @@ interface CreateKeyProps {
|
|||
setData: React.Dispatch<React.SetStateAction<any[] | null>>;
|
||||
}
|
||||
|
||||
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<CreateKeyProps> = ({
|
||||
userID,
|
||||
team,
|
||||
|
@ -55,6 +80,8 @@ const CreateKey: React.FC<CreateKeyProps> = ({
|
|||
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<CreateKeyProps> = ({
|
|||
style={{ width: '100%' }}
|
||||
placeholder="Enter tags"
|
||||
tokenSeparators={[',']}
|
||||
open={false}
|
||||
options={predefinedTags}
|
||||
/>
|
||||
</Form.Item>
|
||||
</AccordionBody>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue