Make user field optional in embedding request (#899)
* make user optional in embedding request * fix unit test
This commit is contained in:
@@ -211,7 +211,7 @@ func TestUploadBatchFileRequest_AddEmbedding(t *testing.T) {
|
|||||||
Input: []string{"Hello", "World"},
|
Input: []string{"Hello", "World"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, []byte("{\"custom_id\":\"req-1\",\"body\":{\"input\":[\"Hello\",\"World\"],\"model\":\"gpt-3.5-turbo\",\"user\":\"\"},\"method\":\"POST\",\"url\":\"/v1/embeddings\"}\n{\"custom_id\":\"req-2\",\"body\":{\"input\":[\"Hello\",\"World\"],\"model\":\"text-embedding-ada-002\",\"user\":\"\"},\"method\":\"POST\",\"url\":\"/v1/embeddings\"}")}, //nolint:lll
|
}, []byte("{\"custom_id\":\"req-1\",\"body\":{\"input\":[\"Hello\",\"World\"],\"model\":\"gpt-3.5-turbo\"},\"method\":\"POST\",\"url\":\"/v1/embeddings\"}\n{\"custom_id\":\"req-2\",\"body\":{\"input\":[\"Hello\",\"World\"],\"model\":\"text-embedding-ada-002\"},\"method\":\"POST\",\"url\":\"/v1/embeddings\"}")}, //nolint:lll
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ const (
|
|||||||
type EmbeddingRequest struct {
|
type EmbeddingRequest struct {
|
||||||
Input any `json:"input"`
|
Input any `json:"input"`
|
||||||
Model EmbeddingModel `json:"model"`
|
Model EmbeddingModel `json:"model"`
|
||||||
User string `json:"user"`
|
User string `json:"user,omitempty"`
|
||||||
EncodingFormat EmbeddingEncodingFormat `json:"encoding_format,omitempty"`
|
EncodingFormat EmbeddingEncodingFormat `json:"encoding_format,omitempty"`
|
||||||
// Dimensions The number of dimensions the resulting output embeddings should have.
|
// Dimensions The number of dimensions the resulting output embeddings should have.
|
||||||
// Only supported in text-embedding-3 and later models.
|
// Only supported in text-embedding-3 and later models.
|
||||||
|
|||||||
Reference in New Issue
Block a user