mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-06-02 09:24:05 +08:00
feat: translate graph and chat text (#1433)
translate graph and chat text
This commit is contained in:
parent
427fb97562
commit
24f9b17ff6
@ -1,3 +1,4 @@
|
|||||||
|
import { useTranslate } from '@/hooks/commonHooks';
|
||||||
import { ResponseType } from '@/interfaces/database/base';
|
import { ResponseType } from '@/interfaces/database/base';
|
||||||
import { DSL, IFlow, IFlowTemplate } from '@/interfaces/database/flow';
|
import { DSL, IFlow, IFlowTemplate } from '@/interfaces/database/flow';
|
||||||
import i18n from '@/locales/config';
|
import i18n from '@/locales/config';
|
||||||
@ -45,6 +46,7 @@ export const EmptyDsl = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const useFetchFlowTemplates = (): ResponseType<IFlowTemplate[]> => {
|
export const useFetchFlowTemplates = (): ResponseType<IFlowTemplate[]> => {
|
||||||
|
const { t } = useTranslate('flow');
|
||||||
const { data } = useQuery({
|
const { data } = useQuery({
|
||||||
queryKey: ['fetchFlowTemplates'],
|
queryKey: ['fetchFlowTemplates'],
|
||||||
initialData: [],
|
initialData: [],
|
||||||
@ -53,8 +55,8 @@ export const useFetchFlowTemplates = (): ResponseType<IFlowTemplate[]> => {
|
|||||||
if (Array.isArray(data?.data)) {
|
if (Array.isArray(data?.data)) {
|
||||||
data.data.unshift({
|
data.data.unshift({
|
||||||
id: uuid(),
|
id: uuid(),
|
||||||
title: 'Blank',
|
title: t('blank'),
|
||||||
description: 'Create from nothing',
|
description: t('createFromNothing'),
|
||||||
dsl: EmptyDsl,
|
dsl: EmptyDsl,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -308,6 +308,7 @@ The above is the content you need to summarize.`,
|
|||||||
ellipse: 'Ellipse',
|
ellipse: 'Ellipse',
|
||||||
},
|
},
|
||||||
chat: {
|
chat: {
|
||||||
|
newConversation: 'New conversation',
|
||||||
createAssistant: 'Create an Assistant',
|
createAssistant: 'Create an Assistant',
|
||||||
assistantSetting: 'Assistant Setting',
|
assistantSetting: 'Assistant Setting',
|
||||||
promptEngine: 'Prompt Engine',
|
promptEngine: 'Prompt Engine',
|
||||||
@ -581,8 +582,18 @@ The above is the content you need to summarize.`,
|
|||||||
promptText: `Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:
|
promptText: `Please summarize the following paragraphs. Be careful with the numbers, do not make things up. Paragraphs as following:
|
||||||
{input}
|
{input}
|
||||||
The above is the content you need to summarize.`,
|
The above is the content you need to summarize.`,
|
||||||
create: 'Create graph',
|
createGraph: 'Create graph',
|
||||||
createFromTemplates: 'Create from templates',
|
createFromTemplates: 'Create from templates',
|
||||||
|
retrieval: 'Retrieval',
|
||||||
|
generate: 'Generate',
|
||||||
|
answer: 'Answer',
|
||||||
|
categorize: 'Categorize',
|
||||||
|
relevant: 'Relevant',
|
||||||
|
rewriteQuestion: 'RewriteQuestion',
|
||||||
|
rewrite: 'Rewrite',
|
||||||
|
Begin: 'Begin',
|
||||||
|
blank: 'Blank',
|
||||||
|
createFromNothing: 'Create from nothing',
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
profile: 'All rights reserved @ React',
|
profile: 'All rights reserved @ React',
|
||||||
|
@ -280,6 +280,7 @@ export default {
|
|||||||
ellipse: '省略',
|
ellipse: '省略',
|
||||||
},
|
},
|
||||||
chat: {
|
chat: {
|
||||||
|
newConversation: '新會話',
|
||||||
createAssistant: '新建助理',
|
createAssistant: '新建助理',
|
||||||
assistantSetting: '助理設置',
|
assistantSetting: '助理設置',
|
||||||
promptEngine: '提示引擎',
|
promptEngine: '提示引擎',
|
||||||
@ -529,6 +530,7 @@ export default {
|
|||||||
run: '運行',
|
run: '運行',
|
||||||
save: '儲存',
|
save: '儲存',
|
||||||
title: '標題:',
|
title: '標題:',
|
||||||
|
|
||||||
beginDescription: '這是流程開始的地方',
|
beginDescription: '這是流程開始的地方',
|
||||||
answerDescription: `該組件用作機器人與人類之間的介面。它接收使用者的輸入並顯示機器人的計算結果。`,
|
answerDescription: `該組件用作機器人與人類之間的介面。它接收使用者的輸入並顯示機器人的計算結果。`,
|
||||||
retrievalDescription: `此元件用於從知識庫中檢索相關資訊。選擇知識庫。如果沒有檢索到任何內容,將傳回「空響應」。`,
|
retrievalDescription: `此元件用於從知識庫中檢索相關資訊。選擇知識庫。如果沒有檢索到任何內容,將傳回「空響應」。`,
|
||||||
@ -544,6 +546,16 @@ export default {
|
|||||||
以上就是你需要總結的內容。`,
|
以上就是你需要總結的內容。`,
|
||||||
createGraph: '建立圖表',
|
createGraph: '建立圖表',
|
||||||
createFromTemplates: '從模板創建',
|
createFromTemplates: '從模板創建',
|
||||||
|
retrieval: '檢索',
|
||||||
|
generate: '產生',
|
||||||
|
answer: '回答',
|
||||||
|
categorize: '分類',
|
||||||
|
relevant: '相關',
|
||||||
|
rewriteQuestion: '重組',
|
||||||
|
rewrite: '重組',
|
||||||
|
begin: '開始',
|
||||||
|
blank: '空',
|
||||||
|
createFromNothing: '從無到有',
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
profile: '“保留所有權利 @ react”',
|
profile: '“保留所有權利 @ react”',
|
||||||
|
@ -297,6 +297,7 @@ export default {
|
|||||||
ellipse: '省略',
|
ellipse: '省略',
|
||||||
},
|
},
|
||||||
chat: {
|
chat: {
|
||||||
|
newConversation: '新会话',
|
||||||
createAssistant: '新建助理',
|
createAssistant: '新建助理',
|
||||||
assistantSetting: '助理设置',
|
assistantSetting: '助理设置',
|
||||||
promptEngine: '提示引擎',
|
promptEngine: '提示引擎',
|
||||||
@ -563,6 +564,16 @@ export default {
|
|||||||
以上就是你需要总结的内容。`,
|
以上就是你需要总结的内容。`,
|
||||||
createGraph: '创建图表',
|
createGraph: '创建图表',
|
||||||
createFromTemplates: '从模板创建',
|
createFromTemplates: '从模板创建',
|
||||||
|
retrieval: '检索',
|
||||||
|
generate: '生成',
|
||||||
|
answer: '回答',
|
||||||
|
categorize: '分类',
|
||||||
|
relevant: '相关',
|
||||||
|
rewriteQuestion: '重组',
|
||||||
|
rewrite: '重组',
|
||||||
|
begin: '开始',
|
||||||
|
blank: '空',
|
||||||
|
createFromNothing: '从无到有',
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
profile: 'All rights reserved @ React',
|
profile: 'All rights reserved @ React',
|
||||||
|
@ -303,14 +303,14 @@ export const useSelectDerivedConversationList = () => {
|
|||||||
const { conversationList, currentDialog } = chatModel;
|
const { conversationList, currentDialog } = chatModel;
|
||||||
const { dialogId } = useGetChatSearchParams();
|
const { dialogId } = useGetChatSearchParams();
|
||||||
const prologue = currentDialog?.prompt_config?.prologue ?? '';
|
const prologue = currentDialog?.prompt_config?.prologue ?? '';
|
||||||
|
const { t } = useTranslate('chat');
|
||||||
const addTemporaryConversation = useCallback(() => {
|
const addTemporaryConversation = useCallback(() => {
|
||||||
setList((pre) => {
|
setList((pre) => {
|
||||||
if (dialogId) {
|
if (dialogId) {
|
||||||
const nextList = [
|
const nextList = [
|
||||||
{
|
{
|
||||||
id: '',
|
id: '',
|
||||||
name: 'New conversation',
|
name: t('newConversation'),
|
||||||
dialog_id: dialogId,
|
dialog_id: dialogId,
|
||||||
message: [
|
message: [
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
|
import { useTranslate } from '@/hooks/commonHooks';
|
||||||
import { Flex } from 'antd';
|
import { Flex } from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import lowerFirst from 'lodash/lowerFirst';
|
||||||
import { Handle, NodeProps, Position } from 'reactflow';
|
import { Handle, NodeProps, Position } from 'reactflow';
|
||||||
import { Operator, operatorMap } from '../../constant';
|
import { Operator, operatorMap } from '../../constant';
|
||||||
import { NodeData } from '../../interface';
|
import { NodeData } from '../../interface';
|
||||||
|
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
// TODO: do not allow other nodes to connect to this node
|
// TODO: do not allow other nodes to connect to this node
|
||||||
export function BeginNode({ id, data, selected }: NodeProps<NodeData>) {
|
export function BeginNode({ id, data, selected }: NodeProps<NodeData>) {
|
||||||
|
const { t } = useTranslate('flow');
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
className={classNames(styles.ragNode, {
|
className={classNames(styles.ragNode, {
|
||||||
@ -27,7 +29,7 @@ export function BeginNode({ id, data, selected }: NodeProps<NodeData>) {
|
|||||||
className={styles.handle}
|
className={styles.handle}
|
||||||
></Handle>
|
></Handle>
|
||||||
<Flex vertical align="center" justify="center" gap={6}>
|
<Flex vertical align="center" justify="center" gap={6}>
|
||||||
<span className={styles.type}>{data.label}</span>
|
<span className={styles.type}>{t(lowerFirst(data.label))}</span>
|
||||||
</Flex>
|
</Flex>
|
||||||
<section className={styles.bottomBox}>
|
<section className={styles.bottomBox}>
|
||||||
<div className={styles.nodeName}>{data.name}</div>
|
<div className={styles.nodeName}>{data.name}</div>
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import { Handle, Position } from 'reactflow';
|
import { Handle, Position } from 'reactflow';
|
||||||
// import { v4 as uuid } from 'uuid';
|
// import { v4 as uuid } from 'uuid';
|
||||||
|
|
||||||
|
import { useTranslate } from '@/hooks/commonHooks';
|
||||||
|
import lowerFirst from 'lodash/lowerFirst';
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
const DEFAULT_HANDLE_STYLE = {
|
const DEFAULT_HANDLE_STYLE = {
|
||||||
@ -18,6 +20,7 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CategorizeHandle = ({ top, right, text, idx }: IProps) => {
|
const CategorizeHandle = ({ top, right, text, idx }: IProps) => {
|
||||||
|
const { t } = useTranslate('flow');
|
||||||
return (
|
return (
|
||||||
<Handle
|
<Handle
|
||||||
type="source"
|
type="source"
|
||||||
@ -33,7 +36,9 @@ const CategorizeHandle = ({ top, right, text, idx }: IProps) => {
|
|||||||
color: 'black',
|
color: 'black',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span className={styles.categorizeAnchorPointText}>{text}</span>
|
<span className={styles.categorizeAnchorPointText}>
|
||||||
|
{lowerFirst(t(text))}
|
||||||
|
</span>
|
||||||
</Handle>
|
</Handle>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
import { useTranslate } from '@/hooks/commonHooks';
|
||||||
import { Flex } from 'antd';
|
import { Flex } from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
|
import lowerFirst from 'lodash/lowerFirst';
|
||||||
import { Handle, NodeProps, Position } from 'reactflow';
|
import { Handle, NodeProps, Position } from 'reactflow';
|
||||||
import {
|
import {
|
||||||
CategorizeAnchorPointPositions,
|
CategorizeAnchorPointPositions,
|
||||||
@ -11,13 +13,12 @@ import { NodeData } from '../../interface';
|
|||||||
import OperatorIcon from '../../operator-icon';
|
import OperatorIcon from '../../operator-icon';
|
||||||
import CategorizeHandle from './categorize-handle';
|
import CategorizeHandle from './categorize-handle';
|
||||||
import NodeDropdown from './dropdown';
|
import NodeDropdown from './dropdown';
|
||||||
|
|
||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
|
|
||||||
export function CategorizeNode({ id, data, selected }: NodeProps<NodeData>) {
|
export function CategorizeNode({ id, data, selected }: NodeProps<NodeData>) {
|
||||||
const categoryData = get(data, 'form.category_description') ?? {};
|
const categoryData = get(data, 'form.category_description') ?? {};
|
||||||
const style = operatorMap[data.label as Operator];
|
const style = operatorMap[data.label as Operator];
|
||||||
|
const { t } = useTranslate('flow');
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
className={classNames(styles.ragNode, {
|
className={classNames(styles.ragNode, {
|
||||||
@ -66,7 +67,7 @@ export function CategorizeNode({ id, data, selected }: NodeProps<NodeData>) {
|
|||||||
name={data.label as Operator}
|
name={data.label as Operator}
|
||||||
fontSize={24}
|
fontSize={24}
|
||||||
></OperatorIcon>
|
></OperatorIcon>
|
||||||
<span className={styles.type}>{data.label}</span>
|
<span className={styles.type}>{t(lowerFirst(data.label))}</span>
|
||||||
<NodeDropdown id={id}></NodeDropdown>
|
<NodeDropdown id={id}></NodeDropdown>
|
||||||
</Flex>
|
</Flex>
|
||||||
<section className={styles.bottomBox}>
|
<section className={styles.bottomBox}>
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
import { useTranslate } from '@/hooks/commonHooks';
|
||||||
import { Flex } from 'antd';
|
import { Flex } from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import lowerFirst from 'lodash/lowerFirst';
|
||||||
import pick from 'lodash/pick';
|
import pick from 'lodash/pick';
|
||||||
import { Handle, NodeProps, Position } from 'reactflow';
|
import { Handle, NodeProps, Position } from 'reactflow';
|
||||||
import { Operator, operatorMap } from '../../constant';
|
import { Operator, operatorMap } from '../../constant';
|
||||||
@ -15,7 +17,7 @@ export function RagNode({
|
|||||||
selected,
|
selected,
|
||||||
}: NodeProps<NodeData>) {
|
}: NodeProps<NodeData>) {
|
||||||
const style = operatorMap[data.label as Operator];
|
const style = operatorMap[data.label as Operator];
|
||||||
|
const { t } = useTranslate('flow');
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
className={classNames(styles.ragNode, {
|
className={classNames(styles.ragNode, {
|
||||||
@ -53,7 +55,9 @@ export function RagNode({
|
|||||||
className={styles.type}
|
className={styles.type}
|
||||||
style={{ fontSize: style.fontSize ?? 14 }}
|
style={{ fontSize: style.fontSize ?? 14 }}
|
||||||
>
|
>
|
||||||
{data.label === Operator.RewriteQuestion ? 'Rewrite' : data.label}
|
{data.label === Operator.RewriteQuestion
|
||||||
|
? t(lowerFirst('Rewrite'))
|
||||||
|
: t(lowerFirst(data.label))}
|
||||||
</span>
|
</span>
|
||||||
<NodeDropdown id={id}></NodeDropdown>
|
<NodeDropdown id={id}></NodeDropdown>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
import { useTranslate } from '@/hooks/commonHooks';
|
||||||
import { Flex } from 'antd';
|
import { Flex } from 'antd';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import lowerFirst from 'lodash/lowerFirst';
|
||||||
import pick from 'lodash/pick';
|
import pick from 'lodash/pick';
|
||||||
import { Handle, NodeProps, Position } from 'reactflow';
|
import { Handle, NodeProps, Position } from 'reactflow';
|
||||||
import { Operator, operatorMap } from '../../constant';
|
import { Operator, operatorMap } from '../../constant';
|
||||||
@ -12,7 +14,7 @@ import styles from './index.less';
|
|||||||
|
|
||||||
export function RelevantNode({ id, data, selected }: NodeProps<NodeData>) {
|
export function RelevantNode({ id, data, selected }: NodeProps<NodeData>) {
|
||||||
const style = operatorMap[data.label as Operator];
|
const style = operatorMap[data.label as Operator];
|
||||||
|
const { t } = useTranslate('flow');
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
className={classNames(styles.ragNode, {
|
className={classNames(styles.ragNode, {
|
||||||
@ -52,7 +54,7 @@ export function RelevantNode({ id, data, selected }: NodeProps<NodeData>) {
|
|||||||
className={styles.type}
|
className={styles.type}
|
||||||
style={{ fontSize: style.fontSize ?? 14 }}
|
style={{ fontSize: style.fontSize ?? 14 }}
|
||||||
>
|
>
|
||||||
{data.label}
|
{t(lowerFirst(data.label))}
|
||||||
</span>
|
</span>
|
||||||
<NodeDropdown id={id}></NodeDropdown>
|
<NodeDropdown id={id}></NodeDropdown>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
@ -53,7 +53,7 @@ const FlowSide = ({ setCollapsed, collapsed }: IProps) => {
|
|||||||
<OperatorIcon name={x.name}></OperatorIcon>
|
<OperatorIcon name={x.name}></OperatorIcon>
|
||||||
<section>
|
<section>
|
||||||
<Tooltip title={t(`${lowerFirst(x.name)}Description`)}>
|
<Tooltip title={t(`${lowerFirst(x.name)}Description`)}>
|
||||||
<b>{x.name}</b>
|
<b>{t(lowerFirst(x.name))}</b>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</section>
|
</section>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
@ -27,7 +27,7 @@ const FlowList = () => {
|
|||||||
icon={<PlusOutlined />}
|
icon={<PlusOutlined />}
|
||||||
onClick={showFlowSettingModal}
|
onClick={showFlowSettingModal}
|
||||||
>
|
>
|
||||||
{t('create')}
|
{t('createGraph')}
|
||||||
</Button>
|
</Button>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Spin spinning={loading}>
|
<Spin spinning={loading}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user