Commit 6e76fb7b6c244bc81894212cb73465bae45a275f
1 parent
e3358a7f
添加未清选择 改成动态引导语
Showing
2 changed files
with
21 additions
and
3 deletions
src/main/java/com/xly/service/XlyErpService.java
| ... | ... | @@ -355,6 +355,8 @@ public class XlyErpService { |
| 355 | 355 | Boolean isConfirmed = dynamicToolProvider.isConfirmed(input) || input.contains("生成") || input.contains("确认"); |
| 356 | 356 | if(ObjectUtil.isNotEmpty(session.getSSystemPrompt()) && isConfirmed){ |
| 357 | 357 | sSystemPrompt = session.getSSystemPrompt(); |
| 358 | + //重新生成新的aiAgent拿新的aiAgent 做选择 | |
| 359 | + aiAgent = createConfirmeAgent(session); | |
| 358 | 360 | } |
| 359 | 361 | Result<String> rs = aiAgent.chat(userId, input,sSystemPrompt); |
| 360 | 362 | sResponMessage = rs.content(); |
| ... | ... | @@ -376,8 +378,6 @@ public class XlyErpService { |
| 376 | 378 | ){ |
| 377 | 379 | //查询缓存是否存在取缓存 直接走 |
| 378 | 380 | Map<String,Object> cachMap = getDynamicTableCach(session,userInput); |
| 379 | - Boolean isAggregation; | |
| 380 | - Boolean bHasCach; | |
| 381 | 381 | String sCleanSql = StrUtil.EMPTY; |
| 382 | 382 | if(ObjectUtil.isEmpty(cachMap)){ |
| 383 | 383 | //查询是否走向量库 还是数据库查询 |
| ... | ... | @@ -385,7 +385,6 @@ public class XlyErpService { |
| 385 | 385 | session.setDbCach("D"); |
| 386 | 386 | // bHasCach = false; |
| 387 | 387 | }else{ |
| 388 | - isAggregation = "MYSQL".equals(cachMap.get("cachType")); | |
| 389 | 388 | session.setDbCach("H"); |
| 390 | 389 | // bHasCach = true; |
| 391 | 390 | sCleanSql = ObjectUtil.isNotEmpty(cachMap.get("sSqlContent"))?cachMap.get("sSqlContent").toString() : StrUtil.EMPTY; |
| ... | ... | @@ -975,6 +974,24 @@ public class XlyErpService { |
| 975 | 974 | return aiAgent; |
| 976 | 975 | } |
| 977 | 976 | |
| 977 | + private ErpAiAgent createConfirmeAgent(UserSceneSession session) { | |
| 978 | + List<ToolSpecificationHolder> dataList = dynamicToolProvider.sceneToolCacheMap.get(session.getCurrentScene().getSId()); | |
| 979 | + Set<String> immediateReturnToolNames = new HashSet<>(); | |
| 980 | + dataList = dataList.stream().filter(one->one.getsName().equals(session.getCurrentTool().getSMethodNo())).collect(Collectors.toUnmodifiableList()); | |
| 981 | + Map<ToolSpecification, ToolExecutor> executors = new HashMap<>(); | |
| 982 | + if(ObjectUtil.isNotEmpty(dataList)){ | |
| 983 | + dataList.forEach(one->{ | |
| 984 | + immediateReturnToolNames.add(one.getsName()); | |
| 985 | + executors.put(one.getToolSpecification(),one.getToolExecutor()); | |
| 986 | + }); | |
| 987 | + } | |
| 988 | + ErpAiAgent aiAgent = AiServices.builder(ErpAiAgent.class) | |
| 989 | + .chatModel(chatModel) | |
| 990 | + .chatMemoryProvider(operableChatMemoryProvider) | |
| 991 | + .tools(executors,immediateReturnToolNames) | |
| 992 | + .build(); | |
| 993 | + return aiAgent; | |
| 994 | + } | |
| 978 | 995 | |
| 979 | 996 | /** |
| 980 | 997 | * 大模型意图解析核心方法(获取场景) | ... | ... |
src/main/java/com/xly/tool/DynamicToolProvider.java
| ... | ... | @@ -313,6 +313,7 @@ public class DynamicToolProvider implements ToolProvider { |
| 313 | 313 | 2. 只要方法返回结果,必须停止调用 |
| 314 | 314 | 3. 禁止重复调用同一个方法 |
| 315 | 315 | 4. 禁止无意义循环调用 |
| 316 | + 5. 当用户输入包含【数据确认】、确认数据、确认、第*条数据确认时,必须调用本工具 | |
| 316 | 317 | """; |
| 317 | 318 | stoolDesc.append(forceToolPrompt); |
| 318 | 319 | if (ObjectUtil.isNotEmpty(meta.getStoolDesc())) { | ... | ... |