package ai;
import cn.iocoder.byzs.module.web.controller.admin.ai.WebAiController;
import com.volcengine.ark.runtime.model.responses.content.InputContentItemImage;
import com.volcengine.ark.runtime.model.responses.content.InputContentItemText;
import com.volcengine.ark.runtime.model.responses.item.ItemEasyMessage;
import com.volcengine.ark.runtime.service.ArkService;
import com.volcengine.ark.runtime.model.responses.request.*;
import com.volcengine.ark.runtime.model.responses.response.ResponseObject;
import com.volcengine.ark.runtime.model.responses.constant.ResponsesConstants;
import com.volcengine.ark.runtime.model.responses.item.MessageContent;

//【单次调用】
public class demo {
    public static void main(String[] args) {
        String apiKey = "4bb6060f-b4a1-4e0a-bf7b-71dcaa6311cb";
        // 创建ArkService实例
        ArkService arkService = ArkService.builder().apiKey(apiKey).baseUrl("https://ark.cn-beijing.volces.com/api/v3").build();

        CreateResponsesRequest request = CreateResponsesRequest.builder()
                .model("doubao-seed-1-8-251228")
                .input(ResponsesInput.builder().addListItem(
                        ItemEasyMessage.builder().role(ResponsesConstants.MESSAGE_ROLE_USER).content(
                                MessageContent.builder()
                                        .addListItem(InputContentItemImage.builder().imageUrl("https://learn-ai.com.cn/admin-api/infra/file/29/get/20251217/网页地图level1-32_1765957974334.png").build())
                                        .addListItem(InputContentItemText.builder().text("这是什么植物").build())
                                        .build()
                        ).build()
                ).build())
                .build();
        ResponseObject resp = arkService.createResponse(request);
        String text = WebAiController.extractTextFromResponse(resp);

        System.out.println("===== 提取到的文本 =====\n" + text);



        arkService.shutdownExecutor();
    }
}