我正在使用 Spring AI 1.0.0-M1 尝试将图像提交到 GPT-4o 进行描述。
以下是代码:
@Autowired
final ChatClient chatClient;
@Override
public String getDescription(MultipartFile file) throws IOException {
OpenAiChatOptions chatOptions = OpenAiChatOptions.builder()
.withModel(OpenAiApi.ChatModel.GPT_4_O.getValue())
.build();
Resource resource = new ByteArrayResource(file.getBytes());
var userMessage = new UserMessage(
"Explain what do you see in this picture?",
List.of(new Media(MimeTypeUtils.IMAGE_JPEG, resource)));
var response = chatClient.prompt().user(userMessage.getContent()).call().chatResponse();
return response.getResult().getOutput().getContent();
}
我不断收到此消息:
"I'm sorry, but I can't see pictures or images. If you describe the picture to me, I'll do my best to help you understand or analyze it!"
我做错了什么吗?