@@ -80,6 +80,9 @@ type EmbeddingConfig struct {
8080 // MaxConcurrentRequests specifies the maximum number of concurrent multi-modal embedding api calls allowed
8181 // Optional. Default: 5
8282 MaxConcurrentRequests * int `json:"max_concurrent_requests"`
83+ // Dimensions The number of dimensions the resulting output embeddings should have.
84+ // Only supported in text-embedding-3 and later models.
85+ Dimensions int `json:"dimensions,omitempty"`
8386}
8487
8588type APIType string
@@ -186,6 +189,7 @@ func (e *Embedder) EmbedStrings(ctx context.Context, texts []string, opts ...emb
186189 Input : texts ,
187190 Model : conf .Model ,
188191 EncodingFormat : encodingFormat ,
192+ Dimensions : e .conf .Dimensions ,
189193 })
190194 if err != nil {
191195 return nil , fmt .Errorf ("[Ark] CreateEmbeddings error: %w" , err )
@@ -207,6 +211,11 @@ func (e *Embedder) EmbedStrings(ctx context.Context, texts []string, opts ...emb
207211 eg .SetLimit (* e .conf .MaxConcurrentRequests )
208212 usage = & embedding.TokenUsage {}
209213 embeddings = make ([][]float64 , len (texts ))
214+ var dim * int = nil
215+ if e .conf .Dimensions > 0 {
216+ copyDim := e .conf .Dimensions
217+ dim = & copyDim
218+ }
210219
211220 for i := 0 ; i < len (texts ); i ++ {
212221 idx := i
@@ -219,6 +228,7 @@ func (e *Embedder) EmbedStrings(ctx context.Context, texts []string, opts ...emb
219228 },
220229 Model : conf .Model ,
221230 EncodingFormat : & encodingFormat ,
231+ Dimensions : dim ,
222232 })
223233 if err != nil {
224234 return fmt .Errorf ("[Ark] CreateMultiModalEmbeddings error: %w" , err )
0 commit comments