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,6 +355,8 @@ public class XlyErpService { | ||
| 355 | Boolean isConfirmed = dynamicToolProvider.isConfirmed(input) || input.contains("生成") || input.contains("确认"); | 355 | Boolean isConfirmed = dynamicToolProvider.isConfirmed(input) || input.contains("生成") || input.contains("确认"); |
| 356 | if(ObjectUtil.isNotEmpty(session.getSSystemPrompt()) && isConfirmed){ | 356 | if(ObjectUtil.isNotEmpty(session.getSSystemPrompt()) && isConfirmed){ |
| 357 | sSystemPrompt = session.getSSystemPrompt(); | 357 | sSystemPrompt = session.getSSystemPrompt(); |
| 358 | + //重新生成新的aiAgent拿新的aiAgent 做选择 | ||
| 359 | + aiAgent = createConfirmeAgent(session); | ||
| 358 | } | 360 | } |
| 359 | Result<String> rs = aiAgent.chat(userId, input,sSystemPrompt); | 361 | Result<String> rs = aiAgent.chat(userId, input,sSystemPrompt); |
| 360 | sResponMessage = rs.content(); | 362 | sResponMessage = rs.content(); |
| @@ -376,8 +378,6 @@ public class XlyErpService { | @@ -376,8 +378,6 @@ public class XlyErpService { | ||
| 376 | ){ | 378 | ){ |
| 377 | //查询缓存是否存在取缓存 直接走 | 379 | //查询缓存是否存在取缓存 直接走 |
| 378 | Map<String,Object> cachMap = getDynamicTableCach(session,userInput); | 380 | Map<String,Object> cachMap = getDynamicTableCach(session,userInput); |
| 379 | - Boolean isAggregation; | ||
| 380 | - Boolean bHasCach; | ||
| 381 | String sCleanSql = StrUtil.EMPTY; | 381 | String sCleanSql = StrUtil.EMPTY; |
| 382 | if(ObjectUtil.isEmpty(cachMap)){ | 382 | if(ObjectUtil.isEmpty(cachMap)){ |
| 383 | //查询是否走向量库 还是数据库查询 | 383 | //查询是否走向量库 还是数据库查询 |
| @@ -385,7 +385,6 @@ public class XlyErpService { | @@ -385,7 +385,6 @@ public class XlyErpService { | ||
| 385 | session.setDbCach("D"); | 385 | session.setDbCach("D"); |
| 386 | // bHasCach = false; | 386 | // bHasCach = false; |
| 387 | }else{ | 387 | }else{ |
| 388 | - isAggregation = "MYSQL".equals(cachMap.get("cachType")); | ||
| 389 | session.setDbCach("H"); | 388 | session.setDbCach("H"); |
| 390 | // bHasCach = true; | 389 | // bHasCach = true; |
| 391 | sCleanSql = ObjectUtil.isNotEmpty(cachMap.get("sSqlContent"))?cachMap.get("sSqlContent").toString() : StrUtil.EMPTY; | 390 | sCleanSql = ObjectUtil.isNotEmpty(cachMap.get("sSqlContent"))?cachMap.get("sSqlContent").toString() : StrUtil.EMPTY; |
| @@ -975,6 +974,24 @@ public class XlyErpService { | @@ -975,6 +974,24 @@ public class XlyErpService { | ||
| 975 | return aiAgent; | 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,6 +313,7 @@ public class DynamicToolProvider implements ToolProvider { | ||
| 313 | 2. 只要方法返回结果,必须停止调用 | 313 | 2. 只要方法返回结果,必须停止调用 |
| 314 | 3. 禁止重复调用同一个方法 | 314 | 3. 禁止重复调用同一个方法 |
| 315 | 4. 禁止无意义循环调用 | 315 | 4. 禁止无意义循环调用 |
| 316 | + 5. 当用户输入包含【数据确认】、确认数据、确认、第*条数据确认时,必须调用本工具 | ||
| 316 | """; | 317 | """; |
| 317 | stoolDesc.append(forceToolPrompt); | 318 | stoolDesc.append(forceToolPrompt); |
| 318 | if (ObjectUtil.isNotEmpty(meta.getStoolDesc())) { | 319 | if (ObjectUtil.isNotEmpty(meta.getStoolDesc())) { |