| | |
| | | private DeepSeekConfig config; |
| | | @Resource |
| | | private DbQueryExecutor dbQueryExecutor; |
| | | @Resource |
| | | private DesensitizeService desensitizeService; |
| | | |
| | | public String chat(String prompt) { |
| | | JSONObject body = JSONUtil.createObj() |
| | |
| | | JSONArray toolCalls = message.getJSONArray("tool_calls"); |
| | | if (toolCalls == null || toolCalls.isEmpty()) { |
| | | String content = message.getStr("content"); |
| | | return content == null ? "(AI 未返回内容)" : content; |
| | | if (content == null) { |
| | | return "(AI 未返回内容)"; |
| | | } |
| | | // 回填给前端前,把企业名称别名还原为真实名称 |
| | | return desensitizeService.unmaskAll(content); |
| | | } |
| | | |
| | | // 回传 assistant 消息(含工具调用),再逐个执行并回填 tool 结果 |
| | |
| | | if (ctx.get("reportId") != null) { |
| | | sb.append("关联上报记录ID: ").append(ctx.get("reportId")).append("\n"); |
| | | } |
| | | if (ctx.get("reportType") != null) { |
| | | sb.append("关联业务类型: ").append(ctx.get("reportType")).append("\n"); |
| | | } |
| | | if (ctx.get("tableName") != null) { |
| | | sb.append("关联数据表: ").append(ctx.get("tableName")).append("(查询该企业解释对应数据时优先查此表,按 id=").append(ctx.get("reportId")).append(" 过滤)\n"); |
| | | } |
| | | } |
| | | sb.append("\n你可以调用 query_database 工具查询数据库获取真实数据,如企业车辆数、吨位、货运量、周转量、轨迹里程、规上规下拆分、去年同期等。\n\n"); |
| | | sb.append("数据库表结构如下(列名一律使用 camelCase,例如 enterpriseName、vehicleTotal、freightTotal、turnoverTotal;filters 的键同样使用 camelCase):\n"); |