Skip to content

Commit

Permalink
Optimize code variables HamaWhiteGG#146
Browse files Browse the repository at this point in the history
  • Loading branch information
HamaWhiteGG committed Dec 7, 2023
1 parent b0b7463 commit 7636f02
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions openai-client/src/main/java/com/hw/openai/OpenAiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.hw.openai.entity.completions.CompletionResp;
import com.hw.openai.entity.embeddings.Embedding;
import com.hw.openai.entity.embeddings.EmbeddingResp;
import com.hw.openai.entity.image.CreateImageRequest;
import com.hw.openai.entity.image.CreateImageReq;
import com.hw.openai.entity.image.ImageResp;
import com.hw.openai.entity.models.Model;
import com.hw.openai.entity.models.ModelResp;
Expand Down Expand Up @@ -321,7 +321,7 @@ public EmbeddingResp createEmbedding(Embedding embedding) {
* @param request the create image request
* @return the image result response
*/
public ImageResp createImage(CreateImageRequest request) {
public ImageResp createImage(CreateImageReq request) {
return execute(service.createImage(request));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@Data
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CreateImageRequest {
public class CreateImageReq {

/**
* A text description of the desired image(s).
Expand Down Expand Up @@ -64,7 +64,7 @@ public class CreateImageRequest {
*/
@JsonProperty("response_format")
@Builder.Default
private ImageResponseFormat responseFormat = ImageResponseFormat.URL;
private ImageRespFormat responseFormat = ImageRespFormat.URL;

/**
* The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024 for dall-e-2.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
/**
* @author HamaWhite
*/
public enum ImageResponseFormat {
public enum ImageRespFormat {

URL("url"),

BASE64_JSON("b64_json");

private final String value;

ImageResponseFormat(String value) {
ImageRespFormat(String value) {
this.value = value;
}

Expand All @@ -42,8 +42,8 @@ public String getValue() {
}

@JsonCreator
public static ImageResponseFormat fromValue(String value) {
for (ImageResponseFormat item : ImageResponseFormat.values()) {
public static ImageRespFormat fromValue(String value) {
for (ImageRespFormat item : ImageRespFormat.values()) {
if (item.value.equalsIgnoreCase(value)) {
return item;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.hw.openai.entity.completions.CompletionResp;
import com.hw.openai.entity.embeddings.Embedding;
import com.hw.openai.entity.embeddings.EmbeddingResp;
import com.hw.openai.entity.image.CreateImageRequest;
import com.hw.openai.entity.image.CreateImageReq;
import com.hw.openai.entity.image.ImageResp;
import com.hw.openai.entity.models.Model;
import com.hw.openai.entity.models.ModelResp;
Expand Down Expand Up @@ -150,5 +150,5 @@ Single<EmbeddingResp> createEmbedding(@Path("deploymentId") String deploymentId,
* @return A Single emitting the response containing the generated image.
*/
@POST("images/generations")
Single<ImageResp> createImage(@Body CreateImageRequest request);
Single<ImageResp> createImage(@Body CreateImageReq request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package com.hw.openai.images;

import com.hw.openai.OpenAiClientTest;
import com.hw.openai.entity.image.CreateImageRequest;
import com.hw.openai.entity.image.CreateImageReq;
import com.hw.openai.entity.image.Image;

import org.junit.jupiter.api.Disabled;
Expand All @@ -42,7 +42,7 @@ public class ImageTest extends OpenAiClientTest {

@Test
void testCreateImage() {
CreateImageRequest request = CreateImageRequest.builder()
CreateImageReq request = CreateImageReq.builder()
.model("dall-e-3")
.prompt("A cute baby sea otter")
.n(1)
Expand Down

0 comments on commit 7636f02

Please sign in to comment.