| | |
| | | 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; |
| | |
| | | |
| | | @Table("tb_ai_llm") |
| | | public class AiLlm extends AiLlmBase { |
| | | |
| | | |
| | | public List<String> getSupportFeatures() { |
| | | List<String> features = new ArrayList<>(); |
| | |
| | | return qwenLlm(); |
| | | case "gitee": |
| | | return giteeLlm(); |
| | | case "deepseek": |
| | | return deepseekLlm(); |
| | | default: |
| | | return null; |
| | | } |
| | |
| | | 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); |
| | | } |
| | | } |