Skip to content

Commit

Permalink
feat: chatbot
Browse files Browse the repository at this point in the history
  • Loading branch information
crazywoola committed Jun 20, 2024
1 parent b06579e commit 20eeb6d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const ChatWrapper = () => {
appMeta,
handleFeedback,
currentChatInstanceRef,
appData,
} = useChatWithHistoryContext()
const appConfig = useMemo(() => {
const config = appParams || {}
Expand Down Expand Up @@ -128,6 +129,7 @@ const ChatWrapper = () => {

return (
<Chat
appData={appData}
config={appConfig}
chatList={chatList}
isResponding={isResponding}
Expand Down
17 changes: 16 additions & 1 deletion web/app/components/base/chat/chat/answer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import LoadingAnim from '@/app/components/app/chat/loading-anim'
import Citation from '@/app/components/app/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'

type AnswerProps = {
item: ChatItem
Expand All @@ -32,6 +33,7 @@ type AnswerProps = {
showPromptLog?: boolean
chatAnswerContainerInner?: string
hideProcessDetail?: boolean
appData?: AppData
}
const Answer: FC<AnswerProps> = ({
item,
Expand All @@ -44,6 +46,7 @@ const Answer: FC<AnswerProps> = ({
showPromptLog,
chatAnswerContainerInner,
hideProcessDetail,
appData,
}) => {
const { t } = useTranslation()
const {
Expand Down Expand Up @@ -129,8 +132,20 @@ const Answer: FC<AnswerProps> = ({
/>
)
}
{/** Render the normal steps */}
{
workflowProcess && (
workflowProcess && !hideProcessDetail && (
<WorkflowProcess
data={workflowProcess}
item={item}
hideInfo
hideProcessDetail={hideProcessDetail}
/>
)
}
{/** Hide workflow steps by it's settings in siteInfo */}
{
workflowProcess && hideProcessDetail && appData && appData.site.workflow === 'show' && (
<WorkflowProcess
data={workflowProcess}
item={item}
Expand Down
4 changes: 4 additions & 0 deletions web/app/components/base/chat/chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ import { StopCircle } from '@/app/components/base/icons/src/vender/solid/mediaAn
import AgentLogModal from '@/app/components/base/agent-log-modal'
import PromptLogModal from '@/app/components/base/prompt-log-modal'
import { useStore as useAppStore } from '@/app/components/app/store'
import type { AppData } from '@/models/share'

export type ChatProps = {
appData?: AppData
chatList: ChatItem[]
config?: ChatConfig
isResponding?: boolean
Expand All @@ -57,6 +59,7 @@ export type ChatProps = {
hideProcessDetail?: boolean
}
const Chat: FC<ChatProps> = ({
appData,
config,
onSend,
chatList,
Expand Down Expand Up @@ -196,6 +199,7 @@ const Chat: FC<ChatProps> = ({
const isLast = item.id === chatList[chatList.length - 1]?.id
return (
<Answer
appData={appData}
key={item.id}
item={item}
question={chatList[index - 1]?.content}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import LogoAvatar from '@/app/components/base/logo/logo-embeded-chat-avatar'

const ChatWrapper = () => {
const {
appData,
appParams,
appPrevChatList,
currentConversationId,
Expand Down Expand Up @@ -114,6 +115,7 @@ const ChatWrapper = () => {

return (
<Chat
appData={appData}
config={appConfig}
chatList={chatList}
isResponding={isResponding}
Expand Down

0 comments on commit 20eeb6d

Please sign in to comment.