Skip to content

feat(client): add some more builder helpers #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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