Skip to content

Commit

Permalink
feat(client): add some more builder helpers (#173)
Browse files Browse the repository at this point in the history
docs: mark more methods as deprecated
chore(internal): shorten `model` method impl
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Jan 27, 2025
1 parent 48e9cf0 commit f314e68
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<String, JsonValue>) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, JsonValue>) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, JsonValue>) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<String, JsonValue>) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ private constructor(
fun model(model: JsonField<ImageModel>) = 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
Expand Down
4 changes: 4 additions & 0 deletions openai-java-core/src/main/kotlin/com/openai/models/Message.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, JsonValue>) = apply {
this.additionalProperties.clear()
putAllAdditionalProperties(additionalProperties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, JsonValue>) = apply {
this.additionalProperties.clear()
Expand Down

0 comments on commit f314e68

Please sign in to comment.