### 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
| @@ -1,5 +1,43 @@ | |||
| // .eslintrc.js | |||
| module.exports = { | |||
| // Umi 项目 | |||
| 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: ['"', '"'], | |||
| }, | |||
| ], | |||
| }, | |||
| ], | |||
| }, | |||
| }; | |||
| @@ -3,6 +3,7 @@ import TerserPlugin from 'terser-webpack-plugin'; | |||
| import { defineConfig } from 'umi'; | |||
| import { appName } from './src/conf.json'; | |||
| import routes from './src/routes'; | |||
| const ESLintPlugin = require('eslint-webpack-plugin'); | |||
| export default defineConfig({ | |||
| title: appName, | |||
| @@ -52,6 +53,15 @@ export default defineConfig({ | |||
| 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; | |||
| }, | |||
| tailwindcss: {}, | |||
| @@ -121,6 +121,8 @@ | |||
| "@umijs/plugins": "^4.1.0", | |||
| "@welldone-software/why-did-you-render": "^8.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", | |||
| "husky": "^9.0.11", | |||
| "jest": "^29.7.0", | |||
| @@ -9147,9 +9149,10 @@ | |||
| } | |||
| }, | |||
| "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, | |||
| "dependencies": { | |||
| "@types/estree": "*", | |||
| @@ -16334,6 +16337,27 @@ | |||
| "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": { | |||
| "version": "27.2.3", | |||
| "resolved": "https://registry.npmmirror.com/eslint-plugin-jest/-/eslint-plugin-jest-27.2.3.tgz", | |||
| @@ -16437,6 +16461,141 @@ | |||
| "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": { | |||
| "version": "4.3.0", | |||
| "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz", | |||
| @@ -17222,9 +17381,10 @@ | |||
| } | |||
| }, | |||
| "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 | |||
| }, | |||
| "node_modules/flatten": { | |||
| @@ -24121,9 +24281,10 @@ | |||
| "integrity": "sha512-oNh6S2WMHWRZrmutsRmDDfkzKtxF+bc2VxLC9dvtrDIRFln627VsFP6fLMgTryGDljgLPjkrzQSDcPrjPyDJ5w==" | |||
| }, | |||
| "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": { | |||
| "braces": "^3.0.3", | |||
| "picomatch": "^2.3.1" | |||
| @@ -132,6 +132,8 @@ | |||
| "@umijs/plugins": "^4.1.0", | |||
| "@welldone-software/why-did-you-render": "^8.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", | |||
| "husky": "^9.0.11", | |||
| "jest": "^29.7.0", | |||
| @@ -80,7 +80,6 @@ export function ChunkMethodDialog({ | |||
| hideModal, | |||
| onOk, | |||
| parserId, | |||
| documentId, | |||
| documentExtension, | |||
| visible, | |||
| parserConfig, | |||
| @@ -1,4 +1,5 @@ | |||
| import { Form, FormInstance, Input, InputRef, Typography } from 'antd'; | |||
| import { omit } from 'lodash'; | |||
| import React, { useContext, useEffect, useRef, useState } from 'react'; | |||
| const EditableContext = React.createContext<FormInstance<any> | null>(null); | |||
| @@ -15,15 +16,12 @@ interface Item { | |||
| address: string; | |||
| } | |||
| export const EditableRow: React.FC<EditableRowProps> = ({ | |||
| index, | |||
| ...props | |||
| }) => { | |||
| export const EditableRow: React.FC<EditableRowProps> = ({ ...props }) => { | |||
| const [form] = Form.useForm(); | |||
| return ( | |||
| <Form form={form} component={false}> | |||
| <EditableContext.Provider value={form}> | |||
| <tr {...props} /> | |||
| <tr {...omit(props, 'index')} /> | |||
| </EditableContext.Provider> | |||
| </Form> | |||
| ); | |||
| @@ -31,7 +31,7 @@ const HightLightMarkdown = ({ | |||
| components={ | |||
| { | |||
| code(props: any) { | |||
| const { children, className, node, ...rest } = props; | |||
| const { children, className, ...rest } = props; | |||
| const match = /language-(\w+)/.exec(className || ''); | |||
| return match ? ( | |||
| <SyntaxHighlighter | |||
| @@ -1,4 +1,4 @@ | |||
| import { PromptIcon } from '@/assets/icon/Icon'; | |||
| import { PromptIcon } from '@/assets/icon/next-icon'; | |||
| import CopyToClipboard from '@/components/copy-to-clipboard'; | |||
| import { useSetModalState } from '@/hooks/common-hooks'; | |||
| import { IRemoveMessageById } from '@/hooks/logic-hooks'; | |||
| @@ -27,6 +27,7 @@ import { | |||
| import { cn } from '@/lib/utils'; | |||
| import { currentReg, replaceTextByOldReg } from '@/pages/chat/utils'; | |||
| import classNames from 'classnames'; | |||
| import { omit } from 'lodash'; | |||
| import { pipe } from 'lodash/fp'; | |||
| import { CircleAlert } from 'lucide-react'; | |||
| import { Button } from '../ui/button'; | |||
| @@ -256,11 +257,12 @@ function MarkdownContent({ | |||
| 'custom-typography': ({ children }: { children: string }) => | |||
| renderReference(children), | |||
| 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 || ''); | |||
| return match ? ( | |||
| <SyntaxHighlighter | |||
| {...rest} | |||
| {...restProps} | |||
| PreTag="div" | |||
| language={match[1]} | |||
| wrapLongLines | |||
| @@ -268,7 +270,10 @@ function MarkdownContent({ | |||
| {String(children).replace(/\n$/, '')} | |||
| </SyntaxHighlighter> | |||
| ) : ( | |||
| <code {...rest} className={classNames(className, 'text-wrap')}> | |||
| <code | |||
| {...restProps} | |||
| className={classNames(className, 'text-wrap')} | |||
| > | |||
| {children} | |||
| </code> | |||
| ); | |||
| @@ -1,4 +1,4 @@ | |||
| import { PromptIcon } from '@/assets/icon/Icon'; | |||
| import { PromptIcon } from '@/assets/icon/next-icon'; | |||
| import CopyToClipboard from '@/components/copy-to-clipboard'; | |||
| import { useSetModalState } from '@/hooks/common-hooks'; | |||
| import { IRemoveMessageById } from '@/hooks/logic-hooks'; | |||
| @@ -17,7 +17,7 @@ import { IRegenerateMessage, IRemoveMessageById } from '@/hooks/logic-hooks'; | |||
| import { INodeEvent, MessageEventType } from '@/hooks/use-send-message'; | |||
| import { cn } from '@/lib/utils'; | |||
| 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 { isEmpty } from 'lodash'; | |||
| import { Atom, ChevronDown, ChevronUp } from 'lucide-react'; | |||
| @@ -124,7 +124,7 @@ interface TimelineIndicatorProps extends React.HTMLAttributes<HTMLDivElement> { | |||
| } | |||
| function TimelineIndicator({ | |||
| asChild = false, | |||
| // asChild = false, | |||
| className, | |||
| children, | |||
| ...props | |||
| @@ -1,7 +1,6 @@ | |||
| import { Input } from '@/components/originui/input'; | |||
| import { useTranslate } from '@/hooks/common-hooks'; | |||
| import { EyeIcon, EyeOffIcon } from 'lucide-react'; | |||
| import { ChangeEvent, LegacyRef, forwardRef, useId, useState } from 'react'; | |||
| import { ChangeEvent, forwardRef, useId, useState } from 'react'; | |||
| type PropType = { | |||
| name: string; | |||
| @@ -10,17 +9,12 @@ type PropType = { | |||
| onChange: (event: ChangeEvent<HTMLInputElement>) => void; | |||
| }; | |||
| function PasswordInput( | |||
| props: PropType, | |||
| ref: LegacyRef<HTMLInputElement> | undefined, | |||
| ) { | |||
| function PasswordInput(props: PropType) { | |||
| const id = useId(); | |||
| const [isVisible, setIsVisible] = useState<boolean>(false); | |||
| const toggleVisibility = () => setIsVisible((prevState) => !prevState); | |||
| const { t } = useTranslate('setting'); | |||
| return ( | |||
| <div className="*:not-first:mt-2 w-full"> | |||
| {/* <Label htmlFor={id}>Show/hide password input</Label> */} | |||
| @@ -39,7 +39,7 @@ const CommandInput = React.forwardRef< | |||
| React.ElementRef<typeof CommandPrimitive.Input>, | |||
| React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input> | |||
| >(({ 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" /> | |||
| <CommandPrimitive.Input | |||
| ref={ref} | |||
| @@ -196,7 +196,7 @@ export const MultiSelect = React.forwardRef< | |||
| animation = 0, | |||
| maxCount = 3, | |||
| modalPopover = false, | |||
| asChild = false, | |||
| // asChild = false, | |||
| className, | |||
| showSelectAll = true, | |||
| ...props | |||
| @@ -26,7 +26,7 @@ const SIDEBAR_WIDTH_MOBILE = '18rem'; | |||
| const SIDEBAR_WIDTH_ICON = '3rem'; | |||
| const SIDEBAR_KEYBOARD_SHORTCUT = 'b'; | |||
| type SidebarContext = { | |||
| type SidebarContextType = { | |||
| state: 'expanded' | 'collapsed'; | |||
| open: boolean; | |||
| setOpen: (open: boolean) => void; | |||
| @@ -36,7 +36,7 @@ type SidebarContext = { | |||
| toggleSidebar: () => void; | |||
| }; | |||
| const SidebarContext = React.createContext<SidebarContext | null>(null); | |||
| const SidebarContext = React.createContext<SidebarContextType | null>(null); | |||
| function useSidebar() { | |||
| const context = React.useContext(SidebarContext); | |||
| @@ -116,7 +116,7 @@ const SidebarProvider = React.forwardRef< | |||
| // This makes it easier to style the sidebar with Tailwind classes. | |||
| const state = open ? 'expanded' : 'collapsed'; | |||
| const contextValue = React.useMemo<SidebarContext>( | |||
| const contextValue = React.useMemo<SidebarContextType>( | |||
| () => ({ | |||
| state, | |||
| open, | |||
| @@ -580,11 +580,8 @@ const SidebarMenuButton = React.forwardRef< | |||
| return button; | |||
| } | |||
| if (typeof tooltip === 'string') { | |||
| tooltip = { | |||
| children: tooltip, | |||
| }; | |||
| } | |||
| const tooltipContent = | |||
| typeof tooltip === 'string' ? { children: tooltip } : tooltip; | |||
| return ( | |||
| <Tooltip> | |||
| @@ -593,7 +590,7 @@ const SidebarMenuButton = React.forwardRef< | |||
| side="right" | |||
| align="center" | |||
| hidden={state !== 'collapsed' || isMobile} | |||
| {...tooltip} | |||
| {...tooltipContent} | |||
| /> | |||
| </Tooltip> | |||
| ); | |||
| @@ -27,7 +27,7 @@ import { useTranslate } from './common-hooks'; | |||
| import { useSetPaginationParams } from './route-hook'; | |||
| import { useFetchTenantInfo, useSaveSetting } from './user-setting-hooks'; | |||
| function usePrevious<T>(value: T) { | |||
| export function usePrevious<T>(value: T) { | |||
| const ref = useRef<T>(); | |||
| useEffect(() => { | |||
| ref.current = value; | |||
| @@ -368,16 +368,7 @@ export const useUploadCanvasFileWithProgress = ( | |||
| { | |||
| url: api.uploadAgentFile(identifier || id), | |||
| data: formData, | |||
| onUploadProgress: ({ | |||
| loaded, | |||
| total, | |||
| progress, | |||
| bytes, | |||
| estimated, | |||
| rate, | |||
| upload, | |||
| lengthComputable, | |||
| }) => { | |||
| onUploadProgress: ({ progress }) => { | |||
| files.forEach((file) => { | |||
| onProgress(file, (progress || 0) * 100); | |||
| }); | |||
| @@ -5,7 +5,7 @@ import { IAskRequestBody } from '@/interfaces/request/chat'; | |||
| import { IClientConversation } from '@/pages/next-chats/chat/interface'; | |||
| import { useGetSharedChatSearchParams } from '@/pages/next-chats/hooks/use-send-shared-message'; | |||
| 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 { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; | |||
| import { useDebounce } from 'ahooks'; | |||
| @@ -13,8 +13,7 @@ import { LanguageList, LanguageMap, ThemeEnum } from '@/constants/common'; | |||
| import { useChangeLanguage } from '@/hooks/logic-hooks'; | |||
| import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks'; | |||
| 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 { camelCase } from 'lodash'; | |||
| import { | |||
| @@ -55,11 +54,11 @@ export function Header() { | |||
| 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) => ({ | |||
| key: x, | |||
| @@ -70,9 +69,9 @@ export function Header() { | |||
| setTheme(theme === ThemeEnum.Dark ? ThemeEnum.Light : ThemeEnum.Dark); | |||
| }, [setTheme, theme]); | |||
| const handleBellClick = useCallback(() => { | |||
| navigate('/user-setting/team'); | |||
| }, [navigate]); | |||
| // const handleBellClick = useCallback(() => { | |||
| // navigate('/user-setting/team'); | |||
| // }, [navigate]); | |||
| const tagsData = useMemo( | |||
| () => [ | |||
| @@ -147,7 +147,7 @@ export const useHandleUploadDocument = () => { | |||
| const [fileList, setFileList] = useState<UploadFile[]>([]); | |||
| const [uploadProgress, setUploadProgress] = useState<number>(0); | |||
| const { uploadDocument, loading } = useUploadNextDocument(); | |||
| const { runDocumentByIds, loading: _ } = useRunNextDocument(); | |||
| const { runDocumentByIds } = useRunNextDocument(); | |||
| const onDocumentUploadOk = useCallback( | |||
| async ({ | |||
| @@ -168,7 +168,7 @@ const KnowledgeFile = () => { | |||
| ), | |||
| dataIndex: 'run', | |||
| key: 'run', | |||
| filters: Object.entries(RunningStatus).map(([key, value]) => ({ | |||
| filters: Object.values(RunningStatus).map((value) => ({ | |||
| text: t(`runningStatus${value}`), | |||
| value: value, | |||
| })), | |||
| @@ -27,7 +27,6 @@ const KnowledgeSidebar = () => { | |||
| const { knowledgeId } = useGetKnowledgeSearchParams(); | |||
| const [windowWidth, setWindowWidth] = useState(getWidth()); | |||
| const [collapsed, setCollapsed] = useState(false); | |||
| const { t } = useTranslation(); | |||
| const { data: knowledgeDetails } = useFetchKnowledgeBaseConfiguration(); | |||
| @@ -92,14 +91,6 @@ const KnowledgeSidebar = () => { | |||
| return list; | |||
| }, [data, getItem]); | |||
| useEffect(() => { | |||
| if (windowWidth.width > 957) { | |||
| setCollapsed(false); | |||
| } else { | |||
| setCollapsed(true); | |||
| } | |||
| }, [windowWidth.width]); | |||
| useEffect(() => { | |||
| const widthSize = () => { | |||
| const width = getWidth(); | |||
| @@ -4,7 +4,7 @@ import { IRetrievalNode } from '@/interfaces/database/flow'; | |||
| import { NodeProps, Position } from '@xyflow/react'; | |||
| import classNames from 'classnames'; | |||
| import { get } from 'lodash'; | |||
| import { memo, useMemo } from 'react'; | |||
| import { memo } from 'react'; | |||
| import { NodeHandleId } from '../../constant'; | |||
| import { useGetVariableLabelByValue } from '../../hooks/use-get-begin-query'; | |||
| import { CommonHandle } from './handle'; | |||
| @@ -21,18 +21,7 @@ function InnerRetrievalNode({ | |||
| selected, | |||
| }: NodeProps<IRetrievalNode>) { | |||
| const knowledgeBaseIds: string[] = get(data, 'form.kb_ids', []); | |||
| console.log('🚀 ~ InnerRetrievalNode ~ knowledgeBaseIds:', knowledgeBaseIds); | |||
| 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); | |||
| @@ -1,8 +1,7 @@ | |||
| import { ModelVariableType } from '@/constants/knowledge'; | |||
| import { RAGFlowNodeType } from '@/interfaces/database/flow'; | |||
| import { get, isEmpty, isPlainObject } from 'lodash'; | |||
| import { isEmpty, isPlainObject } from 'lodash'; | |||
| import { useMemo } from 'react'; | |||
| import { buildCategorizeListFromObject } from '../../utils'; | |||
| const defaultValues = { | |||
| parameter: ModelVariableType.Precise, | |||
| @@ -21,9 +20,6 @@ export function useValues(node?: RAGFlowNodeType) { | |||
| if (isEmpty(formData)) { | |||
| return defaultValues; | |||
| } | |||
| const items = buildCategorizeListFromObject( | |||
| get(node, 'data.form.category_description', {}), | |||
| ); | |||
| if (isPlainObject(formData)) { | |||
| // const nextValues = { | |||
| // ...omit(formData, 'category_description'), | |||
| @@ -1,6 +1,6 @@ | |||
| 'use client'; | |||
| import { SideDown } from '@/assets/icon/Icon'; | |||
| import { SideDown } from '@/assets/icon/next-icon'; | |||
| import { Button } from '@/components/ui/button'; | |||
| import { | |||
| Collapsible, | |||
| @@ -1,4 +1,3 @@ | |||
| import { Edge } from '@xyflow/react'; | |||
| import pick from 'lodash/pick'; | |||
| import { useCallback, useEffect } from 'react'; | |||
| import { IOperatorForm } from '../../interface'; | |||
| @@ -21,16 +20,12 @@ export const useBuildRelevantOptions = () => { | |||
| 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 | |||
| * similar to the categorize-form's useHandleFormValuesChange method | |||
| * @param param0 | |||
| */ | |||
| export const useWatchConnectionChanges = ({ nodeId, form }: IOperatorForm) => { | |||
| const edges = useGraphStore((state) => state.edges); | |||
| const getNode = useGraphStore((state) => state.getNode); | |||
| const node = getNode(nodeId); | |||
| @@ -40,13 +35,6 @@ export const useWatchConnectionChanges = ({ nodeId, form }: IOperatorForm) => { | |||
| } | |||
| }, [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(() => { | |||
| watchFormChanges(); | |||
| }, [watchFormChanges]); | |||
| @@ -8,7 +8,7 @@ import { IModalProps } from '@/interfaces/common'; | |||
| import { NotebookText } from 'lucide-react'; | |||
| import 'react18-json-view/src/style.css'; | |||
| import { useCacheChatLog } from '../hooks/use-cache-chat-log'; | |||
| import { WorkFlowTimeline } from './workFlowTimeline'; | |||
| import { WorkFlowTimeline } from './workflow-timeline'; | |||
| type LogSheetProps = IModalProps<any> & | |||
| Pick< | |||
| @@ -19,7 +19,7 @@ import { | |||
| JsonViewer, | |||
| toLowerCaseStringAndDeleteChar, | |||
| typeMap, | |||
| } from './workFlowTimeline'; | |||
| } from './workflow-timeline'; | |||
| type IToolIcon = | |||
| | Operator.ArXiv | |||
| | Operator.GitHub | |||
| @@ -28,7 +28,7 @@ import JsonView from 'react18-json-view'; | |||
| import { Operator } from '../constant'; | |||
| import { useCacheChatLog } from '../hooks/use-cache-chat-log'; | |||
| import OperatorIcon from '../operator-icon'; | |||
| import ToolTimelineItem from './toolTimelineItem'; | |||
| import ToolTimelineItem from './tool-timeline-item'; | |||
| type LogFlowTimelineProps = Pick< | |||
| ReturnType<typeof useCacheChatLog>, | |||
| 'currentEventListWithoutMessage' | 'currentMessageId' | |||
| @@ -1,4 +1,5 @@ | |||
| import { Form, FormInstance, Input, InputRef } from 'antd'; | |||
| import { omit } from 'lodash'; | |||
| import React, { useContext, useEffect, useRef, useState } from 'react'; | |||
| const EditableContext = React.createContext<FormInstance<any> | null>(null); | |||
| @@ -14,15 +15,12 @@ interface Item { | |||
| address: string; | |||
| } | |||
| export const EditableRow: React.FC<EditableRowProps> = ({ | |||
| index, | |||
| ...props | |||
| }) => { | |||
| export const EditableRow: React.FC<EditableRowProps> = ({ ...props }) => { | |||
| const [form] = Form.useForm(); | |||
| return ( | |||
| <Form form={form} component={false}> | |||
| <EditableContext.Provider value={form}> | |||
| <tr {...props} /> | |||
| <tr {...omit(props, 'index')} /> | |||
| </EditableContext.Provider> | |||
| </Form> | |||
| ); | |||
| @@ -28,6 +28,7 @@ import { | |||
| import { currentReg, replaceTextByOldReg } from '../utils'; | |||
| import classNames from 'classnames'; | |||
| import { omit } from 'lodash'; | |||
| import { pipe } from 'lodash/fp'; | |||
| import styles from './index.less'; | |||
| @@ -247,11 +248,12 @@ const MarkdownContent = ({ | |||
| 'custom-typography': ({ children }: { children: string }) => | |||
| renderReference(children), | |||
| 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 || ''); | |||
| return match ? ( | |||
| <SyntaxHighlighter | |||
| {...rest} | |||
| {...restProps} | |||
| PreTag="div" | |||
| language={match[1]} | |||
| wrapLongLines | |||
| @@ -259,7 +261,10 @@ const MarkdownContent = ({ | |||
| {String(children).replace(/\n$/, '')} | |||
| </SyntaxHighlighter> | |||
| ) : ( | |||
| <code {...rest} className={classNames(className, 'text-wrap')}> | |||
| <code | |||
| {...restProps} | |||
| className={classNames(className, 'text-wrap')} | |||
| > | |||
| {children} | |||
| </code> | |||
| ); | |||
| @@ -26,7 +26,7 @@ export const useGetSharedChatSearchParams = () => { | |||
| const data = Object.fromEntries( | |||
| searchParams | |||
| .entries() | |||
| .filter(([key, value]) => key.startsWith(data_prefix)) | |||
| .filter(([key]) => key.startsWith(data_prefix)) | |||
| .map(([key, value]) => [key.replace(data_prefix, ''), value]), | |||
| ); | |||
| return { | |||
| @@ -19,7 +19,6 @@ import { Switch } from '@/components/ui/switch'; | |||
| import { Textarea } from '@/components/ui/textarea'; | |||
| import { useFetchChunk } from '@/hooks/chunk-hooks'; | |||
| import { IModalProps } from '@/interfaces/common'; | |||
| import { IChunk } from '@/interfaces/database/knowledge'; | |||
| import { Trash2 } from 'lucide-react'; | |||
| import React, { useCallback, useEffect, useState } from 'react'; | |||
| import { FieldValues, FormProvider, useForm } from 'react-hook-form'; | |||
| @@ -31,11 +30,6 @@ import { | |||
| } from '../../utils'; | |||
| import { TagFeatureItem } from './tag-feature-item'; | |||
| type FieldType = Pick< | |||
| IChunk, | |||
| 'content_with_weight' | 'tag_kwd' | 'question_kwd' | 'important_kwd' | |||
| >; | |||
| interface kFProps { | |||
| doc_id: string; | |||
| chunkId: string | undefined; | |||
| @@ -36,7 +36,7 @@ const CSVFileViewer: React.FC<FileViewerProps> = () => { | |||
| const res = await request(url, { | |||
| method: 'GET', | |||
| responseType: 'blob', | |||
| onError: (err) => { | |||
| onError: () => { | |||
| message.error('file load failed'); | |||
| setIsLoading(false); | |||
| }, | |||
| @@ -1,13 +1,9 @@ | |||
| import { useTestRetrieval } from '@/hooks/use-knowledge-request'; | |||
| import { useCallback, useState } from 'react'; | |||
| import { useState } from 'react'; | |||
| import { TopTitle } from '../dataset-title'; | |||
| import TestingForm from './testing-form'; | |||
| import { TestingResult } from './testing-result'; | |||
| function Vertical() { | |||
| return <div>xxx</div>; | |||
| } | |||
| export default function RetrievalTesting() { | |||
| const { | |||
| loading, | |||
| @@ -21,15 +17,7 @@ export default function RetrievalTesting() { | |||
| filterValue, | |||
| } = useTestRetrieval(); | |||
| const [count, setCount] = useState(1); | |||
| const addCount = useCallback(() => { | |||
| setCount(2); | |||
| }, []); | |||
| const removeCount = useCallback(() => { | |||
| setCount(1); | |||
| }, []); | |||
| const [count] = useState(1); | |||
| return ( | |||
| <div className="p-5"> | |||
| @@ -3,7 +3,7 @@ import { | |||
| KeywordIcon, | |||
| QWeatherIcon, | |||
| WikipediaIcon, | |||
| } from '@/assets/icon/Icon'; | |||
| } from '@/assets/icon/next-icon'; | |||
| import { ReactComponent as AkShareIcon } from '@/assets/svg/akshare.svg'; | |||
| import { ReactComponent as ArXivIcon } from '@/assets/svg/arxiv.svg'; | |||
| import { ReactComponent as baiduFanyiIcon } from '@/assets/svg/baidu-fanyi.svg'; | |||
| @@ -1,4 +1,4 @@ | |||
| import { CommaIcon, SemicolonIcon } from '@/assets/icon/Icon'; | |||
| import { CommaIcon, SemicolonIcon } from '@/assets/icon/next-icon'; | |||
| import { Form, Select } from 'antd'; | |||
| import { | |||
| CornerDownLeft, | |||
| @@ -1,4 +1,3 @@ | |||
| import { Edge } from '@xyflow/react'; | |||
| import pick from 'lodash/pick'; | |||
| import { useCallback, useEffect } from 'react'; | |||
| import { IOperatorForm } from '../../interface'; | |||
| @@ -21,8 +20,8 @@ export const useBuildRelevantOptions = () => { | |||
| 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 | |||
| @@ -30,7 +29,7 @@ const getTargetOfEdge = (edges: Edge[], sourceHandle: string) => | |||
| * @param param0 | |||
| */ | |||
| 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 node = getNode(nodeId); | |||
| @@ -40,12 +39,12 @@ export const useWatchConnectionChanges = ({ nodeId, form }: IOperatorForm) => { | |||
| } | |||
| }, [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(() => { | |||
| watchFormChanges(); | |||
| @@ -50,10 +50,14 @@ export const useSaveGraphBeforeOpeningDebugDrawer = (show: () => void) => { | |||
| }; | |||
| export const useWatchAgentChange = (chatDrawerVisible: boolean) => { | |||
| console.log( | |||
| '🚀 ~ useWatchAgentChange ~ chatDrawerVisible:', | |||
| chatDrawerVisible, | |||
| ); | |||
| const [time, setTime] = useState<string>(); | |||
| const nodes = useGraphStore((state) => state.nodes); | |||
| const edges = useGraphStore((state) => state.edges); | |||
| const { saveGraph } = useSaveGraph(); | |||
| // const { saveGraph } = useSaveGraph(); | |||
| const { data: flowDetail } = useFetchFlow(); | |||
| const setSaveTime = useCallback((updateTime: number) => { | |||
| @@ -64,12 +68,12 @@ export const useWatchAgentChange = (chatDrawerVisible: boolean) => { | |||
| setSaveTime(flowDetail?.update_time); | |||
| }, [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( | |||
| () => { | |||
| @@ -11,6 +11,7 @@ export enum Step { | |||
| export const useSwitchStep = (step: Step) => { | |||
| const [_, setSearchParams] = useSearchParams(); | |||
| console.log('🚀 ~ useSwitchStep ~ _:', _); | |||
| const switchStep = useCallback(() => { | |||
| setSearchParams(new URLSearchParams({ step: step.toString() })); | |||
| }, [setSearchParams, step]); | |||
| @@ -16,7 +16,7 @@ export const useGetSharedChatSearchParams = () => { | |||
| const data = Object.fromEntries( | |||
| searchParams | |||
| .entries() | |||
| .filter(([key, value]) => key.startsWith(data_prefix)) | |||
| .filter(([key]) => key.startsWith(data_prefix)) | |||
| .map(([key, value]) => [key.replace(data_prefix, ''), value]), | |||
| ); | |||
| return { | |||
| @@ -116,8 +116,7 @@ const SearchSetting: React.FC<SearchSettingProps> = ({ | |||
| })(); | |||
| } | |||
| }, [avatarFile]); | |||
| const { list: datasetListOrigin, loading: datasetLoading } = | |||
| useFetchKnowledgeList(); | |||
| const { list: datasetListOrigin } = useFetchKnowledgeList(); | |||
| useEffect(() => { | |||
| const datasetListMap = datasetListOrigin.map((item: IKnowledge) => { | |||
| @@ -30,7 +30,7 @@ type SearchFormValues = z.infer<typeof searchFormSchema>; | |||
| export default function SearchList() { | |||
| // const { data } = useFetchFlowList(); | |||
| const { t } = useTranslate('search'); | |||
| const { isLoading, isError, createSearch } = useCreateSearch(); | |||
| const { isLoading, createSearch } = useCreateSearch(); | |||
| const { | |||
| data: list, | |||
| searchParams, | |||
| @@ -24,7 +24,7 @@ export const useSendQuestion = (kbIds: string[]) => { | |||
| api.ask, | |||
| ); | |||
| const { testChunk, loading } = useTestChunkRetrieval(); | |||
| const { testChunkAll, loading: loadingAll } = useTestChunkAllRetrieval(); | |||
| const { testChunkAll } = useTestChunkAllRetrieval(); | |||
| const [sendingLoading, setSendingLoading] = useState(false); | |||
| const [currentAnswer, setCurrentAnswer] = useState({} as IAnswer); | |||
| const { fetchRelatedQuestions, data: relatedQuestions } = | |||
| @@ -102,7 +102,14 @@ export const useSendQuestion = (kbIds: string[]) => { | |||
| size, | |||
| }); | |||
| }, | |||
| [sendingLoading, searchStr, kbIds, testChunk, selectedDocumentIds], | |||
| [ | |||
| searchStr, | |||
| sendingLoading, | |||
| testChunk, | |||
| kbIds, | |||
| selectedDocumentIds, | |||
| testChunkAll, | |||
| ], | |||
| ); | |||
| useEffect(() => { | |||
| @@ -5,7 +5,7 @@ import { | |||
| PasswordIcon, | |||
| ProfileIcon, | |||
| TeamIcon, | |||
| } from '@/assets/icon/Icon'; | |||
| } from '@/assets/icon/next-icon'; | |||
| import { IconFont } from '@/components/icon-font'; | |||
| import { LLMFactory } from '@/constants/llm'; | |||
| import { UserSettingRouteKey } from '@/constants/setting'; | |||
| @@ -1,5 +1,5 @@ | |||
| import { translationTable } from '@/locales/config'; | |||
| import TranslationTable from './TranslationTable'; | |||
| import TranslationTable from './translation-table'; | |||
| function UserSettingLocale() { | |||
| return ( | |||
| @@ -46,7 +46,7 @@ const AzureOpenAIModal = ({ | |||
| { value: 'image2text', label: 'image2text' }, | |||
| ], | |||
| }; | |||
| const getOptions = (factory: string) => { | |||
| const getOptions = () => { | |||
| return optionsMap.Default; | |||
| }; | |||
| const handleKeyDown = async (e: React.KeyboardEvent) => { | |||
| @@ -132,7 +132,7 @@ const AzureOpenAIModal = ({ | |||
| type: 'number', | |||
| message: t('maxTokensInvalidMessage'), | |||
| }, | |||
| ({ getFieldValue }) => ({ | |||
| ({}) => ({ | |||
| validator(_, value) { | |||
| if (value < 0) { | |||
| return Promise.reject(new Error(t('maxTokensMinMessage'))); | |||
| @@ -121,7 +121,7 @@ const BedrockModal = ({ | |||
| type: 'number', | |||
| message: t('maxTokensInvalidMessage'), | |||
| }, | |||
| ({ getFieldValue }) => ({ | |||
| ({}) => ({ | |||
| validator(_, value) { | |||
| if (value < 0) { | |||
| return Promise.reject(new Error(t('maxTokensMinMessage'))); | |||
| @@ -103,7 +103,7 @@ const FishAudioModal = ({ | |||
| type: 'number', | |||
| message: t('maxTokensInvalidMessage'), | |||
| }, | |||
| ({ getFieldValue }) => ({ | |||
| ({}) => ({ | |||
| validator(_, value) { | |||
| if (value < 0) { | |||
| return Promise.reject(new Error(t('maxTokensMinMessage'))); | |||
| @@ -110,7 +110,7 @@ const GoogleModal = ({ | |||
| type: 'number', | |||
| message: t('maxTokensInvalidMessage'), | |||
| }, | |||
| ({ getFieldValue }) => ({ | |||
| ({}) => ({ | |||
| validator(_, value) { | |||
| if (value < 0) { | |||
| return Promise.reject(new Error(t('maxTokensMinMessage'))); | |||
| @@ -114,7 +114,6 @@ export const useSubmitOllama = () => { | |||
| const [initialValues, setInitialValues] = useState< | |||
| Partial<IAddLlmRequestBody> | undefined | |||
| >(); | |||
| const [originalModelName, setOriginalModelName] = useState<string>(''); | |||
| const { addLlm, loading } = useAddLlm(); | |||
| const { | |||
| visible: llmAddingVisible, | |||
| @@ -1,7 +1,7 @@ | |||
| import { useTranslate } from '@/hooks/common-hooks'; | |||
| import { IModalProps } from '@/interfaces/common'; | |||
| import { IAddLlmRequestBody } from '@/interfaces/request/llm'; | |||
| import { Form, Input, Modal, Select } from 'antd'; | |||
| import { Form, Input, Modal } from 'antd'; | |||
| import omit from 'lodash/omit'; | |||
| type FieldType = IAddLlmRequestBody & { | |||
| @@ -10,8 +10,6 @@ type FieldType = IAddLlmRequestBody & { | |||
| hunyuan_sk: string; | |||
| }; | |||
| const { Option } = Select; | |||
| const HunyuanModal = ({ | |||
| visible, | |||
| hideModal, | |||
| @@ -34,7 +34,6 @@ import { CircleHelp } from 'lucide-react'; | |||
| import { useCallback, useMemo } from 'react'; | |||
| import SettingTitle from '../components/setting-title'; | |||
| import { isLocalLlmFactory } from '../utils'; | |||
| import TencentCloudModal from './Tencent-modal'; | |||
| import ApiKeyModal from './api-key-modal'; | |||
| import AzureOpenAIModal from './azure-openai-modal'; | |||
| import BedrockModal from './bedrock-modal'; | |||
| @@ -58,6 +57,7 @@ import { | |||
| } from './hooks'; | |||
| import HunyuanModal from './hunyuan-modal'; | |||
| import styles from './index.less'; | |||
| import TencentCloudModal from './next-tencent-modal'; | |||
| import OllamaModal from './ollama-modal'; | |||
| import SparkModal from './spark-modal'; | |||
| import SystemModelSettingModal from './system-model-setting-modal'; | |||
| @@ -140,7 +140,7 @@ const SparkModal = ({ | |||
| type: 'number', | |||
| message: t('maxTokensInvalidMessage'), | |||
| }, | |||
| ({ getFieldValue }) => ({ | |||
| ({}) => ({ | |||
| validator(_, value) { | |||
| if (value < 0) { | |||
| return Promise.reject(new Error(t('maxTokensMinMessage'))); | |||
| @@ -113,7 +113,7 @@ const VolcEngineModal = ({ | |||
| type: 'number', | |||
| message: t('maxTokensInvalidMessage'), | |||
| }, | |||
| ({ getFieldValue }) => ({ | |||
| ({}) => ({ | |||
| validator(_, value) { | |||
| if (value < 0) { | |||
| return Promise.reject(new Error(t('maxTokensMinMessage'))); | |||
| @@ -108,7 +108,7 @@ const YiyanModal = ({ | |||
| type: 'number', | |||
| message: t('maxTokensInvalidMessage'), | |||
| }, | |||
| ({ getFieldValue }) => ({ | |||
| ({}) => ({ | |||
| validator(_, value) { | |||
| if (value < 0) { | |||
| return Promise.reject(new Error(t('maxTokensMinMessage'))); | |||
| @@ -4,7 +4,7 @@ import { registerNextServer } from '@/utils/register-server'; | |||
| const { | |||
| getDialog, | |||
| setDialog, | |||
| listDialog, | |||
| // listDialog, | |||
| removeDialog, | |||
| getConversation, | |||
| getConversationSSE, | |||
| @@ -1,3 +1,4 @@ | |||
| /* eslint-disable guard-for-in */ | |||
| import { AxiosRequestConfig, AxiosResponse } from 'axios'; | |||
| import { isObject } from 'lodash'; | |||
| import omit from 'lodash/omit'; | |||