From 26bca758843de1ae8519df7d0148da94c53214cf Mon Sep 17 00:00:00 2001 From: StyleZhang Date: Thu, 8 Aug 2024 10:27:21 +0800 Subject: [PATCH] file uploader --- .../chat/chat-with-history/chat-wrapper.tsx | 38 +++++++------- .../base/chat/chat/answer/agent-content.tsx | 2 +- .../base/chat/chat/answer/basic-content.tsx | 13 ++++- .../base/chat/chat/answer/index.tsx | 11 ++-- .../base/chat/chat/chat-input-area/index.tsx | 50 +++++++++++++++---- web/app/components/base/chat/chat/index.tsx | 15 +++++- .../components/base/chat/chat/question.tsx | 7 +-- web/tailwind.config.js | 4 ++ web/themes/dark.css | 3 ++ web/themes/light.css | 3 ++ 10 files changed, 103 insertions(+), 43 deletions(-) diff --git a/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx b/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx index 8eda66c52a..b99555bc44 100644 --- a/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx +++ b/web/app/components/base/chat/chat-with-history/chat-wrapper.tsx @@ -129,23 +129,27 @@ const ChatWrapper = () => { ]) return ( - +
+ +
) } diff --git a/web/app/components/base/chat/chat/answer/agent-content.tsx b/web/app/components/base/chat/chat/answer/agent-content.tsx index 7ac6fcf84e..6f0a603608 100644 --- a/web/app/components/base/chat/chat/answer/agent-content.tsx +++ b/web/app/components/base/chat/chat/answer/agent-content.tsx @@ -36,7 +36,7 @@ const AgentContent: FC = ({ return (
{agent_thoughts?.map((thought, index) => ( -
+
{thought.thought && ( )} diff --git a/web/app/components/base/chat/chat/answer/basic-content.tsx b/web/app/components/base/chat/chat/answer/basic-content.tsx index d438610f68..a9ca3e8630 100644 --- a/web/app/components/base/chat/chat/answer/basic-content.tsx +++ b/web/app/components/base/chat/chat/answer/basic-content.tsx @@ -2,6 +2,7 @@ import type { FC } from 'react' import { memo } from 'react' import type { ChatItem } from '../../types' import { Markdown } from '@/app/components/base/markdown' +import cn from '@/utils/classnames' type BasicContentProps = { item: ChatItem @@ -15,9 +16,17 @@ const BasicContent: FC = ({ } = item if (annotation?.logAnnotation) - return + return - return + return ( + + ) } export default memo(BasicContent) diff --git a/web/app/components/base/chat/chat/answer/index.tsx b/web/app/components/base/chat/chat/answer/index.tsx index 78a0842595..49491efc3d 100644 --- a/web/app/components/base/chat/chat/answer/index.tsx +++ b/web/app/components/base/chat/chat/answer/index.tsx @@ -15,13 +15,13 @@ import BasicContent from './basic-content' import SuggestedQuestions from './suggested-questions' import More from './more' import WorkflowProcess from './workflow-process' -import { AnswerTriangle } from '@/app/components/base/icons/src/vender/solid/general' import { MessageFast } from '@/app/components/base/icons/src/vender/solid/communication' import LoadingAnim from '@/app/components/base/chat/chat/loading-anim' import Citation from '@/app/components/base/chat/chat/citation' import { EditTitle } from '@/app/components/app/annotation/edit-annotation-modal/edit-item' import type { Emoji } from '@/app/components/tools/types' import type { AppData } from '@/models/share' +import cn from '@/utils/classnames' type AnswerProps = { item: ChatItem @@ -105,13 +105,12 @@ const Answer: FC = ({
-
{annotation?.id && (
{ + if (onSend) { + if (!query || !query.trim()) { + notify({ type: 'info', message: t('appAnnotation.errorMessage.queryRequired') }) + return + } + onSend(query) + setQuery('') + } + } + + const handleKeyUp = (e: React.KeyboardEvent) => { + if (e.code === 'Enter') { + e.preventDefault() + // prevent send message when using input method enter + if (!e.shiftKey && !isUseInputMethod.current) + handleSend() + } + } + + const handleKeyDown = (e: React.KeyboardEvent) => { + isUseInputMethod.current = e.nativeEvent.isComposing + if (e.code === 'Enter' && !e.shiftKey) { + setQuery(query.replace(/\n$/, '')) + e.preventDefault() + } + } + const handleShowVoiceInput = useCallback(() => { (Recorder as any).getPermission().then(() => { setShowVoiceInput(true) @@ -63,11 +93,11 @@ const ChatInputArea = ({ return (
-
- +
+ {/* */}
- {value} + {query}