| | |
| | | package cc.mrbird.febs.ai.strategy.Impl; |
| | | |
| | | import cc.mrbird.febs.ai.enumerates.AiTypeEnum; |
| | | import cc.mrbird.febs.ai.strategy.LlmStrategyService; |
| | | import cc.mrbird.febs.ai.strategy.enumerates.LlmApplicationAppIdEnum; |
| | | import cc.mrbird.febs.ai.strategy.enumerates.LlmStrategyContextEnum; |
| | |
| | | private final String bizParam_1 = "prompt_ai_system"; |
| | | private final String bizParam_2 = "question"; |
| | | private final String bizParam_3 = "query"; |
| | | private final String bizParam_4 = "messages"; |
| | | |
| | | private HashMap getPrompt(List<LlmStrategyDto> dto) { |
| | | HashMap<String, String> bizParamsMap = new HashMap<>(); |
| | |
| | | } |
| | | if (StrUtil.equals(dtoItem.getRole(),Role.USER.getValue())){ |
| | | bizParamsMap.put(bizParam_3, dtoItem.getContent()); |
| | | } |
| | | if (StrUtil.equals(dtoItem.getRole(),AiTypeEnum.MESSAGES.getName())){ |
| | | bizParamsMap.put(bizParam_4, JSONUtil.toJsonStr(dtoItem.getMessages())); |
| | | } |
| | | } |
| | | return bizParamsMap; |
| | |
| | | if (StrUtil.equals(dtoItem.getRole(),Role.TOOL.getValue())){ |
| | | int code = Integer.parseInt(dtoItem.getContent()); |
| | | appId = LlmApplicationAppIdEnum.HIGH_LIGHT.getAppIdByCode(code); |
| | | break; |
| | | } |
| | | } |
| | | return appId; |
| | | } |
| | | |
| | | private String getAppIdV2(List<LlmStrategyDto> dto) { |
| | | String appId = null; |
| | | for (LlmStrategyDto dtoItem : dto){ |
| | | if (StrUtil.equals(dtoItem.getRole(),Role.TOOL.getValue())){ |
| | | appId = dtoItem.getContent(); |
| | | break; |
| | | } |
| | | } |
| | |
| | | } |
| | | HashMap prompt = getPrompt(dto); |
| | | String query = getQuery(dto); |
| | | String appId = getAppId(dto); |
| | | // String appId = getAppId(dto); |
| | | String appId = getAppIdV2(dto); |
| | | if (prompt == null || prompt.size() == 0){ |
| | | throw new FebsException("百炼工作流初始化异常"); |
| | | } |