### What problem does this PR solve? Feat: Run eslint when the project is running to standardize everyone's code #9377 ### Type of change - [x] New Feature (non-breaking change which adds functionality)tags/v0.20.2
| // .eslintrc.js | // .eslintrc.js | ||||
| module.exports = { | module.exports = { | ||||
| // Umi 项目 | |||||
| extends: [require.resolve('umi/eslint'), 'plugin:react-hooks/recommended'], | extends: [require.resolve('umi/eslint'), 'plugin:react-hooks/recommended'], | ||||
| plugins: ['check-file'], | |||||
| rules: { | |||||
| '@typescript-eslint/no-use-before-define': [ | |||||
| 'warn', | |||||
| { | |||||
| functions: false, | |||||
| variables: true, | |||||
| }, | |||||
| ], | |||||
| 'check-file/filename-naming-convention': [ | |||||
| 'error', | |||||
| { | |||||
| '**/*.{jsx,tsx}': 'KEBAB_CASE', | |||||
| '**/*.{js,ts}': 'KEBAB_CASE', | |||||
| }, | |||||
| ], | |||||
| 'check-file/folder-naming-convention': [ | |||||
| 'error', | |||||
| { | |||||
| 'src/**/': 'KEBAB_CASE', | |||||
| 'mocks/*/': 'KEBAB_CASE', | |||||
| }, | |||||
| ], | |||||
| 'react/no-unescaped-entities': [ | |||||
| 'warn', | |||||
| { | |||||
| forbid: [ | |||||
| { | |||||
| char: "'", | |||||
| alternatives: [''', '''], | |||||
| }, | |||||
| { | |||||
| char: '"', | |||||
| alternatives: ['"', '"'], | |||||
| }, | |||||
| ], | |||||
| }, | |||||
| ], | |||||
| }, | |||||
| }; | }; |
| import { defineConfig } from 'umi'; | import { defineConfig } from 'umi'; | ||||
| import { appName } from './src/conf.json'; | import { appName } from './src/conf.json'; | ||||
| import routes from './src/routes'; | import routes from './src/routes'; | ||||
| const ESLintPlugin = require('eslint-webpack-plugin'); | |||||
| export default defineConfig({ | export default defineConfig({ | ||||
| title: appName, | title: appName, | ||||
| memo.optimization.minimizer('terser').use(TerserPlugin); // Fixed the issue that the page displayed an error after packaging lexical with terser | memo.optimization.minimizer('terser').use(TerserPlugin); // Fixed the issue that the page displayed an error after packaging lexical with terser | ||||
| memo.plugin('eslint').use(ESLintPlugin, [ | |||||
| { | |||||
| extensions: ['js', 'ts', 'tsx'], | |||||
| failOnError: true, | |||||
| exclude: ['**/node_modules/**', '**/mfsu**', '**/mfsu-virtual-entry**'], | |||||
| files: ['src/**/*.{js,ts,tsx}'], | |||||
| }, | |||||
| ]); | |||||
| return memo; | return memo; | ||||
| }, | }, | ||||
| tailwindcss: {}, | tailwindcss: {}, |
| "@umijs/plugins": "^4.1.0", | "@umijs/plugins": "^4.1.0", | ||||
| "@welldone-software/why-did-you-render": "^8.0.3", | "@welldone-software/why-did-you-render": "^8.0.3", | ||||
| "cross-env": "^7.0.3", | "cross-env": "^7.0.3", | ||||
| "eslint-plugin-check-file": "^2.8.0", | |||||
| "eslint-webpack-plugin": "^4.1.0", | |||||
| "html-loader": "^5.1.0", | "html-loader": "^5.1.0", | ||||
| "husky": "^9.0.11", | "husky": "^9.0.11", | ||||
| "jest": "^29.7.0", | "jest": "^29.7.0", | ||||
| } | } | ||||
| }, | }, | ||||
| "node_modules/@types/eslint": { | "node_modules/@types/eslint": { | ||||
| "version": "8.56.1", | |||||
| "resolved": "https://registry.npmmirror.com/@types/eslint/-/eslint-8.56.1.tgz", | |||||
| "integrity": "sha512-18PLWRzhy9glDQp3+wOgfLYRWlhgX0azxgJ63rdpoUHyrC9z0f5CkFburjQx4uD7ZCruw85ZtMt6K+L+R8fLJQ==", | |||||
| "version": "9.6.1", | |||||
| "resolved": "https://registry.npmmirror.com/@types/eslint/-/eslint-9.6.1.tgz", | |||||
| "integrity": "sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==", | |||||
| "license": "MIT", | |||||
| "peer": true, | "peer": true, | ||||
| "dependencies": { | "dependencies": { | ||||
| "@types/estree": "*", | "@types/estree": "*", | ||||
| "node": "^12.22.0 || ^14.17.0 || >=16.0.0" | "node": "^12.22.0 || ^14.17.0 || >=16.0.0" | ||||
| } | } | ||||
| }, | }, | ||||
| "node_modules/eslint-plugin-check-file": { | |||||
| "version": "2.8.0", | |||||
| "resolved": "https://registry.npmmirror.com/eslint-plugin-check-file/-/eslint-plugin-check-file-2.8.0.tgz", | |||||
| "integrity": "sha512-FvvafMTam2WJYH9uj+FuMxQ1y+7jY3Z6P9T4j2214cH0FBxNzTcmeCiGTj1Lxp3mI6kbbgsXvmgewvf+llKYyw==", | |||||
| "dev": true, | |||||
| "license": "Apache-2.0", | |||||
| "dependencies": { | |||||
| "is-glob": "^4.0.3", | |||||
| "micromatch": "^4.0.5" | |||||
| }, | |||||
| "engines": { | |||||
| "node": ">=18" | |||||
| }, | |||||
| "funding": { | |||||
| "type": "ko_fi", | |||||
| "url": "https://ko-fi.com/huanluo" | |||||
| }, | |||||
| "peerDependencies": { | |||||
| "eslint": ">=7.28.0" | |||||
| } | |||||
| }, | |||||
| "node_modules/eslint-plugin-jest": { | "node_modules/eslint-plugin-jest": { | ||||
| "version": "27.2.3", | "version": "27.2.3", | ||||
| "resolved": "https://registry.npmmirror.com/eslint-plugin-jest/-/eslint-plugin-jest-27.2.3.tgz", | "resolved": "https://registry.npmmirror.com/eslint-plugin-jest/-/eslint-plugin-jest-27.2.3.tgz", | ||||
| "node": ">=10" | "node": ">=10" | ||||
| } | } | ||||
| }, | }, | ||||
| "node_modules/eslint-webpack-plugin": { | |||||
| "version": "4.1.0", | |||||
| "resolved": "https://registry.npmmirror.com/eslint-webpack-plugin/-/eslint-webpack-plugin-4.1.0.tgz", | |||||
| "integrity": "sha512-C3wAG2jyockIhN0YRLuKieKj2nx/gnE/VHmoHemD5ifnAtY6ZU+jNPfzPoX4Zd6RIbUyWTiZUh/ofUlBhoAX7w==", | |||||
| "dev": true, | |||||
| "license": "MIT", | |||||
| "dependencies": { | |||||
| "@types/eslint": "^8.56.5", | |||||
| "jest-worker": "^29.7.0", | |||||
| "micromatch": "^4.0.5", | |||||
| "normalize-path": "^3.0.0", | |||||
| "schema-utils": "^4.2.0" | |||||
| }, | |||||
| "engines": { | |||||
| "node": ">= 14.15.0" | |||||
| }, | |||||
| "funding": { | |||||
| "type": "opencollective", | |||||
| "url": "https://opencollective.com/webpack" | |||||
| }, | |||||
| "peerDependencies": { | |||||
| "eslint": "^8.0.0", | |||||
| "webpack": "^5.0.0" | |||||
| } | |||||
| }, | |||||
| "node_modules/eslint-webpack-plugin/node_modules/@types/eslint": { | |||||
| "version": "8.56.12", | |||||
| "resolved": "https://registry.npmmirror.com/@types/eslint/-/eslint-8.56.12.tgz", | |||||
| "integrity": "sha512-03ruubjWyOHlmljCVoxSuNDdmfZDzsrrz0P2LeJsOXr+ZwFQ+0yQIwNCwt/GYhV7Z31fgtXJTAEs+FYlEL851g==", | |||||
| "dev": true, | |||||
| "license": "MIT", | |||||
| "dependencies": { | |||||
| "@types/estree": "*", | |||||
| "@types/json-schema": "*" | |||||
| } | |||||
| }, | |||||
| "node_modules/eslint-webpack-plugin/node_modules/ajv": { | |||||
| "version": "8.17.1", | |||||
| "resolved": "https://registry.npmmirror.com/ajv/-/ajv-8.17.1.tgz", | |||||
| "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", | |||||
| "dev": true, | |||||
| "license": "MIT", | |||||
| "dependencies": { | |||||
| "fast-deep-equal": "^3.1.3", | |||||
| "fast-uri": "^3.0.1", | |||||
| "json-schema-traverse": "^1.0.0", | |||||
| "require-from-string": "^2.0.2" | |||||
| }, | |||||
| "funding": { | |||||
| "type": "github", | |||||
| "url": "https://github.com/sponsors/epoberezkin" | |||||
| } | |||||
| }, | |||||
| "node_modules/eslint-webpack-plugin/node_modules/ajv-keywords": { | |||||
| "version": "5.1.0", | |||||
| "resolved": "https://registry.npmmirror.com/ajv-keywords/-/ajv-keywords-5.1.0.tgz", | |||||
| "integrity": "sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw==", | |||||
| "dev": true, | |||||
| "license": "MIT", | |||||
| "dependencies": { | |||||
| "fast-deep-equal": "^3.1.3" | |||||
| }, | |||||
| "peerDependencies": { | |||||
| "ajv": "^8.8.2" | |||||
| } | |||||
| }, | |||||
| "node_modules/eslint-webpack-plugin/node_modules/has-flag": { | |||||
| "version": "4.0.0", | |||||
| "resolved": "https://registry.npmmirror.com/has-flag/-/has-flag-4.0.0.tgz", | |||||
| "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", | |||||
| "dev": true, | |||||
| "license": "MIT", | |||||
| "engines": { | |||||
| "node": ">=8" | |||||
| } | |||||
| }, | |||||
| "node_modules/eslint-webpack-plugin/node_modules/jest-worker": { | |||||
| "version": "29.7.0", | |||||
| "resolved": "https://registry.npmmirror.com/jest-worker/-/jest-worker-29.7.0.tgz", | |||||
| "integrity": "sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==", | |||||
| "dev": true, | |||||
| "license": "MIT", | |||||
| "dependencies": { | |||||
| "@types/node": "*", | |||||
| "jest-util": "^29.7.0", | |||||
| "merge-stream": "^2.0.0", | |||||
| "supports-color": "^8.0.0" | |||||
| }, | |||||
| "engines": { | |||||
| "node": "^14.15.0 || ^16.10.0 || >=18.0.0" | |||||
| } | |||||
| }, | |||||
| "node_modules/eslint-webpack-plugin/node_modules/json-schema-traverse": { | |||||
| "version": "1.0.0", | |||||
| "resolved": "https://registry.npmmirror.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", | |||||
| "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", | |||||
| "dev": true, | |||||
| "license": "MIT" | |||||
| }, | |||||
| "node_modules/eslint-webpack-plugin/node_modules/schema-utils": { | |||||
| "version": "4.3.2", | |||||
| "resolved": "https://registry.npmmirror.com/schema-utils/-/schema-utils-4.3.2.tgz", | |||||
| "integrity": "sha512-Gn/JaSk/Mt9gYubxTtSn/QCV4em9mpAPiR1rqy/Ocu19u/G9J5WWdNoUT4SiV6mFC3y6cxyFcFwdzPM3FgxGAQ==", | |||||
| "dev": true, | |||||
| "license": "MIT", | |||||
| "dependencies": { | |||||
| "@types/json-schema": "^7.0.9", | |||||
| "ajv": "^8.9.0", | |||||
| "ajv-formats": "^2.1.1", | |||||
| "ajv-keywords": "^5.1.0" | |||||
| }, | |||||
| "engines": { | |||||
| "node": ">= 10.13.0" | |||||
| }, | |||||
| "funding": { | |||||
| "type": "opencollective", | |||||
| "url": "https://opencollective.com/webpack" | |||||
| } | |||||
| }, | |||||
| "node_modules/eslint-webpack-plugin/node_modules/supports-color": { | |||||
| "version": "8.1.1", | |||||
| "resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-8.1.1.tgz", | |||||
| "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", | |||||
| "dev": true, | |||||
| "license": "MIT", | |||||
| "dependencies": { | |||||
| "has-flag": "^4.0.0" | |||||
| }, | |||||
| "engines": { | |||||
| "node": ">=10" | |||||
| }, | |||||
| "funding": { | |||||
| "url": "https://github.com/chalk/supports-color?sponsor=1" | |||||
| } | |||||
| }, | |||||
| "node_modules/eslint/node_modules/ansi-styles": { | "node_modules/eslint/node_modules/ansi-styles": { | ||||
| "version": "4.3.0", | "version": "4.3.0", | ||||
| "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz", | "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz", | ||||
| } | } | ||||
| }, | }, | ||||
| "node_modules/flatted": { | "node_modules/flatted": { | ||||
| "version": "3.2.9", | |||||
| "resolved": "https://registry.npmmirror.com/flatted/-/flatted-3.2.9.tgz", | |||||
| "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==", | |||||
| "version": "3.3.3", | |||||
| "resolved": "https://registry.npmmirror.com/flatted/-/flatted-3.3.3.tgz", | |||||
| "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", | |||||
| "license": "ISC", | |||||
| "peer": true | "peer": true | ||||
| }, | }, | ||||
| "node_modules/flatten": { | "node_modules/flatten": { | ||||
| "integrity": "sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==" | "integrity": "sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==" | ||||
| }, | }, | ||||
| "node_modules/micromatch": { | "node_modules/micromatch": { | ||||
| "version": "4.0.7", | |||||
| "resolved": "https://registry.npmmirror.com/micromatch/-/micromatch-4.0.7.tgz", | |||||
| "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", | |||||
| "version": "4.0.8", | |||||
| "resolved": "https://registry.npmmirror.com/micromatch/-/micromatch-4.0.8.tgz", | |||||
| "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", | |||||
| "license": "MIT", | |||||
| "dependencies": { | "dependencies": { | ||||
| "braces": "^3.0.3", | "braces": "^3.0.3", | ||||
| "picomatch": "^2.3.1" | "picomatch": "^2.3.1" |
| "@umijs/plugins": "^4.1.0", | "@umijs/plugins": "^4.1.0", | ||||
| "@welldone-software/why-did-you-render": "^8.0.3", | "@welldone-software/why-did-you-render": "^8.0.3", | ||||
| "cross-env": "^7.0.3", | "cross-env": "^7.0.3", | ||||
| "eslint-plugin-check-file": "^2.8.0", | |||||
| "eslint-webpack-plugin": "^4.1.0", | |||||
| "html-loader": "^5.1.0", | "html-loader": "^5.1.0", | ||||
| "husky": "^9.0.11", | "husky": "^9.0.11", | ||||
| "jest": "^29.7.0", | "jest": "^29.7.0", |
| hideModal, | hideModal, | ||||
| onOk, | onOk, | ||||
| parserId, | parserId, | ||||
| documentId, | |||||
| documentExtension, | documentExtension, | ||||
| visible, | visible, | ||||
| parserConfig, | parserConfig, |
| import { Form, FormInstance, Input, InputRef, Typography } from 'antd'; | import { Form, FormInstance, Input, InputRef, Typography } from 'antd'; | ||||
| import { omit } from 'lodash'; | |||||
| import React, { useContext, useEffect, useRef, useState } from 'react'; | import React, { useContext, useEffect, useRef, useState } from 'react'; | ||||
| const EditableContext = React.createContext<FormInstance<any> | null>(null); | const EditableContext = React.createContext<FormInstance<any> | null>(null); | ||||
| address: string; | address: string; | ||||
| } | } | ||||
| export const EditableRow: React.FC<EditableRowProps> = ({ | |||||
| index, | |||||
| ...props | |||||
| }) => { | |||||
| export const EditableRow: React.FC<EditableRowProps> = ({ ...props }) => { | |||||
| const [form] = Form.useForm(); | const [form] = Form.useForm(); | ||||
| return ( | return ( | ||||
| <Form form={form} component={false}> | <Form form={form} component={false}> | ||||
| <EditableContext.Provider value={form}> | <EditableContext.Provider value={form}> | ||||
| <tr {...props} /> | |||||
| <tr {...omit(props, 'index')} /> | |||||
| </EditableContext.Provider> | </EditableContext.Provider> | ||||
| </Form> | </Form> | ||||
| ); | ); |
| components={ | components={ | ||||
| { | { | ||||
| code(props: any) { | code(props: any) { | ||||
| const { children, className, node, ...rest } = props; | |||||
| const { children, className, ...rest } = props; | |||||
| const match = /language-(\w+)/.exec(className || ''); | const match = /language-(\w+)/.exec(className || ''); | ||||
| return match ? ( | return match ? ( | ||||
| <SyntaxHighlighter | <SyntaxHighlighter |
| import { PromptIcon } from '@/assets/icon/Icon'; | |||||
| import { PromptIcon } from '@/assets/icon/next-icon'; | |||||
| import CopyToClipboard from '@/components/copy-to-clipboard'; | import CopyToClipboard from '@/components/copy-to-clipboard'; | ||||
| import { useSetModalState } from '@/hooks/common-hooks'; | import { useSetModalState } from '@/hooks/common-hooks'; | ||||
| import { IRemoveMessageById } from '@/hooks/logic-hooks'; | import { IRemoveMessageById } from '@/hooks/logic-hooks'; |
| import { cn } from '@/lib/utils'; | import { cn } from '@/lib/utils'; | ||||
| import { currentReg, replaceTextByOldReg } from '@/pages/chat/utils'; | import { currentReg, replaceTextByOldReg } from '@/pages/chat/utils'; | ||||
| import classNames from 'classnames'; | import classNames from 'classnames'; | ||||
| import { omit } from 'lodash'; | |||||
| import { pipe } from 'lodash/fp'; | import { pipe } from 'lodash/fp'; | ||||
| import { CircleAlert } from 'lucide-react'; | import { CircleAlert } from 'lucide-react'; | ||||
| import { Button } from '../ui/button'; | import { Button } from '../ui/button'; | ||||
| 'custom-typography': ({ children }: { children: string }) => | 'custom-typography': ({ children }: { children: string }) => | ||||
| renderReference(children), | renderReference(children), | ||||
| code(props: any) { | code(props: any) { | ||||
| const { children, className, node, ...rest } = props; | |||||
| const { children, className, ...rest } = props; | |||||
| const restProps = omit(rest, 'node'); | |||||
| const match = /language-(\w+)/.exec(className || ''); | const match = /language-(\w+)/.exec(className || ''); | ||||
| return match ? ( | return match ? ( | ||||
| <SyntaxHighlighter | <SyntaxHighlighter | ||||
| {...rest} | |||||
| {...restProps} | |||||
| PreTag="div" | PreTag="div" | ||||
| language={match[1]} | language={match[1]} | ||||
| wrapLongLines | wrapLongLines | ||||
| {String(children).replace(/\n$/, '')} | {String(children).replace(/\n$/, '')} | ||||
| </SyntaxHighlighter> | </SyntaxHighlighter> | ||||
| ) : ( | ) : ( | ||||
| <code {...rest} className={classNames(className, 'text-wrap')}> | |||||
| <code | |||||
| {...restProps} | |||||
| className={classNames(className, 'text-wrap')} | |||||
| > | |||||
| {children} | {children} | ||||
| </code> | </code> | ||||
| ); | ); |
| import { PromptIcon } from '@/assets/icon/Icon'; | |||||
| import { PromptIcon } from '@/assets/icon/next-icon'; | |||||
| import CopyToClipboard from '@/components/copy-to-clipboard'; | import CopyToClipboard from '@/components/copy-to-clipboard'; | ||||
| import { useSetModalState } from '@/hooks/common-hooks'; | import { useSetModalState } from '@/hooks/common-hooks'; | ||||
| import { IRemoveMessageById } from '@/hooks/logic-hooks'; | import { IRemoveMessageById } from '@/hooks/logic-hooks'; |
| import { INodeEvent, MessageEventType } from '@/hooks/use-send-message'; | import { INodeEvent, MessageEventType } from '@/hooks/use-send-message'; | ||||
| import { cn } from '@/lib/utils'; | import { cn } from '@/lib/utils'; | ||||
| import { AgentChatContext } from '@/pages/agent/context'; | import { AgentChatContext } from '@/pages/agent/context'; | ||||
| import { WorkFlowTimeline } from '@/pages/agent/log-sheet/workFlowTimeline'; | |||||
| import { WorkFlowTimeline } from '@/pages/agent/log-sheet/workflow-timeline'; | |||||
| import { IMessage } from '@/pages/chat/interface'; | import { IMessage } from '@/pages/chat/interface'; | ||||
| import { isEmpty } from 'lodash'; | import { isEmpty } from 'lodash'; | ||||
| import { Atom, ChevronDown, ChevronUp } from 'lucide-react'; | import { Atom, ChevronDown, ChevronUp } from 'lucide-react'; |
| } | } | ||||
| function TimelineIndicator({ | function TimelineIndicator({ | ||||
| asChild = false, | |||||
| // asChild = false, | |||||
| className, | className, | ||||
| children, | children, | ||||
| ...props | ...props |
| import { Input } from '@/components/originui/input'; | import { Input } from '@/components/originui/input'; | ||||
| import { useTranslate } from '@/hooks/common-hooks'; | |||||
| import { EyeIcon, EyeOffIcon } from 'lucide-react'; | import { EyeIcon, EyeOffIcon } from 'lucide-react'; | ||||
| import { ChangeEvent, LegacyRef, forwardRef, useId, useState } from 'react'; | |||||
| import { ChangeEvent, forwardRef, useId, useState } from 'react'; | |||||
| type PropType = { | type PropType = { | ||||
| name: string; | name: string; | ||||
| onChange: (event: ChangeEvent<HTMLInputElement>) => void; | onChange: (event: ChangeEvent<HTMLInputElement>) => void; | ||||
| }; | }; | ||||
| function PasswordInput( | |||||
| props: PropType, | |||||
| ref: LegacyRef<HTMLInputElement> | undefined, | |||||
| ) { | |||||
| function PasswordInput(props: PropType) { | |||||
| const id = useId(); | const id = useId(); | ||||
| const [isVisible, setIsVisible] = useState<boolean>(false); | const [isVisible, setIsVisible] = useState<boolean>(false); | ||||
| const toggleVisibility = () => setIsVisible((prevState) => !prevState); | const toggleVisibility = () => setIsVisible((prevState) => !prevState); | ||||
| const { t } = useTranslate('setting'); | |||||
| return ( | return ( | ||||
| <div className="*:not-first:mt-2 w-full"> | <div className="*:not-first:mt-2 w-full"> | ||||
| {/* <Label htmlFor={id}>Show/hide password input</Label> */} | {/* <Label htmlFor={id}>Show/hide password input</Label> */} |
| React.ElementRef<typeof CommandPrimitive.Input>, | React.ElementRef<typeof CommandPrimitive.Input>, | ||||
| React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input> | React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input> | ||||
| >(({ className, ...props }, ref) => ( | >(({ className, ...props }, ref) => ( | ||||
| <div className="flex items-center border-b px-3" cmdk-input-wrapper=""> | |||||
| <div className="flex items-center border-b px-3" data-cmdk-input-wrapper=""> | |||||
| <Search className="mr-2 h-4 w-4 shrink-0 opacity-50" /> | <Search className="mr-2 h-4 w-4 shrink-0 opacity-50" /> | ||||
| <CommandPrimitive.Input | <CommandPrimitive.Input | ||||
| ref={ref} | ref={ref} |
| animation = 0, | animation = 0, | ||||
| maxCount = 3, | maxCount = 3, | ||||
| modalPopover = false, | modalPopover = false, | ||||
| asChild = false, | |||||
| // asChild = false, | |||||
| className, | className, | ||||
| showSelectAll = true, | showSelectAll = true, | ||||
| ...props | ...props |
| const SIDEBAR_WIDTH_ICON = '3rem'; | const SIDEBAR_WIDTH_ICON = '3rem'; | ||||
| const SIDEBAR_KEYBOARD_SHORTCUT = 'b'; | const SIDEBAR_KEYBOARD_SHORTCUT = 'b'; | ||||
| type SidebarContext = { | |||||
| type SidebarContextType = { | |||||
| state: 'expanded' | 'collapsed'; | state: 'expanded' | 'collapsed'; | ||||
| open: boolean; | open: boolean; | ||||
| setOpen: (open: boolean) => void; | setOpen: (open: boolean) => void; | ||||
| toggleSidebar: () => void; | toggleSidebar: () => void; | ||||
| }; | }; | ||||
| const SidebarContext = React.createContext<SidebarContext | null>(null); | |||||
| const SidebarContext = React.createContext<SidebarContextType | null>(null); | |||||
| function useSidebar() { | function useSidebar() { | ||||
| const context = React.useContext(SidebarContext); | const context = React.useContext(SidebarContext); | ||||
| // This makes it easier to style the sidebar with Tailwind classes. | // This makes it easier to style the sidebar with Tailwind classes. | ||||
| const state = open ? 'expanded' : 'collapsed'; | const state = open ? 'expanded' : 'collapsed'; | ||||
| const contextValue = React.useMemo<SidebarContext>( | |||||
| const contextValue = React.useMemo<SidebarContextType>( | |||||
| () => ({ | () => ({ | ||||
| state, | state, | ||||
| open, | open, | ||||
| return button; | return button; | ||||
| } | } | ||||
| if (typeof tooltip === 'string') { | |||||
| tooltip = { | |||||
| children: tooltip, | |||||
| }; | |||||
| } | |||||
| const tooltipContent = | |||||
| typeof tooltip === 'string' ? { children: tooltip } : tooltip; | |||||
| return ( | return ( | ||||
| <Tooltip> | <Tooltip> | ||||
| side="right" | side="right" | ||||
| align="center" | align="center" | ||||
| hidden={state !== 'collapsed' || isMobile} | hidden={state !== 'collapsed' || isMobile} | ||||
| {...tooltip} | |||||
| {...tooltipContent} | |||||
| /> | /> | ||||
| </Tooltip> | </Tooltip> | ||||
| ); | ); |
| import { useSetPaginationParams } from './route-hook'; | import { useSetPaginationParams } from './route-hook'; | ||||
| import { useFetchTenantInfo, useSaveSetting } from './user-setting-hooks'; | import { useFetchTenantInfo, useSaveSetting } from './user-setting-hooks'; | ||||
| function usePrevious<T>(value: T) { | |||||
| export function usePrevious<T>(value: T) { | |||||
| const ref = useRef<T>(); | const ref = useRef<T>(); | ||||
| useEffect(() => { | useEffect(() => { | ||||
| ref.current = value; | ref.current = value; |
| { | { | ||||
| url: api.uploadAgentFile(identifier || id), | url: api.uploadAgentFile(identifier || id), | ||||
| data: formData, | data: formData, | ||||
| onUploadProgress: ({ | |||||
| loaded, | |||||
| total, | |||||
| progress, | |||||
| bytes, | |||||
| estimated, | |||||
| rate, | |||||
| upload, | |||||
| lengthComputable, | |||||
| }) => { | |||||
| onUploadProgress: ({ progress }) => { | |||||
| files.forEach((file) => { | files.forEach((file) => { | ||||
| onProgress(file, (progress || 0) * 100); | onProgress(file, (progress || 0) * 100); | ||||
| }); | }); |
| import { IClientConversation } from '@/pages/next-chats/chat/interface'; | import { IClientConversation } from '@/pages/next-chats/chat/interface'; | ||||
| import { useGetSharedChatSearchParams } from '@/pages/next-chats/hooks/use-send-shared-message'; | import { useGetSharedChatSearchParams } from '@/pages/next-chats/hooks/use-send-shared-message'; | ||||
| import { isConversationIdExist } from '@/pages/next-chats/utils'; | import { isConversationIdExist } from '@/pages/next-chats/utils'; | ||||
| import chatService from '@/services/next-chat-service '; | |||||
| import chatService from '@/services/next-chat-service'; | |||||
| import { buildMessageListWithUuid, getConversationId } from '@/utils/chat'; | import { buildMessageListWithUuid, getConversationId } from '@/utils/chat'; | ||||
| import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; | import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; | ||||
| import { useDebounce } from 'ahooks'; | import { useDebounce } from 'ahooks'; |
| import { useChangeLanguage } from '@/hooks/logic-hooks'; | import { useChangeLanguage } from '@/hooks/logic-hooks'; | ||||
| import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks'; | import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks'; | ||||
| import { useNavigateWithFromState } from '@/hooks/route-hook'; | import { useNavigateWithFromState } from '@/hooks/route-hook'; | ||||
| import { useFetchUserInfo, useListTenant } from '@/hooks/user-setting-hooks'; | |||||
| import { TenantRole } from '@/pages/user-setting/constants'; | |||||
| import { useFetchUserInfo } from '@/hooks/user-setting-hooks'; | |||||
| import { Routes } from '@/routes'; | import { Routes } from '@/routes'; | ||||
| import { camelCase } from 'lodash'; | import { camelCase } from 'lodash'; | ||||
| import { | import { | ||||
| changeLanguage(key); | changeLanguage(key); | ||||
| }; | }; | ||||
| const { data } = useListTenant(); | |||||
| // const { data } = useListTenant(); | |||||
| const showBell = useMemo(() => { | |||||
| return data.some((x) => x.role === TenantRole.Invite); | |||||
| }, [data]); | |||||
| // const showBell = useMemo(() => { | |||||
| // return data.some((x) => x.role === TenantRole.Invite); | |||||
| // }, [data]); | |||||
| const items = LanguageList.map((x) => ({ | const items = LanguageList.map((x) => ({ | ||||
| key: x, | key: x, | ||||
| setTheme(theme === ThemeEnum.Dark ? ThemeEnum.Light : ThemeEnum.Dark); | setTheme(theme === ThemeEnum.Dark ? ThemeEnum.Light : ThemeEnum.Dark); | ||||
| }, [setTheme, theme]); | }, [setTheme, theme]); | ||||
| const handleBellClick = useCallback(() => { | |||||
| navigate('/user-setting/team'); | |||||
| }, [navigate]); | |||||
| // const handleBellClick = useCallback(() => { | |||||
| // navigate('/user-setting/team'); | |||||
| // }, [navigate]); | |||||
| const tagsData = useMemo( | const tagsData = useMemo( | ||||
| () => [ | () => [ |
| const [fileList, setFileList] = useState<UploadFile[]>([]); | const [fileList, setFileList] = useState<UploadFile[]>([]); | ||||
| const [uploadProgress, setUploadProgress] = useState<number>(0); | const [uploadProgress, setUploadProgress] = useState<number>(0); | ||||
| const { uploadDocument, loading } = useUploadNextDocument(); | const { uploadDocument, loading } = useUploadNextDocument(); | ||||
| const { runDocumentByIds, loading: _ } = useRunNextDocument(); | |||||
| const { runDocumentByIds } = useRunNextDocument(); | |||||
| const onDocumentUploadOk = useCallback( | const onDocumentUploadOk = useCallback( | ||||
| async ({ | async ({ |
| ), | ), | ||||
| dataIndex: 'run', | dataIndex: 'run', | ||||
| key: 'run', | key: 'run', | ||||
| filters: Object.entries(RunningStatus).map(([key, value]) => ({ | |||||
| filters: Object.values(RunningStatus).map((value) => ({ | |||||
| text: t(`runningStatus${value}`), | text: t(`runningStatus${value}`), | ||||
| value: value, | value: value, | ||||
| })), | })), |
| const { knowledgeId } = useGetKnowledgeSearchParams(); | const { knowledgeId } = useGetKnowledgeSearchParams(); | ||||
| const [windowWidth, setWindowWidth] = useState(getWidth()); | const [windowWidth, setWindowWidth] = useState(getWidth()); | ||||
| const [collapsed, setCollapsed] = useState(false); | |||||
| const { t } = useTranslation(); | const { t } = useTranslation(); | ||||
| const { data: knowledgeDetails } = useFetchKnowledgeBaseConfiguration(); | const { data: knowledgeDetails } = useFetchKnowledgeBaseConfiguration(); | ||||
| return list; | return list; | ||||
| }, [data, getItem]); | }, [data, getItem]); | ||||
| useEffect(() => { | |||||
| if (windowWidth.width > 957) { | |||||
| setCollapsed(false); | |||||
| } else { | |||||
| setCollapsed(true); | |||||
| } | |||||
| }, [windowWidth.width]); | |||||
| useEffect(() => { | useEffect(() => { | ||||
| const widthSize = () => { | const widthSize = () => { | ||||
| const width = getWidth(); | const width = getWidth(); |
| import { NodeProps, Position } from '@xyflow/react'; | import { NodeProps, Position } from '@xyflow/react'; | ||||
| import classNames from 'classnames'; | import classNames from 'classnames'; | ||||
| import { get } from 'lodash'; | import { get } from 'lodash'; | ||||
| import { memo, useMemo } from 'react'; | |||||
| import { memo } from 'react'; | |||||
| import { NodeHandleId } from '../../constant'; | import { NodeHandleId } from '../../constant'; | ||||
| import { useGetVariableLabelByValue } from '../../hooks/use-get-begin-query'; | import { useGetVariableLabelByValue } from '../../hooks/use-get-begin-query'; | ||||
| import { CommonHandle } from './handle'; | import { CommonHandle } from './handle'; | ||||
| selected, | selected, | ||||
| }: NodeProps<IRetrievalNode>) { | }: NodeProps<IRetrievalNode>) { | ||||
| const knowledgeBaseIds: string[] = get(data, 'form.kb_ids', []); | const knowledgeBaseIds: string[] = get(data, 'form.kb_ids', []); | ||||
| console.log('🚀 ~ InnerRetrievalNode ~ knowledgeBaseIds:', knowledgeBaseIds); | |||||
| const { list: knowledgeList } = useFetchKnowledgeList(true); | const { list: knowledgeList } = useFetchKnowledgeList(true); | ||||
| const knowledgeBases = useMemo(() => { | |||||
| return knowledgeBaseIds.map((x) => { | |||||
| const item = knowledgeList.find((y) => x === y.id); | |||||
| return { | |||||
| name: item?.name, | |||||
| avatar: item?.avatar, | |||||
| id: x, | |||||
| }; | |||||
| }); | |||||
| }, [knowledgeList, knowledgeBaseIds]); | |||||
| const getLabel = useGetVariableLabelByValue(id); | const getLabel = useGetVariableLabelByValue(id); | ||||
| import { ModelVariableType } from '@/constants/knowledge'; | import { ModelVariableType } from '@/constants/knowledge'; | ||||
| import { RAGFlowNodeType } from '@/interfaces/database/flow'; | import { RAGFlowNodeType } from '@/interfaces/database/flow'; | ||||
| import { get, isEmpty, isPlainObject } from 'lodash'; | |||||
| import { isEmpty, isPlainObject } from 'lodash'; | |||||
| import { useMemo } from 'react'; | import { useMemo } from 'react'; | ||||
| import { buildCategorizeListFromObject } from '../../utils'; | |||||
| const defaultValues = { | const defaultValues = { | ||||
| parameter: ModelVariableType.Precise, | parameter: ModelVariableType.Precise, | ||||
| if (isEmpty(formData)) { | if (isEmpty(formData)) { | ||||
| return defaultValues; | return defaultValues; | ||||
| } | } | ||||
| const items = buildCategorizeListFromObject( | |||||
| get(node, 'data.form.category_description', {}), | |||||
| ); | |||||
| if (isPlainObject(formData)) { | if (isPlainObject(formData)) { | ||||
| // const nextValues = { | // const nextValues = { | ||||
| // ...omit(formData, 'category_description'), | // ...omit(formData, 'category_description'), |
| 'use client'; | 'use client'; | ||||
| import { SideDown } from '@/assets/icon/Icon'; | |||||
| import { SideDown } from '@/assets/icon/next-icon'; | |||||
| import { Button } from '@/components/ui/button'; | import { Button } from '@/components/ui/button'; | ||||
| import { | import { | ||||
| Collapsible, | Collapsible, |
| import { Edge } from '@xyflow/react'; | |||||
| import pick from 'lodash/pick'; | import pick from 'lodash/pick'; | ||||
| import { useCallback, useEffect } from 'react'; | import { useCallback, useEffect } from 'react'; | ||||
| import { IOperatorForm } from '../../interface'; | import { IOperatorForm } from '../../interface'; | ||||
| return buildRelevantOptions; | return buildRelevantOptions; | ||||
| }; | }; | ||||
| const getTargetOfEdge = (edges: Edge[], sourceHandle: string) => | |||||
| edges.find((x) => x.sourceHandle === sourceHandle)?.target; | |||||
| /** | /** | ||||
| * monitor changes in the connection and synchronize the target to the yes and no fields of the form | * monitor changes in the connection and synchronize the target to the yes and no fields of the form | ||||
| * similar to the categorize-form's useHandleFormValuesChange method | * similar to the categorize-form's useHandleFormValuesChange method | ||||
| * @param param0 | * @param param0 | ||||
| */ | */ | ||||
| export const useWatchConnectionChanges = ({ nodeId, form }: IOperatorForm) => { | export const useWatchConnectionChanges = ({ nodeId, form }: IOperatorForm) => { | ||||
| const edges = useGraphStore((state) => state.edges); | |||||
| const getNode = useGraphStore((state) => state.getNode); | const getNode = useGraphStore((state) => state.getNode); | ||||
| const node = getNode(nodeId); | const node = getNode(nodeId); | ||||
| } | } | ||||
| }, [node, form]); | }, [node, form]); | ||||
| const watchConnectionChanges = useCallback(() => { | |||||
| const edgeList = edges.filter((x) => x.source === nodeId); | |||||
| const yes = getTargetOfEdge(edgeList, 'yes'); | |||||
| const no = getTargetOfEdge(edgeList, 'no'); | |||||
| form?.setFieldsValue({ yes, no }); | |||||
| }, [edges, nodeId, form]); | |||||
| useEffect(() => { | useEffect(() => { | ||||
| watchFormChanges(); | watchFormChanges(); | ||||
| }, [watchFormChanges]); | }, [watchFormChanges]); |
| import { NotebookText } from 'lucide-react'; | import { NotebookText } from 'lucide-react'; | ||||
| import 'react18-json-view/src/style.css'; | import 'react18-json-view/src/style.css'; | ||||
| import { useCacheChatLog } from '../hooks/use-cache-chat-log'; | import { useCacheChatLog } from '../hooks/use-cache-chat-log'; | ||||
| import { WorkFlowTimeline } from './workFlowTimeline'; | |||||
| import { WorkFlowTimeline } from './workflow-timeline'; | |||||
| type LogSheetProps = IModalProps<any> & | type LogSheetProps = IModalProps<any> & | ||||
| Pick< | Pick< |
| JsonViewer, | JsonViewer, | ||||
| toLowerCaseStringAndDeleteChar, | toLowerCaseStringAndDeleteChar, | ||||
| typeMap, | typeMap, | ||||
| } from './workFlowTimeline'; | |||||
| } from './workflow-timeline'; | |||||
| type IToolIcon = | type IToolIcon = | ||||
| | Operator.ArXiv | | Operator.ArXiv | ||||
| | Operator.GitHub | | Operator.GitHub |
| import { Operator } from '../constant'; | import { Operator } from '../constant'; | ||||
| import { useCacheChatLog } from '../hooks/use-cache-chat-log'; | import { useCacheChatLog } from '../hooks/use-cache-chat-log'; | ||||
| import OperatorIcon from '../operator-icon'; | import OperatorIcon from '../operator-icon'; | ||||
| import ToolTimelineItem from './toolTimelineItem'; | |||||
| import ToolTimelineItem from './tool-timeline-item'; | |||||
| type LogFlowTimelineProps = Pick< | type LogFlowTimelineProps = Pick< | ||||
| ReturnType<typeof useCacheChatLog>, | ReturnType<typeof useCacheChatLog>, | ||||
| 'currentEventListWithoutMessage' | 'currentMessageId' | 'currentEventListWithoutMessage' | 'currentMessageId' |
| import { Form, FormInstance, Input, InputRef } from 'antd'; | import { Form, FormInstance, Input, InputRef } from 'antd'; | ||||
| import { omit } from 'lodash'; | |||||
| import React, { useContext, useEffect, useRef, useState } from 'react'; | import React, { useContext, useEffect, useRef, useState } from 'react'; | ||||
| const EditableContext = React.createContext<FormInstance<any> | null>(null); | const EditableContext = React.createContext<FormInstance<any> | null>(null); | ||||
| address: string; | address: string; | ||||
| } | } | ||||
| export const EditableRow: React.FC<EditableRowProps> = ({ | |||||
| index, | |||||
| ...props | |||||
| }) => { | |||||
| export const EditableRow: React.FC<EditableRowProps> = ({ ...props }) => { | |||||
| const [form] = Form.useForm(); | const [form] = Form.useForm(); | ||||
| return ( | return ( | ||||
| <Form form={form} component={false}> | <Form form={form} component={false}> | ||||
| <EditableContext.Provider value={form}> | <EditableContext.Provider value={form}> | ||||
| <tr {...props} /> | |||||
| <tr {...omit(props, 'index')} /> | |||||
| </EditableContext.Provider> | </EditableContext.Provider> | ||||
| </Form> | </Form> | ||||
| ); | ); |
| import { currentReg, replaceTextByOldReg } from '../utils'; | import { currentReg, replaceTextByOldReg } from '../utils'; | ||||
| import classNames from 'classnames'; | import classNames from 'classnames'; | ||||
| import { omit } from 'lodash'; | |||||
| import { pipe } from 'lodash/fp'; | import { pipe } from 'lodash/fp'; | ||||
| import styles from './index.less'; | import styles from './index.less'; | ||||
| 'custom-typography': ({ children }: { children: string }) => | 'custom-typography': ({ children }: { children: string }) => | ||||
| renderReference(children), | renderReference(children), | ||||
| code(props: any) { | code(props: any) { | ||||
| const { children, className, node, ...rest } = props; | |||||
| const { children, className, ...rest } = props; | |||||
| const restProps = omit(rest, 'node'); | |||||
| const match = /language-(\w+)/.exec(className || ''); | const match = /language-(\w+)/.exec(className || ''); | ||||
| return match ? ( | return match ? ( | ||||
| <SyntaxHighlighter | <SyntaxHighlighter | ||||
| {...rest} | |||||
| {...restProps} | |||||
| PreTag="div" | PreTag="div" | ||||
| language={match[1]} | language={match[1]} | ||||
| wrapLongLines | wrapLongLines | ||||
| {String(children).replace(/\n$/, '')} | {String(children).replace(/\n$/, '')} | ||||
| </SyntaxHighlighter> | </SyntaxHighlighter> | ||||
| ) : ( | ) : ( | ||||
| <code {...rest} className={classNames(className, 'text-wrap')}> | |||||
| <code | |||||
| {...restProps} | |||||
| className={classNames(className, 'text-wrap')} | |||||
| > | |||||
| {children} | {children} | ||||
| </code> | </code> | ||||
| ); | ); |
| const data = Object.fromEntries( | const data = Object.fromEntries( | ||||
| searchParams | searchParams | ||||
| .entries() | .entries() | ||||
| .filter(([key, value]) => key.startsWith(data_prefix)) | |||||
| .filter(([key]) => key.startsWith(data_prefix)) | |||||
| .map(([key, value]) => [key.replace(data_prefix, ''), value]), | .map(([key, value]) => [key.replace(data_prefix, ''), value]), | ||||
| ); | ); | ||||
| return { | return { |
| import { Textarea } from '@/components/ui/textarea'; | import { Textarea } from '@/components/ui/textarea'; | ||||
| import { useFetchChunk } from '@/hooks/chunk-hooks'; | import { useFetchChunk } from '@/hooks/chunk-hooks'; | ||||
| import { IModalProps } from '@/interfaces/common'; | import { IModalProps } from '@/interfaces/common'; | ||||
| import { IChunk } from '@/interfaces/database/knowledge'; | |||||
| import { Trash2 } from 'lucide-react'; | import { Trash2 } from 'lucide-react'; | ||||
| import React, { useCallback, useEffect, useState } from 'react'; | import React, { useCallback, useEffect, useState } from 'react'; | ||||
| import { FieldValues, FormProvider, useForm } from 'react-hook-form'; | import { FieldValues, FormProvider, useForm } from 'react-hook-form'; | ||||
| } from '../../utils'; | } from '../../utils'; | ||||
| import { TagFeatureItem } from './tag-feature-item'; | import { TagFeatureItem } from './tag-feature-item'; | ||||
| type FieldType = Pick< | |||||
| IChunk, | |||||
| 'content_with_weight' | 'tag_kwd' | 'question_kwd' | 'important_kwd' | |||||
| >; | |||||
| interface kFProps { | interface kFProps { | ||||
| doc_id: string; | doc_id: string; | ||||
| chunkId: string | undefined; | chunkId: string | undefined; |
| const res = await request(url, { | const res = await request(url, { | ||||
| method: 'GET', | method: 'GET', | ||||
| responseType: 'blob', | responseType: 'blob', | ||||
| onError: (err) => { | |||||
| onError: () => { | |||||
| message.error('file load failed'); | message.error('file load failed'); | ||||
| setIsLoading(false); | setIsLoading(false); | ||||
| }, | }, |
| import { useTestRetrieval } from '@/hooks/use-knowledge-request'; | import { useTestRetrieval } from '@/hooks/use-knowledge-request'; | ||||
| import { useCallback, useState } from 'react'; | |||||
| import { useState } from 'react'; | |||||
| import { TopTitle } from '../dataset-title'; | import { TopTitle } from '../dataset-title'; | ||||
| import TestingForm from './testing-form'; | import TestingForm from './testing-form'; | ||||
| import { TestingResult } from './testing-result'; | import { TestingResult } from './testing-result'; | ||||
| function Vertical() { | |||||
| return <div>xxx</div>; | |||||
| } | |||||
| export default function RetrievalTesting() { | export default function RetrievalTesting() { | ||||
| const { | const { | ||||
| loading, | loading, | ||||
| filterValue, | filterValue, | ||||
| } = useTestRetrieval(); | } = useTestRetrieval(); | ||||
| const [count, setCount] = useState(1); | |||||
| const addCount = useCallback(() => { | |||||
| setCount(2); | |||||
| }, []); | |||||
| const removeCount = useCallback(() => { | |||||
| setCount(1); | |||||
| }, []); | |||||
| const [count] = useState(1); | |||||
| return ( | return ( | ||||
| <div className="p-5"> | <div className="p-5"> |
| KeywordIcon, | KeywordIcon, | ||||
| QWeatherIcon, | QWeatherIcon, | ||||
| WikipediaIcon, | WikipediaIcon, | ||||
| } from '@/assets/icon/Icon'; | |||||
| } from '@/assets/icon/next-icon'; | |||||
| import { ReactComponent as AkShareIcon } from '@/assets/svg/akshare.svg'; | import { ReactComponent as AkShareIcon } from '@/assets/svg/akshare.svg'; | ||||
| import { ReactComponent as ArXivIcon } from '@/assets/svg/arxiv.svg'; | import { ReactComponent as ArXivIcon } from '@/assets/svg/arxiv.svg'; | ||||
| import { ReactComponent as baiduFanyiIcon } from '@/assets/svg/baidu-fanyi.svg'; | import { ReactComponent as baiduFanyiIcon } from '@/assets/svg/baidu-fanyi.svg'; |
| import { CommaIcon, SemicolonIcon } from '@/assets/icon/Icon'; | |||||
| import { CommaIcon, SemicolonIcon } from '@/assets/icon/next-icon'; | |||||
| import { Form, Select } from 'antd'; | import { Form, Select } from 'antd'; | ||||
| import { | import { | ||||
| CornerDownLeft, | CornerDownLeft, |
| import { Edge } from '@xyflow/react'; | |||||
| import pick from 'lodash/pick'; | import pick from 'lodash/pick'; | ||||
| import { useCallback, useEffect } from 'react'; | import { useCallback, useEffect } from 'react'; | ||||
| import { IOperatorForm } from '../../interface'; | import { IOperatorForm } from '../../interface'; | ||||
| return buildRelevantOptions; | return buildRelevantOptions; | ||||
| }; | }; | ||||
| const getTargetOfEdge = (edges: Edge[], sourceHandle: string) => | |||||
| edges.find((x) => x.sourceHandle === sourceHandle)?.target; | |||||
| // const getTargetOfEdge = (edges: Edge[], sourceHandle: string) => | |||||
| // edges.find((x) => x.sourceHandle === sourceHandle)?.target; | |||||
| /** | /** | ||||
| * monitor changes in the connection and synchronize the target to the yes and no fields of the form | * monitor changes in the connection and synchronize the target to the yes and no fields of the form | ||||
| * @param param0 | * @param param0 | ||||
| */ | */ | ||||
| export const useWatchConnectionChanges = ({ nodeId, form }: IOperatorForm) => { | export const useWatchConnectionChanges = ({ nodeId, form }: IOperatorForm) => { | ||||
| const edges = useGraphStore((state) => state.edges); | |||||
| // const edges = useGraphStore((state) => state.edges); | |||||
| const getNode = useGraphStore((state) => state.getNode); | const getNode = useGraphStore((state) => state.getNode); | ||||
| const node = getNode(nodeId); | const node = getNode(nodeId); | ||||
| } | } | ||||
| }, [node, form]); | }, [node, form]); | ||||
| const watchConnectionChanges = useCallback(() => { | |||||
| const edgeList = edges.filter((x) => x.source === nodeId); | |||||
| const yes = getTargetOfEdge(edgeList, 'yes'); | |||||
| const no = getTargetOfEdge(edgeList, 'no'); | |||||
| form?.setFieldsValue({ yes, no }); | |||||
| }, [edges, nodeId, form]); | |||||
| // const watchConnectionChanges = useCallback(() => { | |||||
| // const edgeList = edges.filter((x) => x.source === nodeId); | |||||
| // const yes = getTargetOfEdge(edgeList, 'yes'); | |||||
| // const no = getTargetOfEdge(edgeList, 'no'); | |||||
| // form?.setFieldsValue({ yes, no }); | |||||
| // }, [edges, nodeId, form]); | |||||
| useEffect(() => { | useEffect(() => { | ||||
| watchFormChanges(); | watchFormChanges(); |
| }; | }; | ||||
| export const useWatchAgentChange = (chatDrawerVisible: boolean) => { | export const useWatchAgentChange = (chatDrawerVisible: boolean) => { | ||||
| console.log( | |||||
| '🚀 ~ useWatchAgentChange ~ chatDrawerVisible:', | |||||
| chatDrawerVisible, | |||||
| ); | |||||
| const [time, setTime] = useState<string>(); | const [time, setTime] = useState<string>(); | ||||
| const nodes = useGraphStore((state) => state.nodes); | const nodes = useGraphStore((state) => state.nodes); | ||||
| const edges = useGraphStore((state) => state.edges); | const edges = useGraphStore((state) => state.edges); | ||||
| const { saveGraph } = useSaveGraph(); | |||||
| // const { saveGraph } = useSaveGraph(); | |||||
| const { data: flowDetail } = useFetchFlow(); | const { data: flowDetail } = useFetchFlow(); | ||||
| const setSaveTime = useCallback((updateTime: number) => { | const setSaveTime = useCallback((updateTime: number) => { | ||||
| setSaveTime(flowDetail?.update_time); | setSaveTime(flowDetail?.update_time); | ||||
| }, [flowDetail, setSaveTime]); | }, [flowDetail, setSaveTime]); | ||||
| const saveAgent = useCallback(async () => { | |||||
| if (!chatDrawerVisible) { | |||||
| const ret = await saveGraph(); | |||||
| setSaveTime(ret.data.update_time); | |||||
| } | |||||
| }, [chatDrawerVisible, saveGraph, setSaveTime]); | |||||
| // const saveAgent = useCallback(async () => { | |||||
| // if (!chatDrawerVisible) { | |||||
| // const ret = await saveGraph(); | |||||
| // setSaveTime(ret.data.update_time); | |||||
| // } | |||||
| // }, [chatDrawerVisible, saveGraph, setSaveTime]); | |||||
| useDebounceEffect( | useDebounceEffect( | ||||
| () => { | () => { |
| export const useSwitchStep = (step: Step) => { | export const useSwitchStep = (step: Step) => { | ||||
| const [_, setSearchParams] = useSearchParams(); | const [_, setSearchParams] = useSearchParams(); | ||||
| console.log('🚀 ~ useSwitchStep ~ _:', _); | |||||
| const switchStep = useCallback(() => { | const switchStep = useCallback(() => { | ||||
| setSearchParams(new URLSearchParams({ step: step.toString() })); | setSearchParams(new URLSearchParams({ step: step.toString() })); | ||||
| }, [setSearchParams, step]); | }, [setSearchParams, step]); |
| const data = Object.fromEntries( | const data = Object.fromEntries( | ||||
| searchParams | searchParams | ||||
| .entries() | .entries() | ||||
| .filter(([key, value]) => key.startsWith(data_prefix)) | |||||
| .filter(([key]) => key.startsWith(data_prefix)) | |||||
| .map(([key, value]) => [key.replace(data_prefix, ''), value]), | .map(([key, value]) => [key.replace(data_prefix, ''), value]), | ||||
| ); | ); | ||||
| return { | return { |
| })(); | })(); | ||||
| } | } | ||||
| }, [avatarFile]); | }, [avatarFile]); | ||||
| const { list: datasetListOrigin, loading: datasetLoading } = | |||||
| useFetchKnowledgeList(); | |||||
| const { list: datasetListOrigin } = useFetchKnowledgeList(); | |||||
| useEffect(() => { | useEffect(() => { | ||||
| const datasetListMap = datasetListOrigin.map((item: IKnowledge) => { | const datasetListMap = datasetListOrigin.map((item: IKnowledge) => { |
| export default function SearchList() { | export default function SearchList() { | ||||
| // const { data } = useFetchFlowList(); | // const { data } = useFetchFlowList(); | ||||
| const { t } = useTranslate('search'); | const { t } = useTranslate('search'); | ||||
| const { isLoading, isError, createSearch } = useCreateSearch(); | |||||
| const { isLoading, createSearch } = useCreateSearch(); | |||||
| const { | const { | ||||
| data: list, | data: list, | ||||
| searchParams, | searchParams, |
| api.ask, | api.ask, | ||||
| ); | ); | ||||
| const { testChunk, loading } = useTestChunkRetrieval(); | const { testChunk, loading } = useTestChunkRetrieval(); | ||||
| const { testChunkAll, loading: loadingAll } = useTestChunkAllRetrieval(); | |||||
| const { testChunkAll } = useTestChunkAllRetrieval(); | |||||
| const [sendingLoading, setSendingLoading] = useState(false); | const [sendingLoading, setSendingLoading] = useState(false); | ||||
| const [currentAnswer, setCurrentAnswer] = useState({} as IAnswer); | const [currentAnswer, setCurrentAnswer] = useState({} as IAnswer); | ||||
| const { fetchRelatedQuestions, data: relatedQuestions } = | const { fetchRelatedQuestions, data: relatedQuestions } = | ||||
| size, | size, | ||||
| }); | }); | ||||
| }, | }, | ||||
| [sendingLoading, searchStr, kbIds, testChunk, selectedDocumentIds], | |||||
| [ | |||||
| searchStr, | |||||
| sendingLoading, | |||||
| testChunk, | |||||
| kbIds, | |||||
| selectedDocumentIds, | |||||
| testChunkAll, | |||||
| ], | |||||
| ); | ); | ||||
| useEffect(() => { | useEffect(() => { |
| PasswordIcon, | PasswordIcon, | ||||
| ProfileIcon, | ProfileIcon, | ||||
| TeamIcon, | TeamIcon, | ||||
| } from '@/assets/icon/Icon'; | |||||
| } from '@/assets/icon/next-icon'; | |||||
| import { IconFont } from '@/components/icon-font'; | import { IconFont } from '@/components/icon-font'; | ||||
| import { LLMFactory } from '@/constants/llm'; | import { LLMFactory } from '@/constants/llm'; | ||||
| import { UserSettingRouteKey } from '@/constants/setting'; | import { UserSettingRouteKey } from '@/constants/setting'; |
| import { translationTable } from '@/locales/config'; | import { translationTable } from '@/locales/config'; | ||||
| import TranslationTable from './TranslationTable'; | |||||
| import TranslationTable from './translation-table'; | |||||
| function UserSettingLocale() { | function UserSettingLocale() { | ||||
| return ( | return ( |
| { value: 'image2text', label: 'image2text' }, | { value: 'image2text', label: 'image2text' }, | ||||
| ], | ], | ||||
| }; | }; | ||||
| const getOptions = (factory: string) => { | |||||
| const getOptions = () => { | |||||
| return optionsMap.Default; | return optionsMap.Default; | ||||
| }; | }; | ||||
| const handleKeyDown = async (e: React.KeyboardEvent) => { | const handleKeyDown = async (e: React.KeyboardEvent) => { | ||||
| type: 'number', | type: 'number', | ||||
| message: t('maxTokensInvalidMessage'), | message: t('maxTokensInvalidMessage'), | ||||
| }, | }, | ||||
| ({ getFieldValue }) => ({ | |||||
| ({}) => ({ | |||||
| validator(_, value) { | validator(_, value) { | ||||
| if (value < 0) { | if (value < 0) { | ||||
| return Promise.reject(new Error(t('maxTokensMinMessage'))); | return Promise.reject(new Error(t('maxTokensMinMessage'))); |
| type: 'number', | type: 'number', | ||||
| message: t('maxTokensInvalidMessage'), | message: t('maxTokensInvalidMessage'), | ||||
| }, | }, | ||||
| ({ getFieldValue }) => ({ | |||||
| ({}) => ({ | |||||
| validator(_, value) { | validator(_, value) { | ||||
| if (value < 0) { | if (value < 0) { | ||||
| return Promise.reject(new Error(t('maxTokensMinMessage'))); | return Promise.reject(new Error(t('maxTokensMinMessage'))); |
| type: 'number', | type: 'number', | ||||
| message: t('maxTokensInvalidMessage'), | message: t('maxTokensInvalidMessage'), | ||||
| }, | }, | ||||
| ({ getFieldValue }) => ({ | |||||
| ({}) => ({ | |||||
| validator(_, value) { | validator(_, value) { | ||||
| if (value < 0) { | if (value < 0) { | ||||
| return Promise.reject(new Error(t('maxTokensMinMessage'))); | return Promise.reject(new Error(t('maxTokensMinMessage'))); |
| type: 'number', | type: 'number', | ||||
| message: t('maxTokensInvalidMessage'), | message: t('maxTokensInvalidMessage'), | ||||
| }, | }, | ||||
| ({ getFieldValue }) => ({ | |||||
| ({}) => ({ | |||||
| validator(_, value) { | validator(_, value) { | ||||
| if (value < 0) { | if (value < 0) { | ||||
| return Promise.reject(new Error(t('maxTokensMinMessage'))); | return Promise.reject(new Error(t('maxTokensMinMessage'))); |
| const [initialValues, setInitialValues] = useState< | const [initialValues, setInitialValues] = useState< | ||||
| Partial<IAddLlmRequestBody> | undefined | Partial<IAddLlmRequestBody> | undefined | ||||
| >(); | >(); | ||||
| const [originalModelName, setOriginalModelName] = useState<string>(''); | |||||
| const { addLlm, loading } = useAddLlm(); | const { addLlm, loading } = useAddLlm(); | ||||
| const { | const { | ||||
| visible: llmAddingVisible, | visible: llmAddingVisible, |
| import { useTranslate } from '@/hooks/common-hooks'; | import { useTranslate } from '@/hooks/common-hooks'; | ||||
| import { IModalProps } from '@/interfaces/common'; | import { IModalProps } from '@/interfaces/common'; | ||||
| import { IAddLlmRequestBody } from '@/interfaces/request/llm'; | import { IAddLlmRequestBody } from '@/interfaces/request/llm'; | ||||
| import { Form, Input, Modal, Select } from 'antd'; | |||||
| import { Form, Input, Modal } from 'antd'; | |||||
| import omit from 'lodash/omit'; | import omit from 'lodash/omit'; | ||||
| type FieldType = IAddLlmRequestBody & { | type FieldType = IAddLlmRequestBody & { | ||||
| hunyuan_sk: string; | hunyuan_sk: string; | ||||
| }; | }; | ||||
| const { Option } = Select; | |||||
| const HunyuanModal = ({ | const HunyuanModal = ({ | ||||
| visible, | visible, | ||||
| hideModal, | hideModal, |
| import { useCallback, useMemo } from 'react'; | import { useCallback, useMemo } from 'react'; | ||||
| import SettingTitle from '../components/setting-title'; | import SettingTitle from '../components/setting-title'; | ||||
| import { isLocalLlmFactory } from '../utils'; | import { isLocalLlmFactory } from '../utils'; | ||||
| import TencentCloudModal from './Tencent-modal'; | |||||
| import ApiKeyModal from './api-key-modal'; | import ApiKeyModal from './api-key-modal'; | ||||
| import AzureOpenAIModal from './azure-openai-modal'; | import AzureOpenAIModal from './azure-openai-modal'; | ||||
| import BedrockModal from './bedrock-modal'; | import BedrockModal from './bedrock-modal'; | ||||
| } from './hooks'; | } from './hooks'; | ||||
| import HunyuanModal from './hunyuan-modal'; | import HunyuanModal from './hunyuan-modal'; | ||||
| import styles from './index.less'; | import styles from './index.less'; | ||||
| import TencentCloudModal from './next-tencent-modal'; | |||||
| import OllamaModal from './ollama-modal'; | import OllamaModal from './ollama-modal'; | ||||
| import SparkModal from './spark-modal'; | import SparkModal from './spark-modal'; | ||||
| import SystemModelSettingModal from './system-model-setting-modal'; | import SystemModelSettingModal from './system-model-setting-modal'; |
| type: 'number', | type: 'number', | ||||
| message: t('maxTokensInvalidMessage'), | message: t('maxTokensInvalidMessage'), | ||||
| }, | }, | ||||
| ({ getFieldValue }) => ({ | |||||
| ({}) => ({ | |||||
| validator(_, value) { | validator(_, value) { | ||||
| if (value < 0) { | if (value < 0) { | ||||
| return Promise.reject(new Error(t('maxTokensMinMessage'))); | return Promise.reject(new Error(t('maxTokensMinMessage'))); |
| type: 'number', | type: 'number', | ||||
| message: t('maxTokensInvalidMessage'), | message: t('maxTokensInvalidMessage'), | ||||
| }, | }, | ||||
| ({ getFieldValue }) => ({ | |||||
| ({}) => ({ | |||||
| validator(_, value) { | validator(_, value) { | ||||
| if (value < 0) { | if (value < 0) { | ||||
| return Promise.reject(new Error(t('maxTokensMinMessage'))); | return Promise.reject(new Error(t('maxTokensMinMessage'))); |
| type: 'number', | type: 'number', | ||||
| message: t('maxTokensInvalidMessage'), | message: t('maxTokensInvalidMessage'), | ||||
| }, | }, | ||||
| ({ getFieldValue }) => ({ | |||||
| ({}) => ({ | |||||
| validator(_, value) { | validator(_, value) { | ||||
| if (value < 0) { | if (value < 0) { | ||||
| return Promise.reject(new Error(t('maxTokensMinMessage'))); | return Promise.reject(new Error(t('maxTokensMinMessage'))); |
| const { | const { | ||||
| getDialog, | getDialog, | ||||
| setDialog, | setDialog, | ||||
| listDialog, | |||||
| // listDialog, | |||||
| removeDialog, | removeDialog, | ||||
| getConversation, | getConversation, | ||||
| getConversationSSE, | getConversationSSE, |
| /* eslint-disable guard-for-in */ | |||||
| import { AxiosRequestConfig, AxiosResponse } from 'axios'; | import { AxiosRequestConfig, AxiosResponse } from 'axios'; | ||||
| import { isObject } from 'lodash'; | import { isObject } from 'lodash'; | ||||
| import omit from 'lodash/omit'; | import omit from 'lodash/omit'; |