mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-24 04:10:15 +01:00
* fix: Prevent parsing 'undefined' string in useLocalStorage initialization * feat: first pass, code interpreter badge * feat: Integrate API key authentication and default checked value in Code Interpreter Badge * refactor: Rename showMCPServers to showEphemeralBadges and update related components, memoize values in useChatBadges * refactor: Enhance AttachFileChat to support ephemeral agents in file attachment logic * fix: Add baseURL configuration option to legacy function call * refactor: Update dependency array in useDragHelpers to include handleFiles * refactor: Update isEphemeralAgent function to accept optional endpoint parameter * refactor: Update file handling to support ephemeral agents in AttachFileMenu and useDragHelpers * fix: improve compatibility issues with OpenAI usage field handling in createRun function * refactor: usage field compatibility * fix: ensure mcp servers are no longer "selected" if mcp servers are now unavailable
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { memo, useMemo } from 'react';
|
|
import { useRecoilValue } from 'recoil';
|
|
import {
|
|
Constants,
|
|
supportsFiles,
|
|
mergeFileConfig,
|
|
isAgentsEndpoint,
|
|
isEphemeralAgent,
|
|
EndpointFileConfig,
|
|
fileConfig as defaultFileConfig,
|
|
} from 'librechat-data-provider';
|
|
import { useChatContext } from '~/Providers';
|
|
import { useGetFileConfig } from '~/data-provider';
|
|
import { ephemeralAgentByConvoId } from '~/store';
|
|
import AttachFileMenu from './AttachFileMenu';
|
|
import AttachFile from './AttachFile';
|
|
|
|
function AttachFileChat({ disableInputs }: { disableInputs: boolean }) {
|
|
const { conversation } = useChatContext();
|
|
|
|
const { endpoint: _endpoint, endpointType } = conversation ?? { endpoint: null };
|
|
|
|
const key = conversation?.conversationId ?? Constants.NEW_CONVO;
|
|
const ephemeralAgent = useRecoilValue(ephemeralAgentByConvoId(key));
|
|
const isAgents = useMemo(
|
|
() => isAgentsEndpoint(_endpoint) || isEphemeralAgent(_endpoint, ephemeralAgent),
|
|
[_endpoint, ephemeralAgent],
|
|
);
|
|
|
|
const { data: fileConfig = defaultFileConfig } = useGetFileConfig({
|
|
select: (data) => mergeFileConfig(data),
|
|
});
|
|
|
|
const endpointFileConfig = fileConfig.endpoints[_endpoint ?? ''] as
|
|
| EndpointFileConfig
|
|
| undefined;
|
|
|
|
const endpointSupportsFiles: boolean = supportsFiles[endpointType ?? _endpoint ?? ''] ?? false;
|
|
const isUploadDisabled = (disableInputs || endpointFileConfig?.disabled) ?? false;
|
|
|
|
if (isAgents) {
|
|
return <AttachFileMenu disabled={disableInputs} />;
|
|
}
|
|
if (endpointSupportsFiles && !isUploadDisabled) {
|
|
return <AttachFile disabled={disableInputs} />;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
export default memo(AttachFileChat);
|