Skip to content

Commit 74ed75f

Browse files
authored
Make user field optional in embedding request (#899)
* make user optional in embedding request * fix unit test
1 parent 1687616 commit 74ed75f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

batch_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func TestUploadBatchFileRequest_AddEmbedding(t *testing.T) {
211211
Input: []string{"Hello", "World"},
212212
},
213213
},
214-
}, []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
214+
}, []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
215215
}
216216
for _, tt := range tests {
217217
t.Run(tt.name, func(t *testing.T) {

embeddings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ const (
155155
type EmbeddingRequest struct {
156156
Input any `json:"input"`
157157
Model EmbeddingModel `json:"model"`
158-
User string `json:"user"`
158+
User string `json:"user,omitempty"`
159159
EncodingFormat EmbeddingEncodingFormat `json:"encoding_format,omitempty"`
160160
// Dimensions The number of dimensions the resulting output embeddings should have.
161161
// Only supported in text-embedding-3 and later models.

0 commit comments

Comments
 (0)