Skip to content

Commit 74181e9

Browse files
authored
Merge pull request #219 from 1076032829/response_format
聊天接口入参新增返回格式字段
2 parents 8ae11f6 + 2d165cb commit 74181e9

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/main/java/com/plexpt/chatgpt/entity/chat/ChatCompletion.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ public class ChatCompletion implements Serializable {
103103
*/
104104
private String user;
105105

106+
/**
107+
* 返回格式 当前只有gpt-3.5-turbo-1106和gpt-4-1106-preview 支持json_object格式返回
108+
*/
109+
@JsonProperty("response_format")
110+
private ResponseFormat responseFormat;
111+
106112

107113
@Getter
108114
@AllArgsConstructor
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.plexpt.chatgpt.entity.chat;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import lombok.*;
6+
import lombok.extern.slf4j.Slf4j;
7+
8+
/**
9+
* @author hq
10+
* @version 1.0
11+
* @date 2023/12/11
12+
*/
13+
14+
@Data
15+
@Builder
16+
@AllArgsConstructor
17+
@NoArgsConstructor(force = true)
18+
@JsonInclude(JsonInclude.Include.NON_NULL)
19+
@JsonIgnoreProperties(ignoreUnknown = true)
20+
public class ResponseFormat {
21+
22+
public String type = Type.TEXT.getValue();
23+
24+
@Getter
25+
@AllArgsConstructor
26+
public enum Type {
27+
JSON_OBJECT("json_object"),
28+
TEXT("text");
29+
private final String value;
30+
}
31+
}

0 commit comments

Comments
 (0)