Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions react/src/components/Chat/ChatCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ const ChatCard: React.FC<ChatCardProps> = ({
styles: { chatCard: chatCardStyle, alert: alertStyle, ...chatCardStyles },
} = useStyles();
const formRef = useRef<FormInstance>(null);
const dropContainerRef = useRef<HTMLDivElement>(null);
const [fetchKey, updateFetchKey] = useUpdatableState('first');
const [startTime, setStartTime] = useState<number | null>(null);

Expand Down Expand Up @@ -265,6 +266,7 @@ const ChatCard: React.FC<ChatCardProps> = ({
setMessages={setMessages}
/>
}
ref={dropContainerRef}
>
<CustomModelForm
modelId={modelId}
Expand Down Expand Up @@ -299,6 +301,7 @@ const ChatCard: React.FC<ChatCardProps> = ({
stop={stop}
append={append}
isLoading={isLoading}
dropContainerRef={dropContainerRef}
/>
</Card>
);
Expand Down
11 changes: 7 additions & 4 deletions react/src/components/Chat/ChatInput.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { createDataTransferFiles } from '../../helper';
import Flex from '../Flex';
import ChatSender, { AttachmentChangeInfo } from './ChatSender';
import ChatSender, {
AttachmentChangeInfo,
ChatAttachmentsProps,
} from './ChatSender';
import { CreateMessage, Message } from '@ai-sdk/react';
import type { AttachmentsProps } from '@ant-design/x';
import { ChatRequestOptions } from 'ai';
Expand All @@ -21,7 +24,7 @@ interface ChatRequest {
fetchOnClient?: boolean;
}

interface ChatInputProps extends ChatRequest {
interface ChatInputProps extends ChatRequest, ChatAttachmentsProps {
sync: boolean;
input: string;
setInput: (input: string) => void;
Expand All @@ -40,6 +43,7 @@ const ChatInput: React.FC<ChatInputProps> = ({
stop,
append,
isLoading,
dropContainerRef,
}) => {
const { token } = theme.useToken();

Expand All @@ -50,7 +54,6 @@ const ChatInput: React.FC<ChatInputProps> = ({

const [isOpenAttachments, setIsOpenAttachments] = useState(false);
const [files, setFiles] = useState<AttachmentsProps['items']>([]);
const cardRef = useRef<HTMLDivElement>(null);

const [synchronizedMessage, setSynchronizedMessage] = useAtom(
synchronizedMessageState,
Expand Down Expand Up @@ -202,7 +205,7 @@ const ChatInput: React.FC<ChatInputProps> = ({
value={input}
items={files}
openAttachment={isOpenAttachments}
dropContainerRef={cardRef}
dropContainerRef={dropContainerRef}
loading={isLoading}
onInputChange={handleInputChange}
onInputSubmit={handleInputSubmit}
Expand Down
9 changes: 5 additions & 4 deletions react/src/components/Chat/ChatSender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { isEmpty } from 'lodash';
import { useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';

interface ChageAttachmentsProps extends AttachmentsProps {
export interface ChatAttachmentsProps {
dropContainerRef: React.RefObject<HTMLElement | null>;
}

const ChatAttachments: React.FC<ChageAttachmentsProps> = ({
const ChatAttachments: React.FC<ChatAttachmentsProps & AttachmentsProps> = ({
items,
onChange,
dropContainerRef,
Expand Down Expand Up @@ -51,12 +51,13 @@ export type AttachmentChangeInfo = Parameters<
NonNullable<UploadProps['onChange']>
>[0];

interface ChatSenderProps extends Omit<SenderProps, 'onChange'> {
interface ChatSenderProps
extends Omit<SenderProps, 'onChange'>,
ChatAttachmentsProps {
loading?: boolean;
autoFocus?: boolean;
items?: Attachment[];
openAttachment?: boolean;
dropContainerRef: React.RefObject<HTMLDivElement | null>;
onInputChange?: (value: string) => void;
onInputSubmit?: () => void;
onInputCancel?: () => void;
Expand Down