mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-12 18:19:13 +08:00
### What problem does this PR solve? feat: add icon to graph nodes #918 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
8902d92d0e
commit
ff5ea266d2
@ -552,14 +552,12 @@ export const useSendMessage = (
|
|||||||
const { conversationId } = useGetChatSearchParams();
|
const { conversationId } = useGetChatSearchParams();
|
||||||
const { handleInputChange, value, setValue } = useHandleMessageInputChange();
|
const { handleInputChange, value, setValue } = useHandleMessageInputChange();
|
||||||
|
|
||||||
const fetchConversation = useFetchConversation();
|
|
||||||
|
|
||||||
const { handleClickConversation } = useClickConversationCard();
|
const { handleClickConversation } = useClickConversationCard();
|
||||||
const { send, answer, done } = useSendMessageWithSse();
|
const { send, answer, done } = useSendMessageWithSse();
|
||||||
|
|
||||||
const sendMessage = useCallback(
|
const sendMessage = useCallback(
|
||||||
async (message: string, id?: string) => {
|
async (message: string, id?: string) => {
|
||||||
const res: Response = await send({
|
const res = await send({
|
||||||
conversation_id: id ?? conversationId,
|
conversation_id: id ?? conversationId,
|
||||||
messages: [
|
messages: [
|
||||||
...(conversation?.message ?? []).map((x: IMessage) => omit(x, 'id')),
|
...(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) {
|
if (id) {
|
||||||
console.info('111');
|
console.info('111');
|
||||||
// new conversation
|
// new conversation
|
||||||
@ -579,15 +582,7 @@ export const useSendMessage = (
|
|||||||
console.info('222');
|
console.info('222');
|
||||||
// fetchConversation(conversationId);
|
// fetchConversation(conversationId);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.info('333');
|
|
||||||
|
|
||||||
// cancel loading
|
|
||||||
setValue(message);
|
|
||||||
console.info('removeLatestMessage111');
|
|
||||||
removeLatestMessage();
|
|
||||||
}
|
}
|
||||||
console.info('false');
|
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
conversation?.message,
|
conversation?.message,
|
||||||
|
@ -150,7 +150,7 @@ export const useSendSharedMessage = (
|
|||||||
|
|
||||||
const sendMessage = useCallback(
|
const sendMessage = useCallback(
|
||||||
async (message: string, id?: string) => {
|
async (message: string, id?: string) => {
|
||||||
const res: Response = await send({
|
const res = await send({
|
||||||
conversation_id: id ?? conversationId,
|
conversation_id: id ?? conversationId,
|
||||||
quote: false,
|
quote: false,
|
||||||
messages: [
|
messages: [
|
||||||
@ -162,12 +162,7 @@ export const useSendSharedMessage = (
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res?.status === 200) {
|
if (res && (res?.response.status !== 200 || res?.data?.retcode !== 0)) {
|
||||||
// const data = await fetchConversation(conversationId);
|
|
||||||
// if (data.retcode === 0) {
|
|
||||||
// setCurrentConversation(data.data);
|
|
||||||
// }
|
|
||||||
} else {
|
|
||||||
// cancel loading
|
// cancel loading
|
||||||
setValue(message);
|
setValue(message);
|
||||||
removeLatestMessage();
|
removeLatestMessage();
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { Handle, NodeProps, Position } from 'reactflow';
|
import { Handle, NodeProps, Position } from 'reactflow';
|
||||||
|
|
||||||
|
import { Space } from 'antd';
|
||||||
|
import { Operator } from '../../constant';
|
||||||
|
import OperatorIcon from '../../operator-icon';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
export function TextUpdaterNode({
|
export function TextUpdaterNode({
|
||||||
@ -9,7 +12,7 @@ export function TextUpdaterNode({
|
|||||||
selected,
|
selected,
|
||||||
}: NodeProps<{ label: string }>) {
|
}: NodeProps<{ label: string }>) {
|
||||||
return (
|
return (
|
||||||
<div
|
<section
|
||||||
className={classNames(styles.textUpdaterNode, {
|
className={classNames(styles.textUpdaterNode, {
|
||||||
[styles.selectedNode]: selected,
|
[styles.selectedNode]: selected,
|
||||||
})}
|
})}
|
||||||
@ -30,7 +33,15 @@ export function TextUpdaterNode({
|
|||||||
>
|
>
|
||||||
{/* <PlusCircleOutlined style={{ fontSize: 10 }} /> */}
|
{/* <PlusCircleOutlined style={{ fontSize: 10 }} /> */}
|
||||||
</Handle>
|
</Handle>
|
||||||
<div>{data.label}</div>
|
<div>
|
||||||
</div>
|
<Space>
|
||||||
|
<OperatorIcon
|
||||||
|
name={data.label as Operator}
|
||||||
|
fontSize={12}
|
||||||
|
></OperatorIcon>
|
||||||
|
{data.label}
|
||||||
|
</Space>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ export const useSendMessage = (
|
|||||||
}
|
}
|
||||||
const res = await send(params);
|
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);
|
antMessage.error(res?.data?.retmsg);
|
||||||
|
|
||||||
// cancel loading
|
// cancel loading
|
||||||
|
@ -2,6 +2,7 @@ import {
|
|||||||
MergeCellsOutlined,
|
MergeCellsOutlined,
|
||||||
RocketOutlined,
|
RocketOutlined,
|
||||||
SendOutlined,
|
SendOutlined,
|
||||||
|
SlidersOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
|
|
||||||
export enum Operator {
|
export enum Operator {
|
||||||
@ -11,10 +12,26 @@ export enum Operator {
|
|||||||
Answer = 'Answer',
|
Answer = 'Answer',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const operatorIconMap = {
|
||||||
|
[Operator.Retrieval]: RocketOutlined,
|
||||||
|
[Operator.Generate]: MergeCellsOutlined,
|
||||||
|
[Operator.Answer]: SendOutlined,
|
||||||
|
[Operator.Begin]: SlidersOutlined,
|
||||||
|
};
|
||||||
|
|
||||||
export const componentList = [
|
export const componentList = [
|
||||||
{ name: Operator.Retrieval, icon: <RocketOutlined />, description: '' },
|
{
|
||||||
{ name: Operator.Generate, icon: <MergeCellsOutlined />, description: '' },
|
name: Operator.Retrieval,
|
||||||
{ name: Operator.Answer, icon: <SendOutlined />, description: '' },
|
description: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: Operator.Generate,
|
||||||
|
description: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: Operator.Answer,
|
||||||
|
description: '',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const initialRetrievalValues = {
|
export const initialRetrievalValues = {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import { Avatar, Card, Flex, Layout, Space } from 'antd';
|
import { Card, Flex, Layout, Space } from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import { componentList } from '../constant';
|
import { componentList } from '../constant';
|
||||||
import { useHandleDrag } from '../hooks';
|
import { useHandleDrag } from '../hooks';
|
||||||
|
import OperatorIcon from '../operator-icon';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
const { Sider } = Layout;
|
const { Sider } = Layout;
|
||||||
@ -24,25 +25,31 @@ const FlowSide = ({ setCollapsed, collapsed }: IProps) => {
|
|||||||
onCollapse={(value) => setCollapsed(value)}
|
onCollapse={(value) => setCollapsed(value)}
|
||||||
>
|
>
|
||||||
<Flex vertical gap={10} className={styles.siderContent}>
|
<Flex vertical gap={10} className={styles.siderContent}>
|
||||||
{componentList.map((x) => (
|
{componentList.map((x) => {
|
||||||
<Card
|
return (
|
||||||
key={x.name}
|
<Card
|
||||||
hoverable
|
key={x.name}
|
||||||
draggable
|
hoverable
|
||||||
className={classNames(styles.operatorCard)}
|
draggable
|
||||||
onDragStart={handleDragStart(x.name)}
|
className={classNames(styles.operatorCard)}
|
||||||
>
|
onDragStart={handleDragStart(x.name)}
|
||||||
<Flex justify="space-between" align="center">
|
>
|
||||||
<Space size={15}>
|
<Flex justify="space-between" align="center">
|
||||||
<Avatar icon={x.icon} shape={'square'} />
|
<Space size={15}>
|
||||||
<section>
|
<OperatorIcon name={x.name}></OperatorIcon>
|
||||||
<b>{x.name}</b>
|
{/* <Avatar
|
||||||
<div>{x.description}</div>
|
icon={<OperatorIcon name={x.name}></OperatorIcon>}
|
||||||
</section>
|
shape={'square'}
|
||||||
</Space>
|
/> */}
|
||||||
</Flex>
|
<section>
|
||||||
</Card>
|
<b>{x.name}</b>
|
||||||
))}
|
<div>{x.description}</div>
|
||||||
|
</section>
|
||||||
|
</Space>
|
||||||
|
</Flex>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</Flex>
|
</Flex>
|
||||||
</Sider>
|
</Sider>
|
||||||
);
|
);
|
||||||
|
4
web/src/pages/flow/operator-icon/index.less
Normal file
4
web/src/pages/flow/operator-icon/index.less
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.icon {
|
||||||
|
color: rgb(59, 118, 244);
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
16
web/src/pages/flow/operator-icon/index.tsx
Normal file
16
web/src/pages/flow/operator-icon/index.tsx
Normal file
@ -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 <Icon className={styles.icon} style={{ fontSize }}></Icon>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default OperatorIcon;
|
Loading…
x
Reference in New Issue
Block a user