feat: 添加可配置场景注册表与规则引擎
- 新增场景基类、配置加载、注册表与原语模块 - 添加 r10_refund_split 规则及场景 JSON Schema - 扩展 scan 引擎与 scenarios API - 新增场景注册表/配置/集成测试 - 更新前端 App、api、labels 支持新场景
This commit is contained in:
+15
-1
@@ -1,12 +1,26 @@
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import Dashboard from "./Dashboard";
|
||||
import Clues from "./Clues";
|
||||
import NLQ from "./NLQ";
|
||||
import { api } from "./api";
|
||||
import { setScenarioLabels } from "./labels";
|
||||
|
||||
type Tab = "dashboard" | "clues" | "nlq";
|
||||
|
||||
export default function App() {
|
||||
const [tab, setTab] = useState<Tab>("dashboard");
|
||||
const [, setLabelsReady] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
// 启动时从后端拉取场景元数据,动态填充场景展示名(失败则回退到内置兜底)
|
||||
api
|
||||
.listScenarios()
|
||||
.then((items) => {
|
||||
setScenarioLabels(items);
|
||||
setLabelsReady(true);
|
||||
})
|
||||
.catch(() => undefined);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="app">
|
||||
|
||||
@@ -32,6 +32,13 @@ export interface NLQResponse {
|
||||
egress: boolean;
|
||||
}
|
||||
|
||||
export interface ScenarioMeta {
|
||||
code: string;
|
||||
title: string;
|
||||
label: string;
|
||||
risk_domain: string;
|
||||
}
|
||||
|
||||
async function http<T>(url: string, init?: RequestInit): Promise<T> {
|
||||
const resp = await fetch(url, {
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -65,4 +72,5 @@ export const api = {
|
||||
}),
|
||||
nlq: (question: string) =>
|
||||
http<NLQResponse>("/nlq", { method: "POST", body: JSON.stringify({ question }) }),
|
||||
listScenarios: () => http<ScenarioMeta[]>("/scenarios"),
|
||||
};
|
||||
|
||||
@@ -22,11 +22,19 @@ export const feedbackLabel: Record<string, string> = {
|
||||
false_positive: "误报",
|
||||
};
|
||||
|
||||
// 场景展示名:内置少量兜底,运行时由后端 /scenarios 填充(新增场景无需改前端)
|
||||
export const scenarioLabel: Record<string, string> = {
|
||||
R8: "政企拆单",
|
||||
R9: "养卡骗补",
|
||||
};
|
||||
|
||||
// 用后端返回的场景元数据就地填充展示名(组件仍读同一对象引用,无需改动)
|
||||
export function setScenarioLabels(items: { code: string; label: string }[]): void {
|
||||
for (const it of items) {
|
||||
if (it.code && it.label) scenarioLabel[it.code] = it.label;
|
||||
}
|
||||
}
|
||||
|
||||
export const providerLabel: Record<string, string> = {
|
||||
mock: "本地Mock",
|
||||
vllm: "本地vLLM",
|
||||
|
||||
Reference in New Issue
Block a user