admin
2025-06-06 9cd825aea53fa5ba0cda1485464af027e27f0ce4
aiflowy-modules/aiflowy-module-ai/src/main/java/tech/aiflowy/ai/entity/AiLlm.java
@@ -1,5 +1,7 @@
package tech.aiflowy.ai.entity;
import com.agentsflex.llm.deepseek.DeepseekConfig;
import com.agentsflex.llm.deepseek.DeepseekLlm;
import tech.aiflowy.ai.entity.base.AiLlmBase;
import tech.aiflowy.common.util.PropertiesUtil;
import tech.aiflowy.common.util.StringUtil;
@@ -29,7 +31,6 @@
@Table("tb_ai_llm")
public class AiLlm extends AiLlmBase {
    public List<String> getSupportFeatures() {
        List<String> features = new ArrayList<>();
@@ -92,6 +93,8 @@
                return qwenLlm();
            case "gitee":
                return giteeLlm();
            case "deepseek":
                return deepseekLlm();
            default:
                return null;
        }
@@ -128,22 +131,31 @@
        openAiLlmConfig.setModel(getLlmModel());
        openAiLlmConfig.setDefaultEmbeddingModel(getLlmModel());
        String llmExtraConfig = getLlmExtraConfig();
        Properties prop = PropertiesUtil.textToProperties(llmExtraConfig);
        String chatPath = prop.getProperty("chatPath");
        String embedPath = prop.getProperty("embedPath");
        if (chatPath != null && !chatPath.isEmpty()) {
            openAiLlmConfig.setChatPath(chatPath);
        }
        if (embedPath != null && !embedPath.isEmpty()) {
            openAiLlmConfig.setEmbedPath(embedPath);
        if (llmExtraConfig != null && !llmExtraConfig.isEmpty()){
            Properties prop = PropertiesUtil.textToProperties(llmExtraConfig);
            String chatPath = prop.getProperty("chatPath");
            String embedPath = prop.getProperty("embedPath");
            if (chatPath != null && !chatPath.isEmpty()) {
                openAiLlmConfig.setChatPath(chatPath);
            }
            if (embedPath != null && !embedPath.isEmpty()) {
                openAiLlmConfig.setEmbedPath(embedPath);
            }
        }
        return new OpenAILlm(openAiLlmConfig);
    }
    private Llm sparkLlm() {
        SparkLlmConfig sparkLlmConfig = PropertiesUtil.propertiesTextToEntity(getLlmExtraConfig(), SparkLlmConfig.class);
        sparkLlmConfig.setApiKey(getLlmApiKey());
        return new SparkLlm(sparkLlmConfig);
    }
    private Llm deepseekLlm() {
        DeepseekConfig config = new DeepseekConfig();
        config.setModel(getLlmModel());
        config.setEndpoint(getLlmEndpoint());
        config.setApiKey(getLlmApiKey());
        return new DeepseekLlm(config);
    }
}