mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-26 13:18:51 +01:00
🧹 chore: pre-release cleanup 2 (#3600)
* refactor: scrollToEnd * fix(validateConvoAccess): search conversation by ID for proper validation * feat: Add unique index for conversationId and user in convoSchema * refactor: Update font sizes 1 rem -> font-size-base in style.css * fix: Assistants map type issues * refactor: Remove obsolete scripts * fix: Update DropdownNoState component to handle both string and OptionType values * refactor: Remove config/loader.js file * fix: remove crypto.randomBytes(); refactor: Create reusable function for generating token and hash
This commit is contained in:
parent
6fead1005b
commit
1ff4841603
20 changed files with 172 additions and 637 deletions
|
|
@ -62,12 +62,12 @@ export default function ActionsInput({
|
|||
const [functions, setFunctions] = useState<FunctionTool[] | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!action?.metadata?.raw_spec) {
|
||||
if (!action?.metadata.raw_spec) {
|
||||
return;
|
||||
}
|
||||
setInputValue(action.metadata.raw_spec);
|
||||
debouncedValidation(action.metadata.raw_spec, handleResult);
|
||||
}, [action?.metadata?.raw_spec]);
|
||||
}, [action?.metadata.raw_spec]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!validationResult || !validationResult.status || !validationResult.spec) {
|
||||
|
|
@ -100,7 +100,7 @@ export default function ActionsInput({
|
|||
},
|
||||
onError(error) {
|
||||
showToast({
|
||||
message: (error as Error)?.message ?? localize('com_assistants_update_actions_error'),
|
||||
message: (error as Error).message ?? localize('com_assistants_update_actions_error'),
|
||||
status: 'error',
|
||||
});
|
||||
},
|
||||
|
|
@ -180,7 +180,7 @@ export default function ActionsInput({
|
|||
assistant_id,
|
||||
endpoint,
|
||||
version,
|
||||
model: assistantMap[endpoint][assistant_id].model,
|
||||
model: assistantMap?.[endpoint][assistant_id].model ?? '',
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -195,16 +195,32 @@ export default function ActionsInput({
|
|||
debouncedValidation(newValue, handleResult);
|
||||
};
|
||||
|
||||
const submitContext = () => {
|
||||
if (updateAction.isLoading) {
|
||||
return <Spinner className="icon-md" />;
|
||||
} else if (action?.action_id.length ?? 0) {
|
||||
return localize('com_ui_update');
|
||||
} else {
|
||||
return localize('com_ui_create');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="">
|
||||
<div className="mb-1 flex flex-wrap items-center justify-between gap-4">
|
||||
<label className="text-token-text-primary whitespace-nowrap font-medium">Schema</label>
|
||||
<label
|
||||
htmlFor="example-schema"
|
||||
className="text-token-text-primary whitespace-nowrap font-medium"
|
||||
>
|
||||
Schema
|
||||
</label>
|
||||
<div className="flex items-center gap-2">
|
||||
{/* <button className="btn btn-neutral border-token-border-light relative h-8 min-w-[100px] rounded-lg font-medium">
|
||||
<div className="flex w-full items-center justify-center text-xs">Import from URL</div>
|
||||
</button> */}
|
||||
<select
|
||||
id="example-schema"
|
||||
onChange={(e) => console.log(e.target.value)}
|
||||
className="border-token-border-medium h-8 min-w-[100px] rounded-lg border bg-transparent px-2 py-0 text-sm"
|
||||
>
|
||||
|
|
@ -250,23 +266,15 @@ export default function ActionsInput({
|
|||
</div>
|
||||
)}
|
||||
<div className="mt-4">
|
||||
<div className="mb-1.5 flex items-center">
|
||||
<span className="" data-state="closed">
|
||||
<label className="text-token-text-primary block font-medium">
|
||||
{localize('com_ui_privacy_policy')}
|
||||
</label>
|
||||
</span>
|
||||
</div>
|
||||
<div className="rounded-md border border-gray-300 px-3 py-2 shadow-none focus-within:border-gray-800 focus-within:ring-1 focus-within:ring-gray-800 dark:border-gray-700 dark:bg-gray-700 dark:focus-within:border-gray-500 dark:focus-within:ring-gray-500">
|
||||
<label
|
||||
htmlFor="privacyPolicyUrl"
|
||||
className="block text-xs font-medium text-gray-900 dark:text-gray-100"
|
||||
/>
|
||||
<label htmlFor="privacyPolicyUrl" className="block text-xs text-text-secondary">
|
||||
Privacy Policy URL
|
||||
</label>
|
||||
<div className="relative">
|
||||
<input
|
||||
name="privacyPolicyUrl"
|
||||
id="privacyPolicyUrl"
|
||||
className="block w-full border-0 p-0 text-gray-900 placeholder-gray-500 shadow-none outline-none focus-within:shadow-none focus-within:outline-none focus-within:ring-0 focus:border-none focus:ring-0 dark:bg-gray-700 dark:text-gray-100 sm:text-sm"
|
||||
className="block w-full border-0 bg-transparent p-0 placeholder-text-secondary shadow-none outline-none focus-within:shadow-none focus-within:outline-none focus-within:ring-0 focus:border-none focus:ring-0 sm:text-sm"
|
||||
placeholder="https://api.example-weather-app.com/privacy"
|
||||
// value=""
|
||||
/>
|
||||
|
|
@ -280,13 +288,7 @@ export default function ActionsInput({
|
|||
className="focus:shadow-outline mt-1 flex min-w-[100px] items-center justify-center rounded bg-green-500 px-4 py-2 font-semibold text-white hover:bg-green-400 focus:border-green-500 focus:outline-none focus:ring-0 disabled:bg-green-400"
|
||||
type="button"
|
||||
>
|
||||
{updateAction.isLoading ? (
|
||||
<Spinner className="icon-md" />
|
||||
) : action?.action_id ? (
|
||||
localize('com_ui_update')
|
||||
) : (
|
||||
localize('com_ui_create')
|
||||
)}
|
||||
{submitContext()}
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ function Avatar({
|
|||
const { showToast } = useToastContext();
|
||||
|
||||
const activeModel = useMemo(() => {
|
||||
return assistantsMap[endpoint][assistant_id ?? '']?.model ?? '';
|
||||
return assistantsMap?.[endpoint][assistant_id ?? '']?.model ?? '';
|
||||
}, [assistantsMap, endpoint, assistant_id]);
|
||||
|
||||
const { mutate: uploadAvatar } = useUploadAssistantAvatarMutation({
|
||||
|
|
@ -59,7 +59,7 @@ function Avatar({
|
|||
setProgress(0.4);
|
||||
},
|
||||
onSuccess: (data, vars) => {
|
||||
if (!vars.postCreation) {
|
||||
if (vars.postCreation !== true) {
|
||||
showToast({ message: localize('com_ui_upload_success') });
|
||||
} else if (lastSeenCreatedId.current !== createMutation.data?.id) {
|
||||
lastSeenCreatedId.current = createMutation.data?.id ?? '';
|
||||
|
|
@ -136,9 +136,9 @@ function Avatar({
|
|||
createMutation.isSuccess &&
|
||||
input &&
|
||||
previewUrl &&
|
||||
previewUrl?.includes('base64')
|
||||
previewUrl.includes('base64')
|
||||
);
|
||||
if (sharedUploadCondition && lastSeenCreatedId.current === createMutation.data?.id) {
|
||||
if (sharedUploadCondition && lastSeenCreatedId.current === createMutation.data.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -149,8 +149,8 @@ function Avatar({
|
|||
formData.append('file', input, input.name);
|
||||
formData.append('assistant_id', createMutation.data.id);
|
||||
|
||||
if (typeof createMutation.data?.metadata === 'object') {
|
||||
formData.append('metadata', JSON.stringify(createMutation.data?.metadata));
|
||||
if (typeof createMutation.data.metadata === 'object') {
|
||||
formData.append('metadata', JSON.stringify(createMutation.data.metadata));
|
||||
}
|
||||
|
||||
uploadAvatar({
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ export default function AssistantPanel({
|
|||
const error = err as Error;
|
||||
showToast({
|
||||
message: `${localize('com_assistants_update_error')}${
|
||||
error?.message ? ` ${localize('com_ui_error')}: ${error?.message}` : ''
|
||||
error.message ? ` ${localize('com_ui_error')}: ${error.message}` : ''
|
||||
}`,
|
||||
status: 'error',
|
||||
});
|
||||
|
|
@ -119,7 +119,7 @@ export default function AssistantPanel({
|
|||
const error = err as Error;
|
||||
showToast({
|
||||
message: `${localize('com_assistants_create_error')}${
|
||||
error?.message ? ` ${localize('com_ui_error')}: ${error?.message}` : ''
|
||||
error.message ? ` ${localize('com_ui_error')}: ${error.message}` : ''
|
||||
}`,
|
||||
status: 'error',
|
||||
});
|
||||
|
|
@ -139,7 +139,7 @@ export default function AssistantPanel({
|
|||
return functionName;
|
||||
} else {
|
||||
const assistant = assistantMap?.[endpoint]?.[assistant_id];
|
||||
const tool = assistant?.tools?.find((tool) => tool.function?.name === functionName);
|
||||
const tool = assistant?.tools.find((tool) => tool.function?.name === functionName);
|
||||
if (assistant && tool) {
|
||||
return tool;
|
||||
}
|
||||
|
|
@ -193,6 +193,16 @@ export default function AssistantPanel({
|
|||
});
|
||||
};
|
||||
|
||||
let submitContext: string | JSX.Element;
|
||||
|
||||
if (create.isLoading || update.isLoading) {
|
||||
submitContext = <Spinner className="icon-md" />;
|
||||
} else if (assistant_id) {
|
||||
submitContext = localize('com_ui_save');
|
||||
} else {
|
||||
submitContext = localize('com_ui_create');
|
||||
}
|
||||
|
||||
return (
|
||||
<FormProvider {...methods}>
|
||||
<form
|
||||
|
|
@ -235,7 +245,7 @@ export default function AssistantPanel({
|
|||
<AssistantAvatar
|
||||
createMutation={create}
|
||||
assistant_id={assistant_id ?? null}
|
||||
metadata={assistant?.['metadata'] ?? null}
|
||||
metadata={assistant['metadata'] ?? null}
|
||||
endpoint={endpoint}
|
||||
version={version}
|
||||
/>
|
||||
|
|
@ -425,13 +435,7 @@ export default function AssistantPanel({
|
|||
className="btn btn-primary focus:shadow-outline flex w-full items-center justify-center px-4 py-2 font-semibold text-white hover:bg-green-600 focus:border-green-500"
|
||||
type="submit"
|
||||
>
|
||||
{create.isLoading || update.isLoading ? (
|
||||
<Spinner className="icon-md" />
|
||||
) : assistant_id ? (
|
||||
localize('com_ui_save')
|
||||
) : (
|
||||
localize('com_ui_create')
|
||||
)}
|
||||
{submitContext}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export default function ContextButton({
|
|||
createMutation,
|
||||
endpoint,
|
||||
}: {
|
||||
activeModel: string;
|
||||
activeModel?: string;
|
||||
assistant_id: string;
|
||||
setCurrentAssistantId: React.Dispatch<React.SetStateAction<string | undefined>>;
|
||||
createMutation: UseMutationResult<Assistant, Error, AssistantCreateParams>;
|
||||
|
|
@ -38,7 +38,7 @@ export default function ContextButton({
|
|||
status: 'success',
|
||||
});
|
||||
|
||||
if (createMutation.data?.id) {
|
||||
if (createMutation.data?.id !== undefined) {
|
||||
console.log('[deleteAssistant] resetting createMutation');
|
||||
createMutation.reset();
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@ export default function ContextButton({
|
|||
return setOption('assistant_id')(firstAssistant.id);
|
||||
}
|
||||
|
||||
const currentAssistant = updatedList?.find(
|
||||
const currentAssistant = updatedList.find(
|
||||
(assistant) => assistant.id === conversation?.assistant_id,
|
||||
);
|
||||
|
||||
|
|
@ -75,6 +75,10 @@ export default function ContextButton({
|
|||
return null;
|
||||
}
|
||||
|
||||
if (activeModel?.length === 0 || activeModel === undefined) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog>
|
||||
<DialogTrigger asChild>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue