fix:dimensions not sent in embedding API requests (#1654)

fix:dimensions not sent in embedding API requests
This commit is contained in:
MaoMeng
2026-06-15 17:32:23 +08:00
committed by GitHub
parent a997441392
commit cf0a64b88e
7 changed files with 29 additions and 10 deletions
+11 -2
View File
@@ -39,10 +39,16 @@ func (e *AliyunEmbedder) SetCustomHeaders(headers map[string]string) {
e.customHeaders = headers
}
// AliyunEmbedParameters represents the parameters for Aliyun DashScope multimodal embedding
type AliyunEmbedParameters struct {
Dimension int `json:"dimension,omitempty"`
}
// AliyunEmbedRequest represents an Aliyun DashScope multimodal embedding request
type AliyunEmbedRequest struct {
Model string `json:"model"`
Input AliyunEmbedInput `json:"input"`
Model string `json:"model"`
Input AliyunEmbedInput `json:"input"`
Parameters *AliyunEmbedParameters `json:"parameters,omitempty"`
}
// AliyunEmbedInput represents the input structure for Aliyun embedding
@@ -188,6 +194,9 @@ func (e *AliyunEmbedder) BatchEmbed(ctx context.Context, texts []string) ([][]fl
Contents: contents,
},
}
if e.dimensions > 0 {
reqBody.Parameters = &AliyunEmbedParameters{Dimension: e.dimensions}
}
jsonData, err := json.Marshal(reqBody)
if err != nil {