字段名称 | 说明 |
规则名称 | 设置规则名称。 |
会话标识 | 选择此前配置的会话标识,用于区分不同用户,实现对单个用户的精准算力消耗检测。 说明: 使用 SDK/API 接入方式时,无需配置该参数。 |
匹配方式 | 默认需要选择 LLM 业务匹配方式,选择添加的 LLM 业务防护路径配置。 说明: 单条规则中不同匹配方式为 “与” 关系。 使用 SDK/API 接入方式时,无需配置该参数。 |
防护规则 | 基于请求频次的防护:统计单个用户 ID 在单位时间(1 分钟、5 分钟、10 分钟、30 分钟、60 分钟、6 小时、12 小时、24 小时、每整点小时、每自然天,值为 2-100000,值必须为整数)内的请求次数。 基于 token 消耗量的防护:根据业务类型配置单个用户 ID 在单位时间(1 分钟、5 分钟、10 分钟、30 分钟、60 分钟、6 小时、12 小时、24 小时、每整点小时、每自然天)内的总 Token 消耗量。负载均衡型 WAF 接入的域名暂不支持此功能。 |
执行动作 | WAF 支持针对算力超量用户实现两种处置方式: 观察:仅记录日志。 拦截 当选择类型为基于请求频次的防护:在检测到用户超量后,将阻断用户发往源站的请求,并返回 WAF 默认拦截提示页面,可以前往 基础安全 修改默认拦截提示页面的内容。 当选择类型为基于 token 消耗量防护:在检测到用户超量后,WAF 会中断源站对用户的响应,并在返回的 data 中插入自定义提示内容,可以配置返回给用户的提示内容。 WAF 拦截时,如果是请求拦截,返回 WAF 默认拦截提示页面,可以前往基础安全修改默认拦截提示页面的内容。如果是响应拦截,除了会在返回的 data 中插入自定义提示内容配置以外,还会在返回的 data 数据中插入一个 uuid 字段以及 uuid 值,为了更好的拦截体验,也可以对业务前端进行逻辑修改,在检测到返回字段中存在 uuid 字段时,调整实际拦截效果。 |
优先级 | 配置规则优先级。优先级逻辑:请输入1-100的整数,数字越小,代表这条规则的执行优先级越高;相同优先级下,更新时间越晚,优先级越高。 |
if (!initResponse.ok) {const errorText = await initResponse.text();console.error('API错误响应:', errorText);removeMessage(responseMessageId); // 移除正在显示的消息容器// 解析服务器返回的错误信息let errorMessage = '';try {const errorData = JSON.parse(errorText);errorMessage = errorData.error?.message || errorData.message || errorText;} catch (e) {errorMessage = errorText;}// 显示错误消息到聊天界面addMessage(errorMessage, 'error');updateStatus('请求失败', 'error');return;}
// UUID检测处理 - 基于代码逻辑if (parsed.uuid) {console.log('🚨 检测到内容替换信号!');console.log('原始数据:', parsed);console.log('替换前内容:', fullContent);// 从服务器返回的数据中提取新内容let newContent = '';if (parsed.choices && parsed.choices[0] && parsed.choices[0].delta && parsed.choices[0].delta.content) {newContent = parsed.choices[0].delta.content;console.log('✅ 从 choices[0].delta.content 获取内容:', newContent);} else if (parsed.content) {newContent = parsed.content;console.log('✅ 从 content 获取内容:', newContent);} else {console.log('⚠️ 在数据中找不到 content');}// 完全重置已显示的内容fullContent = newContent;reasoning = '';contentWasReplaced = true;// 清空当前显示内容并重新显示服务器返回的新内容if (selectedModel === 'deepseek-reasoner') {// R1模式:清空思考过程和答案,显示新内容clearR1Message(responseMessageId);updateR1StreamingMessage(responseMessageId, '', fullContent, false);addContentReplacedIndicator(responseMessageId);} else {// 普通模式:清空消息,显示新内容clearStreamingMessage(responseMessageId);updateStreamingMessage(responseMessageId, fullContent, true);addContentReplacedIndicator(responseMessageId);}console.log('✅ 内容替换完成,当前 fullContent:', `"${fullContent}"`);// 停止处理后续数据流shouldStopProcessing = true;console.log('🛑 设置停止处理标记,不再处理后续数据');}
字段名称 | 说明 |
防护规则 | 配置基于 token 消耗量防护,并配置检测值为 1 万 token 每分钟。 |
执行动作 | 拦截。 |
拦截提示使用自定义提示 | 您好,您最近 1 分钟使用的 Token 量较高,请稍等一段时间再使用。 |
优先级 | 1。 |
规则开关 | 开启。 |

文档反馈