feat: update eslint & prettier rules

This commit is contained in:
HYana
2025-04-30 17:36:46 +08:00
parent d4af2d4326
commit 460e065eed
53 changed files with 2241 additions and 2102 deletions
@@ -1,33 +1,29 @@
import styles from "./pipelineCard.module.css";
import {PipelineCardVO} from "@/app/home/pipelines/components/pipeline-card/PipelineCardVO";
import styles from './pipelineCard.module.css';
import { PipelineCardVO } from '@/app/home/pipelines/components/pipeline-card/PipelineCardVO';
export default function PipelineCardComponent({
cardVO
cardVO,
}: {
cardVO: PipelineCardVO
cardVO: PipelineCardVO;
}) {
return (
<div className={`${styles.cardContainer}`}>
{/* icon和基本信息 */}
<div className={`${styles.iconBasicInfoContainer}`}>
{/* icon */}
<div className={`${styles.icon}`}>
ICO
</div>
{/* 基本信息 */}
<div className={`${styles.basicInfoContainer}`}>
<div className={`${styles.basicInfoText} ${styles.bigText}`}>
{cardVO.name}
</div>
<div className={`${styles.basicInfoText}`}>
{cardVO.description}
</div>
</div>
</div>
{/* URL和创建时间 */}
<div className={`${styles.urlAndUpdateText}`}>
{cardVO.version}
</div>
return (
<div className={`${styles.cardContainer}`}>
{/* icon和基本信息 */}
<div className={`${styles.iconBasicInfoContainer}`}>
{/* icon */}
<div className={`${styles.icon}`}>ICO</div>
{/* 基本信息 */}
<div className={`${styles.basicInfoContainer}`}>
<div className={`${styles.basicInfoText} ${styles.bigText}`}>
{cardVO.name}
</div>
<div className={`${styles.basicInfoText}`}>
{cardVO.description}
</div>
</div>
);
}
</div>
{/* URL和创建时间 */}
<div className={`${styles.urlAndUpdateText}`}>{cardVO.version}</div>
</div>
);
}
@@ -1,23 +1,23 @@
export interface IPipelineCardVO {
id: string;
name: string;
description: string;
createTime: string;
version: string;
id: string;
name: string;
description: string;
createTime: string;
version: string;
}
export class PipelineCardVO implements IPipelineCardVO {
createTime: string;
description: string;
id: string;
name: string;
version: string;
createTime: string;
description: string;
id: string;
name: string;
version: string;
constructor(props: IPipelineCardVO) {
this.id = props.id;
this.name = props.name;
this.description = props.description;
this.createTime = props.createTime;
this.version = props.version;
}
}
constructor(props: IPipelineCardVO) {
this.id = props.id;
this.name = props.name;
this.description = props.description;
this.createTime = props.createTime;
this.version = props.version;
}
}
@@ -1,4 +1,4 @@
import { DynamicFormItemConfig } from "@/app/home/components/dynamic-form/DynamicFormItemConfig";
import { DynamicFormItemConfig } from '@/app/home/components/dynamic-form/DynamicFormItemConfig';
export interface IPipelineChildFormEntity {
name: string;
@@ -5,15 +5,15 @@ import {
Select,
Input,
InputNumber,
SelectProps
} from "antd";
import { CaretLeftOutlined, CaretRightOutlined } from "@ant-design/icons";
import { useEffect, useState } from "react";
import styles from "./pipelineFormStyle.module.css";
import { httpClient } from "@/app/infra/http/HttpClient";
import { LLMModel, Pipeline } from "@/app/infra/api/api-types";
import { UUID } from "uuidjs";
import {PipelineFormEntity} from "@/app/home/pipelines/components/pipeline-form/PipelineFormEntity";
SelectProps,
} from 'antd';
import { CaretLeftOutlined, CaretRightOutlined } from '@ant-design/icons';
import { useEffect, useState } from 'react';
import styles from './pipelineFormStyle.module.css';
import { httpClient } from '@/app/infra/http/HttpClient';
import { LLMModel, Pipeline } from '@/app/infra/api/api-types';
import { UUID } from 'uuidjs';
import { PipelineFormEntity } from '@/app/home/pipelines/components/pipeline-form/PipelineFormEntity';
export default function PipelineFormComponent({
initValues,
@@ -30,15 +30,15 @@ export default function PipelineFormComponent({
onFinish: () => void;
}) {
const [nowFormIndex, setNowFormIndex] = useState<number>(0);
const [nowAIRunner, setNowAIRunner] = useState("");
const [llmModelList, setLlmModelList] = useState<SelectProps["options"]>([]);
const [nowAIRunner, setNowAIRunner] = useState('');
const [llmModelList, setLlmModelList] = useState<SelectProps['options']>([]);
// 这里不好,可以改成enum等
const formLabelList: FormLabel[] = [
{ label: "基础", name: "basic" },
{ label: "AI能力", name: "ai" },
{ label: "触发条件", name: "trigger" },
{ label: "安全能力", name: "safety" },
{ label: "输出处理", name: "output" }
{ label: '基础', name: 'basic' },
{ label: 'AI能力', name: 'ai' },
{ label: '触发条件', name: 'trigger' },
{ label: '安全能力', name: 'safety' },
{ label: '输出处理', name: 'output' },
];
const [basicForm] = Form.useForm();
const [aiForm] = Form.useForm();
@@ -51,7 +51,7 @@ export default function PipelineFormComponent({
}, []);
useEffect(() => {
console.log("initValues change: ", initValues);
console.log('initValues change: ', initValues);
if (initValues) {
basicForm.setFieldsValue(initValues.basic);
aiForm.setFieldsValue(initValues.ai);
@@ -59,8 +59,7 @@ export default function PipelineFormComponent({
safetyForm.setFieldsValue(initValues.safety);
outputForm.setFieldsValue(initValues.output);
}
}, [initValues]);
}, [aiForm, basicForm, initValues, outputForm, safetyForm, triggerForm]);
function getLLMModelList() {
httpClient
@@ -70,13 +69,13 @@ export default function PipelineFormComponent({
resp.models.map((model: LLMModel) => {
return {
value: model.uuid,
label: model.name
label: model.name,
};
})
}),
);
})
.catch((err) => {
console.error("get LLM model list error", err);
console.error('get LLM model list error', err);
});
}
@@ -114,9 +113,9 @@ export default function PipelineFormComponent({
function handleCommit() {
if (isEditMode) {
handleModify()
handleModify();
} else {
handleCreate()
handleCreate();
}
}
@@ -126,15 +125,15 @@ export default function PipelineFormComponent({
aiForm.validateFields(),
triggerForm.validateFields(),
safetyForm.validateFields(),
outputForm.validateFields()
outputForm.validateFields(),
])
.then(() => {
const pipeline = assembleForm();
httpClient.createPipeline(pipeline).then(() => onFinish());
})
.catch((e) => {
console.error(e);
});
.then(() => {
const pipeline = assembleForm();
httpClient.createPipeline(pipeline).then(() => onFinish());
})
.catch((e) => {
console.error(e);
});
}
function handleModify() {
@@ -143,61 +142,63 @@ export default function PipelineFormComponent({
aiForm.validateFields(),
triggerForm.validateFields(),
safetyForm.validateFields(),
outputForm.validateFields()
outputForm.validateFields(),
])
.then(() => {
const pipeline = assembleForm();
httpClient.updatePipeline(pipelineId || '', pipeline).then(() => onFinish());
})
.catch((e) => {
console.error(e);
});
.then(() => {
const pipeline = assembleForm();
httpClient
.updatePipeline(pipelineId || '', pipeline)
.then(() => onFinish());
})
.catch((e) => {
console.error(e);
});
}
// TODO 类型混乱,需要优化
function assembleForm(): Pipeline {
console.log("basicForm:", basicForm.getFieldsValue());
console.log("aiForm:", aiForm.getFieldsValue());
console.log("triggerForm:", triggerForm.getFieldsValue());
console.log("safetyForm:", safetyForm.getFieldsValue());
console.log("outputForm:", outputForm.getFieldsValue());
console.log('basicForm:', basicForm.getFieldsValue());
console.log('aiForm:', aiForm.getFieldsValue());
console.log('triggerForm:', triggerForm.getFieldsValue());
console.log('safetyForm:', safetyForm.getFieldsValue());
console.log('outputForm:', outputForm.getFieldsValue());
const config: object = {
ai: aiForm.getFieldsValue(),
trigger: triggerForm.getFieldsValue(),
safety: safetyForm.getFieldsValue(),
output: outputForm.getFieldsValue()
output: outputForm.getFieldsValue(),
};
return {
config,
created_at: "",
created_at: '',
description: basicForm.getFieldsValue().description,
for_version: "",
for_version: '',
name: basicForm.getFieldsValue().name,
stages: [],
updated_at: "",
uuid: UUID.generate()
updated_at: '',
uuid: UUID.generate(),
};
}
return (
<div style={{ maxHeight: "70vh", overflowY: "auto" }}>
<div style={{ maxHeight: '70vh', overflowY: 'auto' }}>
<h1>{getNowFormLabel().label}</h1>
<Form
layout={"vertical"}
layout={'vertical'}
style={{
display: getNowFormLabel().name === "basic" ? "block" : "none"
display: getNowFormLabel().name === 'basic' ? 'block' : 'none',
}}
form={basicForm}
disabled={disableForm}
>
<Form.Item
label="流水线名称"
name={"name"}
name={'name'}
rules={[
{
required: true
}
required: true,
},
]}
>
<Input />
@@ -205,11 +206,11 @@ export default function PipelineFormComponent({
<Form.Item
label="流水线描述"
name={"description"}
name={'description'}
rules={[
{
required: true
}
required: true,
},
]}
>
<Input />
@@ -217,8 +218,8 @@ export default function PipelineFormComponent({
</Form>
{/* AI能力表单 ai */}
<Form
layout={"vertical"}
style={{ display: getNowFormLabel().name === "ai" ? "block" : "none" }}
layout={'vertical'}
style={{ display: getNowFormLabel().name === 'ai' ? 'block' : 'none' }}
form={aiForm}
disabled={disableForm}
>
@@ -226,26 +227,26 @@ export default function PipelineFormComponent({
<div className={`${styles.formItemSubtitle}`}></div>
<Form.Item
label="运行器"
name={["runner", "runner"]}
name={['runner', 'runner']}
rules={[{ required: true }]}
>
<Select
options={[
{ label: "内置 Agent", value: "local-agent" },
{ label: "Dify 服务 API", value: "dify-service-api" },
{ label: "阿里云百炼平台 API", value: "dashscope-app-api" }
{ label: '内置 Agent', value: 'local-agent' },
{ label: 'Dify 服务 API', value: 'dify-service-api' },
{ label: '阿里云百炼平台 API', value: 'dashscope-app-api' },
]}
onChange={(value) => setNowAIRunner(value)}
/>
</Form.Item>
{/* 内置 Agent 配置区块 */}
{nowAIRunner === "local-agent" && (
{nowAIRunner === 'local-agent' && (
<>
<div className={`${styles.formItemSubtitle}`}>Agent</div>
<Form.Item
label="模型"
name={["local-agent", "model"]}
name={['local-agent', 'model']}
rules={[{ required: true }]}
tooltip="从模型库中选择"
>
@@ -257,11 +258,11 @@ export default function PipelineFormComponent({
</Form.Item>
<Form.Item
label="最大回合数"
name={["local-agent", "max-round"]}
name={['local-agent', 'max-round']}
rules={[
{
required: true
}
required: true,
},
]}
>
<InputNumber precision={0} />
@@ -269,7 +270,7 @@ export default function PipelineFormComponent({
{/* TODO 这里要做转换处理 */}
<Form.Item
label="提示词"
name={["local-agent", "prompt"]}
name={['local-agent', 'prompt']}
rules={[{ required: true }]}
tooltip="按JSON格式输入"
>
@@ -281,91 +282,91 @@ export default function PipelineFormComponent({
</>
)}
{/* Dify 服务 API 区块 */}
{nowAIRunner === "dify-service-api" && (
{nowAIRunner === 'dify-service-api' && (
<>
<div className={`${styles.formItemSubtitle}`}>Dify服务API</div>
<Form.Item
label="基础 URL"
name={["dify-service-api", "base-url"]}
name={['dify-service-api', 'base-url']}
rules={[
{ required: true },
{ type: "url", message: "请输入有效的URL地址" }
{ type: 'url', message: '请输入有效的URL地址' },
]}
>
<Input />
</Form.Item>
<Form.Item
label="应用类型"
name={["dify-service-api", "app-type"]}
initialValue={"chat"}
name={['dify-service-api', 'app-type']}
initialValue={'chat'}
rules={[{ required: true }]}
>
<Select
options={[
{ label: "聊天(包括Chatflow", value: "chat" },
{ label: "Agent", value: "agent" },
{ label: "工作流", value: "workflow" }
{ label: '聊天(包括Chatflow', value: 'chat' },
{ label: 'Agent', value: 'agent' },
{ label: '工作流', value: 'workflow' },
]}
/>
</Form.Item>
<Form.Item
label="API 密钥"
name={["dify-service-api", "api-key"]}
name={['dify-service-api', 'api-key']}
rules={[{ required: true }]}
>
<Input.Password visibilityToggle={false} />
</Form.Item>
<Form.Item
label="思维链转换"
name={["dify-service-api", "thinking-convert"]}
name={['dify-service-api', 'thinking-convert']}
rules={[{ required: true }]}
>
<Select
options={[
{ label: "转换成 \<think\>...\<\/think\>", value: "plain" },
{ label: "原始", value: "original" },
{ label: "移除", value: "remove" }
{ label: '转换成 \<think\>...\<\/think\>', value: 'plain' },
{ label: '原始', value: 'original' },
{ label: '移除', value: 'remove' },
]}
/>
</Form.Item>
</>
)}
{/* 阿里云百炼区块 */}
{nowAIRunner === "dashscope-app-api" && (
{nowAIRunner === 'dashscope-app-api' && (
<>
<div className={`${styles.formItemSubtitle}`}>
API
</div>
<Form.Item
label="应用类型"
name={["dashscope-app-api", "app-type"]}
name={['dashscope-app-api', 'app-type']}
rules={[{ required: true }]}
>
<Select
options={[
{ label: "Agent", value: "agent" },
{ label: "工作流", value: "workflow" }
{ label: 'Agent', value: 'agent' },
{ label: '工作流', value: 'workflow' },
]}
/>
</Form.Item>
<Form.Item
label="API 密钥"
name={["dashscope-app-api", "api-key"]}
name={['dashscope-app-api', 'api-key']}
rules={[{ required: true }]}
>
<Input.Password visibilityToggle={false} />
</Form.Item>
<Form.Item
label="应用 ID"
name={["dashscope-app-api", "app-id"]}
name={['dashscope-app-api', 'app-id']}
rules={[{ required: true }]}
>
<Input />
</Form.Item>
<Form.Item
label="引用文本"
name={["dashscope-app-api", "references_quote"]}
initialValue={"参考资料来自:"}
name={['dashscope-app-api', 'references_quote']}
initialValue={'参考资料来自:'}
>
<Input.TextArea rows={2} />
</Form.Item>
@@ -375,9 +376,9 @@ export default function PipelineFormComponent({
{/* 触发条件表单 trigger */}
<Form
layout={"vertical"}
layout={'vertical'}
style={{
display: getNowFormLabel().name === "trigger" ? "block" : "none"
display: getNowFormLabel().name === 'trigger' ? 'block' : 'none',
}}
form={triggerForm}
disabled={disableForm}
@@ -385,15 +386,15 @@ export default function PipelineFormComponent({
{/* 群响应规则块 */}
<div className={`${styles.formItemSubtitle}`}> </div>
<Form.Item
label={"是否在消息@机器人时触发"}
name={["group-respond-rules", "at"]}
label={'是否在消息@机器人时触发'}
name={['group-respond-rules', 'at']}
rules={[{ required: true }]}
>
<Switch />
</Form.Item>
<Form.Item
label={"消息前缀"}
name={["group-respond-rules", "prefix"]}
label={'消息前缀'}
name={['group-respond-rules', 'prefix']}
rules={[{ required: true }]}
>
<Select
@@ -401,76 +402,76 @@ export default function PipelineFormComponent({
/>
</Form.Item>
<Form.Item
label={"正则表达式"}
name={["group-respond-rules", "regexp"]}
label={'正则表达式'}
name={['group-respond-rules', 'regexp']}
rules={[{ required: true }]}
>
<Select mode="tags" options={[]} />
</Form.Item>
<Form.Item
label={"随机"}
name={["group-respond-rules", "random"]}
label={'随机'}
name={['group-respond-rules', 'random']}
rules={[{ required: false }]}
>
<InputNumber max={1} min={0} step={0.05} />
</Form.Item>
<div className={`${styles.formItemSubtitle}`}> 访 </div>
<Form.Item
label={"模式"}
name={["access-control", "mode"]}
label={'模式'}
name={['access-control', 'mode']}
rules={[{ required: true }]}
tooltip={"访问控制模式"}
tooltip={'访问控制模式'}
>
<Select
options={[
{ label: "黑名单", value: "blacklist" },
{ label: "白名单", value: "Whitelist" }
{ label: '黑名单', value: 'blacklist' },
{ label: '白名单', value: 'Whitelist' },
]}
/>
</Form.Item>
<Form.Item
label={"黑名单"}
name={["access-control", "blacklist"]}
label={'黑名单'}
name={['access-control', 'blacklist']}
rules={[{ required: true }]}
>
<Select mode={"tags"} options={[]} />
<Select mode={'tags'} options={[]} />
</Form.Item>
<Form.Item
label={"白名单"}
name={["access-control", "whitelist"]}
label={'白名单'}
name={['access-control', 'whitelist']}
rules={[{ required: true }]}
>
<Select mode={"tags"} options={[]} />
<Select mode={'tags'} options={[]} />
</Form.Item>
<div className={`${styles.formItemSubtitle}`}> </div>
<Form.Item
label={"前缀"}
name={["ignore-rules", "whitelist"]}
label={'前缀'}
name={['ignore-rules', 'whitelist']}
rules={[{ required: true }]}
tooltip={"消息前缀"}
tooltip={'消息前缀'}
>
<Select mode={"tags"} options={[]} />
<Select mode={'tags'} options={[]} />
</Form.Item>
<Form.Item
label={"正则表达式"}
name={["ignore-rules", "regexp"]}
label={'正则表达式'}
name={['ignore-rules', 'regexp']}
rules={[{ required: true }]}
tooltip={"消息正则表达式"}
tooltip={'消息正则表达式'}
>
<Select mode={"tags"} options={[]} />
<Select mode={'tags'} options={[]} />
</Form.Item>
</Form>
{/* 安全控制表单 safety */}
<Form
layout={"vertical"}
layout={'vertical'}
style={{
display: getNowFormLabel().name === "safety" ? "block" : "none"
display: getNowFormLabel().name === 'safety' ? 'block' : 'none',
}}
form={safetyForm}
disabled={disableForm}
@@ -478,22 +479,22 @@ export default function PipelineFormComponent({
{/* 内容过滤块 content-filter */}
<div className={`${styles.formItemSubtitle}`}> </div>
<Form.Item
label={"检查范围"}
name={["content-filter", "scope"]}
label={'检查范围'}
name={['content-filter', 'scope']}
rules={[{ required: true }]}
>
<Select
options={[
{ label: "全部", value: "all" },
{ label: "传入消息(用户消息)", value: "income-msg" },
{ label: "传出消息(机器人消息)", value: "output-msg" }
{ label: '全部', value: 'all' },
{ label: '传入消息(用户消息)', value: 'income-msg' },
{ label: '传出消息(机器人消息)', value: 'output-msg' },
]}
/>
</Form.Item>
<Form.Item
label={"检查敏感词"}
name={["content-filter", "check-sensitive-words"]}
label={'检查敏感词'}
name={['content-filter', 'check-sensitive-words']}
rules={[{ required: true }]}
>
<Switch />
@@ -502,31 +503,31 @@ export default function PipelineFormComponent({
{/* 速率限制块 rate-limit */}
<div className={`${styles.formItemSubtitle}`}> </div>
<Form.Item
label={"窗口长度(秒)"}
name={["rate-limit", "window-length"]}
label={'窗口长度(秒)'}
name={['rate-limit', 'window-length']}
rules={[{ required: true }]}
initialValue={60}
>
<InputNumber></InputNumber>
</Form.Item>
<Form.Item
label={"限制次数"}
name={["rate-limit", "limitation"]}
label={'限制次数'}
name={['rate-limit', 'limitation']}
rules={[{ required: true }]}
initialValue={60}
>
<InputNumber />
</Form.Item>
<Form.Item
label={"策略"}
name={["rate-limit", "strategy"]}
label={'策略'}
name={['rate-limit', 'strategy']}
rules={[{ required: true }]}
initialValue={"drop"}
initialValue={'drop'}
>
<Select
options={[
{ label: "丢弃", value: "drop" },
{ label: "等待", value: "wait" }
{ label: '丢弃', value: 'drop' },
{ label: '等待', value: 'wait' },
]}
/>
</Form.Item>
@@ -534,9 +535,9 @@ export default function PipelineFormComponent({
{/* 输出处理控制表单 output */}
<Form
layout={"vertical"}
layout={'vertical'}
style={{
display: getNowFormLabel().name === "output" ? "block" : "none"
display: getNowFormLabel().name === 'output' ? 'block' : 'none',
}}
form={outputForm}
disabled={disableForm}
@@ -545,26 +546,26 @@ export default function PipelineFormComponent({
<div className={`${styles.formItemSubtitle}`}> </div>
<Form.Item
label="阈值"
name={["long-text-processing", "threshold"]}
name={['long-text-processing', 'threshold']}
rules={[{ required: true }]}
>
<InputNumber />
</Form.Item>
<Form.Item
label="策略"
name={["long-text-processing", "strategy"]}
name={['long-text-processing', 'strategy']}
rules={[{ required: true }]}
>
<Select
options={[
{ label: "转发消息组件", value: "forward" },
{ label: "转换为图片", value: "image" }
{ label: '转发消息组件', value: 'forward' },
{ label: '转换为图片', value: 'image' },
]}
/>
</Form.Item>
<Form.Item
label="字体路径"
name={["long-text-processing", "font-path"]}
name={['long-text-processing', 'font-path']}
rules={[{ required: true }]}
>
<Input />
@@ -574,14 +575,14 @@ export default function PipelineFormComponent({
<div className={`${styles.formItemSubtitle}`}> </div>
<Form.Item
label="最小秒数"
name={["force-delay", "min"]}
name={['force-delay', 'min']}
rules={[{ required: true }]}
>
<InputNumber />
</Form.Item>
<Form.Item
label="最大秒数"
name={["force-delay", "max"]}
name={['force-delay', 'max']}
rules={[{ required: true }]}
>
<InputNumber />
@@ -591,7 +592,7 @@ export default function PipelineFormComponent({
<div className={`${styles.formItemSubtitle}`}> </div>
<Form.Item
label="不输出异常信息给用户"
name={["misc", "hide-exception"]}
name={['misc', 'hide-exception']}
rules={[{ required: true }]}
valuePropName="checked"
>
@@ -599,7 +600,7 @@ export default function PipelineFormComponent({
</Form.Item>
<Form.Item
label="在回复中@发送者"
name={["misc", "at-sender"]}
name={['misc', 'at-sender']}
rules={[{ required: true }]}
valuePropName="checked"
>
@@ -607,7 +608,7 @@ export default function PipelineFormComponent({
</Form.Item>
<Form.Item
label="引用原文"
name={["misc", "quote-origin"]}
name={['misc', 'quote-origin']}
rules={[{ required: true }]}
valuePropName="checked"
>
@@ -615,7 +616,7 @@ export default function PipelineFormComponent({
</Form.Item>
<Form.Item
label="跟踪函数调用"
name={["misc", "track-function-calls"]}
name={['misc', 'track-function-calls']}
rules={[{ required: true }]}
valuePropName="checked"
>
@@ -630,16 +631,16 @@ export default function PipelineFormComponent({
onClick={reduceFormLabelIndex}
disabled={!getPreFormLabel()}
>
{getPreFormLabel()?.label || "暂无更多"}
{getPreFormLabel()?.label || '暂无更多'}
</Button>
<Button
type="primary"
icon={<CaretRightOutlined />}
onClick={addFormLabelIndex}
disabled={!getNextFormLabel()}
iconPosition={"end"}
iconPosition={'end'}
>
{getNextFormLabel()?.label || "暂无更多"}
{getNextFormLabel()?.label || '暂无更多'}
</Button>
<Button type="primary" onClick={handleCommit}>
@@ -1,7 +1,7 @@
export interface PipelineFormEntity {
basic: object,
ai: object,
trigger: object,
safety: object,
output: object,
}
basic: object;
ai: object;
trigger: object;
safety: object;
output: object;
}