mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 01:10:14 +01:00
🔀 fix: Assistants API File Attachments
This commit is contained in:
parent
59d00e99f3
commit
5d267aa8e2
1 changed files with 6 additions and 2 deletions
|
|
@ -4,18 +4,21 @@ import {
|
||||||
supportsFiles,
|
supportsFiles,
|
||||||
mergeFileConfig,
|
mergeFileConfig,
|
||||||
isAgentsEndpoint,
|
isAgentsEndpoint,
|
||||||
|
isAssistantsEndpoint,
|
||||||
fileConfig as defaultFileConfig,
|
fileConfig as defaultFileConfig,
|
||||||
} from 'librechat-data-provider';
|
} from 'librechat-data-provider';
|
||||||
import type { EndpointFileConfig } from 'librechat-data-provider';
|
import type { EndpointFileConfig } from 'librechat-data-provider';
|
||||||
import { useGetFileConfig } from '~/data-provider';
|
import { useGetFileConfig } from '~/data-provider';
|
||||||
import AttachFileMenu from './AttachFileMenu';
|
import AttachFileMenu from './AttachFileMenu';
|
||||||
import { useChatContext } from '~/Providers';
|
import { useChatContext } from '~/Providers';
|
||||||
|
import AttachFile from './AttachFile';
|
||||||
|
|
||||||
function AttachFileChat({ disableInputs }: { disableInputs: boolean }) {
|
function AttachFileChat({ disableInputs }: { disableInputs: boolean }) {
|
||||||
const { conversation } = useChatContext();
|
const { conversation } = useChatContext();
|
||||||
const conversationId = conversation?.conversationId ?? Constants.NEW_CONVO;
|
const conversationId = conversation?.conversationId ?? Constants.NEW_CONVO;
|
||||||
const { endpoint, endpointType } = conversation ?? { endpoint: null };
|
const { endpoint, endpointType } = conversation ?? { endpoint: null };
|
||||||
const isAgents = useMemo(() => isAgentsEndpoint(endpoint), [endpoint]);
|
const isAgents = useMemo(() => isAgentsEndpoint(endpoint), [endpoint]);
|
||||||
|
const isAssistants = useMemo(() => isAssistantsEndpoint(endpoint), [endpoint]);
|
||||||
|
|
||||||
const { data: fileConfig = defaultFileConfig } = useGetFileConfig({
|
const { data: fileConfig = defaultFileConfig } = useGetFileConfig({
|
||||||
select: (data) => mergeFileConfig(data),
|
select: (data) => mergeFileConfig(data),
|
||||||
|
|
@ -25,7 +28,9 @@ function AttachFileChat({ disableInputs }: { disableInputs: boolean }) {
|
||||||
const endpointSupportsFiles: boolean = supportsFiles[endpointType ?? endpoint ?? ''] ?? false;
|
const endpointSupportsFiles: boolean = supportsFiles[endpointType ?? endpoint ?? ''] ?? false;
|
||||||
const isUploadDisabled = (disableInputs || endpointFileConfig?.disabled) ?? false;
|
const isUploadDisabled = (disableInputs || endpointFileConfig?.disabled) ?? false;
|
||||||
|
|
||||||
if (isAgents || (endpointSupportsFiles && !isUploadDisabled)) {
|
if (isAssistants && endpointSupportsFiles && !isUploadDisabled) {
|
||||||
|
return <AttachFile disabled={disableInputs} />;
|
||||||
|
} else if (isAgents || (endpointSupportsFiles && !isUploadDisabled)) {
|
||||||
return (
|
return (
|
||||||
<AttachFileMenu
|
<AttachFileMenu
|
||||||
disabled={disableInputs}
|
disabled={disableInputs}
|
||||||
|
|
@ -34,7 +39,6 @@ function AttachFileChat({ disableInputs }: { disableInputs: boolean }) {
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue