chore: add response format param in completion (#42)

This commit is contained in:
tomsun28 2025-08-25 16:04:26 +08:00 committed by GitHub
parent 9993e205fa
commit 6430107d74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 60 additions and 3 deletions

View file

@ -7,9 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.*;
import lombok.experimental.SuperBuilder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
@ -75,6 +73,14 @@ public class ChatCompletionCreateParams extends CommonRequest implements ClientR
*/
private List<String> stop;
/**
* Specifies the response format of the model. Defaults to text. Supports two
* formats:"text" "json_object". When using JSON mode, its recommended to clearly
* request JSON output in the prompt.
*/
@JsonProperty("response_format")
private ResponseFormat responseFormat;
/**
* Sensitive word detection control
*/

View file

@ -0,0 +1,16 @@
package ai.z.openapi.service.model;
import com.fasterxml.jackson.annotation.JsonValue;
public enum ChatThinkingType {
ENABLED,
DISABLED,;
@JsonValue
public String value() {
return this.name().toLowerCase();
}
}

View file

@ -0,0 +1,18 @@
package ai.z.openapi.service.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
public class ResponseFormat {
@JsonProperty("type")
private String type;
}

View file

@ -0,0 +1,16 @@
package ai.z.openapi.service.model;
import com.fasterxml.jackson.annotation.JsonValue;
public enum ResponseFormatType {
TEXT,
JSON_OBJECT,;
@JsonValue
public String value() {
return this.name().toLowerCase();
}
}

View file

@ -33,7 +33,8 @@ public class ChatCompletionExample {
.build()
))
.stream(false)
.thinking(ChatThinking.builder().type("enabled").build())
.thinking(ChatThinking.builder().type(ChatThinkingType.ENABLED.value()).build())
.responseFormat(ResponseFormat.builder().type(ResponseFormatType.TEXT.value()).build())
.temperature(0.7f)
.maxTokens(1024)
.build();