model platform optimize

This commit is contained in:
moyangzhan 2024-05-08 19:02:26 +08:00
parent 2341c92cf8
commit 7a6f404c74
3 changed files with 11 additions and 13 deletions

View File

@ -37,11 +37,14 @@ public class ImageModelContext {
} }
public static void addImageModelService(AbstractImageModelService modelService) { public static void addImageModelService(AbstractImageModelService modelService) {
AiModel aiModel = modelService.getAiModel();
ImageModelInfo imageModelInfo = new ImageModelInfo(); ImageModelInfo imageModelInfo = new ImageModelInfo();
imageModelInfo.setModelId(aiModel.getId());
imageModelInfo.setModelService(modelService); imageModelInfo.setModelService(modelService);
imageModelInfo.setModelName(modelService.getAiModel().getName()); imageModelInfo.setModelName(aiModel.getName());
imageModelInfo.setModelPlatform(aiModel.getPlatform());
imageModelInfo.setEnable(modelService.isEnabled()); imageModelInfo.setEnable(modelService.isEnabled());
NAME_TO_MODEL.put(modelService.getAiModel().getName(), imageModelInfo); NAME_TO_MODEL.put(aiModel.getName(), imageModelInfo);
} }
public AbstractImageModelService getModelService() { public AbstractImageModelService getModelService() {

View File

@ -2,13 +2,9 @@ package com.moyz.adi.common.helper;
import com.moyz.adi.common.entity.AiModel; import com.moyz.adi.common.entity.AiModel;
import com.moyz.adi.common.interfaces.AbstractLLMService; import com.moyz.adi.common.interfaces.AbstractLLMService;
import com.moyz.adi.common.util.JsonUtil;
import com.moyz.adi.common.util.LocalCache;
import com.moyz.adi.common.vo.CommonAiPlatformSetting;
import com.moyz.adi.common.vo.LLMModelInfo; import com.moyz.adi.common.vo.LLMModelInfo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
@ -36,8 +32,11 @@ public class LLMContext {
} }
public static void addLLMService(AbstractLLMService llmService) { public static void addLLMService(AbstractLLMService llmService) {
AiModel aiModel = llmService.getAiModel();
LLMModelInfo llmModelInfo = new LLMModelInfo(); LLMModelInfo llmModelInfo = new LLMModelInfo();
llmModelInfo.setModelName(llmService.getAiModel().getName()); llmModelInfo.setModelId(aiModel.getId());
llmModelInfo.setModelName(aiModel.getName());
llmModelInfo.setModelPlatform(aiModel.getPlatform());
llmModelInfo.setEnable(llmService.isEnabled()); llmModelInfo.setEnable(llmService.isEnabled());
llmModelInfo.setLlmService(llmService); llmModelInfo.setLlmService(llmService);
NAME_TO_MODEL.put(llmService.getAiModel().getName(), llmModelInfo); NAME_TO_MODEL.put(llmService.getAiModel().getName(), llmModelInfo);
@ -46,10 +45,4 @@ public class LLMContext {
public AbstractLLMService getLLMService() { public AbstractLLMService getLLMService() {
return llmService; return llmService;
} }
public static String[] getSupportModels(String settingName) {
String st = LocalCache.CONFIGS.get(settingName);
CommonAiPlatformSetting setting = JsonUtil.fromJson(st, CommonAiPlatformSetting.class);
return setting.getModels();
}
} }

View File

@ -4,6 +4,8 @@ import lombok.Data;
@Data @Data
public class ModelInfo { public class ModelInfo {
private Long modelId;
private String modelName; private String modelName;
private Boolean enable; private Boolean enable;
private String modelPlatform;
} }