Skip to content

Commit

Permalink
Support response json format
Browse files Browse the repository at this point in the history
  • Loading branch information
Konboi committed Mar 7, 2024
1 parent 39febda commit e2e7d3b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ public class ChatCompletionRequest {
*/
List<ChatMessage> messages;

/**
* An object specifying the format that the model must output. Compatible with GPT-4 Turbo and all
* GPT-3.5 Turbo models newer than gpt-3.5-turbo-1106.
* https://platform.openai.com/docs/api-reference/chat/create#chat-create-response_format
*/
@JsonProperty("response_format")
ChatResponseFormat responseFormat;

/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output
* more random, while lower values like 0.2 will make it more focused and deterministic.<br> We
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.launchableinc.openai.completion.chat;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Builder;
import lombok.Data;

/*
* OpenAI API Document:https://platform.openai.com/docs/api-reference/chat/create#chat-create-response_format
*/
@Data
@Builder
public class ChatResponseFormat {

private ResponseFormat type;

public enum ResponseFormat {
TEXT("text"), JSON("json_object");

private final String value;

ResponseFormat(String value) {
this.value = value;
}

@JsonValue
public String getValue() {
return value;
}
}

}

0 comments on commit e2e7d3b

Please sign in to comment.