From f314e68915560703970c9acc16e96030202de9d1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 22:10:45 +0000 Subject: [PATCH] feat(client): add some more builder helpers (#173) docs: mark more methods as deprecated chore(internal): shorten `model` method impl --- .../kotlin/com/openai/models/BetaAssistantCreateParams.kt | 2 +- .../com/openai/models/BetaThreadCreateAndRunParams.kt | 5 ++++- .../main/kotlin/com/openai/models/BetaThreadCreateParams.kt | 3 +++ .../com/openai/models/BetaThreadMessageCreateParams.kt | 3 +++ .../kotlin/com/openai/models/BetaThreadRunCreateParams.kt | 5 ++++- .../kotlin/com/openai/models/ChatCompletionCreateParams.kt | 6 +++++- .../main/kotlin/com/openai/models/CompletionCreateParams.kt | 2 +- .../main/kotlin/com/openai/models/EmbeddingCreateParams.kt | 2 +- .../kotlin/com/openai/models/FineTuningJobCreateParams.kt | 2 +- .../main/kotlin/com/openai/models/ImageGenerateParams.kt | 2 +- .../src/main/kotlin/com/openai/models/Message.kt | 4 ++++ .../main/kotlin/com/openai/models/ModerationCreateParams.kt | 2 +- 12 files changed, 29 insertions(+), 9 deletions(-) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantCreateParams.kt index 8507230..0c44bb4 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaAssistantCreateParams.kt @@ -468,7 +468,7 @@ private constructor( * all of your available models, or see our * [Model overview](https://platform.openai.com/docs/models) for descriptions of them. */ - fun model(value: String) = apply { model(ChatModel.of(value)) } + fun model(value: String) = model(ChatModel.of(value)) /** The description of the assistant. The maximum length is 512 characters. */ fun description(description: String?) = description(JsonField.ofNullable(description)) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateAndRunParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateAndRunParams.kt index 1ec100a..9ceadfe 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateAndRunParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateAndRunParams.kt @@ -822,7 +822,7 @@ private constructor( * associated with the assistant. If not, the model associated with the assistant will * be used. */ - fun model(value: String) = apply { model(ChatModel.of(value)) } + fun model(value: String) = model(ChatModel.of(value)) /** * Whether to enable @@ -2728,6 +2728,9 @@ private constructor( fun addTool(codeInterpreter: CodeInterpreterTool) = addTool(Tool.ofCodeInterpreter(codeInterpreter)) + /** The tools to add this file to. */ + fun addToolFileSearch() = addTool(Tool.ofFileSearch()) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateParams.kt index 84f8635..cf8895e 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadCreateParams.kt @@ -1057,6 +1057,9 @@ private constructor( fun addTool(codeInterpreter: CodeInterpreterTool) = addTool(Tool.ofCodeInterpreter(codeInterpreter)) + /** The tools to add this file to. */ + fun addToolFileSearch() = addTool(Tool.ofFileSearch()) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadMessageCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadMessageCreateParams.kt index 931bae9..5670491 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadMessageCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadMessageCreateParams.kt @@ -889,6 +889,9 @@ private constructor( fun addTool(codeInterpreter: CodeInterpreterTool) = addTool(Tool.ofCodeInterpreter(codeInterpreter)) + /** The tools to add this file to. */ + fun addToolFileSearch() = addTool(Tool.ofFileSearch()) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadRunCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadRunCreateParams.kt index def84db..0957f8a 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadRunCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/BetaThreadRunCreateParams.kt @@ -910,7 +910,7 @@ private constructor( * associated with the assistant. If not, the model associated with the assistant will * be used. */ - fun model(value: String) = apply { model(ChatModel.of(value)) } + fun model(value: String) = model(ChatModel.of(value)) /** * Whether to enable @@ -2634,6 +2634,9 @@ private constructor( fun addTool(codeInterpreter: CodeInterpreterTool) = addTool(Tool.ofCodeInterpreter(codeInterpreter)) + /** The tools to add this file to. */ + fun addToolFileSearch() = addTool(Tool.ofFileSearch()) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionCreateParams.kt index 17818fc..aa49e72 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ChatCompletionCreateParams.kt @@ -1431,7 +1431,7 @@ private constructor( * [model endpoint compatibility](https://platform.openai.com/docs/models#model-endpoint-compatibility) * table for details on which models work with the Chat API. */ - fun model(value: String) = apply { model(ChatModel.of(value)) } + fun model(value: String) = model(ChatModel.of(value)) /** * Parameters for audio output. Required when audio output is requested with @@ -1527,12 +1527,14 @@ private constructor( * `none` means the model will not call a function and instead generates a message. * `auto` means the model can pick between generating a message or calling a function. */ + @Deprecated("deprecated") fun functionCall(auto: FunctionCall.Auto) = functionCall(FunctionCall.ofAuto(auto)) /** * Specifying a particular function via `{"name": "my_function"}` forces the model to * call that function. */ + @Deprecated("deprecated") fun functionCall(functionCallOption: ChatCompletionFunctionCallOption) = functionCall(FunctionCall.ofFunctionCallOption(functionCallOption)) @@ -2649,12 +2651,14 @@ private constructor( * `none` means the model will not call a function and instead generates a message. `auto` * means the model can pick between generating a message or calling a function. */ + @Deprecated("deprecated") fun functionCall(auto: FunctionCall.Auto) = apply { body.functionCall(auto) } /** * Specifying a particular function via `{"name": "my_function"}` forces the model to call * that function. */ + @Deprecated("deprecated") fun functionCall(functionCallOption: ChatCompletionFunctionCallOption) = apply { body.functionCall(functionCallOption) } diff --git a/openai-java-core/src/main/kotlin/com/openai/models/CompletionCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/CompletionCreateParams.kt index dea43a8..f93a9f9 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/CompletionCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/CompletionCreateParams.kt @@ -807,7 +807,7 @@ private constructor( * all of your available models, or see our * [Model overview](https://platform.openai.com/docs/models) for descriptions of them. */ - fun model(value: String) = apply { model(Model.of(value)) } + fun model(value: String) = model(Model.of(value)) /** * The prompt(s) to generate completions for, encoded as a string, array of strings, diff --git a/openai-java-core/src/main/kotlin/com/openai/models/EmbeddingCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/EmbeddingCreateParams.kt index 84d2c5b..e3c682d 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/EmbeddingCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/EmbeddingCreateParams.kt @@ -336,7 +336,7 @@ private constructor( * all of your available models, or see our * [Model overview](https://platform.openai.com/docs/models) for descriptions of them. */ - fun model(value: String) = apply { model(EmbeddingModel.of(value)) } + fun model(value: String) = model(EmbeddingModel.of(value)) /** * The number of dimensions the resulting output embeddings should have. Only supported diff --git a/openai-java-core/src/main/kotlin/com/openai/models/FineTuningJobCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/FineTuningJobCreateParams.kt index fd0c1ea..7c0eb14 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/FineTuningJobCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/FineTuningJobCreateParams.kt @@ -450,7 +450,7 @@ private constructor( * The name of the model to fine-tune. You can select one of the * [supported models](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned). */ - fun model(value: String) = apply { model(Model.of(value)) } + fun model(value: String) = model(Model.of(value)) /** * The ID of an uploaded file that contains training data. diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ImageGenerateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/ImageGenerateParams.kt index 85b6b5e..21ff71b 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ImageGenerateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ImageGenerateParams.kt @@ -343,7 +343,7 @@ private constructor( fun model(model: JsonField) = apply { this.model = model } /** The model to use for image generation. */ - fun model(value: String) = apply { model(ImageModel.of(value)) } + fun model(value: String) = model(ImageModel.of(value)) /** * The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only diff --git a/openai-java-core/src/main/kotlin/com/openai/models/Message.kt b/openai-java-core/src/main/kotlin/com/openai/models/Message.kt index 2b0ffb2..0af5d70 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/Message.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/Message.kt @@ -604,6 +604,10 @@ private constructor( fun addTool(codeInterpreter: CodeInterpreterTool) = addTool(Tool.ofCodeInterpreter(codeInterpreter)) + /** The tools to add this file to. */ + fun addToolAssistantToolsFileSearchTypeOnly() = + addTool(Tool.ofAssistantToolsFileSearchTypeOnly()) + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) diff --git a/openai-java-core/src/main/kotlin/com/openai/models/ModerationCreateParams.kt b/openai-java-core/src/main/kotlin/com/openai/models/ModerationCreateParams.kt index c4206e7..80b5bfa 100644 --- a/openai-java-core/src/main/kotlin/com/openai/models/ModerationCreateParams.kt +++ b/openai-java-core/src/main/kotlin/com/openai/models/ModerationCreateParams.kt @@ -198,7 +198,7 @@ private constructor( * [the moderation guide](https://platform.openai.com/docs/guides/moderation), and learn * about available models [here](https://platform.openai.com/docs/models#moderation). */ - fun model(value: String) = apply { model(ModerationModel.of(value)) } + fun model(value: String) = model(ModerationModel.of(value)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear()