package cn.iocoder.yudao.module.qcreport.config;
|
|
import lombok.Data;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.stereotype.Component;
|
|
/**
|
* AI 导入模板草稿配置
|
* <p>
|
* 对应 application.yml 中的 yudao.qcreport.ai-import 前缀配置。
|
* <p>
|
* 这里的每一项都是**硬上限**,不是性能调优参数:每次导入会真的发出 1~5 次大模型调用,
|
* 扫描件按图计费,无上限意味着一次误操作就能烧掉一整天的额度。所以宁可报错让用户分批,
|
* 也不要静默截断——静默截断还会让用户以为整份文件都识别过了。
|
*/
|
@Component
|
@ConfigurationProperties(prefix = "yudao.qcreport.ai-import", ignoreUnknownFields = true)
|
@Data
|
public class QcReportAiImportProperties {
|
|
/** 是否启用 AI 导入。需要能出网访问大模型服务;内网部署时关掉它,接口会明确报「未启用」而不是挂住 */
|
private Boolean enabled = true;
|
|
/** 一次请求最多几个文件 */
|
private Integer maxFiles = 3;
|
|
/** 单个文件最多几页。超出直接报错,不静默截断 */
|
private Integer maxPagesPerFile = 5;
|
|
/** 一次请求的累计页数上限。多文件叠加后的总闸,防止「每个文件都没超、加起来却很多」 */
|
private Integer maxPagesPerRequest = 8;
|
|
/**
|
* 一次导入的总耗时上限(秒),在两次模型调用之间检查。
|
* <p>
|
* 页数与文件数上限只约束了调用**次数**,没约束**时长**:模型排队时每次调用都能耗满
|
* {@code yudao.ai.timeout},8 次叠加能把一次误操作拖成好几分钟的付费调用。
|
* <p>
|
* 单次调用无法中途打断({@code AiChatApi} 不接受超时参数),所以只能在两次调用之间关门,
|
* 最坏会多出一个单次调用超时。前端 axios 超时必须比「本项 + yudao.ai.timeout」更宽,
|
* 否则用户先看到浏览器断开,而不是这里的明确提示。取 180 秒:常规 8 次以内的调用都跑得完,
|
* 只有模型明显变慢时才会触发。
|
*/
|
private Integer maxDurationSeconds = 180;
|
|
/** 单个文件大小上限(MB) */
|
private Integer maxFileSizeMb = 20;
|
|
/** 识别出的组件总数上限,超出截断并在 warnings 里提示补录 */
|
private Integer maxComponents = 200;
|
|
/**
|
* PDF 判定走文本通道还是图片通道的阈值:平均每页字符数。
|
* <p>
|
* 依据是「这份 PDF 有没有文本层」而不是「它是不是 PDF」。阈值取 30 是经验值:
|
* 真正有文本层的报告每页至少几十字,而扫描件即便带上 OCR 层也往往只有零星几个字符。
|
*/
|
private Integer pdfTextPageThreshold = 30;
|
|
/** 扫描页转图时的 DPI。低于 200 时中文字形会糊,多模态模型容易认错;调高则每次调用更贵 */
|
private Integer renderDpi = 200;
|
|
/** Excel 单表最多读取的行数,防止超大表把提示词撑爆 */
|
private Integer maxXlsxRows = 300;
|
|
}
|