Skip to content
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

Add new struct filed dimensions for embedding API #645

Merged
merged 3 commits into from
Jan 29, 2024
Merged
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
11 changes: 11 additions & 0 deletions embeddings.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ type EmbeddingRequest struct {
Model EmbeddingModel `json:"model"`
User string `json:"user"`
EncodingFormat EmbeddingEncodingFormat `json:"encoding_format,omitempty"`
// Dimensions The number of dimensions the resulting output embeddings should have.
// Only supported in text-embedding-3 and later models.
Dimensions int `json:"dimensions,omitempty"`
}

func (r EmbeddingRequest) Convert() EmbeddingRequest {
Expand All @@ -181,6 +184,9 @@ type EmbeddingRequestStrings struct {
// Currently, only "float" and "base64" are supported, however, "base64" is not officially documented.
// If not specified OpenAI will use "float".
EncodingFormat EmbeddingEncodingFormat `json:"encoding_format,omitempty"`
// Dimensions The number of dimensions the resulting output embeddings should have.
// Only supported in text-embedding-3 and later models.
Dimensions int `json:"dimensions,omitempty"`
}

func (r EmbeddingRequestStrings) Convert() EmbeddingRequest {
Expand All @@ -189,6 +195,7 @@ func (r EmbeddingRequestStrings) Convert() EmbeddingRequest {
Model: r.Model,
User: r.User,
EncodingFormat: r.EncodingFormat,
Dimensions: r.Dimensions,
}
}

Expand All @@ -209,6 +216,9 @@ type EmbeddingRequestTokens struct {
// Currently, only "float" and "base64" are supported, however, "base64" is not officially documented.
// If not specified OpenAI will use "float".
EncodingFormat EmbeddingEncodingFormat `json:"encoding_format,omitempty"`
// Dimensions The number of dimensions the resulting output embeddings should have.
// Only supported in text-embedding-3 and later models.
Dimensions int `json:"dimensions,omitempty"`
}

func (r EmbeddingRequestTokens) Convert() EmbeddingRequest {
Expand All @@ -217,6 +227,7 @@ func (r EmbeddingRequestTokens) Convert() EmbeddingRequest {
Model: r.Model,
User: r.User,
EncodingFormat: r.EncodingFormat,
Dimensions: r.Dimensions,
}
}

Expand Down
Loading