Skip to content

Commit faae5f3

Browse files
authored
Merge pull request #45 from CJCrafter/embeddings-dimensions
Embeddings dimensions
2 parents 11ed06e + 2137373 commit faae5f3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/kotlin/com/cjcrafter/openai/embeddings/EmbeddingsRequest.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ import com.fasterxml.jackson.annotation.JsonProperty
1212
* @property input The input(s) to convert to embeddings.
1313
* @property model Which [model](https://platform.openai.com/docs/models/embeddings) to use to generate the embeddings.
1414
* @property encodingFormat Determines how the embeddings are encoded. Defaults to [EncodingFormat.FLOAT].
15+
* @property dimensions The number of dimensions to use for the embeddings.
1516
* @property user The user ID to associate with this request.
1617
* @constructor Create empty Embeddings request
1718
*/
1819
data class EmbeddingsRequest internal constructor(
1920
var input: Any,
2021
var model: String,
2122
@JsonProperty("encoding_format") var encodingFormat: EncodingFormat? = null,
23+
var dimensions: Int? = null,
2224
var user: String? = null,
2325
) {
2426

@@ -30,20 +32,23 @@ data class EmbeddingsRequest internal constructor(
3032
private var input: Any? = null
3133
private var model: String? = null
3234
private var encodingFormat: EncodingFormat? = null
35+
private var dimensions: Int? = null
3336
private var user: String? = null
3437

3538
fun input(input: String) = apply { this.input = input }
3639
fun input(input: List<String>) = apply { this.input = input }
3740
fun model(model: String) = apply { this.model = model }
3841
fun encodingFormat(encodingFormat: EncodingFormat) = apply { this.encodingFormat = encodingFormat }
42+
fun dimensions(dimensions: Int) = apply { this.dimensions = dimensions }
3943
fun user(user: String) = apply { this.user = user }
4044

4145
fun build(): EmbeddingsRequest {
4246
return EmbeddingsRequest(
4347
input = input ?: throw IllegalStateException("input must be defined to use EmbeddingsRequest"),
4448
model = model ?: throw IllegalStateException("model must be defined to use EmbeddingsRequest"),
4549
encodingFormat = encodingFormat,
46-
user = user
50+
dimensions = dimensions,
51+
user = user,
4752
)
4853
}
4954
}

0 commit comments

Comments
 (0)