Skip to content

Commit dabb60c

Browse files
feat(client): add some more builder helpers (#173)
docs: mark more methods as deprecated chore(internal): shorten `model` method impl
1 parent 48e9cf0 commit dabb60c

12 files changed

+29
-9
lines changed

openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantCreateParams.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ private constructor(
468468
* all of your available models, or see our
469469
* [Model overview](https://platform.openai.com/docs/models) for descriptions of them.
470470
*/
471-
fun model(value: String) = apply { model(ChatModel.of(value)) }
471+
fun model(value: String) = model(ChatModel.of(value))
472472

473473
/** The description of the assistant. The maximum length is 512 characters. */
474474
fun description(description: String?) = description(JsonField.ofNullable(description))

openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateAndRunParams.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ private constructor(
822822
* associated with the assistant. If not, the model associated with the assistant will
823823
* be used.
824824
*/
825-
fun model(value: String) = apply { model(ChatModel.of(value)) }
825+
fun model(value: String) = model(ChatModel.of(value))
826826

827827
/**
828828
* Whether to enable
@@ -2728,6 +2728,9 @@ private constructor(
27282728
fun addTool(codeInterpreter: CodeInterpreterTool) =
27292729
addTool(Tool.ofCodeInterpreter(codeInterpreter))
27302730

2731+
/** The tools to add this file to. */
2732+
fun addToolFileSearch() = addTool(Tool.ofFileSearch())
2733+
27312734
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
27322735
this.additionalProperties.clear()
27332736
putAllAdditionalProperties(additionalProperties)

openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateParams.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,9 @@ private constructor(
10571057
fun addTool(codeInterpreter: CodeInterpreterTool) =
10581058
addTool(Tool.ofCodeInterpreter(codeInterpreter))
10591059

1060+
/** The tools to add this file to. */
1061+
fun addToolFileSearch() = addTool(Tool.ofFileSearch())
1062+
10601063
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
10611064
this.additionalProperties.clear()
10621065
putAllAdditionalProperties(additionalProperties)

openai-java-core/src/main/kotlin/com/openai/models/BetaThreadMessageCreateParams.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,9 @@ private constructor(
889889
fun addTool(codeInterpreter: CodeInterpreterTool) =
890890
addTool(Tool.ofCodeInterpreter(codeInterpreter))
891891

892+
/** The tools to add this file to. */
893+
fun addToolFileSearch() = addTool(Tool.ofFileSearch())
894+
892895
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
893896
this.additionalProperties.clear()
894897
putAllAdditionalProperties(additionalProperties)

openai-java-core/src/main/kotlin/com/openai/models/BetaThreadRunCreateParams.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ private constructor(
910910
* associated with the assistant. If not, the model associated with the assistant will
911911
* be used.
912912
*/
913-
fun model(value: String) = apply { model(ChatModel.of(value)) }
913+
fun model(value: String) = model(ChatModel.of(value))
914914

915915
/**
916916
* Whether to enable
@@ -2634,6 +2634,9 @@ private constructor(
26342634
fun addTool(codeInterpreter: CodeInterpreterTool) =
26352635
addTool(Tool.ofCodeInterpreter(codeInterpreter))
26362636

2637+
/** The tools to add this file to. */
2638+
fun addToolFileSearch() = addTool(Tool.ofFileSearch())
2639+
26372640
fun additionalProperties(additionalProperties: Map<String, JsonValue>) = apply {
26382641
this.additionalProperties.clear()
26392642
putAllAdditionalProperties(additionalProperties)

openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionCreateParams.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,7 @@ private constructor(
14311431
* [model endpoint compatibility](https://platform.openai.com/docs/models#model-endpoint-compatibility)
14321432
* table for details on which models work with the Chat API.
14331433
*/
1434-
fun model(value: String) = apply { model(ChatModel.of(value)) }
1434+
fun model(value: String) = model(ChatModel.of(value))
14351435

14361436
/**
14371437
* Parameters for audio output. Required when audio output is requested with
@@ -1527,12 +1527,14 @@ private constructor(
15271527
* `none` means the model will not call a function and instead generates a message.
15281528
* `auto` means the model can pick between generating a message or calling a function.
15291529
*/
1530+
@Deprecated("deprecated")
15301531
fun functionCall(auto: FunctionCall.Auto) = functionCall(FunctionCall.ofAuto(auto))
15311532

15321533
/**
15331534
* Specifying a particular function via `{"name": "my_function"}` forces the model to
15341535
* call that function.
15351536
*/
1537+
@Deprecated("deprecated")
15361538
fun functionCall(functionCallOption: ChatCompletionFunctionCallOption) =
15371539
functionCall(FunctionCall.ofFunctionCallOption(functionCallOption))
15381540

@@ -2649,12 +2651,14 @@ private constructor(
26492651
* `none` means the model will not call a function and instead generates a message. `auto`
26502652
* means the model can pick between generating a message or calling a function.
26512653
*/
2654+
@Deprecated("deprecated")
26522655
fun functionCall(auto: FunctionCall.Auto) = apply { body.functionCall(auto) }
26532656

26542657
/**
26552658
* Specifying a particular function via `{"name": "my_function"}` forces the model to call
26562659
* that function.
26572660
*/
2661+
@Deprecated("deprecated")
26582662
fun functionCall(functionCallOption: ChatCompletionFunctionCallOption) = apply {
26592663
body.functionCall(functionCallOption)
26602664
}

openai-java-core/src/main/kotlin/com/openai/models/CompletionCreateParams.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ private constructor(
807807
* all of your available models, or see our
808808
* [Model overview](https://platform.openai.com/docs/models) for descriptions of them.
809809
*/
810-
fun model(value: String) = apply { model(Model.of(value)) }
810+
fun model(value: String) = model(Model.of(value))
811811

812812
/**
813813
* The prompt(s) to generate completions for, encoded as a string, array of strings,

openai-java-core/src/main/kotlin/com/openai/models/EmbeddingCreateParams.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ private constructor(
336336
* all of your available models, or see our
337337
* [Model overview](https://platform.openai.com/docs/models) for descriptions of them.
338338
*/
339-
fun model(value: String) = apply { model(EmbeddingModel.of(value)) }
339+
fun model(value: String) = model(EmbeddingModel.of(value))
340340

341341
/**
342342
* The number of dimensions the resulting output embeddings should have. Only supported

openai-java-core/src/main/kotlin/com/openai/models/FineTuningJobCreateParams.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ private constructor(
450450
* The name of the model to fine-tune. You can select one of the
451451
* [supported models](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned).
452452
*/
453-
fun model(value: String) = apply { model(Model.of(value)) }
453+
fun model(value: String) = model(Model.of(value))
454454

455455
/**
456456
* The ID of an uploaded file that contains training data.

openai-java-core/src/main/kotlin/com/openai/models/ImageGenerateParams.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ private constructor(
343343
fun model(model: JsonField<ImageModel>) = apply { this.model = model }
344344

345345
/** The model to use for image generation. */
346-
fun model(value: String) = apply { model(ImageModel.of(value)) }
346+
fun model(value: String) = model(ImageModel.of(value))
347347

348348
/**
349349
* The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only

0 commit comments

Comments
 (0)