Skip to content

Commit

Permalink
chore: update example values in tests and docs (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Dec 11, 2024
1 parent 5a6eb17 commit e74f2b5
Show file tree
Hide file tree
Showing 17 changed files with 266 additions and 55 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,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);
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
}

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -43,7 +43,7 @@ class BatchTest {
.failedAt(0L)
.finalizingAt(0L)
.inProgressAt(0L)
.metadata(JsonNull.of())
.metadata(JsonValue.from(mapOf<String, Any>()))
.outputFileId("output_file_id")
.requestCounts(
BatchRequestCounts.builder().completed(0L).failed(0L).total(0L).build()
Expand Down Expand Up @@ -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<String, Any>()))
assertThat(batch.outputFileId()).contains("output_file_id")
assertThat(batch.requestCounts())
.contains(BatchRequestCounts.builder().completed(0L).failed(0L).total(0L).build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
)
Expand All @@ -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()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down Expand Up @@ -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()
)
Expand Down
Loading

0 comments on commit e74f2b5

Please sign in to comment.