(feat) ui - show user key when creating key

This commit is contained in:
ishaan-jaff 2024-02-12 16:55:34 -08:00
parent 151f75b68f
commit 2bdc5a81ec
2 changed files with 35 additions and 60 deletions

View file

@ -14,6 +14,7 @@ interface CreateKeyProps {
userRole: string | null;
accessToken: string;
data: any[] | null;
userModels: string[];
setData: React.Dispatch<React.SetStateAction<any[] | null>>;
}
@ -22,6 +23,7 @@ const CreateKey: React.FC<CreateKeyProps> = ({
userRole,
accessToken,
data,
userModels,
setData,
}) => {
const [form] = Form.useForm();
@ -42,14 +44,6 @@ const CreateKey: React.FC<CreateKeyProps> = ({
const handleCreate = async (formValues: Record<string, any>) => {
try {
message.info("Making API Call");
// Check if "models" exists and is not an empty string
if (formValues.models && formValues.models.trim() !== '') {
// Format the "models" field as an array
formValues.models = formValues.models.split(',').map((model: string) => model.trim());
} else {
// If "models" is undefined or an empty string, set it to an empty array
formValues.models = [];
}
setIsModalVisible(true);
const response = await keyCreateCall(accessToken, userID, formValues);
setData((prevData) => (prevData ? [...prevData, response] : [response])); // Check if prevData is null
@ -90,13 +84,22 @@ const CreateKey: React.FC<CreateKeyProps> = ({
>
<Input placeholder="ai_team" />
</Form.Item>
<Form.Item
label="Models (Comma Separated). Eg: gpt-3.5-turbo,gpt-4"
name="models"
label="Models"
name="models"
>
<Select
mode="multiple"
placeholder="Select models"
style={{ width: '100%' }}
>
<Input placeholder="gpt-4,gpt-3.5-turbo" />
</Form.Item>
{userModels.map((model) => (
<Option key={model} value={model}>
{model}
</Option>
))}
</Select>
</Form.Item>
<Form.Item