diff --git a/README.md b/README.md index f4d6866..2e155a5 100644 --- a/README.md +++ b/README.md @@ -87,10 +87,10 @@ import java.util.List; ChatCompletionCreateParams params = ChatCompletionCreateParams.builder() .message(List.of(ChatCompletionMessageParam.ofChatCompletionUserMessageParam(ChatCompletionUserMessageParam.builder() + .role(ChatCompletionUserMessageParam.Role.USER) .content(ChatCompletionUserMessageParam.Content.ofTextContent("Say this is a test")) - .role(ChatCompletionUserMessageParam.Role.user) .build()))) - .model("gpt-4o") + .model(ChatModel.O1_PREVIEW) .build(); ChatCompletion chatCompletion = client.chat().completions().create(params); ``` diff --git a/openai-java-core/src/test/kotlin/com/openai/models/BatchCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/BatchCreateParamsTest.kt index fd23d07..bbb8141 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/BatchCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/BatchCreateParamsTest.kt @@ -2,6 +2,7 @@ package com.openai.models +import com.openai.core.JsonValue import com.openai.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -14,7 +15,11 @@ class BatchCreateParamsTest { .completionWindow(BatchCreateParams.CompletionWindow._24H) .endpoint(BatchCreateParams.Endpoint.V1_CHAT_COMPLETIONS) .inputFileId("input_file_id") - .metadata(BatchCreateParams.Metadata.builder().build()) + .metadata( + BatchCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() } @@ -25,14 +30,23 @@ class BatchCreateParamsTest { .completionWindow(BatchCreateParams.CompletionWindow._24H) .endpoint(BatchCreateParams.Endpoint.V1_CHAT_COMPLETIONS) .inputFileId("input_file_id") - .metadata(BatchCreateParams.Metadata.builder().build()) + .metadata( + BatchCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() val body = params.getBody() assertThat(body).isNotNull assertThat(body.completionWindow()).isEqualTo(BatchCreateParams.CompletionWindow._24H) assertThat(body.endpoint()).isEqualTo(BatchCreateParams.Endpoint.V1_CHAT_COMPLETIONS) assertThat(body.inputFileId()).isEqualTo("input_file_id") - assertThat(body.metadata()).isEqualTo(BatchCreateParams.Metadata.builder().build()) + assertThat(body.metadata()) + .isEqualTo( + BatchCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) } @Test diff --git a/openai-java-core/src/test/kotlin/com/openai/models/BatchTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/BatchTest.kt index 163e6ad..7d9226b 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/BatchTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/BatchTest.kt @@ -2,7 +2,7 @@ package com.openai.models -import com.openai.core.JsonNull +import com.openai.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -43,7 +43,7 @@ class BatchTest { .failedAt(0L) .finalizingAt(0L) .inProgressAt(0L) - .metadata(JsonNull.of()) + .metadata(JsonValue.from(mapOf())) .outputFileId("output_file_id") .requestCounts( BatchRequestCounts.builder().completed(0L).failed(0L).total(0L).build() @@ -82,7 +82,7 @@ class BatchTest { assertThat(batch.failedAt()).contains(0L) assertThat(batch.finalizingAt()).contains(0L) assertThat(batch.inProgressAt()).contains(0L) - assertThat(batch._metadata()).isEqualTo(JsonNull.of()) + assertThat(batch._metadata()).isEqualTo(JsonValue.from(mapOf())) assertThat(batch.outputFileId()).contains("output_file_id") assertThat(batch.requestCounts()) .contains(BatchRequestCounts.builder().completed(0L).failed(0L).total(0L).build()) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionCreateParamsTest.kt index 500c69f..ffc1f05 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionCreateParamsTest.kt @@ -2,6 +2,7 @@ package com.openai.models +import com.openai.core.JsonValue import com.openai.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -42,15 +43,27 @@ class ChatCompletionCreateParamsTest { ChatCompletionCreateParams.Function.builder() .name("name") .description("description") - .parameters(FunctionParameters.builder().build()) + .parameters( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) ) - .logitBias(ChatCompletionCreateParams.LogitBias.builder().build()) + .logitBias( + ChatCompletionCreateParams.LogitBias.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .logprobs(true) .maxCompletionTokens(0L) .maxTokens(0L) - .metadata(ChatCompletionCreateParams.Metadata.builder().build()) + .metadata( + ChatCompletionCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .modalities(listOf(ChatCompletionModality.TEXT)) .n(1L) .parallelToolCalls(true) @@ -84,7 +97,11 @@ class ChatCompletionCreateParamsTest { FunctionDefinition.builder() .name("name") .description("description") - .parameters(FunctionParameters.builder().build()) + .parameters( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .strict(true) .build() ) @@ -133,15 +150,27 @@ class ChatCompletionCreateParamsTest { ChatCompletionCreateParams.Function.builder() .name("name") .description("description") - .parameters(FunctionParameters.builder().build()) + .parameters( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) ) - .logitBias(ChatCompletionCreateParams.LogitBias.builder().build()) + .logitBias( + ChatCompletionCreateParams.LogitBias.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .logprobs(true) .maxCompletionTokens(0L) .maxTokens(0L) - .metadata(ChatCompletionCreateParams.Metadata.builder().build()) + .metadata( + ChatCompletionCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .modalities(listOf(ChatCompletionModality.TEXT)) .n(1L) .parallelToolCalls(true) @@ -175,7 +204,11 @@ class ChatCompletionCreateParamsTest { FunctionDefinition.builder() .name("name") .description("description") - .parameters(FunctionParameters.builder().build()) + .parameters( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .strict(true) .build() ) @@ -224,16 +257,29 @@ class ChatCompletionCreateParamsTest { ChatCompletionCreateParams.Function.builder() .name("name") .description("description") - .parameters(FunctionParameters.builder().build()) + .parameters( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) ) assertThat(body.logitBias()) - .isEqualTo(ChatCompletionCreateParams.LogitBias.builder().build()) + .isEqualTo( + ChatCompletionCreateParams.LogitBias.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) assertThat(body.logprobs()).isEqualTo(true) assertThat(body.maxCompletionTokens()).isEqualTo(0L) assertThat(body.maxTokens()).isEqualTo(0L) - assertThat(body.metadata()).isEqualTo(ChatCompletionCreateParams.Metadata.builder().build()) + assertThat(body.metadata()) + .isEqualTo( + ChatCompletionCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) assertThat(body.modalities()).isEqualTo(listOf(ChatCompletionModality.TEXT)) assertThat(body.n()).isEqualTo(1L) assertThat(body.parallelToolCalls()).isEqualTo(true) @@ -272,7 +318,11 @@ class ChatCompletionCreateParamsTest { FunctionDefinition.builder() .name("name") .description("description") - .parameters(FunctionParameters.builder().build()) + .parameters( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .strict(true) .build() ) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionToolTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionToolTest.kt index adf7d0d..613c31e 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionToolTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/ChatCompletionToolTest.kt @@ -2,6 +2,7 @@ package com.openai.models +import com.openai.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,7 +16,11 @@ class ChatCompletionToolTest { FunctionDefinition.builder() .name("name") .description("description") - .parameters(FunctionParameters.builder().build()) + .parameters( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .strict(true) .build() ) @@ -27,7 +32,11 @@ class ChatCompletionToolTest { FunctionDefinition.builder() .name("name") .description("description") - .parameters(FunctionParameters.builder().build()) + .parameters( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .strict(true) .build() ) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/CompletionChoiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/CompletionChoiceTest.kt index a1de204..4f6f5d2 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/CompletionChoiceTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/CompletionChoiceTest.kt @@ -2,6 +2,7 @@ package com.openai.models +import com.openai.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -18,7 +19,13 @@ class CompletionChoiceTest { .textOffset(listOf(0L)) .tokenLogprobs(listOf(0.0)) .tokens(listOf("string")) - .topLogprobs(listOf(CompletionChoice.Logprobs.TopLogprob.builder().build())) + .topLogprobs( + listOf( + CompletionChoice.Logprobs.TopLogprob.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + ) .build() ) .text("text") @@ -32,7 +39,13 @@ class CompletionChoiceTest { .textOffset(listOf(0L)) .tokenLogprobs(listOf(0.0)) .tokens(listOf("string")) - .topLogprobs(listOf(CompletionChoice.Logprobs.TopLogprob.builder().build())) + .topLogprobs( + listOf( + CompletionChoice.Logprobs.TopLogprob.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + ) .build() ) assertThat(completionChoice.text()).isEqualTo("text") diff --git a/openai-java-core/src/test/kotlin/com/openai/models/CompletionCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/CompletionCreateParamsTest.kt index 21ff1f1..a1419ce 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/CompletionCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/CompletionCreateParamsTest.kt @@ -2,6 +2,7 @@ package com.openai.models +import com.openai.core.JsonValue import com.openai.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -16,7 +17,11 @@ class CompletionCreateParamsTest { .bestOf(0L) .echo(true) .frequencyPenalty(-2.0) - .logitBias(CompletionCreateParams.LogitBias.builder().build()) + .logitBias( + CompletionCreateParams.LogitBias.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .logprobs(0L) .maxTokens(16L) .n(1L) @@ -40,7 +45,11 @@ class CompletionCreateParamsTest { .bestOf(0L) .echo(true) .frequencyPenalty(-2.0) - .logitBias(CompletionCreateParams.LogitBias.builder().build()) + .logitBias( + CompletionCreateParams.LogitBias.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .logprobs(0L) .maxTokens(16L) .n(1L) @@ -61,7 +70,12 @@ class CompletionCreateParamsTest { assertThat(body.bestOf()).isEqualTo(0L) assertThat(body.echo()).isEqualTo(true) assertThat(body.frequencyPenalty()).isEqualTo(-2.0) - assertThat(body.logitBias()).isEqualTo(CompletionCreateParams.LogitBias.builder().build()) + assertThat(body.logitBias()) + .isEqualTo( + CompletionCreateParams.LogitBias.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) assertThat(body.logprobs()).isEqualTo(0L) assertThat(body.maxTokens()).isEqualTo(16L) assertThat(body.n()).isEqualTo(1L) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/CompletionTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/CompletionTest.kt index b2c7916..8c9d34c 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/CompletionTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/CompletionTest.kt @@ -2,6 +2,7 @@ package com.openai.models +import com.openai.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -24,7 +25,9 @@ class CompletionTest { .tokens(listOf("string")) .topLogprobs( listOf( - CompletionChoice.Logprobs.TopLogprob.builder().build() + CompletionChoice.Logprobs.TopLogprob.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() ) ) .build() @@ -72,7 +75,11 @@ class CompletionTest { .tokenLogprobs(listOf(0.0)) .tokens(listOf("string")) .topLogprobs( - listOf(CompletionChoice.Logprobs.TopLogprob.builder().build()) + listOf( + CompletionChoice.Logprobs.TopLogprob.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) ) .build() ) diff --git a/openai-java-core/src/test/kotlin/com/openai/models/EmbeddingCreateParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/EmbeddingCreateParamsTest.kt index 910bb2c..b2b8eb8 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/EmbeddingCreateParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/EmbeddingCreateParamsTest.kt @@ -11,7 +11,9 @@ class EmbeddingCreateParamsTest { @Test fun createEmbeddingCreateParams() { EmbeddingCreateParams.builder() - .input(EmbeddingCreateParams.Input.ofString("This is a test.")) + .input( + EmbeddingCreateParams.Input.ofString("The quick brown fox jumped over the lazy dog") + ) .model(EmbeddingModel.TEXT_EMBEDDING_ADA_002) .dimensions(1L) .encodingFormat(EmbeddingCreateParams.EncodingFormat.FLOAT) @@ -23,7 +25,11 @@ class EmbeddingCreateParamsTest { fun getBody() { val params = EmbeddingCreateParams.builder() - .input(EmbeddingCreateParams.Input.ofString("This is a test.")) + .input( + EmbeddingCreateParams.Input.ofString( + "The quick brown fox jumped over the lazy dog" + ) + ) .model(EmbeddingModel.TEXT_EMBEDDING_ADA_002) .dimensions(1L) .encodingFormat(EmbeddingCreateParams.EncodingFormat.FLOAT) @@ -31,7 +37,10 @@ class EmbeddingCreateParamsTest { .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.input()).isEqualTo(EmbeddingCreateParams.Input.ofString("This is a test.")) + assertThat(body.input()) + .isEqualTo( + EmbeddingCreateParams.Input.ofString("The quick brown fox jumped over the lazy dog") + ) assertThat(body.model()).isEqualTo(EmbeddingModel.TEXT_EMBEDDING_ADA_002) assertThat(body.dimensions()).isEqualTo(1L) assertThat(body.encodingFormat()).isEqualTo(EmbeddingCreateParams.EncodingFormat.FLOAT) @@ -42,12 +51,19 @@ class EmbeddingCreateParamsTest { fun getBodyWithoutOptionalFields() { val params = EmbeddingCreateParams.builder() - .input(EmbeddingCreateParams.Input.ofString("This is a test.")) + .input( + EmbeddingCreateParams.Input.ofString( + "The quick brown fox jumped over the lazy dog" + ) + ) .model(EmbeddingModel.TEXT_EMBEDDING_ADA_002) .build() val body = params.getBody() assertThat(body).isNotNull - assertThat(body.input()).isEqualTo(EmbeddingCreateParams.Input.ofString("This is a test.")) + assertThat(body.input()) + .isEqualTo( + EmbeddingCreateParams.Input.ofString("The quick brown fox jumped over the lazy dog") + ) assertThat(body.model()).isEqualTo(EmbeddingModel.TEXT_EMBEDDING_ADA_002) } } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/FunctionDefinitionTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/FunctionDefinitionTest.kt index e30c8d6..205099d 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/FunctionDefinitionTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/FunctionDefinitionTest.kt @@ -2,6 +2,7 @@ package com.openai.models +import com.openai.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -13,13 +14,22 @@ class FunctionDefinitionTest { FunctionDefinition.builder() .name("name") .description("description") - .parameters(FunctionParameters.builder().build()) + .parameters( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .strict(true) .build() assertThat(functionDefinition).isNotNull assertThat(functionDefinition.name()).isEqualTo("name") assertThat(functionDefinition.description()).contains("description") - assertThat(functionDefinition.parameters()).contains(FunctionParameters.builder().build()) + assertThat(functionDefinition.parameters()) + .contains( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) assertThat(functionDefinition.strict()).contains(true) } } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/FunctionParametersTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/FunctionParametersTest.kt index 01460e3..9a78f71 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/FunctionParametersTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/FunctionParametersTest.kt @@ -2,6 +2,7 @@ package com.openai.models +import com.openai.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -9,7 +10,8 @@ class FunctionParametersTest { @Test fun createFunctionParameters() { - val functionParameters = FunctionParameters.builder().build() + val functionParameters = + FunctionParameters.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() assertThat(functionParameters).isNotNull } } diff --git a/openai-java-core/src/test/kotlin/com/openai/models/ResponseFormatJsonSchemaTest.kt b/openai-java-core/src/test/kotlin/com/openai/models/ResponseFormatJsonSchemaTest.kt index 0641427..df5aae8 100644 --- a/openai-java-core/src/test/kotlin/com/openai/models/ResponseFormatJsonSchemaTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/models/ResponseFormatJsonSchemaTest.kt @@ -2,6 +2,7 @@ package com.openai.models +import com.openai.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,7 +16,11 @@ class ResponseFormatJsonSchemaTest { ResponseFormatJsonSchema.JsonSchema.builder() .name("name") .description("description") - .schema(ResponseFormatJsonSchema.JsonSchema.Schema.builder().build()) + .schema( + ResponseFormatJsonSchema.JsonSchema.Schema.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .strict(true) .build() ) @@ -27,7 +32,11 @@ class ResponseFormatJsonSchemaTest { ResponseFormatJsonSchema.JsonSchema.builder() .name("name") .description("description") - .schema(ResponseFormatJsonSchema.JsonSchema.Schema.builder().build()) + .schema( + ResponseFormatJsonSchema.JsonSchema.Schema.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .strict(true) .build() ) diff --git a/openai-java-core/src/test/kotlin/com/openai/services/ServiceParamsTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/ServiceParamsTest.kt index b93e15d..ab5fd0d 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/ServiceParamsTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/ServiceParamsTest.kt @@ -89,15 +89,27 @@ class ServiceParamsTest { ChatCompletionCreateParams.Function.builder() .name("name") .description("description") - .parameters(FunctionParameters.builder().build()) + .parameters( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) ) - .logitBias(ChatCompletionCreateParams.LogitBias.builder().build()) + .logitBias( + ChatCompletionCreateParams.LogitBias.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .logprobs(true) .maxCompletionTokens(0L) .maxTokens(0L) - .metadata(ChatCompletionCreateParams.Metadata.builder().build()) + .metadata( + ChatCompletionCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .modalities(listOf(ChatCompletionModality.TEXT)) .n(1L) .parallelToolCalls(true) @@ -131,7 +143,11 @@ class ServiceParamsTest { FunctionDefinition.builder() .name("name") .description("description") - .parameters(FunctionParameters.builder().build()) + .parameters( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .strict(true) .build() ) diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/BatchServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/BatchServiceTest.kt index 7d54a03..4c74fd2 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/blocking/BatchServiceTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/BatchServiceTest.kt @@ -4,6 +4,7 @@ package com.openai.services.blocking import com.openai.TestServerExtension import com.openai.client.okhttp.OpenAIOkHttpClient +import com.openai.core.JsonValue import com.openai.models.* import com.openai.models.BatchListParams import org.junit.jupiter.api.Test @@ -26,7 +27,11 @@ class BatchServiceTest { .completionWindow(BatchCreateParams.CompletionWindow._24H) .endpoint(BatchCreateParams.Endpoint.V1_CHAT_COMPLETIONS) .inputFileId("input_file_id") - .metadata(BatchCreateParams.Metadata.builder().build()) + .metadata( + BatchCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .build() ) println(batch) diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/CompletionServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/CompletionServiceTest.kt index 1983d85..ed85d00 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/blocking/CompletionServiceTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/CompletionServiceTest.kt @@ -4,6 +4,7 @@ package com.openai.services.blocking import com.openai.TestServerExtension import com.openai.client.okhttp.OpenAIOkHttpClient +import com.openai.core.JsonValue import com.openai.models.* import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -27,7 +28,11 @@ class CompletionServiceTest { .bestOf(0L) .echo(true) .frequencyPenalty(-2.0) - .logitBias(CompletionCreateParams.LogitBias.builder().build()) + .logitBias( + CompletionCreateParams.LogitBias.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .logprobs(0L) .maxTokens(16L) .n(1L) @@ -62,7 +67,11 @@ class CompletionServiceTest { .bestOf(0L) .echo(true) .frequencyPenalty(-2.0) - .logitBias(CompletionCreateParams.LogitBias.builder().build()) + .logitBias( + CompletionCreateParams.LogitBias.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .logprobs(0L) .maxTokens(16L) .n(1L) diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/EmbeddingServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/EmbeddingServiceTest.kt index 5dae5d0..29636b6 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/blocking/EmbeddingServiceTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/EmbeddingServiceTest.kt @@ -22,7 +22,11 @@ class EmbeddingServiceTest { val createEmbeddingResponse = embeddingService.create( EmbeddingCreateParams.builder() - .input(EmbeddingCreateParams.Input.ofString("This is a test.")) + .input( + EmbeddingCreateParams.Input.ofString( + "The quick brown fox jumped over the lazy dog" + ) + ) .model(EmbeddingModel.TEXT_EMBEDDING_ADA_002) .dimensions(1L) .encodingFormat(EmbeddingCreateParams.EncodingFormat.FLOAT) diff --git a/openai-java-core/src/test/kotlin/com/openai/services/blocking/chat/CompletionServiceTest.kt b/openai-java-core/src/test/kotlin/com/openai/services/blocking/chat/CompletionServiceTest.kt index 894841a..b044e45 100644 --- a/openai-java-core/src/test/kotlin/com/openai/services/blocking/chat/CompletionServiceTest.kt +++ b/openai-java-core/src/test/kotlin/com/openai/services/blocking/chat/CompletionServiceTest.kt @@ -4,6 +4,7 @@ package com.openai.services.blocking.chat import com.openai.TestServerExtension import com.openai.client.okhttp.OpenAIOkHttpClient +import com.openai.core.JsonValue import com.openai.models.* import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -55,15 +56,27 @@ class CompletionServiceTest { ChatCompletionCreateParams.Function.builder() .name("name") .description("description") - .parameters(FunctionParameters.builder().build()) + .parameters( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) ) - .logitBias(ChatCompletionCreateParams.LogitBias.builder().build()) + .logitBias( + ChatCompletionCreateParams.LogitBias.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .logprobs(true) .maxCompletionTokens(0L) .maxTokens(0L) - .metadata(ChatCompletionCreateParams.Metadata.builder().build()) + .metadata( + ChatCompletionCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .modalities(listOf(ChatCompletionModality.TEXT)) .n(1L) .parallelToolCalls(true) @@ -99,7 +112,11 @@ class CompletionServiceTest { FunctionDefinition.builder() .name("name") .description("description") - .parameters(FunctionParameters.builder().build()) + .parameters( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .strict(true) .build() ) @@ -161,15 +178,27 @@ class CompletionServiceTest { ChatCompletionCreateParams.Function.builder() .name("name") .description("description") - .parameters(FunctionParameters.builder().build()) + .parameters( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) ) - .logitBias(ChatCompletionCreateParams.LogitBias.builder().build()) + .logitBias( + ChatCompletionCreateParams.LogitBias.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) .logprobs(true) .maxCompletionTokens(0L) .maxTokens(0L) - .metadata(ChatCompletionCreateParams.Metadata.builder().build()) + .metadata( + ChatCompletionCreateParams.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .modalities(listOf(ChatCompletionModality.TEXT)) .n(1L) .parallelToolCalls(true) @@ -205,7 +234,11 @@ class CompletionServiceTest { FunctionDefinition.builder() .name("name") .description("description") - .parameters(FunctionParameters.builder().build()) + .parameters( + FunctionParameters.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .strict(true) .build() )