diff --git a/web/.husky/pre-commit b/web/.husky/pre-commit index 832da580..aa89fa4b 100644 --- a/web/.husky/pre-commit +++ b/web/.husky/pre-commit @@ -1,3 +1,2 @@ cd web pnpm lint-staged -pnpm test \ No newline at end of file diff --git a/web/.lintstagedrc.json b/web/.lintstagedrc.json index f7a24c1f..253287a0 100644 --- a/web/.lintstagedrc.json +++ b/web/.lintstagedrc.json @@ -1,3 +1,3 @@ { - "*.{js,jsx,ts,tsx}": ["prettier --write", "eslint --fix", "eslint"] -} \ No newline at end of file + "*.{js,jsx,ts,tsx}": ["eslint --fix", "eslint"] +} diff --git a/web/.prettierrc.mjs b/web/.prettierrc.mjs index 0ce90351..01ed3d48 100644 --- a/web/.prettierrc.mjs +++ b/web/.prettierrc.mjs @@ -3,7 +3,20 @@ * @type {import("prettier").Config} */ const config = { - trailingComma: "none", + // 单行长度 + printWidth: 80, + // 缩进 + tabWidth: 2, + // 使用空格代替tab缩进 + useTabs: false, + // 句末使用分号 + semi: true, + // 使用单引号 + singleQuote: true, + // 大括号前后空格 + bracketSpacing: true, + attributeVerticalAlignment: 'auto', + trailingComma: 'all', }; -export default config; \ No newline at end of file +export default config; diff --git a/web/eslint.config.mjs b/web/eslint.config.mjs index c85fb67c..18b74c95 100644 --- a/web/eslint.config.mjs +++ b/web/eslint.config.mjs @@ -1,6 +1,7 @@ -import { dirname } from "path"; -import { fileURLToPath } from "url"; -import { FlatCompat } from "@eslint/eslintrc"; +import { dirname } from 'path'; +import { fileURLToPath } from 'url'; +import { FlatCompat } from '@eslint/eslintrc'; +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); @@ -10,7 +11,8 @@ const compat = new FlatCompat({ }); const eslintConfig = [ - ...compat.extends("next/core-web-vitals", "next/typescript"), + ...compat.extends('next/core-web-vitals', 'next/typescript'), + eslintPluginPrettierRecommended, ]; export default eslintConfig; diff --git a/web/next.config.ts b/web/next.config.ts index 9d1f4a25..1abe320c 100644 --- a/web/next.config.ts +++ b/web/next.config.ts @@ -1,8 +1,8 @@ -import type { NextConfig } from "next"; +import type { NextConfig } from 'next'; const nextConfig: NextConfig = { /* config options here */ - output: 'export' + output: 'export', }; export default nextConfig; diff --git a/web/package-lock.json b/web/package-lock.json index 73cc51e1..3ee13d82 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -25,10 +25,13 @@ "@types/react-dom": "^19", "eslint": "^9", "eslint-config-next": "15.2.4", + "eslint-config-prettier": "^10.1.2", + "eslint-plugin-prettier": "^5.2.6", "husky": "^9.1.7", "lint-staged": "^15.5.1", "prettier": "^3.5.3", - "typescript": "^5" + "typescript": "^5.8.3", + "typescript-eslint": "^8.31.1" } }, "node_modules/@ant-design/colors": { @@ -906,6 +909,18 @@ "node": ">=12.4.0" } }, + "node_modules/@pkgr/core": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.2.4.tgz", + "integrity": "sha512-ROFF39F6ZrnzSUEmQQZUar0Jt4xVoP9WnDRdWwF4NNcXs3xBTLgBUDoOwW141y1jP+S8nahIbdxbFC7IShw9Iw==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/pkgr" + } + }, "node_modules/@rc-component/async-validator": { "version": "5.0.4", "resolved": "https://registry.npmmirror.com/@rc-component/async-validator/-/async-validator-5.0.4.tgz", @@ -1133,16 +1148,16 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.28.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.28.0.tgz", - "integrity": "sha512-lvFK3TCGAHsItNdWZ/1FkvpzCxTHUVuFrdnOGLMa0GGCFIbCgQWVk3CzCGdA7kM3qGVc+dfW9tr0Z/sHnGDFyg==", + "version": "8.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.31.1.tgz", + "integrity": "sha512-oUlH4h1ABavI4F0Xnl8/fOtML/eu8nI2A1nYd+f+55XI0BLu+RIqKoCiZKNo6DtqZBEQm5aNKA20G3Z5w3R6GQ==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.28.0", - "@typescript-eslint/type-utils": "8.28.0", - "@typescript-eslint/utils": "8.28.0", - "@typescript-eslint/visitor-keys": "8.28.0", + "@typescript-eslint/scope-manager": "8.31.1", + "@typescript-eslint/type-utils": "8.31.1", + "@typescript-eslint/utils": "8.31.1", + "@typescript-eslint/visitor-keys": "8.31.1", "graphemer": "^1.4.0", "ignore": "^5.3.1", "natural-compare": "^1.4.0", @@ -1162,15 +1177,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.28.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.28.0.tgz", - "integrity": "sha512-LPcw1yHD3ToaDEoljFEfQ9j2xShY367h7FZ1sq5NJT9I3yj4LHer1Xd1yRSOdYy9BpsrxU7R+eoDokChYM53lQ==", + "version": "8.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.31.1.tgz", + "integrity": "sha512-oU/OtYVydhXnumd0BobL9rkJg7wFJ9bFFPmSmB/bf/XWN85hlViji59ko6bSKBXyseT9V8l+CN1nwmlbiN0G7Q==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "8.28.0", - "@typescript-eslint/types": "8.28.0", - "@typescript-eslint/typescript-estree": "8.28.0", - "@typescript-eslint/visitor-keys": "8.28.0", + "@typescript-eslint/scope-manager": "8.31.1", + "@typescript-eslint/types": "8.31.1", + "@typescript-eslint/typescript-estree": "8.31.1", + "@typescript-eslint/visitor-keys": "8.31.1", "debug": "^4.3.4" }, "engines": { @@ -1186,13 +1201,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.28.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.28.0.tgz", - "integrity": "sha512-u2oITX3BJwzWCapoZ/pXw6BCOl8rJP4Ij/3wPoGvY8XwvXflOzd1kLrDUUUAIEdJSFh+ASwdTHqtan9xSg8buw==", + "version": "8.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.31.1.tgz", + "integrity": "sha512-BMNLOElPxrtNQMIsFHE+3P0Yf1z0dJqV9zLdDxN/xLlWMlXK/ApEsVEKzpizg9oal8bAT5Sc7+ocal7AC1HCVw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "8.28.0", - "@typescript-eslint/visitor-keys": "8.28.0" + "@typescript-eslint/types": "8.31.1", + "@typescript-eslint/visitor-keys": "8.31.1" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1203,13 +1218,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.28.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.28.0.tgz", - "integrity": "sha512-oRoXu2v0Rsy/VoOGhtWrOKDiIehvI+YNrDk5Oqj40Mwm0Yt01FC/Q7nFqg088d3yAsR1ZcZFVfPCTTFCe/KPwg==", + "version": "8.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.31.1.tgz", + "integrity": "sha512-fNaT/m9n0+dpSp8G/iOQ05GoHYXbxw81x+yvr7TArTuZuCA6VVKbqWYVZrV5dVagpDTtj/O8k5HBEE/p/HM5LA==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "8.28.0", - "@typescript-eslint/utils": "8.28.0", + "@typescript-eslint/typescript-estree": "8.31.1", + "@typescript-eslint/utils": "8.31.1", "debug": "^4.3.4", "ts-api-utils": "^2.0.1" }, @@ -1226,9 +1241,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.28.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.28.0.tgz", - "integrity": "sha512-bn4WS1bkKEjx7HqiwG2JNB3YJdC1q6Ue7GyGlwPHyt0TnVq6TtD/hiOdTZt71sq0s7UzqBFXD8t8o2e63tXgwA==", + "version": "8.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.31.1.tgz", + "integrity": "sha512-SfepaEFUDQYRoA70DD9GtytljBePSj17qPxFHA/h3eg6lPTqGJ5mWOtbXCk1YrVU1cTJRd14nhaXWFu0l2troQ==", "dev": true, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1239,13 +1254,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.28.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.28.0.tgz", - "integrity": "sha512-H74nHEeBGeklctAVUvmDkxB1mk+PAZ9FiOMPFncdqeRBXxk1lWSYraHw8V12b7aa6Sg9HOBNbGdSHobBPuQSuA==", + "version": "8.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.31.1.tgz", + "integrity": "sha512-kaA0ueLe2v7KunYOyWYtlf/QhhZb7+qh4Yw6Ni5kgukMIG+iP773tjgBiLWIXYumWCwEq3nLW+TUywEp8uEeag==", "dev": true, "dependencies": { - "@typescript-eslint/types": "8.28.0", - "@typescript-eslint/visitor-keys": "8.28.0", + "@typescript-eslint/types": "8.31.1", + "@typescript-eslint/visitor-keys": "8.31.1", "debug": "^4.3.4", "fast-glob": "^3.3.2", "is-glob": "^4.0.3", @@ -1317,15 +1332,15 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "8.28.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.28.0.tgz", - "integrity": "sha512-OELa9hbTYciYITqgurT1u/SzpQVtDLmQMFzy/N8pQE+tefOyCWT79jHsav294aTqV1q1u+VzqDGbuujvRYaeSQ==", + "version": "8.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.31.1.tgz", + "integrity": "sha512-2DSI4SNfF5T4oRveQ4nUrSjUqjMND0nLq9rEkz0gfGr3tg0S5KB6DhwR+WZPCjzkZl3cH+4x2ce3EsL50FubjQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "8.28.0", - "@typescript-eslint/types": "8.28.0", - "@typescript-eslint/typescript-estree": "8.28.0" + "@typescript-eslint/scope-manager": "8.31.1", + "@typescript-eslint/types": "8.31.1", + "@typescript-eslint/typescript-estree": "8.31.1" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -1340,12 +1355,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.28.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.28.0.tgz", - "integrity": "sha512-hbn8SZ8w4u2pRwgQ1GlUrPKE+t2XvcCW5tTRF7j6SMYIuYG37XuzIW44JCZPa36evi0Oy2SnM664BlIaAuQcvg==", + "version": "8.31.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.31.1.tgz", + "integrity": "sha512-I+/rgqOVBn6f0o7NDTmAPWWC6NuqhV174lfYvAm9fUaWeiefLdux9/YI3/nLugEn9L8fcSi0XmpKi/r5u0nmpw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "8.28.0", + "@typescript-eslint/types": "8.31.1", "eslint-visitor-keys": "^4.2.0" }, "engines": { @@ -2640,6 +2655,18 @@ } } }, + "node_modules/eslint-config-prettier": { + "version": "10.1.2", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-10.1.2.tgz", + "integrity": "sha512-Epgp/EofAUeEpIdZkW60MHKvPyru1ruQJxPL+WIycnaPApuseK0Zpkrh/FwL9oIpQvIhJwV7ptOy0DWUjTlCiA==", + "dev": true, + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, "node_modules/eslint-import-resolver-node": { "version": "0.3.9", "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz", @@ -2800,6 +2827,36 @@ "eslint": "^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9" } }, + "node_modules/eslint-plugin-prettier": { + "version": "5.2.6", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.6.tgz", + "integrity": "sha512-mUcf7QG2Tjk7H055Jk0lGBjbgDnfrvqjhXh9t2xLMSCjZVcw9Rb1V6sVNXO0th3jgeO7zllWPTNRil3JW94TnQ==", + "dev": true, + "dependencies": { + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.11.0" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint-plugin-prettier" + }, + "peerDependencies": { + "@types/eslint": ">=8.0.0", + "eslint": ">=8.0.0", + "eslint-config-prettier": ">= 7.0.0 <10.0.0 || >=10.1.0", + "prettier": ">=3.0.0" + }, + "peerDependenciesMeta": { + "@types/eslint": { + "optional": true + }, + "eslint-config-prettier": { + "optional": true + } + } + }, "node_modules/eslint-plugin-react": { "version": "7.37.4", "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.37.4.tgz", @@ -2992,6 +3049,12 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, + "node_modules/fast-diff": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", + "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", + "dev": true + }, "node_modules/fast-glob": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.1.tgz", @@ -4715,6 +4778,18 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", + "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", + "dev": true, + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", @@ -6117,6 +6192,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/synckit": { + "version": "0.11.4", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.11.4.tgz", + "integrity": "sha512-Q/XQKRaJiLiFIBNN+mndW7S/RHxvwzuZS6ZwmRzUBqJBv/5QIKCEwkBC8GBf8EQJKYnaFs0wOZbKTXBPj8L9oQ==", + "dev": true, + "dependencies": { + "@pkgr/core": "^0.2.3", + "tslib": "^2.8.1" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/synckit" + } + }, "node_modules/throttle-debounce": { "version": "5.0.2", "resolved": "https://registry.npmmirror.com/throttle-debounce/-/throttle-debounce-5.0.2.tgz", @@ -6300,9 +6391,9 @@ } }, "node_modules/typescript": { - "version": "5.8.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz", - "integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==", + "version": "5.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", + "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -6312,6 +6403,28 @@ "node": ">=14.17" } }, + "node_modules/typescript-eslint": { + "version": "8.31.1", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.31.1.tgz", + "integrity": "sha512-j6DsEotD/fH39qKzXTQRwYYWlt7D+0HmfpOK+DVhwJOFLcdmn92hq3mBb7HlKJHbjjI/gTOqEcc9d6JfpFf/VA==", + "dev": true, + "dependencies": { + "@typescript-eslint/eslint-plugin": "8.31.1", + "@typescript-eslint/parser": "8.31.1", + "@typescript-eslint/utils": "8.31.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0", + "typescript": ">=4.8.4 <5.9.0" + } + }, "node_modules/unbox-primitive": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.1.0.tgz", diff --git a/web/package.json b/web/package.json index 2fc93f2e..17b7ffda 100644 --- a/web/package.json +++ b/web/package.json @@ -28,9 +28,12 @@ "@types/react-dom": "^19", "eslint": "^9", "eslint-config-next": "15.2.4", + "eslint-config-prettier": "^10.1.2", + "eslint-plugin-prettier": "^5.2.6", "husky": "^9.1.7", "lint-staged": "^15.5.1", "prettier": "^3.5.3", - "typescript": "^5" + "typescript": "^5.8.3", + "typescript-eslint": "^8.31.1" } } diff --git a/web/src/app/home/bots/components/bot-card/BotCard.tsx b/web/src/app/home/bots/components/bot-card/BotCard.tsx index 92d2449a..f57a2761 100644 --- a/web/src/app/home/bots/components/bot-card/BotCard.tsx +++ b/web/src/app/home/bots/components/bot-card/BotCard.tsx @@ -1,39 +1,33 @@ -import {BotCardVO} from "@/app/home/bots/components/bot-card/BotCardVO"; -import styles from "./botCard.module.css"; +import { BotCardVO } from '@/app/home/bots/components/bot-card/BotCardVO'; +import styles from './botCard.module.css'; -export default function BotCard({ - botCardVO -}: { - botCardVO: BotCardVO; -}) { - return ( -
- {/* icon和基本信息 */} -
- {/* icon */} -
- ICO -
- {/* bot基本信息 */} -
-
- {botCardVO.name} -
-
- 平台:{botCardVO.adapter} -
-
- 绑定流水线:{botCardVO.pipelineName} -
-
-
- {/* 描述和创建时间 */} -
- 描述:{botCardVO.description} -
- {/*
+export default function BotCard({ botCardVO }: { botCardVO: BotCardVO }) { + return ( +
+ {/* icon和基本信息 */} +
+ {/* icon */} +
ICO
+ {/* bot基本信息 */} +
+
+ {botCardVO.name} +
+
+ 平台:{botCardVO.adapter} +
+
+ 绑定流水线:{botCardVO.pipelineName} +
+
+
+ {/* 描述和创建时间 */} +
+ 描述:{botCardVO.description} +
+ {/*
更新时间:{botCardVO.updateTime}
*/} -
- ) -} \ No newline at end of file +
+ ); +} diff --git a/web/src/app/home/bots/components/bot-card/BotCardVO.ts b/web/src/app/home/bots/components/bot-card/BotCardVO.ts index 6f32b183..a015a6c7 100644 --- a/web/src/app/home/bots/components/bot-card/BotCardVO.ts +++ b/web/src/app/home/bots/components/bot-card/BotCardVO.ts @@ -1,28 +1,26 @@ export interface IBotCardVO { - id: string; - name: string; - adapter: string; - description: string; - updateTime: string; - pipelineName: string; + id: string; + name: string; + adapter: string; + description: string; + updateTime: string; + pipelineName: string; } export class BotCardVO implements IBotCardVO { - id: string; - adapter: string; - description: string; - name: string; - updateTime: string; - pipelineName: string; + id: string; + adapter: string; + description: string; + name: string; + updateTime: string; + pipelineName: string; - - constructor(props: IBotCardVO) { - this.id = props.id; - this.name = props.name; - this.adapter = props.adapter; - this.description = props.description; - this.updateTime = props.updateTime; - this.pipelineName = props.pipelineName; - } - -} \ No newline at end of file + constructor(props: IBotCardVO) { + this.id = props.id; + this.name = props.name; + this.adapter = props.adapter; + this.description = props.description; + this.updateTime = props.updateTime; + this.pipelineName = props.pipelineName; + } +} diff --git a/web/src/app/home/bots/components/bot-form/BotForm.tsx b/web/src/app/home/bots/components/bot-form/BotForm.tsx index 5c3e804d..156ee581 100644 --- a/web/src/app/home/bots/components/bot-form/BotForm.tsx +++ b/web/src/app/home/bots/components/bot-form/BotForm.tsx @@ -1,24 +1,24 @@ import { BotFormEntity, - IBotFormEntity -} from "@/app/home/bots/components/bot-form/BotFormEntity"; -import { Button, Form, Input, notification, Select, Space } from "antd"; -import { useEffect, useState } from "react"; -import { IChooseAdapterEntity } from "@/app/home/bots/components/bot-form/ChooseAdapterEntity"; + IBotFormEntity, +} from '@/app/home/bots/components/bot-form/BotFormEntity'; +import { Button, Form, Input, notification, Select, Space } from 'antd'; +import { useEffect, useState } from 'react'; +import { IChooseAdapterEntity } from '@/app/home/bots/components/bot-form/ChooseAdapterEntity'; import { DynamicFormItemConfig, IDynamicFormItemConfig, - parseDynamicFormItemType -} from "@/app/home/components/dynamic-form/DynamicFormItemConfig"; -import { UUID } from "uuidjs"; -import DynamicFormComponent from "@/app/home/components/dynamic-form/DynamicFormComponent"; -import { httpClient } from "@/app/infra/http/HttpClient"; -import { Bot } from "@/app/infra/api/api-types"; + parseDynamicFormItemType, +} from '@/app/home/components/dynamic-form/DynamicFormItemConfig'; +import { UUID } from 'uuidjs'; +import DynamicFormComponent from '@/app/home/components/dynamic-form/DynamicFormComponent'; +import { httpClient } from '@/app/infra/http/HttpClient'; +import { Bot } from '@/app/infra/api/api-types'; export default function BotForm({ initBotId, onFormSubmit, - onFormCancel + onFormCancel, }: { initBotId?: string; onFormSubmit: (value: IBotFormEntity) => void; @@ -55,9 +55,9 @@ export default function BotForm({ rawAdapterList.adapters.map((item) => { return { label: item.label.zh_CN, - value: item.name + value: item.name, }; - }) + }), ); // 初始化适配器表单map rawAdapterList.adapters.forEach((rawAdapter) => { @@ -71,9 +71,9 @@ export default function BotForm({ label: item.label, name: item.name, required: item.required, - type: parseDynamicFormItemType(item.type) - }) - ) + type: parseDynamicFormItemType(item.type), + }), + ), ); }); // 拉取初始化表单信息 @@ -99,12 +99,12 @@ export default function BotForm({ adapter: bot.adapter, description: bot.description, name: bot.name, - adapter_config: bot.adapter_config + adapter_config: bot.adapter_config, }); } function handleAdapterSelect(adapterName: string) { - console.log("Select adapter: ", adapterName); + console.log('Select adapter: ', adapterName); if (adapterName) { const dynamicFormConfigList = adapterNameToDynamicConfigMap.get(adapterName); @@ -129,33 +129,33 @@ export default function BotForm({ // 只有通过外层固定表单验证才会走到这里,真正的提交逻辑在这里 function onDynamicFormSubmit(value: object) { setIsLoading(true); - console.log("set loading", true); + console.log('set loading', true); if (initBotId) { // 编辑提交 - console.log("submit edit", form.getFieldsValue(), value); + console.log('submit edit', form.getFieldsValue(), value); const updateBot: Bot = { uuid: initBotId, name: form.getFieldsValue().name, description: form.getFieldsValue().description, adapter: form.getFieldsValue().adapter, - adapter_config: value + adapter_config: value, }; httpClient .updateBot(initBotId, updateBot) .then((res) => { // TODO success toast - console.log("update bot success", res); + console.log('update bot success', res); onFormSubmit(form.getFieldsValue()); notification.success({ - message: "更新成功", - description: "机器人更新成功" + message: '更新成功', + description: '机器人更新成功', }); }) .catch(() => { // TODO error toast notification.error({ - message: "更新失败", - description: "机器人更新失败" + message: '更新失败', + description: '机器人更新失败', }); }) .finally(() => { @@ -165,20 +165,20 @@ export default function BotForm({ }); } else { // 创建提交 - console.log("submit create", form.getFieldsValue(), value); + console.log('submit create', form.getFieldsValue(), value); const newBot: Bot = { name: form.getFieldsValue().name, description: form.getFieldsValue().description, adapter: form.getFieldsValue().adapter, - adapter_config: value + adapter_config: value, }; httpClient .createBot(newBot) .then((res) => { // TODO success toast notification.success({ - message: "创建成功", - description: "机器人创建成功" + message: '创建成功', + description: '机器人创建成功', }); console.log(res); onFormSubmit(form.getFieldsValue()); @@ -186,8 +186,8 @@ export default function BotForm({ .catch(() => { // TODO error toast notification.error({ - message: "创建失败", - description: "机器人创建失败" + message: '创建失败', + description: '机器人创建失败', }); }) .finally(() => { @@ -197,7 +197,7 @@ export default function BotForm({ }); } setShowDynamicForm(false); - console.log("set loading", false); + console.log('set loading', false); // TODO 刷新bot列表 // TODO 关闭当前弹窗 Already closed @setShowDynamicForm(false)? } @@ -217,9 +217,9 @@ export default function BotForm({ disabled={isLoading} > - label={"机器人名称"} - name={"name"} - rules={[{ required: true, message: "该项为必填项哦~" }]} + label={'机器人名称'} + name={'name'} + rules={[{ required: true, message: '该项为必填项哦~' }]} > - label={"描述"} - name={"description"} - rules={[{ required: true, message: "该项为必填项哦~" }]} + label={'描述'} + name={'description'} + rules={[{ required: true, message: '该项为必填项哦~' }]} > - label={"平台/适配器选择"} - name={"adapter"} - rules={[{ required: true, message: "该项为必填项哦~" }]} + label={'平台/适配器选择'} + name={'adapter'} + rules={[{ required: true, message: '该项为必填项哦~' }]} > - } + {config.type === DynamicFormItemType.STRING && } - { - config.type === DynamicFormItemType.BOOLEAN && - - } + {config.type === DynamicFormItemType.BOOLEAN && } - { - config.type === DynamicFormItemType.STRING_ARRAY && - + )} + + ); +} diff --git a/web/src/app/home/components/dynamic-form/DynamicFormItemConfig.ts b/web/src/app/home/components/dynamic-form/DynamicFormItemConfig.ts index 8937b0c5..d18dfa47 100644 --- a/web/src/app/home/components/dynamic-form/DynamicFormItemConfig.ts +++ b/web/src/app/home/components/dynamic-form/DynamicFormItemConfig.ts @@ -1,51 +1,54 @@ export interface IDynamicFormItemConfig { - id: string; - default: string | number | boolean | Array; - label: IDynamicFormItemLabel; - name: string; - required: boolean; - type: DynamicFormItemType - description?: IDynamicFormItemLabel; + id: string; + default: string | number | boolean | Array; + label: IDynamicFormItemLabel; + name: string; + required: boolean; + type: DynamicFormItemType; + description?: IDynamicFormItemLabel; } export class DynamicFormItemConfig implements IDynamicFormItemConfig { - id: string; - name: string; - default: string | number | boolean | Array; - label: IDynamicFormItemLabel; - required: boolean; - type: DynamicFormItemType; - description?: IDynamicFormItemLabel; - - constructor(params: IDynamicFormItemConfig) { - this.id = params.id; - this.name = params.name; - this.default = params.default; - this.label = params.label; - this.required = params.required; - this.type = params.type; - this.description = params.description; - } + id: string; + name: string; + default: string | number | boolean | Array; + label: IDynamicFormItemLabel; + required: boolean; + type: DynamicFormItemType; + description?: IDynamicFormItemLabel; + constructor(params: IDynamicFormItemConfig) { + this.id = params.id; + this.name = params.name; + this.default = params.default; + this.label = params.label; + this.required = params.required; + this.type = params.type; + this.description = params.description; + } } export interface IDynamicFormItemLabel { - en_US: string, - zh_CN: string, + en_US: string; + zh_CN: string; } export enum DynamicFormItemType { - INT = "integer", - STRING = "string", - BOOLEAN = "boolean", - STRING_ARRAY = "array[string]", - UNKNOWN = "unknown", + INT = 'integer', + STRING = 'string', + BOOLEAN = 'boolean', + STRING_ARRAY = 'array[string]', + UNKNOWN = 'unknown', } -export function isDynamicFormItemType(value: string): value is DynamicFormItemType { - return Object.values(DynamicFormItemType).includes(value as DynamicFormItemType); +export function isDynamicFormItemType( + value: string, +): value is DynamicFormItemType { + return Object.values(DynamicFormItemType).includes( + value as DynamicFormItemType, + ); } export function parseDynamicFormItemType(value: string): DynamicFormItemType { - return isDynamicFormItemType(value) ? value : DynamicFormItemType.UNKNOWN; -} \ No newline at end of file + return isDynamicFormItemType(value) ? value : DynamicFormItemType.UNKNOWN; +} diff --git a/web/src/app/home/components/dynamic-form/testDynamicConfigList.ts b/web/src/app/home/components/dynamic-form/testDynamicConfigList.ts index e7ff7ecc..244d7645 100644 --- a/web/src/app/home/components/dynamic-form/testDynamicConfigList.ts +++ b/web/src/app/home/components/dynamic-form/testDynamicConfigList.ts @@ -1,41 +1,41 @@ import { - DynamicFormItemConfig, - DynamicFormItemType, - IDynamicFormItemConfig -} from "@/app/home/components/dynamic-form/DynamicFormItemConfig"; + DynamicFormItemConfig, + DynamicFormItemType, + IDynamicFormItemConfig, +} from '@/app/home/components/dynamic-form/DynamicFormItemConfig'; export const testDynamicConfigList: IDynamicFormItemConfig[] = [ - new DynamicFormItemConfig({ - default: "", - id: "111", - label: { - zh_CN: "测试字段string", - en_US: "eng test" - }, - name: "string_test", - required: false, - type: DynamicFormItemType.STRING - }), - new DynamicFormItemConfig({ - default: "", - id: "222", - label: { - zh_CN: "测试字段int", - en_US: "int eng test" - }, - name: "int_test", - required: true, - type: DynamicFormItemType.INT - }), - new DynamicFormItemConfig({ - default: "", - id: "333", - label: { - zh_CN: "测试字段boolean", - en_US: "boolean eng test" - }, - name: "boolean_test", - required: false, - type: DynamicFormItemType.BOOLEAN - }), -] \ No newline at end of file + new DynamicFormItemConfig({ + default: '', + id: '111', + label: { + zh_CN: '测试字段string', + en_US: 'eng test', + }, + name: 'string_test', + required: false, + type: DynamicFormItemType.STRING, + }), + new DynamicFormItemConfig({ + default: '', + id: '222', + label: { + zh_CN: '测试字段int', + en_US: 'int eng test', + }, + name: 'int_test', + required: true, + type: DynamicFormItemType.INT, + }), + new DynamicFormItemConfig({ + default: '', + id: '333', + label: { + zh_CN: '测试字段boolean', + en_US: 'boolean eng test', + }, + name: 'boolean_test', + required: false, + type: DynamicFormItemType.BOOLEAN, + }), +]; diff --git a/web/src/app/home/components/empty-and-create-component/EmptyAndCreateComponent.tsx b/web/src/app/home/components/empty-and-create-component/EmptyAndCreateComponent.tsx index 19ab7fef..b55b4cee 100644 --- a/web/src/app/home/components/empty-and-create-component/EmptyAndCreateComponent.tsx +++ b/web/src/app/home/components/empty-and-create-component/EmptyAndCreateComponent.tsx @@ -1,35 +1,27 @@ -import styles from "./emptyAndCreate.module.css"; +import styles from './emptyAndCreate.module.css'; -export default function EmptyAndCreateComponent({ - title, - subTitle, - buttonText, - onButtonClick, +export default function EmptyAndCreateComponent({ + title, + subTitle, + buttonText, + onButtonClick, }: { - title: string, - subTitle: string, - buttonText: string, - onButtonClick: () => void, + title: string; + subTitle: string; + buttonText: string; + onButtonClick: () => void; }) { - - return ( -
-
-
-
- {title} -
-
- {subTitle} -
-
-
- {buttonText} -
-
+ return ( +
+
+
+
{title}
+
{subTitle}
- ) -} \ No newline at end of file +
+ {buttonText} +
+
+
+ ); +} diff --git a/web/src/app/home/components/home-sidebar/HomeSidebar.tsx b/web/src/app/home/components/home-sidebar/HomeSidebar.tsx index 7a950e91..302abc27 100644 --- a/web/src/app/home/components/home-sidebar/HomeSidebar.tsx +++ b/web/src/app/home/components/home-sidebar/HomeSidebar.tsx @@ -1,17 +1,17 @@ -"use client"; +'use client'; -import styles from "./HomeSidebar.module.css"; -import { useEffect, useState } from "react"; +import styles from './HomeSidebar.module.css'; +import { useEffect, useState } from 'react'; import { SidebarChild, - SidebarChildVO -} from "@/app/home/components/home-sidebar/HomeSidebarChild"; -import { useRouter, usePathname } from "next/navigation"; -import { sidebarConfigList } from "@/app/home/components/home-sidebar/sidbarConfigList"; + SidebarChildVO, +} from '@/app/home/components/home-sidebar/HomeSidebarChild'; +import { useRouter, usePathname } from 'next/navigation'; +import { sidebarConfigList } from '@/app/home/components/home-sidebar/sidbarConfigList'; // TODO 侧边导航栏要加动画 export default function HomeSidebar({ - onSelectedChangeAction + onSelectedChangeAction, }: { onSelectedChangeAction: (sidebarChild: SidebarChildVO) => void; }) { @@ -24,13 +24,13 @@ export default function HomeSidebar({ }, [pathname]); const [selectedChild, setSelectedChild] = useState( - sidebarConfigList[0] + sidebarConfigList[0], ); useEffect(() => { - console.log("HomeSidebar挂载完成"); + console.log('HomeSidebar挂载完成'); initSelect(); - return () => console.log("HomeSidebar卸载"); + return () => console.log('HomeSidebar卸载'); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -52,14 +52,14 @@ export default function HomeSidebar({ function handleRouteChange(pathname: string) { // TODO 这段逻辑并不好,未来router封装好后改掉 // 判断在home下,并且路由更改的是自己的路由子组件则更新UI - const routeList = pathname.split("/"); + const routeList = pathname.split('/'); if ( - routeList[1] === "home" && + routeList[1] === 'home' && sidebarConfigList.find((childConfig) => childConfig.route === pathname) ) { - console.log("find success"); + console.log('find success'); const routeSelectChild = sidebarConfigList.find( - (childConfig) => childConfig.route === pathname + (childConfig) => childConfig.route === pathname, ); if (routeSelectChild) { setSelectedChild(routeSelectChild); @@ -67,42 +67,34 @@ export default function HomeSidebar({ } } - - return ( -
- {/* LangBot、ICON区域 */} -
- {/* icon */} -
- L -
-
- Langbot -
+ return ( +
+ {/* LangBot、ICON区域 */} +
+ {/* icon */} +
L
+
Langbot
+
+ {/* 菜单列表,后期可升级成配置驱动 */} +
+ {sidebarConfigList.map((config) => { + return ( +
{ + console.log('click:', config.id); + handleChildClick(config); + }} + > +
- {/* 菜单列表,后期可升级成配置驱动 */} -
- { - sidebarConfigList.map(config => { - return ( -
{ - console.log('click:', config.id) - handleChildClick(config) - }} - > - -
- ) - }) - } - -
-
- ); -} \ No newline at end of file + ); + })} +
+
+ ); +} diff --git a/web/src/app/home/components/home-sidebar/HomeSidebarChild.tsx b/web/src/app/home/components/home-sidebar/HomeSidebarChild.tsx index e1089eba..2451e82b 100644 --- a/web/src/app/home/components/home-sidebar/HomeSidebarChild.tsx +++ b/web/src/app/home/components/home-sidebar/HomeSidebarChild.tsx @@ -1,4 +1,4 @@ -import styles from "./HomeSidebar.module.css"; +import styles from './HomeSidebar.module.css'; export interface ISidebarChildVO { id: string; @@ -24,7 +24,7 @@ export class SidebarChildVO { export function SidebarChild({ icon, name, - isSelected + isSelected, }: { icon: string; name: string; diff --git a/web/src/app/home/components/home-sidebar/sidbarConfigList.ts b/web/src/app/home/components/home-sidebar/sidbarConfigList.ts index 4c83ea79..518d4f14 100644 --- a/web/src/app/home/components/home-sidebar/sidbarConfigList.ts +++ b/web/src/app/home/components/home-sidebar/sidbarConfigList.ts @@ -1,28 +1,28 @@ -import {SidebarChildVO} from "@/app/home/components/home-sidebar/HomeSidebarChild"; +import { SidebarChildVO } from '@/app/home/components/home-sidebar/HomeSidebarChild'; export const sidebarConfigList = [ - new SidebarChildVO({ - id: "models", - name: "模型配置", - icon: "", - route: "/home/models", - }), - new SidebarChildVO({ - id: "bots", - name: "机器人", - icon: "", - route: "/home/bots", - }), - new SidebarChildVO({ - id: "pipelines", - name: "流水线", - icon: "", - route: "/home/pipelines", - }), - new SidebarChildVO({ - id: "plugins", - name: "插件管理", - icon: "", - route: "/home/plugins", - }), -] + new SidebarChildVO({ + id: 'models', + name: '模型配置', + icon: '', + route: '/home/models', + }), + new SidebarChildVO({ + id: 'bots', + name: '机器人', + icon: '', + route: '/home/bots', + }), + new SidebarChildVO({ + id: 'pipelines', + name: '流水线', + icon: '', + route: '/home/pipelines', + }), + new SidebarChildVO({ + id: 'plugins', + name: '插件管理', + icon: '', + route: '/home/plugins', + }), +]; diff --git a/web/src/app/home/components/home-titlebar/HomeTitleBar.tsx b/web/src/app/home/components/home-titlebar/HomeTitleBar.tsx index 7011055d..a00c961c 100644 --- a/web/src/app/home/components/home-titlebar/HomeTitleBar.tsx +++ b/web/src/app/home/components/home-titlebar/HomeTitleBar.tsx @@ -1,16 +1,9 @@ -import styles from "./HomeTittleBar.module.css" +import styles from './HomeTittleBar.module.css'; - -export default function HomeTitleBar({ - title, -}: { - title: string -}) { - return ( -
-
{title}
-
- ); -} \ No newline at end of file +export default function HomeTitleBar({ title }: { title: string }) { + return ( +
+
{title}
+
+ ); +} diff --git a/web/src/app/home/layout.tsx b/web/src/app/home/layout.tsx index c765aef0..b3828614 100644 --- a/web/src/app/home/layout.tsx +++ b/web/src/app/home/layout.tsx @@ -1,35 +1,31 @@ -"use client" +'use client'; import '@ant-design/v5-patch-for-react-19'; -import styles from "./layout.module.css" -import HomeSidebar from "@/app/home/components/home-sidebar/HomeSidebar"; -import HomeTitleBar from "@/app/home/components/home-titlebar/HomeTitleBar"; -import React, { useState } from "react"; -import { SidebarChildVO } from "@/app/home/components/home-sidebar/HomeSidebarChild"; -import { useRouter } from 'next/navigation'; +import styles from './layout.module.css'; +import HomeSidebar from '@/app/home/components/home-sidebar/HomeSidebar'; +import HomeTitleBar from '@/app/home/components/home-titlebar/HomeTitleBar'; +import React, { useState } from 'react'; +import { SidebarChildVO } from '@/app/home/components/home-sidebar/HomeSidebarChild'; import { Layout } from 'antd'; const { Sider, Content } = Layout; export default function HomeLayout({ - children + children, }: Readonly<{ children: React.ReactNode; }>) { - const router = useRouter(); - const [title, setTitle] = useState("") + const [title, setTitle] = useState(''); const onSelectedChangeAction = (child: SidebarChildVO) => { - setTitle(child.name) - } + setTitle(child.name); + }; return ( {/* homeLayoutContainer 是整个容器的入口,使用 flex 的左右布局 */} - + {/* HomeSidebar 为侧边栏 */} @@ -44,5 +40,5 @@ export default function HomeLayout({ - ) + ); } diff --git a/web/src/app/home/mock-api/index.ts b/web/src/app/home/mock-api/index.ts index ec6db0ef..8791ecfd 100644 --- a/web/src/app/home/mock-api/index.ts +++ b/web/src/app/home/mock-api/index.ts @@ -1,733 +1,736 @@ -import {GetMetaDataResponse} from "@/app/infra/api/api-types/pipelines/GetMetaDataResponse"; -import {ApiResponse} from "@/app/infra/api/api-types"; +import { GetMetaDataResponse } from '@/app/infra/api/api-types/pipelines/GetMetaDataResponse'; +import { ApiResponse } from '@/app/infra/api/api-types'; -export async function fetchPipelineMetaData(): Promise> { - return { - "code": 0, - "data": { - "configs": [ +export async function fetchPipelineMetaData(): Promise< + ApiResponse +> { + return { + code: 0, + data: { + configs: [ + { + label: { + en_US: 'Trigger', + zh_CN: '触发条件', + }, + name: 'trigger', + stages: [ + { + config: [ { - "label": { - "en_US": "Trigger", - "zh_CN": "触发条件" - }, - "name": "trigger", - "stages": [ - { - "config": [ - { - "default": false, - "description": { - "en_US": "Whether to trigger when the message mentions the bot", - "zh_CN": "是否在消息@机器人时触发" - }, - "label": { - "en_US": "At", - "zh_CN": "@" - }, - "name": "at", - "required": true, - "type": "boolean" - }, - { - "default": [], - "description": { - "en_US": "The prefix of the message", - "zh_CN": "消息前缀" - }, - "items": { - "type": "string" - }, - "label": { - "en_US": "Prefix", - "zh_CN": "前缀" - }, - "name": "prefix", - "required": true, - "type": "array" - }, - { - "default": [], - "description": { - "en_US": "The regexp of the message", - "zh_CN": "消息正则表达式" - }, - "items": { - "type": "string" - }, - "label": { - "en_US": "Regexp", - "zh_CN": "正则表达式" - }, - "name": "regexp", - "required": true, - "type": "array" - }, - { - "default": 0, - "description": { - "en_US": "The probability of the random response, range from 0.0 to 1.0", - "zh_CN": "随机响应概率,范围为 0.0-1.0" - }, - "label": { - "en_US": "Random", - "zh_CN": "随机" - }, - "name": "random", - "required": false, - "type": "float" - } - ], - "description": { - "en_US": "The group respond rule of the pipeline", - "zh_CN": "群响应规则" - }, - "label": { - "en_US": "Group Respond Rule", - "zh_CN": "群响应规则" - }, - "name": "group-respond-rules" - }, - { - "config": [ - { - "default": "blacklist", - "description": { - "en_US": "The mode of the access control", - "zh_CN": "访问控制模式" - }, - "label": { - "en_US": "Mode", - "zh_CN": "模式" - }, - "name": "mode", - "options": [ - { - "label": { - "en_US": "Blacklist", - "zh_CN": "黑名单" - }, - "name": "blacklist" - }, - { - "label": { - "en_US": "Whitelist", - "zh_CN": "白名单" - }, - "name": "whitelist" - } - ], - "required": true, - "type": "select" - }, - { - "default": [], - "items": { - "type": "string" - }, - "label": { - "en_US": "Blacklist", - "zh_CN": "黑名单" - }, - "name": "blacklist", - "required": true, - "type": "array" - }, - { - "default": [], - "items": { - "type": "string" - }, - "label": { - "en_US": "Whitelist", - "zh_CN": "白名单" - }, - "name": "whitelist", - "required": true, - "type": "array" - } - ], - "label": { - "en_US": "Access Control", - "zh_CN": "访问控制" - }, - "name": "access-control" - }, - { - "config": [ - { - "default": [], - "description": { - "en_US": "The prefix of the message", - "zh_CN": "消息前缀" - }, - "items": { - "type": "string" - }, - "label": { - "en_US": "Prefix", - "zh_CN": "前缀" - }, - "name": "prefix", - "required": true, - "type": "array" - }, - { - "default": [], - "description": { - "en_US": "The regexp of the message", - "zh_CN": "消息正则表达式" - }, - "items": { - "type": "string" - }, - "label": { - "en_US": "Regexp", - "zh_CN": "正则表达式" - }, - "name": "regexp", - "required": true, - "type": "array" - } - ], - "label": { - "en_US": "Ignore Rules", - "zh_CN": "消息忽略规则" - }, - "name": "ignore-rules" - } - ] + default: false, + description: { + en_US: + 'Whether to trigger when the message mentions the bot', + zh_CN: '是否在消息@机器人时触发', + }, + label: { + en_US: 'At', + zh_CN: '@', + }, + name: 'at', + required: true, + type: 'boolean', }, { - "label": { - "en_US": "Safety Control", - "zh_CN": "安全控制" - }, - "name": "safety", - "stages": [ - { - "config": [ - { - "default": "all", - "label": { - "en_US": "Scope", - "zh_CN": "检查范围" - }, - "name": "scope", - "options": [ - { - "label": { - "en_US": "All", - "zh_CN": "全部" - }, - "name": "all" - }, - { - "label": { - "en_US": "Income Message", - "zh_CN": "传入消息(用户消息)" - }, - "name": "income-msg" - }, - { - "label": { - "en_US": "Output Message", - "zh_CN": "传出消息(机器人消息)" - }, - "name": "output-msg" - } - ], - "required": true, - "type": "select" - }, - { - "default": false, - "label": { - "en_US": "Check Sensitive Words", - "zh_CN": "检查敏感词" - }, - "name": "check-sensitive-words", - "required": true, - "type": "boolean" - } - ], - "label": { - "en_US": "Content Filter", - "zh_CN": "内容过滤" - }, - "name": "content-filter" - }, - { - "config": [ - { - "default": 60, - "label": { - "en_US": "Window Length", - "zh_CN": "窗口长度(秒)" - }, - "name": "window-length", - "required": true, - "type": "integer" - }, - { - "default": 60, - "label": { - "en_US": "Limitation", - "zh_CN": "限制次数" - }, - "name": "limitation", - "required": true, - "type": "integer" - }, - { - "default": "drop", - "label": { - "en_US": "Strategy", - "zh_CN": "策略" - }, - "name": "strategy", - "options": [ - { - "label": { - "en_US": "Drop", - "zh_CN": "丢弃" - }, - "name": "drop" - }, - { - "label": { - "en_US": "Wait", - "zh_CN": "等待" - }, - "name": "wait" - } - ], - "required": true, - "type": "select" - } - ], - "label": { - "en_US": "Rate Limit", - "zh_CN": "速率限制" - }, - "name": "rate-limit" - } - ] + default: [], + description: { + en_US: 'The prefix of the message', + zh_CN: '消息前缀', + }, + items: { + type: 'string', + }, + label: { + en_US: 'Prefix', + zh_CN: '前缀', + }, + name: 'prefix', + required: true, + type: 'array', }, { - "label": { - "en_US": "AI Feature", - "zh_CN": "AI 能力" - }, - "name": "ai", - "stages": [ - { - "config": [ - { - "default": "local-agent", - "label": { - "en_US": "Runner", - "zh_CN": "运行器" - }, - "name": "runner", - "options": [ - { - "label": { - "en_US": "Embedded Agent", - "zh_CN": "内置 Agent" - }, - "name": "local-agent" - }, - { - "label": { - "en_US": "Dify Service API", - "zh_CN": "Dify 服务 API" - }, - "name": "dify-service-api" - }, - { - "label": { - "en_US": "Aliyun Dashscope App API", - "zh_CN": "阿里云百炼平台 API" - }, - "name": "dashscope-app-api" - } - ], - "required": true, - "type": "select" - } - ], - "label": { - "en_US": "Runner", - "zh_CN": "运行方式" - }, - "name": "runner" - }, - { - "config": [ - { - "label": { - "en_US": "Model", - "zh_CN": "模型" - }, - "name": "model", - "required": true, - "scope": "/provider/models/llm", - "type": "select" - }, - { - "default": 10, - "label": { - "en_US": "Max Round", - "zh_CN": "最大回合数" - }, - "name": "max-round", - "required": true, - "type": "integer" - }, - { - "items": { - "properties": { - "content": { - "type": "string" - }, - "role": { - "default": "user", - "type": "string" - } - }, - "type": "object" - }, - "label": { - "en_US": "Prompt", - "zh_CN": "提示词" - }, - "name": "prompt", - "required": true, - "type": "array" - } - ], - "description": { - "en_US": "Configure the embedded agent of the pipeline", - "zh_CN": "配置内置 Agent" - }, - "label": { - "en_US": "Embedded Agent", - "zh_CN": "内置 Agent" - }, - "name": "local-agent" - }, - { - "config": [ - { - "label": { - "en_US": "Base URL", - "zh_CN": "基础 URL" - }, - "name": "base-url", - "required": true, - "type": "string" - }, - { - "default": "chat", - "label": { - "en_US": "App Type", - "zh_CN": "应用类型" - }, - "name": "app-type", - "options": [ - { - "label": { - "en_US": "Chat", - "zh_CN": "聊天(包括Chatflow)" - }, - "name": "chat" - }, - { - "label": { - "en_US": "Agent", - "zh_CN": "Agent" - }, - "name": "agent" - }, - { - "label": { - "en_US": "Workflow", - "zh_CN": "工作流" - }, - "name": "workflow" - } - ], - "required": true, - "type": "select" - }, - { - "label": { - "en_US": "API Key", - "zh_CN": "API 密钥" - }, - "name": "api-key", - "required": true, - "type": "string" - }, - { - "default": "plain", - "label": { - "en_US": "CoT Convert", - "zh_CN": "思维链转换策略" - }, - "name": "thinking-convert", - "options": [ - { - "label": { - "en_US": "Convert to ...", - "zh_CN": "转换成 ..." - }, - "name": "plain" - }, - { - "label": { - "en_US": "Original", - "zh_CN": "原始" - }, - "name": "original" - }, - { - "label": { - "en_US": "Remove", - "zh_CN": "移除" - }, - "name": "remove" - } - ], - "required": true, - "type": "select" - } - ], - "description": { - "en_US": "Configure the Dify service API of the pipeline", - "zh_CN": "配置 Dify 服务 API" - }, - "label": { - "en_US": "Dify Service API", - "zh_CN": "Dify 服务 API" - }, - "name": "dify-service-api" - }, - { - "config": [ - { - "default": "agent", - "label": { - "en_US": "App Type", - "zh_CN": "应用类型" - }, - "name": "app-type", - "options": [ - { - "label": { - "en_US": "Agent", - "zh_CN": "Agent" - }, - "name": "agent" - }, - { - "label": { - "en_US": "Workflow", - "zh_CN": "工作流" - }, - "name": "workflow" - } - ], - "required": true, - "type": "select" - }, - { - "label": { - "en_US": "API Key", - "zh_CN": "API 密钥" - }, - "name": "api-key", - "required": true, - "type": "string" - }, - { - "label": { - "en_US": "App ID", - "zh_CN": "应用 ID" - }, - "name": "app-id", - "required": true, - "type": "string" - }, - { - "default": "参考资料来自:", - "label": { - "en_US": "References Quote", - "zh_CN": "引用文本" - }, - "name": "references_quote", - "required": false, - "type": "string" - } - ], - "description": { - "en_US": "Configure the Aliyun Dashscope App API of the pipeline", - "zh_CN": "配置阿里云百炼平台 API" - }, - "label": { - "en_US": "Aliyun Dashscope App API", - "zh_CN": "阿里云百炼平台 API" - }, - "name": "dashscope-app-api" - } - ] + default: [], + description: { + en_US: 'The regexp of the message', + zh_CN: '消息正则表达式', + }, + items: { + type: 'string', + }, + label: { + en_US: 'Regexp', + zh_CN: '正则表达式', + }, + name: 'regexp', + required: true, + type: 'array', }, { - "label": { - "en_US": "Output Processing", - "zh_CN": "输出处理" + default: 0, + description: { + en_US: + 'The probability of the random response, range from 0.0 to 1.0', + zh_CN: '随机响应概率,范围为 0.0-1.0', + }, + label: { + en_US: 'Random', + zh_CN: '随机', + }, + name: 'random', + required: false, + type: 'float', + }, + ], + description: { + en_US: 'The group respond rule of the pipeline', + zh_CN: '群响应规则', + }, + label: { + en_US: 'Group Respond Rule', + zh_CN: '群响应规则', + }, + name: 'group-respond-rules', + }, + { + config: [ + { + default: 'blacklist', + description: { + en_US: 'The mode of the access control', + zh_CN: '访问控制模式', + }, + label: { + en_US: 'Mode', + zh_CN: '模式', + }, + name: 'mode', + options: [ + { + label: { + en_US: 'Blacklist', + zh_CN: '黑名单', + }, + name: 'blacklist', }, - "name": "output", - "stages": [ - { - "config": [ - { - "default": 1000, - "label": { - "en_US": "Threshold", - "zh_CN": "阈值" - }, - "name": "threshold", - "required": true, - "type": "integer" - }, - { - "default": "forward", - "label": { - "en_US": "Strategy", - "zh_CN": "策略" - }, - "name": "strategy", - "options": [ - { - "label": { - "en_US": "Forward Message Component", - "zh_CN": "转发消息组件" - }, - "name": "forward" - }, - { - "label": { - "en_US": "Convert to Image", - "zh_CN": "转换为图片" - }, - "name": "image" - } - ], - "required": true, - "type": "select" - }, - { - "default": "", - "label": { - "en_US": "Font Path", - "zh_CN": "字体路径" - }, - "name": "font-path", - "required": true, - "type": "string" - } - ], - "label": { - "en_US": "Long Text Processing", - "zh_CN": "长文本处理" - }, - "name": "long-text-processing" - }, - { - "config": [ - { - "default": 0, - "label": { - "en_US": "Min", - "zh_CN": "最小秒数" - }, - "name": "min", - "required": true, - "type": "integer" - }, - { - "default": 0, - "label": { - "en_US": "Max", - "zh_CN": "最大秒数" - }, - "name": "max", - "required": true, - "type": "integer" - } - ], - "label": { - "en_US": "Force Delay", - "zh_CN": "强制延迟" - }, - "name": "force-delay" - }, - { - "config": [ - { - "default": true, - "label": { - "en_US": "Hide Exception", - "zh_CN": "不输出异常信息给用户" - }, - "name": "hide-exception", - "required": true, - "type": "boolean" - }, - { - "default": true, - "label": { - "en_US": "At Sender", - "zh_CN": "在回复中@发送者" - }, - "name": "at-sender", - "required": true, - "type": "boolean" - }, - { - "default": false, - "label": { - "en_US": "Quote Origin", - "zh_CN": "引用原文" - }, - "name": "quote-origin", - "required": true, - "type": "boolean" - }, - { - "default": true, - "label": { - "en_US": "Track Function Calls", - "zh_CN": "跟踪函数调用" - }, - "name": "track-function-calls", - "required": true, - "type": "boolean" - } - ], - "label": { - "en_US": "Misc", - "zh_CN": "杂项" - }, - "name": "misc" - } - ] - } - ] + { + label: { + en_US: 'Whitelist', + zh_CN: '白名单', + }, + name: 'whitelist', + }, + ], + required: true, + type: 'select', + }, + { + default: [], + items: { + type: 'string', + }, + label: { + en_US: 'Blacklist', + zh_CN: '黑名单', + }, + name: 'blacklist', + required: true, + type: 'array', + }, + { + default: [], + items: { + type: 'string', + }, + label: { + en_US: 'Whitelist', + zh_CN: '白名单', + }, + name: 'whitelist', + required: true, + type: 'array', + }, + ], + label: { + en_US: 'Access Control', + zh_CN: '访问控制', + }, + name: 'access-control', + }, + { + config: [ + { + default: [], + description: { + en_US: 'The prefix of the message', + zh_CN: '消息前缀', + }, + items: { + type: 'string', + }, + label: { + en_US: 'Prefix', + zh_CN: '前缀', + }, + name: 'prefix', + required: true, + type: 'array', + }, + { + default: [], + description: { + en_US: 'The regexp of the message', + zh_CN: '消息正则表达式', + }, + items: { + type: 'string', + }, + label: { + en_US: 'Regexp', + zh_CN: '正则表达式', + }, + name: 'regexp', + required: true, + type: 'array', + }, + ], + label: { + en_US: 'Ignore Rules', + zh_CN: '消息忽略规则', + }, + name: 'ignore-rules', + }, + ], }, - "msg": "ok" - } + { + label: { + en_US: 'Safety Control', + zh_CN: '安全控制', + }, + name: 'safety', + stages: [ + { + config: [ + { + default: 'all', + label: { + en_US: 'Scope', + zh_CN: '检查范围', + }, + name: 'scope', + options: [ + { + label: { + en_US: 'All', + zh_CN: '全部', + }, + name: 'all', + }, + { + label: { + en_US: 'Income Message', + zh_CN: '传入消息(用户消息)', + }, + name: 'income-msg', + }, + { + label: { + en_US: 'Output Message', + zh_CN: '传出消息(机器人消息)', + }, + name: 'output-msg', + }, + ], + required: true, + type: 'select', + }, + { + default: false, + label: { + en_US: 'Check Sensitive Words', + zh_CN: '检查敏感词', + }, + name: 'check-sensitive-words', + required: true, + type: 'boolean', + }, + ], + label: { + en_US: 'Content Filter', + zh_CN: '内容过滤', + }, + name: 'content-filter', + }, + { + config: [ + { + default: 60, + label: { + en_US: 'Window Length', + zh_CN: '窗口长度(秒)', + }, + name: 'window-length', + required: true, + type: 'integer', + }, + { + default: 60, + label: { + en_US: 'Limitation', + zh_CN: '限制次数', + }, + name: 'limitation', + required: true, + type: 'integer', + }, + { + default: 'drop', + label: { + en_US: 'Strategy', + zh_CN: '策略', + }, + name: 'strategy', + options: [ + { + label: { + en_US: 'Drop', + zh_CN: '丢弃', + }, + name: 'drop', + }, + { + label: { + en_US: 'Wait', + zh_CN: '等待', + }, + name: 'wait', + }, + ], + required: true, + type: 'select', + }, + ], + label: { + en_US: 'Rate Limit', + zh_CN: '速率限制', + }, + name: 'rate-limit', + }, + ], + }, + { + label: { + en_US: 'AI Feature', + zh_CN: 'AI 能力', + }, + name: 'ai', + stages: [ + { + config: [ + { + default: 'local-agent', + label: { + en_US: 'Runner', + zh_CN: '运行器', + }, + name: 'runner', + options: [ + { + label: { + en_US: 'Embedded Agent', + zh_CN: '内置 Agent', + }, + name: 'local-agent', + }, + { + label: { + en_US: 'Dify Service API', + zh_CN: 'Dify 服务 API', + }, + name: 'dify-service-api', + }, + { + label: { + en_US: 'Aliyun Dashscope App API', + zh_CN: '阿里云百炼平台 API', + }, + name: 'dashscope-app-api', + }, + ], + required: true, + type: 'select', + }, + ], + label: { + en_US: 'Runner', + zh_CN: '运行方式', + }, + name: 'runner', + }, + { + config: [ + { + label: { + en_US: 'Model', + zh_CN: '模型', + }, + name: 'model', + required: true, + scope: '/provider/models/llm', + type: 'select', + }, + { + default: 10, + label: { + en_US: 'Max Round', + zh_CN: '最大回合数', + }, + name: 'max-round', + required: true, + type: 'integer', + }, + { + items: { + properties: { + content: { + type: 'string', + }, + role: { + default: 'user', + type: 'string', + }, + }, + type: 'object', + }, + label: { + en_US: 'Prompt', + zh_CN: '提示词', + }, + name: 'prompt', + required: true, + type: 'array', + }, + ], + description: { + en_US: 'Configure the embedded agent of the pipeline', + zh_CN: '配置内置 Agent', + }, + label: { + en_US: 'Embedded Agent', + zh_CN: '内置 Agent', + }, + name: 'local-agent', + }, + { + config: [ + { + label: { + en_US: 'Base URL', + zh_CN: '基础 URL', + }, + name: 'base-url', + required: true, + type: 'string', + }, + { + default: 'chat', + label: { + en_US: 'App Type', + zh_CN: '应用类型', + }, + name: 'app-type', + options: [ + { + label: { + en_US: 'Chat', + zh_CN: '聊天(包括Chatflow)', + }, + name: 'chat', + }, + { + label: { + en_US: 'Agent', + zh_CN: 'Agent', + }, + name: 'agent', + }, + { + label: { + en_US: 'Workflow', + zh_CN: '工作流', + }, + name: 'workflow', + }, + ], + required: true, + type: 'select', + }, + { + label: { + en_US: 'API Key', + zh_CN: 'API 密钥', + }, + name: 'api-key', + required: true, + type: 'string', + }, + { + default: 'plain', + label: { + en_US: 'CoT Convert', + zh_CN: '思维链转换策略', + }, + name: 'thinking-convert', + options: [ + { + label: { + en_US: 'Convert to ...', + zh_CN: '转换成 ...', + }, + name: 'plain', + }, + { + label: { + en_US: 'Original', + zh_CN: '原始', + }, + name: 'original', + }, + { + label: { + en_US: 'Remove', + zh_CN: '移除', + }, + name: 'remove', + }, + ], + required: true, + type: 'select', + }, + ], + description: { + en_US: 'Configure the Dify service API of the pipeline', + zh_CN: '配置 Dify 服务 API', + }, + label: { + en_US: 'Dify Service API', + zh_CN: 'Dify 服务 API', + }, + name: 'dify-service-api', + }, + { + config: [ + { + default: 'agent', + label: { + en_US: 'App Type', + zh_CN: '应用类型', + }, + name: 'app-type', + options: [ + { + label: { + en_US: 'Agent', + zh_CN: 'Agent', + }, + name: 'agent', + }, + { + label: { + en_US: 'Workflow', + zh_CN: '工作流', + }, + name: 'workflow', + }, + ], + required: true, + type: 'select', + }, + { + label: { + en_US: 'API Key', + zh_CN: 'API 密钥', + }, + name: 'api-key', + required: true, + type: 'string', + }, + { + label: { + en_US: 'App ID', + zh_CN: '应用 ID', + }, + name: 'app-id', + required: true, + type: 'string', + }, + { + default: '参考资料来自:', + label: { + en_US: 'References Quote', + zh_CN: '引用文本', + }, + name: 'references_quote', + required: false, + type: 'string', + }, + ], + description: { + en_US: 'Configure the Aliyun Dashscope App API of the pipeline', + zh_CN: '配置阿里云百炼平台 API', + }, + label: { + en_US: 'Aliyun Dashscope App API', + zh_CN: '阿里云百炼平台 API', + }, + name: 'dashscope-app-api', + }, + ], + }, + { + label: { + en_US: 'Output Processing', + zh_CN: '输出处理', + }, + name: 'output', + stages: [ + { + config: [ + { + default: 1000, + label: { + en_US: 'Threshold', + zh_CN: '阈值', + }, + name: 'threshold', + required: true, + type: 'integer', + }, + { + default: 'forward', + label: { + en_US: 'Strategy', + zh_CN: '策略', + }, + name: 'strategy', + options: [ + { + label: { + en_US: 'Forward Message Component', + zh_CN: '转发消息组件', + }, + name: 'forward', + }, + { + label: { + en_US: 'Convert to Image', + zh_CN: '转换为图片', + }, + name: 'image', + }, + ], + required: true, + type: 'select', + }, + { + default: '', + label: { + en_US: 'Font Path', + zh_CN: '字体路径', + }, + name: 'font-path', + required: true, + type: 'string', + }, + ], + label: { + en_US: 'Long Text Processing', + zh_CN: '长文本处理', + }, + name: 'long-text-processing', + }, + { + config: [ + { + default: 0, + label: { + en_US: 'Min', + zh_CN: '最小秒数', + }, + name: 'min', + required: true, + type: 'integer', + }, + { + default: 0, + label: { + en_US: 'Max', + zh_CN: '最大秒数', + }, + name: 'max', + required: true, + type: 'integer', + }, + ], + label: { + en_US: 'Force Delay', + zh_CN: '强制延迟', + }, + name: 'force-delay', + }, + { + config: [ + { + default: true, + label: { + en_US: 'Hide Exception', + zh_CN: '不输出异常信息给用户', + }, + name: 'hide-exception', + required: true, + type: 'boolean', + }, + { + default: true, + label: { + en_US: 'At Sender', + zh_CN: '在回复中@发送者', + }, + name: 'at-sender', + required: true, + type: 'boolean', + }, + { + default: false, + label: { + en_US: 'Quote Origin', + zh_CN: '引用原文', + }, + name: 'quote-origin', + required: true, + type: 'boolean', + }, + { + default: true, + label: { + en_US: 'Track Function Calls', + zh_CN: '跟踪函数调用', + }, + name: 'track-function-calls', + required: true, + type: 'boolean', + }, + ], + label: { + en_US: 'Misc', + zh_CN: '杂项', + }, + name: 'misc', + }, + ], + }, + ], + }, + msg: 'ok', + }; } - diff --git a/web/src/app/home/models/ICreateLLMField.ts b/web/src/app/home/models/ICreateLLMField.ts index 2c484f97..4ded490b 100644 --- a/web/src/app/home/models/ICreateLLMField.ts +++ b/web/src/app/home/models/ICreateLLMField.ts @@ -1,8 +1,8 @@ export interface ICreateLLMField { - name: string; - model_provider: string; - url: string; - api_key: string; - abilities: string[]; - extra_args: string[]; -} \ No newline at end of file + name: string; + model_provider: string; + url: string; + api_key: string; + abilities: string[]; + extra_args: string[]; +} diff --git a/web/src/app/home/models/component/llm-card/LLMCard.tsx b/web/src/app/home/models/component/llm-card/LLMCard.tsx index a7672445..96040fa9 100644 --- a/web/src/app/home/models/component/llm-card/LLMCard.tsx +++ b/web/src/app/home/models/component/llm-card/LLMCard.tsx @@ -1,33 +1,25 @@ -import styles from "../../LLMConfig.module.css" -import {LLMCardVO} from "@/app/home/models/component/llm-card/LLMCardVO"; +import styles from '../../LLMConfig.module.css'; +import { LLMCardVO } from '@/app/home/models/component/llm-card/LLMCardVO'; -export default function LLMCard({ - cardVO -}: { - cardVO: LLMCardVO -}) { - return ( -
- {/* icon和基本信息 */} -
- {/* icon */} -
- ICO -
- {/* bot基本信息 */} -
-
- {cardVO.name} -
-
- 厂商:{cardVO.company} -
-
-
- {/* URL和创建时间 */} -
- URL:{cardVO.URL} -
+export default function LLMCard({ cardVO }: { cardVO: LLMCardVO }) { + return ( +
+ {/* icon和基本信息 */} +
+ {/* icon */} +
ICO
+ {/* bot基本信息 */} +
+
+ {cardVO.name} +
+
+ 厂商:{cardVO.company} +
- ); -} \ No newline at end of file +
+ {/* URL和创建时间 */} +
URL:{cardVO.URL}
+
+ ); +} diff --git a/web/src/app/home/models/component/llm-card/LLMCardVO.ts b/web/src/app/home/models/component/llm-card/LLMCardVO.ts index 6d62cb3c..7f731fcd 100644 --- a/web/src/app/home/models/component/llm-card/LLMCardVO.ts +++ b/web/src/app/home/models/component/llm-card/LLMCardVO.ts @@ -1,21 +1,20 @@ export interface ILLMCardVO { - id: string; - name: string; - company: string; - URL: string; + id: string; + name: string; + company: string; + URL: string; } export class LLMCardVO implements ILLMCardVO { - id: string; - name: string; - company: string; - URL: string; + id: string; + name: string; + company: string; + URL: string; - constructor(props: ILLMCardVO) { - this.id = props.id; - this.name = props.name; - this.company = props.company; - this.URL = props.URL; - } - -} \ No newline at end of file + constructor(props: ILLMCardVO) { + this.id = props.id; + this.name = props.name; + this.company = props.company; + this.URL = props.URL; + } +} diff --git a/web/src/app/home/models/component/llm-form/ChooseAdapterEntity.ts b/web/src/app/home/models/component/llm-form/ChooseAdapterEntity.ts index dd97d284..5728c1ce 100644 --- a/web/src/app/home/models/component/llm-form/ChooseAdapterEntity.ts +++ b/web/src/app/home/models/component/llm-form/ChooseAdapterEntity.ts @@ -1,4 +1,4 @@ export interface IChooseRequesterEntity { - label: string - value: string -} \ No newline at end of file + label: string; + value: string; +} diff --git a/web/src/app/home/models/component/llm-form/LLMForm.tsx b/web/src/app/home/models/component/llm-form/LLMForm.tsx index 4832cc6c..2768443a 100644 --- a/web/src/app/home/models/component/llm-form/LLMForm.tsx +++ b/web/src/app/home/models/component/llm-form/LLMForm.tsx @@ -1,18 +1,18 @@ -import styles from "@/app/home/models/LLMConfig.module.css"; -import { Button, Form, Input, Select, SelectProps, Space, Modal } from "antd"; -import { ICreateLLMField } from "@/app/home/models/ICreateLLMField"; -import { useEffect, useState } from "react"; -import { IChooseRequesterEntity } from "@/app/home/models/component/llm-form/ChooseAdapterEntity"; -import { httpClient } from "@/app/infra/http/HttpClient"; -import { LLMModel } from "@/app/infra/api/api-types"; -import { UUID } from "uuidjs"; +import styles from '@/app/home/models/LLMConfig.module.css'; +import { Button, Form, Input, Select, SelectProps, Space, Modal } from 'antd'; +import { ICreateLLMField } from '@/app/home/models/ICreateLLMField'; +import { useEffect, useState } from 'react'; +import { IChooseRequesterEntity } from '@/app/home/models/component/llm-form/ChooseAdapterEntity'; +import { httpClient } from '@/app/infra/http/HttpClient'; +import { LLMModel } from '@/app/infra/api/api-types'; +import { UUID } from 'uuidjs'; export default function LLMForm({ editMode, initLLMId, onFormSubmit, onFormCancel, - onLLMDeleted + onLLMDeleted, }: { editMode: boolean; initLLMId?: string; @@ -21,18 +21,18 @@ export default function LLMForm({ onLLMDeleted: () => void; }) { const [form] = Form.useForm(); - const extraOptions: SelectProps["options"] = []; + const extraOptions: SelectProps['options'] = []; const [initValue] = useState(); const [showDeleteConfirmModal, setShowDeleteConfirmModal] = useState(false); - const abilityOptions: SelectProps["options"] = [ + const abilityOptions: SelectProps['options'] = [ { - label: "函数调用", - value: "func_call" + label: '函数调用', + value: 'func_call', }, { - label: "图像识别", - value: "vision" - } + label: '图像识别', + value: 'vision', + }, ]; const [requesterNameList, setRequesterNameList] = useState< IChooseRequesterEntity[] @@ -56,9 +56,9 @@ export default function LLMForm({ requesterNameList.requesters.map((item) => { return { label: item.label.zh_CN, - value: item.name + value: item.name, }; - }) + }), ); } @@ -76,7 +76,7 @@ export default function LLMForm({ url: llmModel.model.requester_config?.base_url, api_key: llmModel.model.api_keys[0], abilities: llmModel.model.abilities, - extra_args: fakeExtraArgs + extra_args: fakeExtraArgs, }; } @@ -110,19 +110,19 @@ export default function LLMForm({ // } function onCreateLLM(value: ICreateLLMField) { - console.log("create llm", value); + console.log('create llm', value); const requestParam: LLMModel = { uuid: UUID.generate(), name: value.name, - description: "", + description: '', requester: value.model_provider, requester_config: { base_url: value.url, - timeout: 120 + timeout: 120, }, extra_args: value.extra_args, api_keys: [value.api_key], - abilities: value.abilities + abilities: value.abilities, // created_at: 'Sun Apr 27 2025 21:56:35 GMT+0800', // updated_at: 'Sun Apr 27 2025 21:56:35 GMT+0800', }; @@ -145,15 +145,15 @@ export default function LLMForm({
setShowDeleteConfirmModal(false)} footer={