diff --git a/build.gradle b/build.gradle
index 03ed587..57e443b 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ plugins {
project.group = 'me.lookforfps'
project.description = "OpenAI Java API"
-project.version = new Version("1", "0", "0")
+project.version = new Version("1", "0", "1")
java {
sourceCompatibility = JavaVersion.VERSION_1_8
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index b692886..fb17731 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,8 +1,8 @@
[versions]
-com-fasterxml-jackson-core-jackson-databind = "2.17.0"
-org-projectlombok-lombok = "1.18.32"
-org-slf4j-slf4j-api = "2.0.13"
+com-fasterxml-jackson-core-jackson-databind = "2.17.2"
+org-projectlombok-lombok = "1.18.34"
+org-slf4j-slf4j-api = "2.0.16"
[libraries]
com-fasterxml-jackson-core-jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "com-fasterxml-jackson-core-jackson-databind" }
diff --git a/src/main/java/me/lookforfps/oja/chatcompletion/ChatCompletionService.java b/src/main/java/me/lookforfps/oja/chatcompletion/ChatCompletionService.java
index fae88b2..972f303 100644
--- a/src/main/java/me/lookforfps/oja/chatcompletion/ChatCompletionService.java
+++ b/src/main/java/me/lookforfps/oja/chatcompletion/ChatCompletionService.java
@@ -153,9 +153,7 @@ private byte[] buildRequest() throws IOException {
requestDto.setMax_tokens(config.getMaxTokens());
requestDto.setN(config.getChoices());
requestDto.setPresence_penalty(config.getPresencePenalty());
- if(config.getResponseType() != null) {
- requestDto.setResponse_format(new ResponseFormat(config.getResponseType().getIdentifier()));
- }
+ requestDto.setResponse_format(config.getResponseFormat());
requestDto.setSeed(config.getSeed());
if(config.getServiceTier() != null) {
requestDto.setService_tier(config.getServiceTier().getIdentifier());
diff --git a/src/main/java/me/lookforfps/oja/chatcompletion/config/ChatCompletionConfiguration.java b/src/main/java/me/lookforfps/oja/chatcompletion/config/ChatCompletionConfiguration.java
index 13e54ae..1e4a870 100644
--- a/src/main/java/me/lookforfps/oja/chatcompletion/config/ChatCompletionConfiguration.java
+++ b/src/main/java/me/lookforfps/oja/chatcompletion/config/ChatCompletionConfiguration.java
@@ -2,6 +2,7 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
+import me.lookforfps.oja.chatcompletion.model.natives.request.ResponseFormat;
import me.lookforfps.oja.chatcompletion.model.natives.request.ResponseType;
import me.lookforfps.oja.chatcompletion.model.natives.request.ServiceTier;
import me.lookforfps.oja.chatcompletion.model.natives.tools.Tool;
@@ -111,7 +112,7 @@ public class ChatCompletionConfiguration extends Configuration {
*
* Setting to { "type": "json_object" }
enables JSON mode, which guarantees the message the model generates is valid JSON.
*/
- private ResponseType responseType;
+ private ResponseFormat responseFormat;
/**
* What sampling temperature to use, between 0 and 2.
* Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
@@ -163,4 +164,11 @@ public void removeTool(Tool tool) {
public void removeTool(int toolIndex) {
tools.remove(toolIndex);
}
+
+ public void setResponseFormat(ResponseType responsetype) {
+ this.responseFormat = new ResponseFormat(responsetype.getIdentifier());
+ }
+ public void setResponseFormat(String jsonSchema) {
+ this.responseFormat = new ResponseFormat("json_schema", jsonSchema);
+ }
}
diff --git a/src/main/java/me/lookforfps/oja/chatcompletion/model/natives/message/AssistantMessage.java b/src/main/java/me/lookforfps/oja/chatcompletion/model/natives/message/AssistantMessage.java
index 0bf6360..51ce3a5 100644
--- a/src/main/java/me/lookforfps/oja/chatcompletion/model/natives/message/AssistantMessage.java
+++ b/src/main/java/me/lookforfps/oja/chatcompletion/model/natives/message/AssistantMessage.java
@@ -14,15 +14,20 @@ public class AssistantMessage extends Message {
private String content;
private String name;
+ private String refusal;
private List tool_calls;
- public AssistantMessage(String content, String name, List tool_calls) {
+ public AssistantMessage(String content, String name, String refusal, List tool_calls) {
super(MessageRole.ASSISTANT);
this.content = content;
this.name = name;
+ this.refusal = refusal;
this.tool_calls = tool_calls;
}
+ public AssistantMessage(String content, String name, List tool_calls) {
+ this(content, name, null, tool_calls);
+ }
public AssistantMessage(String content, List tool_calls) {
this(content, null, tool_calls);
}
diff --git a/src/main/java/me/lookforfps/oja/chatcompletion/model/natives/request/ResponseFormat.java b/src/main/java/me/lookforfps/oja/chatcompletion/model/natives/request/ResponseFormat.java
index 2290783..6372fec 100644
--- a/src/main/java/me/lookforfps/oja/chatcompletion/model/natives/request/ResponseFormat.java
+++ b/src/main/java/me/lookforfps/oja/chatcompletion/model/natives/request/ResponseFormat.java
@@ -1,12 +1,19 @@
package me.lookforfps.oja.chatcompletion.model.natives.request;
-import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
-@AllArgsConstructor
@NoArgsConstructor
public class ResponseFormat {
private String type;
+ private String json_schema;
+
+ public ResponseFormat(String type, String jsonSchema) {
+ this.type = type;
+ this.json_schema = jsonSchema;
+ }
+ public ResponseFormat(String type) {
+ this(type, null);
+ }
}
diff --git a/src/main/java/me/lookforfps/oja/chatcompletion/model/streaming/choice/Delta.java b/src/main/java/me/lookforfps/oja/chatcompletion/model/streaming/choice/Delta.java
index 51c5f27..812d048 100644
--- a/src/main/java/me/lookforfps/oja/chatcompletion/model/streaming/choice/Delta.java
+++ b/src/main/java/me/lookforfps/oja/chatcompletion/model/streaming/choice/Delta.java
@@ -10,5 +10,6 @@ public class Delta {
private String role;
private String content;
+ private String refusal;
private List tool_calls;
}