mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 16:43:16 +00:00
(feat: attach) handle them locally from message input
This commit is contained in:
@@ -29,11 +29,6 @@ import { ActiveState } from '../models/misc';
|
||||
import ConversationMessages from './ConversationMessages';
|
||||
import MessageInput from '../components/MessageInput';
|
||||
|
||||
interface AttachmentState {
|
||||
fileName: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export default function Conversation() {
|
||||
const token = useSelector(selectToken);
|
||||
const queries = useSelector(selectQueries);
|
||||
@@ -50,7 +45,6 @@ export default function Conversation() {
|
||||
useState<ActiveState>('INACTIVE');
|
||||
const [files, setFiles] = useState<File[]>([]);
|
||||
const [handleDragActive, setHandleDragActive] = useState<boolean>(false);
|
||||
const [attachments, setAttachments] = useState<AttachmentState[]>([]);
|
||||
|
||||
const onDrop = useCallback((acceptedFiles: File[]) => {
|
||||
setUploadModalState('ACTIVE');
|
||||
@@ -101,13 +95,11 @@ export default function Conversation() {
|
||||
isRetry = false,
|
||||
updated = null,
|
||||
indx = undefined,
|
||||
attachments = [],
|
||||
}: {
|
||||
question: string;
|
||||
isRetry?: boolean;
|
||||
updated?: boolean | null;
|
||||
indx?: number;
|
||||
attachments?: { fileName: string; id: string }[];
|
||||
}) => {
|
||||
if (updated === true) {
|
||||
!isRetry &&
|
||||
@@ -116,11 +108,8 @@ export default function Conversation() {
|
||||
} else {
|
||||
question = question.trim();
|
||||
if (question === '') return;
|
||||
!isRetry && dispatch(addQuery({ prompt: question, attachments }));
|
||||
fetchStream.current = dispatch(fetchAnswer({
|
||||
question,
|
||||
attachments: attachments.map(a => a.id)
|
||||
}));
|
||||
!isRetry && dispatch(addQuery({ prompt: question }));
|
||||
fetchStream.current = dispatch(fetchAnswer({ question }));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -172,10 +161,8 @@ export default function Conversation() {
|
||||
});
|
||||
} else {
|
||||
handleQuestion({
|
||||
question: input,
|
||||
attachments: attachments
|
||||
question: input,
|
||||
});
|
||||
setAttachments([]);
|
||||
}
|
||||
setInput('');
|
||||
}
|
||||
@@ -260,7 +247,6 @@ export default function Conversation() {
|
||||
onChange={(e) => setInput(e.target.value)}
|
||||
onSubmit={handleQuestionSubmission}
|
||||
loading={status === 'loading'}
|
||||
onAttachmentChange={setAttachments}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user