【增加】ai image对接通义

This commit is contained in:
cherishsince 2024-07-10 21:34:42 +08:00
parent 28018b1f7f
commit d6b3b5e9bd
4 changed files with 6 additions and 4 deletions

View File

@ -137,9 +137,9 @@ public class AiImageServiceImpl implements AiImageService {
.withStylePreset(String.valueOf(draw.getOptions().get("stylePreset")))
.withClipGuidancePreset(String.valueOf(draw.getOptions().get("clipGuidancePreset")))
.build();
} else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.TONG_YI_WAN_XIANG.getPlatform())) {
} else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.TONG_YI.getPlatform())) {
return TongYiImagesOptions.builder()
.withModel(draw.getModel()).withN(Integer.valueOf(draw.getOptions().get("n")))
.withModel(draw.getModel()).withN(1)
.withHeight(draw.getHeight()).withWidth(draw.getWidth())
.build();
}

View File

@ -106,7 +106,7 @@ public class AiApiKeyServiceImpl implements AiApiKeyService {
@Override
public ImageModel getImageModel(AiPlatformEnum platform) {
AiApiKeyDO apiKey = apiKeyMapper.selectFirstByPlatformAndStatus(platform.getName(), CommonStatusEnum.ENABLE.getStatus());
AiApiKeyDO apiKey = apiKeyMapper.selectFirstByPlatformAndStatus(platform.getPlatform(), CommonStatusEnum.ENABLE.getStatus());
if (apiKey == null) {
throw exception(API_KEY_IMAGE_NODE_FOUND, platform.getName());
}

View File

@ -28,7 +28,6 @@ public enum AiPlatformEnum {
STABLE_DIFFUSION("StableDiffusion", "StableDiffusion"), // Stability AI
MIDJOURNEY("Midjourney", "Midjourney"), // Midjourney
SUNO("Suno", "Suno"), // Suno AI
TONG_YI_WAN_XIANG("TongYiWanXiang", "通义万相"), // Suno AI
;

View File

@ -17,6 +17,7 @@ import com.alibaba.cloud.ai.tongyi.TongYiAutoConfiguration;
import com.alibaba.cloud.ai.tongyi.TongYiConnectionProperties;
import com.alibaba.cloud.ai.tongyi.chat.TongYiChatModel;
import com.alibaba.cloud.ai.tongyi.chat.TongYiChatProperties;
import com.alibaba.cloud.ai.tongyi.image.TongYiImagesModel;
import com.alibaba.dashscope.aigc.generation.Generation;
import org.springframework.ai.autoconfigure.ollama.OllamaAutoConfiguration;
import org.springframework.ai.autoconfigure.openai.OpenAiAutoConfiguration;
@ -125,6 +126,8 @@ public class AiModelFactoryImpl implements AiModelFactory {
return buildOpenAiImageModel(apiKey, url);
case STABLE_DIFFUSION:
return buildStabilityAiImageModel(apiKey, url);
case TONG_YI:
return SpringUtil.getBean(TongYiImagesModel.class);
default:
throw new IllegalArgumentException(StrUtil.format("未知平台({})", platform));
}