Skip to content

Commit 717a8d5

Browse files
docs: improve examples
1 parent 49cc5be commit 717a8d5

34 files changed

Lines changed: 182 additions & 243 deletions

openai-java-core/src/test/kotlin/com/openai/models/audio/speech/SpeechCreateParamsTest.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal class SpeechCreateParamsTest {
1212
SpeechCreateParams.builder()
1313
.input("input")
1414
.model(SpeechModel.TTS_1)
15-
.voice("string")
15+
.voice(SpeechCreateParams.Voice.UnionMember1.ALLOY)
1616
.instructions("instructions")
1717
.responseFormat(SpeechCreateParams.ResponseFormat.MP3)
1818
.speed(0.25)
@@ -26,7 +26,7 @@ internal class SpeechCreateParamsTest {
2626
SpeechCreateParams.builder()
2727
.input("input")
2828
.model(SpeechModel.TTS_1)
29-
.voice("string")
29+
.voice(SpeechCreateParams.Voice.UnionMember1.ALLOY)
3030
.instructions("instructions")
3131
.responseFormat(SpeechCreateParams.ResponseFormat.MP3)
3232
.speed(0.25)
@@ -37,7 +37,10 @@ internal class SpeechCreateParamsTest {
3737

3838
assertThat(body.input()).isEqualTo("input")
3939
assertThat(body.model()).isEqualTo(SpeechModel.TTS_1)
40-
assertThat(body.voice()).isEqualTo(SpeechCreateParams.Voice.ofString("string"))
40+
assertThat(body.voice())
41+
.isEqualTo(
42+
SpeechCreateParams.Voice.ofUnionMember1(SpeechCreateParams.Voice.UnionMember1.ALLOY)
43+
)
4144
assertThat(body.instructions()).contains("instructions")
4245
assertThat(body.responseFormat()).contains(SpeechCreateParams.ResponseFormat.MP3)
4346
assertThat(body.speed()).contains(0.25)
@@ -50,13 +53,16 @@ internal class SpeechCreateParamsTest {
5053
SpeechCreateParams.builder()
5154
.input("input")
5255
.model(SpeechModel.TTS_1)
53-
.voice("string")
56+
.voice(SpeechCreateParams.Voice.UnionMember1.ALLOY)
5457
.build()
5558

5659
val body = params._body()
5760

5861
assertThat(body.input()).isEqualTo("input")
5962
assertThat(body.model()).isEqualTo(SpeechModel.TTS_1)
60-
assertThat(body.voice()).isEqualTo(SpeechCreateParams.Voice.ofString("string"))
63+
assertThat(body.voice())
64+
.isEqualTo(
65+
SpeechCreateParams.Voice.ofUnionMember1(SpeechCreateParams.Voice.UnionMember1.ALLOY)
66+
)
6167
}
6268
}

openai-java-core/src/test/kotlin/com/openai/models/chat/completions/ChatCompletionAudioParamTest.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ internal class ChatCompletionAudioParamTest {
1414
val chatCompletionAudioParam =
1515
ChatCompletionAudioParam.builder()
1616
.format(ChatCompletionAudioParam.Format.WAV)
17-
.voice("string")
17+
.voice(ChatCompletionAudioParam.Voice.UnionMember1.ALLOY)
1818
.build()
1919

2020
assertThat(chatCompletionAudioParam.format()).isEqualTo(ChatCompletionAudioParam.Format.WAV)
2121
assertThat(chatCompletionAudioParam.voice())
22-
.isEqualTo(ChatCompletionAudioParam.Voice.ofString("string"))
22+
.isEqualTo(
23+
ChatCompletionAudioParam.Voice.ofUnionMember1(
24+
ChatCompletionAudioParam.Voice.UnionMember1.ALLOY
25+
)
26+
)
2327
}
2428

2529
@Test
@@ -28,7 +32,7 @@ internal class ChatCompletionAudioParamTest {
2832
val chatCompletionAudioParam =
2933
ChatCompletionAudioParam.builder()
3034
.format(ChatCompletionAudioParam.Format.WAV)
31-
.voice("string")
35+
.voice(ChatCompletionAudioParam.Voice.UnionMember1.ALLOY)
3236
.build()
3337

3438
val roundtrippedChatCompletionAudioParam =

openai-java-core/src/test/kotlin/com/openai/models/chat/completions/ChatCompletionCreateParamsTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ internal class ChatCompletionCreateParamsTest {
2424
.audio(
2525
ChatCompletionAudioParam.builder()
2626
.format(ChatCompletionAudioParam.Format.WAV)
27-
.voice("string")
27+
.voice(ChatCompletionAudioParam.Voice.UnionMember1.ALLOY)
2828
.build()
2929
)
3030
.frequencyPenalty(-2.0)
@@ -128,7 +128,7 @@ internal class ChatCompletionCreateParamsTest {
128128
.audio(
129129
ChatCompletionAudioParam.builder()
130130
.format(ChatCompletionAudioParam.Format.WAV)
131-
.voice("string")
131+
.voice(ChatCompletionAudioParam.Voice.UnionMember1.ALLOY)
132132
.build()
133133
)
134134
.frequencyPenalty(-2.0)
@@ -234,7 +234,7 @@ internal class ChatCompletionCreateParamsTest {
234234
.contains(
235235
ChatCompletionAudioParam.builder()
236236
.format(ChatCompletionAudioParam.Format.WAV)
237-
.voice("string")
237+
.voice(ChatCompletionAudioParam.Voice.UnionMember1.ALLOY)
238238
.build()
239239
)
240240
assertThat(body.frequencyPenalty()).contains(-2.0)

openai-java-core/src/test/kotlin/com/openai/models/realtime/RealtimeAudioConfigOutputTest.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal class RealtimeAudioConfigOutputTest {
2020
.build()
2121
)
2222
.speed(0.25)
23-
.voice("string")
23+
.voice(RealtimeAudioConfigOutput.Voice.UnionMember1.ALLOY)
2424
.build()
2525

2626
assertThat(realtimeAudioConfigOutput.format())
@@ -34,7 +34,11 @@ internal class RealtimeAudioConfigOutputTest {
3434
)
3535
assertThat(realtimeAudioConfigOutput.speed()).contains(0.25)
3636
assertThat(realtimeAudioConfigOutput.voice())
37-
.contains(RealtimeAudioConfigOutput.Voice.ofString("string"))
37+
.contains(
38+
RealtimeAudioConfigOutput.Voice.ofUnionMember1(
39+
RealtimeAudioConfigOutput.Voice.UnionMember1.ALLOY
40+
)
41+
)
3842
}
3943

4044
@Test
@@ -49,7 +53,7 @@ internal class RealtimeAudioConfigOutputTest {
4953
.build()
5054
)
5155
.speed(0.25)
52-
.voice("string")
56+
.voice(RealtimeAudioConfigOutput.Voice.UnionMember1.ALLOY)
5357
.build()
5458

5559
val roundtrippedRealtimeAudioConfigOutput =

openai-java-core/src/test/kotlin/com/openai/models/realtime/RealtimeAudioConfigTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ internal class RealtimeAudioConfigTest {
5454
.build()
5555
)
5656
.speed(0.25)
57-
.voice("string")
57+
.voice(RealtimeAudioConfigOutput.Voice.UnionMember1.ALLOY)
5858
.build()
5959
)
6060
.build()
@@ -102,7 +102,7 @@ internal class RealtimeAudioConfigTest {
102102
.build()
103103
)
104104
.speed(0.25)
105-
.voice("string")
105+
.voice(RealtimeAudioConfigOutput.Voice.UnionMember1.ALLOY)
106106
.build()
107107
)
108108
}
@@ -153,7 +153,7 @@ internal class RealtimeAudioConfigTest {
153153
.build()
154154
)
155155
.speed(0.25)
156-
.voice("string")
156+
.voice(RealtimeAudioConfigOutput.Voice.UnionMember1.ALLOY)
157157
.build()
158158
)
159159
.build()

openai-java-core/src/test/kotlin/com/openai/models/realtime/RealtimeClientEventTest.kt

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,11 @@ internal class RealtimeClientEventTest {
422422
.type(RealtimeAudioFormats.AudioPcm.Type.AUDIO_PCM)
423423
.build()
424424
)
425-
.voice("string")
425+
.voice(
426+
RealtimeResponseCreateAudioOutput.Output.Voice
427+
.UnionMember1
428+
.ALLOY
429+
)
426430
.build()
427431
)
428432
.build()
@@ -445,7 +449,7 @@ internal class RealtimeClientEventTest {
445449
.build()
446450
)
447451
.instructions("instructions")
448-
.maxOutputTokens(0L)
452+
.maxOutputTokensInf()
449453
.metadata(
450454
RealtimeResponseCreateParams.Metadata.builder()
451455
.putAdditionalProperty("foo", JsonValue.from("string"))
@@ -512,7 +516,11 @@ internal class RealtimeClientEventTest {
512516
)
513517
.build()
514518
)
515-
.voice("string")
519+
.voice(
520+
RealtimeResponseCreateAudioOutput.Output.Voice
521+
.UnionMember1
522+
.ALLOY
523+
)
516524
.build()
517525
)
518526
.build()
@@ -537,7 +545,7 @@ internal class RealtimeClientEventTest {
537545
.build()
538546
)
539547
.instructions("instructions")
540-
.maxOutputTokens(0L)
548+
.maxOutputTokensInf()
541549
.metadata(
542550
RealtimeResponseCreateParams.Metadata.builder()
543551
.putAdditionalProperty("foo", JsonValue.from("string"))
@@ -627,7 +635,7 @@ internal class RealtimeClientEventTest {
627635
.build()
628636
)
629637
.speed(0.25)
630-
.voice("string")
638+
.voice(RealtimeAudioConfigOutput.Voice.UnionMember1.ALLOY)
631639
.build()
632640
)
633641
.build()
@@ -637,7 +645,7 @@ internal class RealtimeClientEventTest {
637645
.ITEM_INPUT_AUDIO_TRANSCRIPTION_LOGPROBS
638646
)
639647
.instructions("instructions")
640-
.maxOutputTokens(0L)
648+
.maxOutputTokensInf()
641649
.model(RealtimeSessionCreateRequest.Model.GPT_REALTIME)
642650
.addOutputModality(RealtimeSessionCreateRequest.OutputModality.TEXT)
643651
.prompt(
@@ -737,7 +745,9 @@ internal class RealtimeClientEventTest {
737745
.build()
738746
)
739747
.speed(0.25)
740-
.voice("string")
748+
.voice(
749+
RealtimeAudioConfigOutput.Voice.UnionMember1.ALLOY
750+
)
741751
.build()
742752
)
743753
.build()
@@ -747,7 +757,7 @@ internal class RealtimeClientEventTest {
747757
.ITEM_INPUT_AUDIO_TRANSCRIPTION_LOGPROBS
748758
)
749759
.instructions("instructions")
750-
.maxOutputTokens(0L)
760+
.maxOutputTokensInf()
751761
.model(RealtimeSessionCreateRequest.Model.GPT_REALTIME)
752762
.addOutputModality(RealtimeSessionCreateRequest.OutputModality.TEXT)
753763
.prompt(

openai-java-core/src/test/kotlin/com/openai/models/realtime/RealtimeResponseCreateAudioOutputTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ internal class RealtimeResponseCreateAudioOutputTest {
2121
.type(RealtimeAudioFormats.AudioPcm.Type.AUDIO_PCM)
2222
.build()
2323
)
24-
.voice("string")
24+
.voice(RealtimeResponseCreateAudioOutput.Output.Voice.UnionMember1.ALLOY)
2525
.build()
2626
)
2727
.build()
@@ -35,7 +35,7 @@ internal class RealtimeResponseCreateAudioOutputTest {
3535
.type(RealtimeAudioFormats.AudioPcm.Type.AUDIO_PCM)
3636
.build()
3737
)
38-
.voice("string")
38+
.voice(RealtimeResponseCreateAudioOutput.Output.Voice.UnionMember1.ALLOY)
3939
.build()
4040
)
4141
}
@@ -53,7 +53,7 @@ internal class RealtimeResponseCreateAudioOutputTest {
5353
.type(RealtimeAudioFormats.AudioPcm.Type.AUDIO_PCM)
5454
.build()
5555
)
56-
.voice("string")
56+
.voice(RealtimeResponseCreateAudioOutput.Output.Voice.UnionMember1.ALLOY)
5757
.build()
5858
)
5959
.build()

openai-java-core/src/test/kotlin/com/openai/models/realtime/RealtimeResponseCreateMcpToolTest.kt

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,7 @@ internal class RealtimeResponseCreateMcpToolTest {
2525
.build()
2626
)
2727
.requireApproval(
28-
RealtimeResponseCreateMcpTool.RequireApproval.McpToolApprovalFilter.builder()
29-
.always(
30-
RealtimeResponseCreateMcpTool.RequireApproval.McpToolApprovalFilter
31-
.Always
32-
.builder()
33-
.readOnly(true)
34-
.addToolName("string")
35-
.build()
36-
)
37-
.never(
38-
RealtimeResponseCreateMcpTool.RequireApproval.McpToolApprovalFilter
39-
.Never
40-
.builder()
41-
.readOnly(true)
42-
.addToolName("string")
43-
.build()
44-
)
45-
.build()
28+
RealtimeResponseCreateMcpTool.RequireApproval.McpToolApprovalSetting.ALWAYS
4629
)
4730
.serverDescription("server_description")
4831
.serverUrl("server_url")
@@ -63,25 +46,8 @@ internal class RealtimeResponseCreateMcpToolTest {
6346
)
6447
assertThat(realtimeResponseCreateMcpTool.requireApproval())
6548
.contains(
66-
RealtimeResponseCreateMcpTool.RequireApproval.ofMcpToolApprovalFilter(
67-
RealtimeResponseCreateMcpTool.RequireApproval.McpToolApprovalFilter.builder()
68-
.always(
69-
RealtimeResponseCreateMcpTool.RequireApproval.McpToolApprovalFilter
70-
.Always
71-
.builder()
72-
.readOnly(true)
73-
.addToolName("string")
74-
.build()
75-
)
76-
.never(
77-
RealtimeResponseCreateMcpTool.RequireApproval.McpToolApprovalFilter
78-
.Never
79-
.builder()
80-
.readOnly(true)
81-
.addToolName("string")
82-
.build()
83-
)
84-
.build()
49+
RealtimeResponseCreateMcpTool.RequireApproval.ofMcpToolApprovalSetting(
50+
RealtimeResponseCreateMcpTool.RequireApproval.McpToolApprovalSetting.ALWAYS
8551
)
8652
)
8753
assertThat(realtimeResponseCreateMcpTool.serverDescription()).contains("server_description")
@@ -104,24 +70,7 @@ internal class RealtimeResponseCreateMcpToolTest {
10470
.build()
10571
)
10672
.requireApproval(
107-
RealtimeResponseCreateMcpTool.RequireApproval.McpToolApprovalFilter.builder()
108-
.always(
109-
RealtimeResponseCreateMcpTool.RequireApproval.McpToolApprovalFilter
110-
.Always
111-
.builder()
112-
.readOnly(true)
113-
.addToolName("string")
114-
.build()
115-
)
116-
.never(
117-
RealtimeResponseCreateMcpTool.RequireApproval.McpToolApprovalFilter
118-
.Never
119-
.builder()
120-
.readOnly(true)
121-
.addToolName("string")
122-
.build()
123-
)
124-
.build()
73+
RealtimeResponseCreateMcpTool.RequireApproval.McpToolApprovalSetting.ALWAYS
12574
)
12675
.serverDescription("server_description")
12776
.serverUrl("server_url")

0 commit comments

Comments
 (0)