(feat: attach) handle them locally from message input

This commit is contained in:
ManishMadan2882
2025-04-02 15:33:35 +05:30
parent 95e189d1d8
commit 856824316b
4 changed files with 26 additions and 35 deletions

View File

@@ -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>