Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b1565ce

Browse files
add dimensions argument to embeddings
1 parent fd4b5dd commit b1565ce

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.cjcrafter.openai.embeddings
2+
3+
/**
4+
* Represents the handler for the embeddings endpoint. This class holds all the
5+
* actions that can be performed on an embedding.
6+
*/
7+
interface EmbeddingHandler {
8+
9+
10+
}

‎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)

AltStyle によって変換されたページ (->オリジナル) /