Solon v3.2.0

image - 图片生成模型

</> markdown

图片生成模型(ImageModel) 与 聊天生成模型(ChatModel)接口差不多。更简单,只有提示与生成。暂时只提供生成功能,后续会增加修改支持。

1、构建图片生成模型

添加配置

solon.ai.image:
  demo:
    apiUrl: "https://ai.gitee.com/v1/images/generations" # 使用完整地址(而不是 api_base)
    model: "stable-diffusion-3.5-large-turbo"

构建并测试

@Configuration
public class DemoConfig {
    @Bean
    public ImageModel build(@Inject("${solon.ai.chat.image}") ImageConfig config) {
        return ImageModel.of(config).build();
    }

    @Bean
    public void test(ImageModel imageModel) throws IOException {
        //一次性返回
        ImageResponse resp = imageModel.prompt("一只白色的小花猫").call();

        //打印消息
        System.out.println(resp.getImage().getUrl());
    }
}

2、方言适配

图片生成模型(ImageModel)同样支持方言适配。