This repository was archived by the owner on Jun 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathEmbeddingRequest.java
62 lines (53 loc) · 1.81 KB
/
EmbeddingRequest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.theokanning.openai.embedding;
import lombok.*;
import java.util.List;
/**
* Creates an embedding vector representing the input text.
*
* https://beta.openai.com/docs/api-reference/embeddings/create
*/
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Data
public class EmbeddingRequest {
/**
* The name of the model to use.
* Required if using the new v1/embeddings endpoint.
*/
String model;
/**
* Input text to get embeddings for, encoded as a string or array of tokens.
* To get embeddings for multiple inputs in a single request, pass an array of strings or array of token arrays.
* Each input must not exceed 2048 tokens in length.
* <p>
* Unless you are embedding code, we suggest replacing newlines (\n) in your input with a single space,
* as we have observed inferior results when newlines are present.
*/
@NonNull
List<String> input;
/**
* A unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse.
*/
String user;
/**
* The number of dimensions to be used by the model to represent each input text as the feature
* vector.
*/
@Setter(AccessLevel.NONE)
Integer dimensions = null;
/**
* Set the number of dimensions to be used by the model to represent each input text as the feature vector.
*
* @param dimensions The number of dimensions to be used by the model. Only supported for models from or after
* third generation.
*/
public void setDimensions(Integer dimensions) {
EmbeddingModel embeddingModel = EmbeddingModel.fromValue(this.model);
if (embeddingModel.getGeneration() > 2) {
this.dimensions = dimensions;
} else {
this.dimensions = null;
}
}
}