openai-java icon indicating copy to clipboard operation
openai-java copied to clipboard

Add support for gpt-4-vision

Open JanCong opened this issue 1 year ago • 7 comments

support the content in chat completion with format https://platform.openai.com/docs/guides/vision

JanCong avatar Nov 19 '23 06:11 JanCong

I would love it if this or #423 could be added

Jegorex avatar Nov 26 '23 23:11 Jegorex

Excuse me , Do these code in class ChatCompletionResult not need to be modified?

    @JsonProperty("finish_reason")
    String finishReason;

because I found that these changed to 'finish_details' in GPT-4V's return value, like:

"finish_details":{
    "type":"stop",
    "stop":"<|fim_suffix|>"
}

yangleimiao avatar Nov 30 '23 08:11 yangleimiao

Excuse me , Do these code in class ChatCompletionResult not need to be modified?

    @JsonProperty("finish_reason")
    String finishReason;

because I found that these changed to 'finish_details' in GPT-4V's return value, like:

"finish_details":{
    "type":"stop",
    "stop":"<|fim_suffix|>"
}

Yes, I've noticed too, and I've already made the changes. Thank you very much for your suggestion.

JanCong avatar Dec 03 '23 13:12 JanCong

I really don't like the parameterized ChatMessage, it completely breaks my entire code.

It'll be better with something like

@JsonInclude() // content should always exist in the call, even if it is null
Object content;
public ChatMessage(String role, List<ChatMessageContent> content) {
	this.role = role;
	this.content = content;
}

public ChatMessage(String role, List<ChatMessageContent> content, String name) {
	this.role = role;
	this.content = content;
	this.name = name;
}

public ChatMessage(String role, String content) {
	this.role = role;
	this.content = content;
}

public ChatMessage(String role, String content, String name) {
	this.role = role;
	this.content = content;
	this.name = name;
}

@JsonIgnore
public String getStringContent() {
	return content instanceof String ? (String) content : null;
}

This atleast keeps the code compatible

Ran-Mewo avatar Jan 01 '24 17:01 Ran-Mewo

when can we have this feature merged ?

ittech17 avatar Feb 06 '24 05:02 ittech17

I wonder if we could speed up the merger

caopengan avatar Feb 21 '24 01:02 caopengan

@JanCong, is this ever going to be merged?

fedorBir avatar Feb 23 '24 19:02 fedorBir