From 74ed75f291f8f55d1104a541090d46c021169115 Mon Sep 17 00:00:00 2001 From: nagar-ajay Date: Thu, 21 Nov 2024 02:09:44 +0530 Subject: [PATCH] Make user field optional in embedding request (#899) * make user optional in embedding request * fix unit test --- batch_test.go | 2 +- embeddings.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/batch_test.go b/batch_test.go index 4b2261e0e..f4714f4eb 100644 --- a/batch_test.go +++ b/batch_test.go @@ -211,7 +211,7 @@ func TestUploadBatchFileRequest_AddEmbedding(t *testing.T) { 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 { t.Run(tt.name, func(t *testing.T) { diff --git a/embeddings.go b/embeddings.go index 74eb8aa57..4a0e682da 100644 --- a/embeddings.go +++ b/embeddings.go @@ -155,7 +155,7 @@ const ( type EmbeddingRequest struct { Input any `json:"input"` Model EmbeddingModel `json:"model"` - User string `json:"user"` + User string `json:"user,omitempty"` 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.