package com.jambotronGroup.jambotron.ZhiPuAi;


import org.springframework.ai.image.ImagePrompt;
import org.springframework.ai.image.ImageResponse;
import org.springframework.ai.zhipuai.ZhiPuAiImageModel;
import org.springframework.ai.zhipuai.api.ZhiPuAiImageApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
//import org.springframework.web.reactive.function.client.WebClient;
//
@Service
public class ZhiPuAiImageService {

    @Value("${spring.ai.zhipuai.base-url}")
    private String baseUrl;

    @Value("${spring.ai.zhipuai.api-key}")
    private String apiKey;


    private ZhiPuAiImageApi _zhiPuAiImageApi;

    private ZhiPuAiImageModel _zhiPuAiImageModel;

    public ZhiPuAiImageService() {

        _zhiPuAiImageApi = new ZhiPuAiImageApi("628447c8c65845a48a7226391464a2ea.Dw8ci6TiW0BRF5LI");

        _zhiPuAiImageModel = new ZhiPuAiImageModel(_zhiPuAiImageApi);
    }

    public ImageResponse generateImage(String prompt) {
        // Create an ImagePrompt object with the desired prompt
        ImagePrompt imagePrompt = new ImagePrompt(prompt);

        // Call the generate method to get the image response
        ImageResponse imageResponse = _zhiPuAiImageModel.call(imagePrompt);

        // Return the image response
        return imageResponse;
    }


}