mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
【代码优化】AI:ChatGlm 替换成 ZhiPuAiImage 实现
This commit is contained in:
@ -9,7 +9,6 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.iocoder.yudao.framework.ai.core.enums.AiPlatformEnum;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.chatglm.ChatGlmImageOptions;
|
||||
import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
@ -34,6 +33,7 @@ import org.springframework.ai.image.ImageResponse;
|
||||
import org.springframework.ai.openai.OpenAiImageOptions;
|
||||
import org.springframework.ai.qianfan.QianFanImageOptions;
|
||||
import org.springframework.ai.stabilityai.api.StabilityAiImageOptions;
|
||||
import org.springframework.ai.zhipuai.ZhiPuAiImageOptions;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -105,7 +105,9 @@ public class AiImageServiceImpl implements AiImageService {
|
||||
ImageResponse response = imageModel.call(new ImagePrompt(req.getPrompt(), request));
|
||||
|
||||
// 2. 上传到文件服务
|
||||
byte[] fileContent = Base64.decode(response.getResult().getOutput().getB64Json());
|
||||
String b64Json = response.getResult().getOutput().getB64Json();
|
||||
byte[] fileContent = StrUtil.isNotEmpty(b64Json) ? Base64.decode(b64Json)
|
||||
: HttpUtil.downloadBytes(response.getResult().getOutput().getUrl());
|
||||
String filePath = fileApi.createFile(fileContent);
|
||||
|
||||
// 3. 更新数据库
|
||||
@ -149,8 +151,8 @@ public class AiImageServiceImpl implements AiImageService {
|
||||
.withModel(draw.getModel()).withN(1)
|
||||
.withHeight(draw.getHeight()).withWidth(draw.getWidth())
|
||||
.build();
|
||||
} else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.CHATGLM.getPlatform())) {
|
||||
return ChatGlmImageOptions.builder()
|
||||
} else if (ObjUtil.equal(draw.getPlatform(), AiPlatformEnum.ZHI_PU.getPlatform())) {
|
||||
return ZhiPuAiImageOptions.builder()
|
||||
.withModel(draw.getModel())
|
||||
.build();
|
||||
}
|
||||
|
Reference in New Issue
Block a user