chore: add response format param in completion (#42)
This commit is contained in:
parent
9993e205fa
commit
6430107d74
5 changed files with 60 additions and 3 deletions
|
|
@ -7,9 +7,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
|
|
@ -75,6 +73,14 @@ public class ChatCompletionCreateParams extends CommonRequest implements ClientR
|
||||||
*/
|
*/
|
||||||
private List<String> stop;
|
private List<String> stop;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the response format of the model. Defaults to text. Supports two
|
||||||
|
* formats:"text" "json_object". When using JSON mode, it’s recommended to clearly
|
||||||
|
* request JSON output in the prompt.
|
||||||
|
*/
|
||||||
|
@JsonProperty("response_format")
|
||||||
|
private ResponseFormat responseFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sensitive word detection control
|
* Sensitive word detection control
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -33,7 +33,8 @@ public class ChatCompletionExample {
|
||||||
.build()
|
.build()
|
||||||
))
|
))
|
||||||
.stream(false)
|
.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)
|
.temperature(0.7f)
|
||||||
.maxTokens(1024)
|
.maxTokens(1024)
|
||||||
.build();
|
.build();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue