Files
leaudit-platform-frontend/app/models/evaluation_points.ts
T

331 lines
9.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 评查点数据类型定义
*/
interface EvaluationPoint {
id?: number;
name?: string; // 评查点名称
code?: string; // 评查点编码
risk?: string; // 风险级别
is_enabled?: boolean; // 是否启用
description?: string; // 描述
references_laws?: { // 法律法规引用
name?: string; // 法规名称
articles?: string[]; // 条款列表
content?: string; // 法规内容
};
evaluation_point_groups_pid?: number | null; // 评查点类型组ID
evaluation_point_groups_id?: number | null; // 所属评查组ID
extraction_config?: ExtactionConfigType; // 抽取配置
evaluation_config?: EvaluationConfigType; // 评查配置
pass_message?: string; // 通过消息
fail_message?: string; // 失败消息
suggestion_message?: string; // 建议消息
suggestion_message_type?: SuggestionMessageType; // 建议消息类型 默认warninginfo/warning/error
post_action?: PostActionType; // 评查后动作 可为空(none/manual/replace
action_config?: string; // 动作配置
score?: number; // 分数
}
/**
* 风险级别类型定义
*/
type RiskLevelType = 'high' | 'medium' | 'low';
/**
* 建议消息类型定义
*/
type SuggestionMessageType = 'info' | 'warning' | 'error';
/**
* 评查后动作类型定义
*/
type PostActionType = 'none' | 'manual' | 'replace';
/**
* 抽取配置类型定义
*/
interface ExtactionConfigType {
llm: {
fields: string[];
prompt_setting: LLMPromptSetting;
};
vlm: {
fields: Array<{
name: string;
type: VLMFieldType; // 多模态字段类型 默认、货币、打印、印章、骑缝章、英文、数字、手写、自定义
template?: string; // 自定义类型的提示词模板(仅当 type 为 custom 时使用)
}>;
prompt_setting: VLMPromptSetting;
};
regex: {
fields: Array<{
field: string;
pattern: string;
}>;
};
}
/**
* VLM字段类型定义
*/
type VLMFieldType = 'vlm_default_prompt' | 'vlm_currency_prompt' | 'vlm_print_prompt' | 'vlm_seal_prompt' | 'vlm_acrossPageSeal_prompt' | 'vlm_english_prompt' | 'vlm_number_prompt' | 'vlm_handwriting_prompt' | 'custom';
/**
* llm提示配置类型定义
*/
interface LLMPromptSetting {
type: LLMPromptType; // "llm_default_prompt" or "custom" 如果为 "custom" 则为自定义提示
template: string; // 提示模板
}
/**
* vlm提示配置类型定义
*/
interface VLMPromptSetting {
type: VLMPromptType; // "vlm_default_prompt" or "custom" 如果为 "custom" 则为自定义提示
template: string; // 提示模板
}
/**
* llm提示类型定义
*/
type LLMPromptType = 'llm_default_prompt' | 'custom';
/**
* llm提示类型定义
*/
type VLMPromptType = 'vlm_default_prompt' | 'custom';
/**
* 评查配置类型定义
*/
interface EvaluationConfigType {
logicType: LogicType;
customLogic: string; // 自定义逻辑:(规则1 AND 规则2) OR 规则3
rules: Rule[];
}
/**
* 逻辑类型定义
*/
type LogicType = 'and' | 'or' | 'custom';
interface Rule {
id: string;
type: RuleType; // 规则类型 有无、一致性、格式、逻辑、正则、AI、代码
config: {
// exists 规则配置
fields?: string[];
logic?: LogicOperator;
// consistency 规则配置
pairs?: Array<{
sourceField: string;
targetField: string;
compareMethod: CompareMethod; // 比较方法 包含、精确、大模型语义
}>;
// format 规则配置
field?: string;
formatType?: FormatType; // 格式类型 日期格式、数字格式、电话号码、电子邮箱、银行卡号、身份证号码、邮政编码、统一社会信用代码
parameters?: string;
// logic 规则配置
conditions?: Array<{
field: string;
operator: ComparisonOperator; // 比较运算符 等于、不等于、大于、大于等于、小于、小于等于、包含、不包含
value: string;
}>;
// regex 规则配置
pattern?: string;
matchType?: MatchType; // 匹配类型 必须匹配(符合为通过)、不得匹配(不符合为通过)
// ai 规则配置
model?: string; // 大模型名称
temperature?: number; // 温度
prompt?: string; // 提示
// code 规则配置
language?: ProgrammingLanguage;
code?: string;
}
}
/**
* 规则类型定义
*/
type RuleType = 'exists' | 'consistency' | 'format' | 'logic' | 'regex' | 'ai' | 'code';
/**
* 逻辑操作符定义
*/
type LogicOperator = 'and' | 'or';
/**
* 比较方法定义
*/
type CompareMethod = 'contains' | 'exact' | 'semantic';
/**
* 格式类型定义
*/
type FormatType = 'date' | 'number' | 'phone' | 'email' | 'bank' | 'id' | 'postal' | 'credit';
/**
* 比较运算符定义
*/
type ComparisonOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'contains' | 'not_contains';
/**
* 匹配类型定义
*/
type MatchType = 'match' | 'not_match';
/**
* 编程语言定义
*/
type ProgrammingLanguage = 'python' | 'javascript';
/**
* 下拉选项数据集
*/
export const EVALUATION_OPTIONS = {
// 风险级别选项
riskLevelOptions: [
{ value: 'high', label: '高风险' },
{ value: 'medium', label: '中风险' },
{ value: 'low', label: '低风险' }
],
// 建议消息类型选项
suggestionMessageTypeOptions: [
{ value: 'info', label: '提示' },
{ value: 'warning', label: '警告' },
{ value: 'error', label: '错误' }
],
// 评查后动作选项
postActionOptions: [
{ value: 'none', label: '无' },
{ value: 'manual', label: '人工确认' },
{ value: 'replace', label: '内容替换' }
],
// VLM字段类型选项
vlmFieldTypeOptions: [
{ value: 'vlm_default_prompt', label: '默认' },
{ value: 'vlm_currency_prompt', label: '货币' },
{ value: 'vlm_print_prompt', label: '打印' },
{ value: 'vlm_seal_prompt', label: '印章' },
{ value: 'vlm_acrossPageSeal_prompt', label: '骑缝章' },
{ value: 'vlm_english_prompt', label: '英文' },
{ value: 'vlm_number_prompt', label: '数字' },
{ value: 'vlm_handwriting_prompt', label: '手写' },
{ value: 'custom', label: '自定义' }
],
// vlm提示词类型选项
vlmPromptTypeOptions: [
{ value: 'vlm_default_prompt', label: '使用系统默认提示词' },
{ value: 'custom', label: '使用自定义提示词' }
],
// llm提示词类型选项
llmPromptTypeOptions: [
{ value: 'llm_default_prompt', label: '使用系统默认提示词' }
// { value: 'custom', label: '使用自定义提示词' }
],
// 逻辑类型选项
logicTypeOptions: [
{ value: 'and', label: '全部满足(AND' },
{ value: 'or', label: '任一满足(OR' },
{ value: 'custom', label: '自定义组合' }
],
// 规则类型选项
ruleTypeOptions: [
{ value: 'exists', label: '有无判断' },
{ value: 'consistency', label: '一致性判断' },
{ value: 'format', label: '格式判断' },
{ value: 'logic', label: '逻辑判断' },
{ value: 'regex', label: '正则表达式' },
{ value: 'ai', label: '大模型判断' },
// { value: 'code', label: '自定义代码' }
],
// 逻辑操作符选项
logicOperatorOptions: [
{ value: 'and', label: 'AND(所有条件都满足)' },
{ value: 'or', label: 'OR(任一条件满足)' }
],
// 比较方法选项
compareMethodOptions: [
{ value: 'contains', label: '包含关系' },
{ value: 'exact', label: '精确匹配' },
{ value: 'semantic', label: '大模型语义匹配' }
],
// 格式类型选项
formatTypeOptions: [
{ value: 'date', label: '日期格式' },
{ value: 'number', label: '数字格式' },
{ value: 'phone', label: '电话号码' },
{ value: 'email', label: '电子邮箱' },
{ value: 'bank', label: '银行卡号' },
{ value: 'id', label: '身份证号码' },
{ value: 'postal', label: '邮政编码' },
{ value: 'credit', label: '统一社会信用代码' }
],
// 比较运算符选项
comparisonOperatorOptions: [
{ value: 'eq', label: '等于(=)' },
{ value: 'neq', label: '不等于(≠)' },
{ value: 'gt', label: '大于(>)' },
{ value: 'gte', label: '大于等于(≥)' },
{ value: 'lt', label: '小于(<)' },
{ value: 'lte', label: '小于等于(≤)' },
{ value: 'contains', label: '包含' },
{ value: 'not_contains', label: '不包含' }
],
// 匹配类型选项
matchTypeOptions: [
{ value: 'match', label: '必须匹配(符合为通过)' },
{ value: 'not_match', label: '不得匹配(不符合为通过)' }
],
// 编程语言选项
programmingLanguageOptions: [
{ value: 'python', label: 'Python' },
{ value: 'javascript', label: 'JavaScript' }
]
};
// 导出类型定义供其他模块使用
export type {
EvaluationPoint,
RiskLevelType,
SuggestionMessageType,
PostActionType,
ExtactionConfigType,
VLMPromptSetting,
VLMFieldType,
LLMPromptSetting,
LLMPromptType,
EvaluationConfigType,
LogicType,
Rule,
RuleType,
LogicOperator,
CompareMethod,
FormatType,
ComparisonOperator,
MatchType,
ProgrammingLanguage
};