mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-27 11:46:05 +08:00 
			
		
		
		
	【代码评审】AI:硅基流动的图片生成
This commit is contained in:
		| @ -1,36 +0,0 @@ | |||||||
| package cn.iocoder.yudao.module.ai.controller.admin.creation; |  | ||||||
|  |  | ||||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; |  | ||||||
| import cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style.AiartReplaceBackgroundReqVO; |  | ||||||
| import cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style.AiartReplaceBackgroundResVO; |  | ||||||
| import cn.iocoder.yudao.module.ai.service.creation.AiartCreationService; |  | ||||||
| import io.swagger.v3.oas.annotations.Operation; |  | ||||||
| import io.swagger.v3.oas.annotations.tags.Tag; |  | ||||||
| import jakarta.annotation.Resource; |  | ||||||
| import jakarta.validation.Valid; |  | ||||||
| import org.springframework.validation.annotation.Validated; |  | ||||||
| import org.springframework.web.bind.annotation.PostMapping; |  | ||||||
| import org.springframework.web.bind.annotation.RequestBody; |  | ||||||
| import org.springframework.web.bind.annotation.RequestMapping; |  | ||||||
| import org.springframework.web.bind.annotation.RestController; |  | ||||||
|  |  | ||||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |  | ||||||
| import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |  | ||||||
|  |  | ||||||
| @Tag(name = "管理后台 - 艺术创作") |  | ||||||
| @RestController |  | ||||||
| @RequestMapping("/ai/artcreation") |  | ||||||
| @Validated |  | ||||||
| public class AiartCreationController { |  | ||||||
|  |  | ||||||
|     @Resource |  | ||||||
|     private AiartCreationService aiartCreationService; |  | ||||||
|  |  | ||||||
|     @Operation(summary = "商品图替换背景") |  | ||||||
|     @PostMapping("/replacebackground") |  | ||||||
|     public CommonResult<AiartReplaceBackgroundResVO> replaceBackground(@Valid @RequestBody AiartReplaceBackgroundReqVO replaceBackgroundReqVO) { |  | ||||||
|         return success(aiartCreationService.replaceBackground(getLoginUserId(), replaceBackgroundReqVO)); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |  | ||||||
| } |  | ||||||
| @ -1,40 +0,0 @@ | |||||||
| package cn.iocoder.yudao.module.ai.controller.admin.creation; |  | ||||||
|  |  | ||||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; |  | ||||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |  | ||||||
| import cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style.BackgroundTemplateReqVO; |  | ||||||
| import cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style.BackgroundTemplateResVO; |  | ||||||
| import cn.iocoder.yudao.module.ai.dal.dataobject.creation.AiartStyleBackgroundTemplateDO; |  | ||||||
| import cn.iocoder.yudao.module.ai.service.creation.AiartStyleService; |  | ||||||
| import io.swagger.v3.oas.annotations.Operation; |  | ||||||
| import io.swagger.v3.oas.annotations.tags.Tag; |  | ||||||
| import jakarta.annotation.Resource; |  | ||||||
| import jakarta.validation.Valid; |  | ||||||
| import org.springframework.security.access.prepost.PreAuthorize; |  | ||||||
| import org.springframework.validation.annotation.Validated; |  | ||||||
| import org.springframework.web.bind.annotation.PostMapping; |  | ||||||
| import org.springframework.web.bind.annotation.RequestBody; |  | ||||||
| import org.springframework.web.bind.annotation.RequestMapping; |  | ||||||
| import org.springframework.web.bind.annotation.RestController; |  | ||||||
|  |  | ||||||
| import java.util.List; |  | ||||||
|  |  | ||||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |  | ||||||
|  |  | ||||||
| @Tag(name = "管理后台 - 艺术创作模版") |  | ||||||
| @RestController |  | ||||||
| @RequestMapping("/ai/artstyle") |  | ||||||
| @Validated |  | ||||||
| public class AiartStyleController { |  | ||||||
|  |  | ||||||
|     @Resource |  | ||||||
|     private AiartStyleService aiartStyleService; |  | ||||||
|  |  | ||||||
|     @PostMapping("/backgroundtemplate-list") |  | ||||||
|     @Operation(summary = "获取商品背景模版列表") |  | ||||||
|     @PreAuthorize("@ss.hasPermission('ai:artstyle-background:query')") |  | ||||||
|     public CommonResult<List<BackgroundTemplateResVO>> queryBackgroundStyle(@Valid @RequestBody BackgroundTemplateReqVO backgroundTemplateReqVO) { |  | ||||||
|         List<AiartStyleBackgroundTemplateDO> res = aiartStyleService.queryBackgroundStyle(backgroundTemplateReqVO); |  | ||||||
|         return success(BeanUtils.toBean(res,BackgroundTemplateResVO.class)); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,17 +0,0 @@ | |||||||
| package cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style; |  | ||||||
|  |  | ||||||
| import io.swagger.v3.oas.annotations.media.Schema; |  | ||||||
| import jakarta.validation.constraints.NotEmpty; |  | ||||||
| import jakarta.validation.constraints.Size; |  | ||||||
| import lombok.Data; |  | ||||||
|  |  | ||||||
| @Schema(description = "管理后台 - 商品替换背景请求 VO") |  | ||||||
| @Data |  | ||||||
| public class AiartReplaceBackgroundReqVO { |  | ||||||
|  |  | ||||||
|     @Schema(description = "提示词", requiredMode = Schema.RequiredMode.REQUIRED, example = "画一个长城") |  | ||||||
|     @NotEmpty(message = "提示词不能为空") |  | ||||||
|     @Size(max = 1200, message = "提示词最大 1200") |  | ||||||
|     private String prompt; |  | ||||||
|  |  | ||||||
| } |  | ||||||
| @ -1,18 +0,0 @@ | |||||||
| package cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style; |  | ||||||
|  |  | ||||||
| import io.swagger.v3.oas.annotations.media.Schema; |  | ||||||
| import lombok.Data; |  | ||||||
|  |  | ||||||
| @Schema(description = "管理后台 - 商品替换背景结果 VO") |  | ||||||
| @Data |  | ||||||
| public class AiartReplaceBackgroundResVO { |  | ||||||
|  |  | ||||||
|     @Schema(description = "结果url", requiredMode = Schema.RequiredMode.REQUIRED, example = "根据参数不同不一样") |  | ||||||
|     private String resultImage; |  | ||||||
|  |  | ||||||
|     @Schema(description = "唯一请求 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "由服务端生成") |  | ||||||
|     private String requestId; |  | ||||||
|  |  | ||||||
|     @Schema(description = "MaskUrl", requiredMode = Schema.RequiredMode.REQUIRED, example = "如果 MaskUrl 未传,则返回使用内置商品分割算法得到的 Mask 结果") |  | ||||||
|     private String maskImage; |  | ||||||
| } |  | ||||||
| @ -1,16 +0,0 @@ | |||||||
| package cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style; |  | ||||||
|  |  | ||||||
| import io.swagger.v3.oas.annotations.media.Schema; |  | ||||||
| import lombok.Data; |  | ||||||
|  |  | ||||||
| @Schema(description = "管理后台 - AI API 密钥新增/修改 Request VO") |  | ||||||
| @Data |  | ||||||
| public class BackgroundTemplateReqVO { |  | ||||||
|  |  | ||||||
|     @Schema(description = "一级级次名称", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "通用") |  | ||||||
|     private String fistLevelName; |  | ||||||
|  |  | ||||||
|     @Schema(description = "二级级次名称", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "色彩背景") |  | ||||||
|     private String secondLevelName; |  | ||||||
|  |  | ||||||
| } |  | ||||||
| @ -1,28 +0,0 @@ | |||||||
| package cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style; |  | ||||||
|  |  | ||||||
| import io.swagger.v3.oas.annotations.media.Schema; |  | ||||||
| import lombok.Data; |  | ||||||
|  |  | ||||||
| @Schema(description = "管理后台 - 商品替换背景模版 VO") |  | ||||||
| @Data |  | ||||||
| public class BackgroundTemplateResVO { |  | ||||||
|  |  | ||||||
|     @Schema(description = "一级分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "汽车、通用") |  | ||||||
|     private String levelFirst; |  | ||||||
|  |  | ||||||
|     @Schema(description = "二级分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "色彩背景") |  | ||||||
|     private String levelSecond; |  | ||||||
|  |  | ||||||
|     @Schema(description = "背景模版名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "彩虹渐变") |  | ||||||
|     private String name; |  | ||||||
|  |  | ||||||
|     @Schema(description = "背景模版提示词", requiredMode = Schema.RequiredMode.REQUIRED, example = "背景为彩虹渐变墙面,亮暖色,清新简约风格,喷涂效果") |  | ||||||
|     private String prompt; |  | ||||||
|  |  | ||||||
|     @Schema(description = "背景模版商品示例", requiredMode = Schema.RequiredMode.REQUIRED, example = "小熊玩偶") |  | ||||||
|     private String demProduct; |  | ||||||
|  |  | ||||||
|     @Schema(description = "背景模版商品示例效果", requiredMode = Schema.RequiredMode.REQUIRED, example = "url") |  | ||||||
|     private String demUrl; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| @ -1,65 +0,0 @@ | |||||||
| package cn.iocoder.yudao.module.ai.dal.dataobject.creation; |  | ||||||
|  |  | ||||||
| import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |  | ||||||
| import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |  | ||||||
| import com.baomidou.mybatisplus.annotation.KeySequence; |  | ||||||
| import com.baomidou.mybatisplus.annotation.TableId; |  | ||||||
| import com.baomidou.mybatisplus.annotation.TableName; |  | ||||||
| import lombok.AllArgsConstructor; |  | ||||||
| import lombok.Builder; |  | ||||||
| import lombok.Data; |  | ||||||
| import lombok.NoArgsConstructor; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * AI art商品背景风格 DO |  | ||||||
|  * |  | ||||||
|  * @author 芋道源码 |  | ||||||
|  */ |  | ||||||
| @TableName("ai_backgroundtemplate") |  | ||||||
| @KeySequence("ai_chat_conversation_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 |  | ||||||
| @Data |  | ||||||
| @Builder |  | ||||||
| @NoArgsConstructor |  | ||||||
| @AllArgsConstructor |  | ||||||
| public class AiartStyleBackgroundTemplateDO extends BaseDO { |  | ||||||
|     /** |  | ||||||
|      * 编号 |  | ||||||
|      */ |  | ||||||
|     @TableId |  | ||||||
|     private Long id; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 名称 |  | ||||||
|      */ |  | ||||||
|     private String levelFirst; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 名称 |  | ||||||
|      */ |  | ||||||
|     private String levelSecond; |  | ||||||
|     /** |  | ||||||
|      * 模版名称 |  | ||||||
|      */ |  | ||||||
|     private String name; |  | ||||||
|     /** |  | ||||||
|      * 模版提示词 |  | ||||||
|      */ |  | ||||||
|     private String prompt; |  | ||||||
|     /** |  | ||||||
|      * 示例商品 |  | ||||||
|      */ |  | ||||||
|     private String demoProduct; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 示例效果 |  | ||||||
|      */ |  | ||||||
|     private String demoUrl; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 状态 |  | ||||||
|      * |  | ||||||
|      * 枚举 {@link CommonStatusEnum} |  | ||||||
|      */ |  | ||||||
|     private Integer status; |  | ||||||
|  |  | ||||||
| } |  | ||||||
| @ -1,33 +0,0 @@ | |||||||
| package cn.iocoder.yudao.module.ai.dal.mysql.creation; |  | ||||||
|  |  | ||||||
| import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |  | ||||||
| import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |  | ||||||
| import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |  | ||||||
| import cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style.BackgroundTemplateReqVO; |  | ||||||
| import cn.iocoder.yudao.module.ai.dal.dataobject.creation.AiartStyleBackgroundTemplateDO; |  | ||||||
| import org.apache.ibatis.annotations.Mapper; |  | ||||||
|  |  | ||||||
| import java.util.List; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * AI style分隔 Mapper |  | ||||||
|  * |  | ||||||
|  * @author 芋道源码 |  | ||||||
|  */ |  | ||||||
| @Mapper |  | ||||||
| public interface AiartStyleBackgroundTemplateMapper extends BaseMapperX<AiartStyleBackgroundTemplateDO> { |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 获取有效的商品后端模版 |  | ||||||
|      * @param reqVO 请求对象 |  | ||||||
|      * @return 结果 |  | ||||||
|      */ |  | ||||||
|     default List<AiartStyleBackgroundTemplateDO> selectList(BackgroundTemplateReqVO reqVO) { |  | ||||||
|         return selectList(new LambdaQueryWrapperX<AiartStyleBackgroundTemplateDO>() |  | ||||||
|                 .eqIfPresent(AiartStyleBackgroundTemplateDO::getLevelFirst,reqVO.getFistLevelName()) |  | ||||||
|                 .eqIfPresent(AiartStyleBackgroundTemplateDO::getLevelSecond,reqVO.getSecondLevelName()) |  | ||||||
|                 .eqIfPresent(AiartStyleBackgroundTemplateDO::getStatus, CommonStatusEnum.ENABLE.getStatus()) |  | ||||||
|                 .orderByDesc(AiartStyleBackgroundTemplateDO::getId)); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
| } |  | ||||||
| @ -1,21 +0,0 @@ | |||||||
| package cn.iocoder.yudao.module.ai.service.creation; |  | ||||||
|  |  | ||||||
| import cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style.AiartReplaceBackgroundReqVO; |  | ||||||
| import cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style.AiartReplaceBackgroundResVO; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * AI创作Service 接口 |  | ||||||
|  * |  | ||||||
|  * @author zzt |  | ||||||
|  */ |  | ||||||
| public interface AiartCreationService { |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 替换商品背景图片 |  | ||||||
|      * @param loginUserId 当前登录用户 |  | ||||||
|      * @param replaceBackgroundReqVO 请求对象 |  | ||||||
|      * @return 结果 |  | ||||||
|      */ |  | ||||||
|     AiartReplaceBackgroundResVO replaceBackground(Long loginUserId, AiartReplaceBackgroundReqVO replaceBackgroundReqVO); |  | ||||||
| } |  | ||||||
| @ -1,22 +0,0 @@ | |||||||
| package cn.iocoder.yudao.module.ai.service.creation; |  | ||||||
|  |  | ||||||
| import cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style.AiartReplaceBackgroundReqVO; |  | ||||||
| import cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style.AiartReplaceBackgroundResVO; |  | ||||||
| import org.springframework.stereotype.Service; |  | ||||||
| import org.springframework.validation.annotation.Validated; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * AI创作Service 实现类 |  | ||||||
|  * |  | ||||||
|  * @author zzt |  | ||||||
|  */ |  | ||||||
| @Service |  | ||||||
| @Validated |  | ||||||
| public class AiartCreationServiceImpl implements AiartCreationService { |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public AiartReplaceBackgroundResVO replaceBackground(Long loginUserId, AiartReplaceBackgroundReqVO replaceBackgroundReqVO) { |  | ||||||
|         return null; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,23 +0,0 @@ | |||||||
| package cn.iocoder.yudao.module.ai.service.creation; |  | ||||||
|  |  | ||||||
| import cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style.BackgroundTemplateReqVO; |  | ||||||
| import cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style.BackgroundTemplateResVO; |  | ||||||
| import cn.iocoder.yudao.module.ai.dal.dataobject.creation.AiartStyleBackgroundTemplateDO; |  | ||||||
|  |  | ||||||
| import java.util.List; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * AI风格Service 接口 |  | ||||||
|  * |  | ||||||
|  * @author zzt |  | ||||||
|  */ |  | ||||||
| public interface AiartStyleService { |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 查询商品背景模版列表 |  | ||||||
|      * @param backgroundTemplateReqVO 商品背景模版请求对象 |  | ||||||
|      * @return 结果 |  | ||||||
|      */ |  | ||||||
|     List<AiartStyleBackgroundTemplateDO> queryBackgroundStyle(BackgroundTemplateReqVO backgroundTemplateReqVO); |  | ||||||
| } |  | ||||||
| @ -1,27 +0,0 @@ | |||||||
| package cn.iocoder.yudao.module.ai.service.creation; |  | ||||||
|  |  | ||||||
| import cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style.BackgroundTemplateReqVO; |  | ||||||
| import cn.iocoder.yudao.module.ai.controller.admin.creation.vo.style.BackgroundTemplateResVO; |  | ||||||
| import cn.iocoder.yudao.module.ai.dal.dataobject.creation.AiartStyleBackgroundTemplateDO; |  | ||||||
| import cn.iocoder.yudao.module.ai.dal.mysql.creation.AiartStyleBackgroundTemplateMapper; |  | ||||||
| import cn.iocoder.yudao.module.ai.dal.mysql.model.AiApiKeyMapper; |  | ||||||
| import jakarta.annotation.Resource; |  | ||||||
|  |  | ||||||
| import java.util.List; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * AI风格Service 接口 |  | ||||||
|  * |  | ||||||
|  * @author zzt |  | ||||||
|  */ |  | ||||||
| public class AiartStyleServiceImpl implements AiartStyleService{ |  | ||||||
|  |  | ||||||
|     @Resource |  | ||||||
|     private AiartStyleBackgroundTemplateMapper backgroundTemplateMapper; |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public List<AiartStyleBackgroundTemplateDO> queryBackgroundStyle(BackgroundTemplateReqVO backgroundTemplateReqVO) { |  | ||||||
|         return backgroundTemplateMapper.selectList(backgroundTemplateReqVO); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -147,8 +147,8 @@ public class AiImageServiceImpl implements AiImageService { | |||||||
|                     .build(); |                     .build(); | ||||||
|         } else if (ObjUtil.equal(model.getPlatform(), AiPlatformEnum.SILICON_FLOW.getPlatform())) { |         } else if (ObjUtil.equal(model.getPlatform(), AiPlatformEnum.SILICON_FLOW.getPlatform())) { | ||||||
|             // https://docs.siliconflow.cn/cn/api-reference/images/images-generations |             // https://docs.siliconflow.cn/cn/api-reference/images/images-generations | ||||||
|             return SiliconflowImageOptions.builder().withModel(model.getModel()) |             return SiliconflowImageOptions.builder().model(model.getModel()) | ||||||
|                     .withHeight(draw.getHeight()).withWidth(draw.getWidth()) |                     .withHeight(draw.getHeight()).withHeight(draw.getWidth()) | ||||||
|                     .build(); |                     .build(); | ||||||
|         }  else if (ObjUtil.equal(model.getPlatform(), AiPlatformEnum.STABLE_DIFFUSION.getPlatform())) { |         }  else if (ObjUtil.equal(model.getPlatform(), AiPlatformEnum.STABLE_DIFFUSION.getPlatform())) { | ||||||
|             // https://platform.stability.ai/docs/api-reference#tag/SDXL-and-SD1.6/operation/textToImage |             // https://platform.stability.ai/docs/api-reference#tag/SDXL-and-SD1.6/operation/textToImage | ||||||
|  | |||||||
| @ -117,13 +117,6 @@ | |||||||
|             </exclusions> |             </exclusions> | ||||||
|         </dependency> |         </dependency> | ||||||
|  |  | ||||||
|         <!-- 腾讯大模型图像创作引擎--> |  | ||||||
|         <dependency> |  | ||||||
|             <groupId>com.tencentcloudapi</groupId> |  | ||||||
|             <artifactId>tencentcloud-sdk-java-aiart</artifactId> |  | ||||||
|             <version>3.1.1215</version> |  | ||||||
|         </dependency> |  | ||||||
|  |  | ||||||
|         <!-- Test 测试相关 --> |         <!-- Test 测试相关 --> | ||||||
|         <dependency> |         <dependency> | ||||||
|             <groupId>org.springframework.boot</groupId> |             <groupId>org.springframework.boot</groupId> | ||||||
|  | |||||||
| @ -9,7 +9,6 @@ import cn.iocoder.yudao.framework.ai.core.model.doubao.DouBaoChatModel; | |||||||
| import cn.iocoder.yudao.framework.ai.core.model.hunyuan.HunYuanChatModel; | import cn.iocoder.yudao.framework.ai.core.model.hunyuan.HunYuanChatModel; | ||||||
| import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi; | import cn.iocoder.yudao.framework.ai.core.model.midjourney.api.MidjourneyApi; | ||||||
| import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiiconflowApiConstants; | import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiiconflowApiConstants; | ||||||
| import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiiconflowmageApi; |  | ||||||
| import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconFlowChatModel; | import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconFlowChatModel; | ||||||
| import cn.iocoder.yudao.framework.ai.core.model.suno.api.SunoApi; | import cn.iocoder.yudao.framework.ai.core.model.suno.api.SunoApi; | ||||||
| import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatModel; | import cn.iocoder.yudao.framework.ai.core.model.xinghuo.XingHuoChatModel; | ||||||
|  | |||||||
| @ -50,8 +50,8 @@ public class AiUtils { | |||||||
|             case HUN_YUAN: // 复用 OpenAI 客户端 |             case HUN_YUAN: // 复用 OpenAI 客户端 | ||||||
|             case XING_HUO: // 复用 OpenAI 客户端 |             case XING_HUO: // 复用 OpenAI 客户端 | ||||||
|             case SILICON_FLOW: // 复用 OpenAI 客户端 |             case SILICON_FLOW: // 复用 OpenAI 客户端 | ||||||
|                 OpenAiChatOptions.Builder builder = OpenAiChatOptions.builder().model(model).temperature(temperature).maxTokens(maxTokens); |                 return OpenAiChatOptions.builder().model(model).temperature(temperature).maxTokens(maxTokens) | ||||||
|                 return toolNames == null ? builder.build() : builder.toolNames(toolNames).build(); |                         .toolNames(toolNames).build(); | ||||||
|             case AZURE_OPENAI: |             case AZURE_OPENAI: | ||||||
|                 // TODO 芋艿:貌似没 model 字段???! |                 // TODO 芋艿:貌似没 model 字段???! | ||||||
|                 return AzureOpenAiChatOptions.builder().deploymentName(model).temperature(temperature).maxTokens(maxTokens) |                 return AzureOpenAiChatOptions.builder().deploymentName(model).temperature(temperature).maxTokens(maxTokens) | ||||||
|  | |||||||
| @ -0,0 +1,35 @@ | |||||||
|  | package cn.iocoder.yudao.framework.ai.image; | ||||||
|  |  | ||||||
|  | import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiiconflowmageApi; | ||||||
|  | import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconflowImageModel; | ||||||
|  | import cn.iocoder.yudao.framework.ai.core.model.siliconflow.SiliconflowImageOptions; | ||||||
|  | import org.junit.jupiter.api.Disabled; | ||||||
|  | import org.junit.jupiter.api.Test; | ||||||
|  | import org.springframework.ai.image.ImagePrompt; | ||||||
|  | import org.springframework.ai.image.ImageResponse; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * {@link SiliconflowImageModel} 集成测试 | ||||||
|  |  */ | ||||||
|  | public class SiliconFlowImageModelTests { | ||||||
|  |  | ||||||
|  |     private final SiliconflowImageModel imageModel = new SiliconflowImageModel( | ||||||
|  |             new SiiconflowmageApi("sk-epsakfenqnyzoxhmbucsxlhkdqlcbnimslqoivkshalvdozz") // 密钥 | ||||||
|  |     ); | ||||||
|  |  | ||||||
|  |     @Test | ||||||
|  |     @Disabled | ||||||
|  |     public void testCall() { | ||||||
|  |         // 准备参数 | ||||||
|  |         SiliconflowImageOptions imageOptions = SiliconflowImageOptions.builder() | ||||||
|  |                 .model("Kwai-Kolors/Kolors") | ||||||
|  |                 .build(); | ||||||
|  |         ImagePrompt prompt = new ImagePrompt("万里长城", imageOptions); | ||||||
|  |  | ||||||
|  |         // 方法调用 | ||||||
|  |         ImageResponse response = imageModel.call(prompt); | ||||||
|  |         // 打印结果 | ||||||
|  |         System.out.println(response); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV