OpenAIUploadFilesBuilder

DSL builder for creating a list of OpenAIUploadFileRequest.

See also

Samples

val uploadFilesRequests = openAIUploadFilesRequest {
    // You can set default purpose, it will be used in all requests in this dsl, example: defaultPurpose = OpenAIFilePurpose.ASSISTANTS

    fileFromPath(
        path = "path/to/file1.ext"
        // You can set a purpose for this file using field `purpose`, example: purpose = OpenAIFilePurpose.ASSISTANTS
    )
    fileFromPath("path/to/file2.ext")
}

// example: Send files to OpenAI.
val response = client.uploadOpenAIFiles(uploadFilesRequests)

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Default purpose applied to files added without an explicit purpose.

Functions

Link copied to clipboard
Link copied to clipboard
fun createFile(filePath: String, rewriteExists: Boolean = false, purpose: OpenAIFilePurpose = defaultPurpose, block: (KoryFile) -> Unit)

Creates a new file and adds it to the upload list.

Link copied to clipboard
fun file(file: KoryFile, purpose: OpenAIFilePurpose = defaultPurpose)

Adds a file to the upload list.

Link copied to clipboard
fun fileFromPath(path: String, purpose: OpenAIFilePurpose = defaultPurpose)

Loads a file from the given path and adds it to the upload list.

Link copied to clipboard

Adds a pre-built request to the upload list.

fun request(purpose: OpenAIFilePurpose = defaultPurpose, block: OpenAIUploadFileRequestBuilder.() -> Unit)

Adds a request built via the nested request DSL.

Link copied to clipboard
fun requests(vararg requests: OpenAIUploadFileRequest)

Adds multiple pre-built requests to the upload list.