src/main/java/cc/mrbird/febs/ai/strategy/Impl/AliApplicationLlmStrategyServiceImpl.java
@@ -1,5 +1,6 @@
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;
@@ -38,6 +39,7 @@
    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<>();
@@ -51,8 +53,41 @@
            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;
    }
    private List<Message> getMessages(List<LlmStrategyDto> dto) {
        List<Message> messages = new ArrayList<>();
        for (LlmStrategyDto item : dto){
            if (StrUtil.equals(item.getRole(),AiTypeEnum.MESSAGES.getName())){
                List<LlmStrategyDto> messagesList = item.getMessages();
                for (LlmStrategyDto dtoItem : messagesList){
                    if (StrUtil.equals(dtoItem.getRole(),Role.SYSTEM.getValue())){
                        messages.add(Message.builder()
                                .role(Role.SYSTEM.getValue())
                                .content(dtoItem.getContent())
                                .build());
                    }
                    if (StrUtil.equals(dtoItem.getRole(),Role.USER.getValue())){
                        messages.add(Message.builder()
                                .role(Role.USER.getValue())
                                .content(dtoItem.getContent())
                                .build());
                    }
                    if (StrUtil.equals(dtoItem.getRole(),Role.ASSISTANT.getValue())){
                        messages.add(Message.builder()
                                .role(Role.ASSISTANT.getValue())
                                .content(dtoItem.getContent())
                                .build());
                    }
                }
            }
        }
        return messages;
    }
    private String getQuery(List<LlmStrategyDto> dto) {
@@ -72,6 +107,17 @@
            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;
            }
        }
@@ -161,7 +207,8 @@
        }
        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("百炼工作流初始化异常");
        }
@@ -171,6 +218,8 @@
        if (appId == null){
            throw new FebsException("百炼工作流初始化异常");
        }
        List<Message> messages = getMessages(dto);
        long startTime = System.currentTimeMillis();
        ApplicationParam param = ApplicationParam.builder()
                // 若没有配置环境变量,可用百炼API Key将下行替换为:.apiKey("sk-xxx")。但不建议在生产环境中直接将API Key硬编码到代码中,以减少API Key泄露风险。
@@ -178,6 +227,7 @@
                .appId(appId) //替换为实际的应用 ID
                .flowStreamMode(FlowStreamMode.MESSAGE_FORMAT)
                .prompt(query)
                .messages( messages)
                .bizParams(JsonUtils.toJsonObject( prompt))
                .build();