diff --git a/web/src/pages/chat/hooks.ts b/web/src/pages/chat/hooks.ts index 7aef84389..115174f84 100644 --- a/web/src/pages/chat/hooks.ts +++ b/web/src/pages/chat/hooks.ts @@ -552,14 +552,12 @@ export const useSendMessage = ( const { conversationId } = useGetChatSearchParams(); const { handleInputChange, value, setValue } = useHandleMessageInputChange(); - const fetchConversation = useFetchConversation(); - const { handleClickConversation } = useClickConversationCard(); const { send, answer, done } = useSendMessageWithSse(); const sendMessage = useCallback( async (message: string, id?: string) => { - const res: Response = await send({ + const res = await send({ conversation_id: id ?? conversationId, messages: [ ...(conversation?.message ?? []).map((x: IMessage) => omit(x, 'id')), @@ -570,7 +568,12 @@ export const useSendMessage = ( ], }); - if (res.status === 200) { + if (res && (res?.response.status !== 200 || res?.data?.retcode !== 0)) { + // cancel loading + setValue(message); + console.info('removeLatestMessage111'); + removeLatestMessage(); + } else { if (id) { console.info('111'); // new conversation @@ -579,15 +582,7 @@ export const useSendMessage = ( console.info('222'); // fetchConversation(conversationId); } - } else { - console.info('333'); - - // cancel loading - setValue(message); - console.info('removeLatestMessage111'); - removeLatestMessage(); } - console.info('false'); }, [ conversation?.message, diff --git a/web/src/pages/chat/shared-hooks.ts b/web/src/pages/chat/shared-hooks.ts index 92072a3e9..d406ff95d 100644 --- a/web/src/pages/chat/shared-hooks.ts +++ b/web/src/pages/chat/shared-hooks.ts @@ -150,7 +150,7 @@ export const useSendSharedMessage = ( const sendMessage = useCallback( async (message: string, id?: string) => { - const res: Response = await send({ + const res = await send({ conversation_id: id ?? conversationId, quote: false, messages: [ @@ -162,12 +162,7 @@ export const useSendSharedMessage = ( ], }); - if (res?.status === 200) { - // const data = await fetchConversation(conversationId); - // if (data.retcode === 0) { - // setCurrentConversation(data.data); - // } - } else { + if (res && (res?.response.status !== 200 || res?.data?.retcode !== 0)) { // cancel loading setValue(message); removeLatestMessage(); diff --git a/web/src/pages/flow/canvas/node/index.tsx b/web/src/pages/flow/canvas/node/index.tsx index bd501799d..c9c19c6a5 100644 --- a/web/src/pages/flow/canvas/node/index.tsx +++ b/web/src/pages/flow/canvas/node/index.tsx @@ -1,6 +1,9 @@ import classNames from 'classnames'; import { Handle, NodeProps, Position } from 'reactflow'; +import { Space } from 'antd'; +import { Operator } from '../../constant'; +import OperatorIcon from '../../operator-icon'; import styles from './index.less'; export function TextUpdaterNode({ @@ -9,7 +12,7 @@ export function TextUpdaterNode({ selected, }: NodeProps<{ label: string }>) { return ( -
{/* */} -
{data.label}
-
+
+ + + {data.label} + +
+ ); } diff --git a/web/src/pages/flow/chat/hooks.ts b/web/src/pages/flow/chat/hooks.ts index 49027b567..a44d27506 100644 --- a/web/src/pages/flow/chat/hooks.ts +++ b/web/src/pages/flow/chat/hooks.ts @@ -112,7 +112,7 @@ export const useSendMessage = ( } const res = await send(params); - if (res?.response.status !== 200 || res?.data?.retcode !== 0) { + if (res && (res?.response.status !== 200 || res?.data?.retcode !== 0)) { antMessage.error(res?.data?.retmsg); // cancel loading diff --git a/web/src/pages/flow/constant.tsx b/web/src/pages/flow/constant.tsx index ccd42b6c0..5fb0f06ee 100644 --- a/web/src/pages/flow/constant.tsx +++ b/web/src/pages/flow/constant.tsx @@ -2,6 +2,7 @@ import { MergeCellsOutlined, RocketOutlined, SendOutlined, + SlidersOutlined, } from '@ant-design/icons'; export enum Operator { @@ -11,10 +12,26 @@ export enum Operator { Answer = 'Answer', } +export const operatorIconMap = { + [Operator.Retrieval]: RocketOutlined, + [Operator.Generate]: MergeCellsOutlined, + [Operator.Answer]: SendOutlined, + [Operator.Begin]: SlidersOutlined, +}; + export const componentList = [ - { name: Operator.Retrieval, icon: , description: '' }, - { name: Operator.Generate, icon: , description: '' }, - { name: Operator.Answer, icon: , description: '' }, + { + name: Operator.Retrieval, + description: '', + }, + { + name: Operator.Generate, + description: '', + }, + { + name: Operator.Answer, + description: '', + }, ]; export const initialRetrievalValues = { diff --git a/web/src/pages/flow/flow-sider/index.tsx b/web/src/pages/flow/flow-sider/index.tsx index 484196446..29d7b2593 100644 --- a/web/src/pages/flow/flow-sider/index.tsx +++ b/web/src/pages/flow/flow-sider/index.tsx @@ -1,8 +1,9 @@ -import { Avatar, Card, Flex, Layout, Space } from 'antd'; +import { Card, Flex, Layout, Space } from 'antd'; import classNames from 'classnames'; import { componentList } from '../constant'; import { useHandleDrag } from '../hooks'; +import OperatorIcon from '../operator-icon'; import styles from './index.less'; const { Sider } = Layout; @@ -24,25 +25,31 @@ const FlowSide = ({ setCollapsed, collapsed }: IProps) => { onCollapse={(value) => setCollapsed(value)} > - {componentList.map((x) => ( - - - - -
- {x.name} -
{x.description}
-
-
-
-
- ))} + {componentList.map((x) => { + return ( + + + + + {/* } + shape={'square'} + /> */} +
+ {x.name} +
{x.description}
+
+
+
+
+ ); + })}
); diff --git a/web/src/pages/flow/operator-icon/index.less b/web/src/pages/flow/operator-icon/index.less new file mode 100644 index 000000000..b6a992b05 --- /dev/null +++ b/web/src/pages/flow/operator-icon/index.less @@ -0,0 +1,4 @@ +.icon { + color: rgb(59, 118, 244); + font-size: 24px; +} diff --git a/web/src/pages/flow/operator-icon/index.tsx b/web/src/pages/flow/operator-icon/index.tsx new file mode 100644 index 000000000..1a006251c --- /dev/null +++ b/web/src/pages/flow/operator-icon/index.tsx @@ -0,0 +1,16 @@ +import React from 'react'; +import { Operator, operatorIconMap } from '../constant'; + +import styles from './index.less'; + +interface IProps { + name: Operator; + fontSize?: number; +} + +const OperatorIcon = ({ name, fontSize }: IProps) => { + const Icon = operatorIconMap[name] || React.Fragment; + return ; +}; + +export default OperatorIcon;