Skip to content

Commit 4f40921

Browse files
committed
feat: response api
1 parent 1372c41 commit 4f40921

File tree

14 files changed

+49
-8
lines changed

14 files changed

+49
-8
lines changed

api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>top.bella</groupId>
88
<artifactId>openai-java</artifactId>
9-
<version>0.23.56</version>
9+
<version>0.23.57</version>
1010
</parent>
1111
<packaging>jar</packaging>
1212
<artifactId>openai-api</artifactId>

api/src/main/java/com/theokanning/openai/assistants/message/content/Annotation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
@Data
1515
@NoArgsConstructor
1616
@AllArgsConstructor
17+
@JsonInclude(JsonInclude.Include.NON_NULL)
1718
public class Annotation {
1819

1920
Integer index;

api/src/main/java/com/theokanning/openai/image/CreateImageRequest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,17 @@ public class CreateImageRequest {
6161
* doubao模型使用:是否生成水印
6262
*/
6363
Boolean watermark;
64+
65+
/**
66+
* The format in which the generated images are returned. This parameter is only supported for gpt-image-1. Must be one of png, jpeg, or webp.
67+
*/
68+
@JsonProperty("output_format")
69+
String outputFormat;
70+
71+
72+
/**
73+
* Allows to set transparency for the background of the generated image(s). This parameter is only supported for gpt-image-1. Must be one of transparent, opaque or auto (default value). When auto is used, the model will automatically determine the best background for the image.
74+
* If transparent, the output format needs to support transparency, so it should be set to either png (default value) or webp.
75+
*/
76+
String background;
6477
}

api/src/main/java/com/theokanning/openai/response/stream/BaseStreamEvent.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,12 @@ public abstract class BaseStreamEvent {
8282
private Integer sequenceNumber;
8383

8484
public abstract String getType();
85+
86+
public void setOutputIndex(Integer outputIndex) {
87+
88+
}
89+
90+
public void setItemId(String itemId) {
91+
92+
}
8593
}

api/src/main/java/com/theokanning/openai/response/stream/ImageGenerationPartialImageEvent.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ public class ImageGenerationPartialImageEvent extends BaseStreamEvent {
2929
@JsonProperty("output_index")
3030
private Integer outputIndex;
3131

32+
/**
33+
* url partial image data, suitable for rendering as an image.
34+
*/
35+
@JsonProperty("partial_image_url")
36+
private String partialImageUrl;
37+
3238
/**
3339
* Base64-encoded partial image data, suitable for rendering as an image.
3440
*/

api/src/main/java/com/theokanning/openai/response/tool/CodeInterpreterToolCall.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.annotation.JsonProperty;
44
import com.fasterxml.jackson.annotation.JsonSubTypes;
55
import com.fasterxml.jackson.annotation.JsonTypeInfo;
6+
import com.theokanning.openai.response.ItemStatus;
67
import lombok.AllArgsConstructor;
78
import lombok.Builder;
89
import lombok.Data;
@@ -50,7 +51,7 @@ public class CodeInterpreterToolCall extends ToolCall {
5051
/**
5152
* Execution status.
5253
*/
53-
private String status;
54+
private ItemStatus status;
5455

5556
@Override
5657
public String getType() {

api/src/main/java/com/theokanning/openai/response/tool/FileSearchToolCall.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.theokanning.openai.response.tool;
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.theokanning.openai.response.ItemStatus;
45
import lombok.AllArgsConstructor;
56
import lombok.Builder;
67
import lombok.Data;
@@ -38,7 +39,7 @@ public class FileSearchToolCall extends ToolCall {
3839
/**
3940
* Execution status.
4041
*/
41-
private String status;
42+
private ItemStatus status;
4243

4344
/**
4445
* Search results.

api/src/main/java/com/theokanning/openai/response/tool/ImageGenerationToolCall.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.theokanning.openai.response.tool;
22

33
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
45
import com.theokanning.openai.response.ItemStatus;
56
import lombok.AllArgsConstructor;
67
import lombok.Builder;
@@ -30,7 +31,7 @@ public class ImageGenerationToolCall extends ToolCall {
3031
private String id;
3132

3233
/**
33-
* The generated image encoded in base64.
34+
* The generated image encoded in base64 / url.
3435
*/
3536
private String result;
3637

@@ -39,6 +40,12 @@ public class ImageGenerationToolCall extends ToolCall {
3940
*/
4041
private ItemStatus status;
4142

43+
/**
44+
* base64 / url
45+
*/
46+
@JsonProperty("data_type")
47+
private String dataType;
48+
4249
@Override
4350
public String getType() {
4451
return type;

api/src/main/java/com/theokanning/openai/response/tool/ToolCall.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@
3131
@JsonInclude(JsonInclude.Include.NON_NULL)
3232
public abstract class ToolCall implements ResponseItem {
3333
public abstract String getId();
34+
public abstract void setId(String id);
3435
}

api/src/main/java/com/theokanning/openai/response/tool/WebSearchToolCall.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.annotation.JsonSubTypes;
44
import com.fasterxml.jackson.annotation.JsonTypeInfo;
5+
import com.theokanning.openai.response.ItemStatus;
56
import lombok.AllArgsConstructor;
67
import lombok.Builder;
78
import lombok.Data;
@@ -33,7 +34,7 @@ public class WebSearchToolCall extends ToolCall {
3334
/**
3435
* Execution status.
3536
*/
36-
private String status;
37+
private ItemStatus status;
3738

3839
/**
3940
* Specific action performed.

0 commit comments

Comments
 (0)