Commit 330696fb902725adabdf167b437c58234777efc9

Authored by cherishsince
1 parent 7467c241

【增加】autoconfig自动配置 增加 style 适配。

yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/config/YudaoAiAutoConfiguration.java
@@ -100,6 +100,7 @@ public class YudaoAiAutoConfiguration { @@ -100,6 +100,7 @@ public class YudaoAiAutoConfiguration {
100 new OpenAiImageOptions() 100 new OpenAiImageOptions()
101 .setModel(openAiImageProperties.getModel()) 101 .setModel(openAiImageProperties.getModel())
102 .setResponseFormat(OpenAiImageOptions.ResponseFormatEnum.URL.getValue()) 102 .setResponseFormat(OpenAiImageOptions.ResponseFormatEnum.URL.getValue())
  103 + .setStyle(openAiImageProperties.getStyle())
103 ); 104 );
104 } 105 }
105 } 106 }
106 \ No newline at end of file 107 \ No newline at end of file
yudao-module-ai/yudao-spring-boot-starter-ai/src/main/java/cn/iocoder/yudao/framework/ai/imageopenai/OpenAiImageStyleEnum.java 0 → 100644
  1 +package cn.iocoder.yudao.framework.ai.imageopenai;
  2 +
  3 +import lombok.AllArgsConstructor;
  4 +import lombok.Getter;
  5 +
  6 +/**
  7 + * open ai image style
  8 + *
  9 + * @author fansili
  10 + * @time 2024/4/28 16:15
  11 + * @since 1.0
  12 + */
  13 +@AllArgsConstructor
  14 +@Getter
  15 +public enum OpenAiImageStyleEnum {
  16 +
  17 + // 图像生成的风格。可为vivid(生动)或 natural(自然)。vivid会使模型偏向生成超现实和戏剧性的图像,而natural则会让模型产出更自然、不那么超现实的图像。该参数仅对dall-e-3模型有效。
  18 +
  19 + VIVID("vivid", "生动"),
  20 + NATURAL("natural", "自然"),
  21 +
  22 + ;
  23 +
  24 + private String style;
  25 +
  26 + private String name;
  27 +
  28 + public static OpenAiImageStyleEnum valueOfStyle(String style) {
  29 + for (OpenAiImageStyleEnum itemEnum : OpenAiImageStyleEnum.values()) {
  30 + if (itemEnum.getStyle().equals(style)) {
  31 + return itemEnum;
  32 + }
  33 + }
  34 + throw new IllegalArgumentException("Invalid MessageType value: " + style);
  35 + }
  36 +}