From 227a7da00e160bb0f691a3219d28cf87ca59bfa2 Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Sat, 2 Sep 2023 01:50:53 +0200 Subject: [PATCH 01/17] chore: support base64 embedding format --- embeddings.go | 111 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 101 insertions(+), 10 deletions(-) diff --git a/embeddings.go b/embeddings.go index 1d3199597..93270a57a 100644 --- a/embeddings.go +++ b/embeddings.go @@ -2,6 +2,9 @@ package openai import ( "context" + "encoding/base64" + "encoding/binary" + "math" "net/http" ) @@ -129,15 +132,66 @@ type EmbeddingResponse struct { Usage Usage `json:"usage"` } +// base64Embedding is a container for base64 encoded embeddings. +type base64Embedding struct { + Object string `json:"object"` + Embedding string `json:"embedding"` + Index int `json:"index"` +} + +// embeddingResponseBase64 is the response from a Create embeddings request with base64 encoding format. +type embeddingResponseBase64 struct { + Object string `json:"object"` + Data []base64Embedding `json:"data"` + Model EmbeddingModel `json:"model"` + Usage Usage `json:"usage"` +} + +// ToEmbeddingResponse converts an embeddingResponseBase64 to an EmbeddingResponse. +func (r *embeddingResponseBase64) ToEmbeddingResponse() (EmbeddingResponse, error) { + data := make([]Embedding, len(r.Data)) + + for i, base64Embedding := range r.Data { + embedding, err := decodeBase64EmbeddingToFloat32Embedding(base64Embedding.Embedding) + if err != nil { + return EmbeddingResponse{}, err + } + + data[i] = Embedding{ + Object: base64Embedding.Object, + Embedding: embedding, + Index: base64Embedding.Index, + } + } + + return EmbeddingResponse{ + Object: r.Object, + Model: r.Model, + Data: data, + Usage: r.Usage, + }, nil +} + type EmbeddingRequestConverter interface { // Needs to be of type EmbeddingRequestStrings or EmbeddingRequestTokens Convert() EmbeddingRequest } +// EmbeddingEncodingFormat is the format of the embeddings data. +// Currently, only "float" and "base64" are supported, however, "base64" is not officially documented. +// If not specified OpenAI will use "float". +type EmbeddingEncodingFormat string + +const ( + EmbeddingEncodingFormatFloat EmbeddingEncodingFormat = "float" + EmbeddingEncodingFormatBase64 EmbeddingEncodingFormat = "base64" +) + type EmbeddingRequest struct { - Input any `json:"input"` - Model EmbeddingModel `json:"model"` - User string `json:"user"` + Input any `json:"input"` + Model EmbeddingModel `json:"model"` + User string `json:"user"` + EncodingFormat EmbeddingEncodingFormat `json:"encoding_format,omitempty"` } func (r EmbeddingRequest) Convert() EmbeddingRequest { @@ -158,13 +212,18 @@ type EmbeddingRequestStrings struct { Model EmbeddingModel `json:"model"` // A unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse. User string `json:"user"` + // EmbeddingEncodingFormat is the format of the embeddings data. + // Currently, only "float" and "base64" are supported, however, "base64" is not officially documented. + // If not specified OpenAI will use "float". + EncodingFormat EmbeddingEncodingFormat `json:"encoding_format,omitempty"` } func (r EmbeddingRequestStrings) Convert() EmbeddingRequest { return EmbeddingRequest{ - Input: r.Input, - Model: r.Model, - User: r.User, + Input: r.Input, + Model: r.Model, + User: r.User, + EncodingFormat: r.EncodingFormat, } } @@ -181,13 +240,18 @@ type EmbeddingRequestTokens struct { Model EmbeddingModel `json:"model"` // A unique identifier representing your end-user, which will help OpenAI to monitor and detect abuse. User string `json:"user"` + // EmbeddingEncodingFormat is the format of the embeddings data. + // Currently, only "float" and "base64" are supported, however, "base64" is not officially documented. + // If not specified OpenAI will use "float". + EncodingFormat EmbeddingEncodingFormat `json:"encoding_format,omitempty"` } func (r EmbeddingRequestTokens) Convert() EmbeddingRequest { return EmbeddingRequest{ - Input: r.Input, - Model: r.Model, - User: r.User, + Input: r.Input, + Model: r.Model, + User: r.User, + EncodingFormat: r.EncodingFormat, } } @@ -203,7 +267,34 @@ func (c *Client) CreateEmbeddings(ctx context.Context, conv EmbeddingRequestConv return } - err = c.sendRequest(req, &res) + var embeddingResponse any = &EmbeddingResponse{} + if baseReq.EncodingFormat == EmbeddingEncodingFormatBase64 { + embeddingResponse = &embeddingResponseBase64{} + } + + err = c.sendRequest(req, embeddingResponse) + if err != nil { + return + } + + if baseReq.EncodingFormat == EmbeddingEncodingFormatBase64 { + res, err = embeddingResponse.(*embeddingResponseBase64).ToEmbeddingResponse() + return + } return } + +func decodeBase64EmbeddingToFloat32Embedding(data string) ([]float32, error) { + decodedData, err := base64.StdEncoding.DecodeString(data) + if err != nil { + return nil, err + } + + floats := make([]float32, len(decodedData)/4) + for i := 0; i < len(floats); i++ { + floats[i] = math.Float32frombits(binary.LittleEndian.Uint32(decodedData[i*4 : (i+1)*4])) + } + + return floats, nil +} From 7009b74f0855f61440af5f632763643424f30c2f Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Sat, 2 Sep 2023 02:07:18 +0200 Subject: [PATCH 02/17] fix: add sizeOfFloat32 --- embeddings.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/embeddings.go b/embeddings.go index 93270a57a..923ce7c39 100644 --- a/embeddings.go +++ b/embeddings.go @@ -291,7 +291,8 @@ func decodeBase64EmbeddingToFloat32Embedding(data string) ([]float32, error) { return nil, err } - floats := make([]float32, len(decodedData)/4) + const sizeOfFloat32 = 4 + floats := make([]float32, len(decodedData)/sizeOfFloat32) for i := 0; i < len(floats); i++ { floats[i] = math.Float32frombits(binary.LittleEndian.Uint32(decodedData[i*4 : (i+1)*4])) } From 5f1acebf1b5656315b310c325f0fd442102f49ab Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Sat, 2 Sep 2023 02:33:09 +0200 Subject: [PATCH 03/17] chore: refactor base64 decoding --- embeddings.go | 59 ++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/embeddings.go b/embeddings.go index 923ce7c39..0083da18d 100644 --- a/embeddings.go +++ b/embeddings.go @@ -4,6 +4,7 @@ import ( "context" "encoding/base64" "encoding/binary" + "fmt" "math" "net/http" ) @@ -132,27 +133,46 @@ type EmbeddingResponse struct { Usage Usage `json:"usage"` } -// base64Embedding is a container for base64 encoded embeddings. -type base64Embedding struct { - Object string `json:"object"` - Embedding string `json:"embedding"` - Index int `json:"index"` +type base64String string + +func (b base64String) Decode() ([]float32, error) { + + fmt.Println(b) + decodedData, err := base64.StdEncoding.DecodeString(string(b)) + if err != nil { + return nil, err + } + + const sizeOfFloat32 = 4 + floats := make([]float32, len(decodedData)/sizeOfFloat32) + for i := 0; i < len(floats); i++ { + floats[i] = math.Float32frombits(binary.LittleEndian.Uint32(decodedData[i*4 : (i+1)*4])) + } + + return floats, nil +} + +// Base64Embedding is a container for base64 encoded embeddings. +type Base64Embedding struct { + Object string `json:"object"` + Embedding base64String `json:"embedding"` + Index int `json:"index"` } -// embeddingResponseBase64 is the response from a Create embeddings request with base64 encoding format. -type embeddingResponseBase64 struct { +// EmbeddingResponseBase64 is the response from a Create embeddings request with base64 encoding format. +type EmbeddingResponseBase64 struct { Object string `json:"object"` - Data []base64Embedding `json:"data"` + Data []Base64Embedding `json:"data"` Model EmbeddingModel `json:"model"` Usage Usage `json:"usage"` } // ToEmbeddingResponse converts an embeddingResponseBase64 to an EmbeddingResponse. -func (r *embeddingResponseBase64) ToEmbeddingResponse() (EmbeddingResponse, error) { +func (r *EmbeddingResponseBase64) ToEmbeddingResponse() (EmbeddingResponse, error) { data := make([]Embedding, len(r.Data)) for i, base64Embedding := range r.Data { - embedding, err := decodeBase64EmbeddingToFloat32Embedding(base64Embedding.Embedding) + embedding, err := base64Embedding.Embedding.Decode() if err != nil { return EmbeddingResponse{}, err } @@ -269,7 +289,7 @@ func (c *Client) CreateEmbeddings(ctx context.Context, conv EmbeddingRequestConv var embeddingResponse any = &EmbeddingResponse{} if baseReq.EncodingFormat == EmbeddingEncodingFormatBase64 { - embeddingResponse = &embeddingResponseBase64{} + embeddingResponse = &EmbeddingResponseBase64{} } err = c.sendRequest(req, embeddingResponse) @@ -278,24 +298,9 @@ func (c *Client) CreateEmbeddings(ctx context.Context, conv EmbeddingRequestConv } if baseReq.EncodingFormat == EmbeddingEncodingFormatBase64 { - res, err = embeddingResponse.(*embeddingResponseBase64).ToEmbeddingResponse() + res, err = embeddingResponse.(*EmbeddingResponseBase64).ToEmbeddingResponse() return } return } - -func decodeBase64EmbeddingToFloat32Embedding(data string) ([]float32, error) { - decodedData, err := base64.StdEncoding.DecodeString(data) - if err != nil { - return nil, err - } - - const sizeOfFloat32 = 4 - floats := make([]float32, len(decodedData)/sizeOfFloat32) - for i := 0; i < len(floats); i++ { - floats[i] = math.Float32frombits(binary.LittleEndian.Uint32(decodedData[i*4 : (i+1)*4])) - } - - return floats, nil -} From 38b1b57ed5809b72f0407ea1cbe8257d591fdf5a Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Sat, 2 Sep 2023 02:33:17 +0200 Subject: [PATCH 04/17] chore: add tests --- embeddings_test.go | 1606 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 1603 insertions(+), 3 deletions(-) diff --git a/embeddings_test.go b/embeddings_test.go index 47c4f5108..efca82871 100644 --- a/embeddings_test.go +++ b/embeddings_test.go @@ -1,15 +1,16 @@ package openai_test import ( - . "github.com/sashabaranov/go-openai" - "github.com/sashabaranov/go-openai/internal/test/checks" - "bytes" "context" "encoding/json" "fmt" "net/http" + "reflect" "testing" + + . "github.com/sashabaranov/go-openai" + "github.com/sashabaranov/go-openai/internal/test/checks" ) func TestEmbedding(t *testing.T) { @@ -108,6 +109,15 @@ func TestEmbeddingEndpoint(t *testing.T) { _, err := client.CreateEmbeddings(context.Background(), EmbeddingRequest{}) checks.NoError(t, err, "CreateEmbeddings error") + // test create embeddings with strings (simple embedding request) + _, err = client.CreateEmbeddings( + context.Background(), + EmbeddingRequest{ + EncodingFormat: EmbeddingEncodingFormatBase64, + }, + ) + checks.NoError(t, err, "CreateEmbeddings error") + // test create embeddings with strings _, err = client.CreateEmbeddings(context.Background(), EmbeddingRequestStrings{}) checks.NoError(t, err, "CreateEmbeddings strings error") @@ -116,3 +126,1593 @@ func TestEmbeddingEndpoint(t *testing.T) { _, err = client.CreateEmbeddings(context.Background(), EmbeddingRequestTokens{}) checks.NoError(t, err, "CreateEmbeddings tokens error") } + +func TestEmbeddingResponseBase64_ToEmbeddingResponse(t *testing.T) { + type fields struct { + Object string + Data []Base64Embedding + Model EmbeddingModel + Usage Usage + } + tests := []struct { + name string + fields fields + want EmbeddingResponse + wantErr bool + }{ + { + name: "test embedding response base64 to embedding response", + fields: fields{ + Data: []Base64Embedding{ + { + Embedding: "/1jku0G/rLvA/EI8Fq3MvCUnybz9gSI9HiQmvOxZG7zgAVm8Z/AjvPyZPLyMxf47kaZnvLGr/TtNQCY89kSku9/wuzzwe9W69IV1PAN0KLxsNJ87h1hMPB9vnjvdQjE8gcnYuzD6t7nGi7Y7bahOvBkahjxVGpI7zo7ZOyox6bvIYni8EB7Zu/zTl7xtHIU7Nk9QO+xZm7zIYvg80J/2uz4ABTzsWRs8u4+QuvDe57lvyg+8BUvqvGYIPjtbDBg8Zd+GPEy70juuw5485lZxPC4S0rzOZSK84AFZu98ZczzfKhe9VlRmPHJPXDzOApA7fqeeu3vXUjv95DS8AsYdO5GmZ7y6RJi8MF3KvNpyZbsdwZM8RPIKPGGbCz2G03g8tYxmPKmo2rtvkLQ8jDm1PBScrzt4GKs8oDEIPA3CQ7zdzvo7M1bNvCcPLzzag4k8vT0bPJQTIbqolz272SftPGXfBr2jfPm8PAf7OwB7pTx5YyM8ffmTPCi9ubviwAc8A3QovDvNpjzGi7Y8F88NvcvPsTvrN1o8R+uNvMxUBbxb+/O8qRyRPAIpsDx7S4m8W6mFPB9eejtysu68b/NGPMm+lLx2B4681mhFO1ZlijzAmTA8mONlvBScr7wK8ve8GisjPHjeTzztSPc8OHGRvCKR2DxHTqA8vQPAu0JEAL1qEt47Sjb/upVeGT2pRcg8YWEwPJ2Kczx3k1e8M/O6PO6kE72+6yU7r5rgvM/ZUbw5SFM8YNzcPLLNPjvCqk27bahOPEqqNTwDERa7g04svNIMsDyJBle8KggyuzbDhju78qI7NhV1vM8TLbyb7Yw8XmitO6R1AzwL6wE79IX1vBBYNDzpYBg8VmWKPKwEcLxzDgs9EWlRPfzCc7uGR687RBvCu7KkB7xjOPK8R9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tnqK8PlLzvBf4xDwqzlY7xu7IO4RfSTz8wvO8SnDavBYhg7zooem8G/HHPBghfLzZYcg6m+2MvIf1OT33LAq8cNssvGHEwrwLd0s8ES/2ucDTi7zFBmM8xReHOs92P7zj+lu8340pu9SRg7s7ahQ9fJaBPOz2iDwbt2y81IBfPKpnCbzDkrM8qX8jPNRXqDuRpme8Vo5BO2kq+DxV4LY8tQAdvHBndrpFPQO8Ii5GOxcyoLymr1c8Dfyeuw5HFzkkFiw8LcfZO4Es6zour787/MJzPPmguTwLTpQ7QqcSvEy70jqay8u7bDSfu9ezPbl4tRi9jMX+vMzgTjwQkg+7nqw0vIOIB7xSIQ893XyMPNUFs7zA/MI8XUbsOgW/ILzaD9O8tN7bPEuSm7oLPfA70YfcPBdbV7wNiGg81IBfO+iyDTwAQcq8Ye35O2FhMDuNIRu8Qm03O/k9p7vlHJ28My0WOlBzBDwwlyW8VRoSPW0L4bukO6g9RT0Du68OF7vGxRE86f2Fu0hfvTwl/hE8eBirPJjjZbz5oDk7ugo9PJKOTTtQcwS8yBAKvIOIh7z8/E686Sa9u9/HhDzIEIq8lwwkPLpEmDxma1A8UzKsPIbTeDwWrUy8iu68vIruvDy0QW68MCNvvHik9LztH0C8deXMuqmo2ryvqwS85X8vPJB9MDxq6aa7BqcGvev9frtqdXA8aWRTO67s1TzuBya8w1hYu4+VyrnzrjM8AmOLvERVnbimTMW8", + }, + }, + }, + want: EmbeddingResponse{ + Data: []Embedding{ + { + Embedding: []float32{ + + -0.006968617, + -0.0052718227, + 0.011901081, + -0.024984878, + -0.024554798, + 0.039674748, + -0.010140447, + -0.009481888, + -0.013245076, + -0.010006047, + -0.011511322, + 0.0077750143, + -0.014138834, + 0.0077414145, + 0.010147166, + -0.0050131036, + 0.022942005, + -0.0016287547, + 0.01498555, + -0.010281566, + 0.004858544, + 0.012472278, + 0.004835024, + 0.010819164, + -0.006615818, + -0.00035090884, + 0.0055708615, + -0.012613398, + 0.016369866, + 0.0044587054, + 0.006639338, + -0.0071164565, + -0.01516027, + -0.006625898, + -0.0185337, + 0.0040622265, + 0.0031785495, + -0.018963777, + 0.03032054, + -0.0075263754, + 0.0081177335, + 0.009481888, + -0.0011029163, + -0.00044225855, + -0.008776291, + -0.028600225, + 0.0028996705, + 0.0092802895, + 0.016463945, + 0.006431019, + 0.019380417, + 0.014730191, + -0.025643434, + -0.009911967, + -0.003311269, + 0.014837711, + -0.03690612, + 0.014058193, + 0.013446676, + 0.0043948656, + -0.004841744, + 0.0032171893, + -0.011040923, + 0.002407432, + -0.014138834, + -0.018587459, + -0.024702638, + -0.0035011084, + 0.01803642, + 0.008480612, + 0.034083728, + 0.01518715, + 0.014071633, + -0.006672938, + 0.022041528, + 0.022122167, + 0.005359182, + 0.020885691, + 0.008312613, + -0.011948121, + 0.0076540546, + -0.025065517, + 0.010684765, + 0.016786505, + 0.009475169, + -0.000614458, + -0.0028929505, + 0.028949665, + -0.03292789, + -0.03045494, + 0.0076607745, + 0.020200253, + 0.009972447, + 0.018063301, + -0.005668301, + 0.008285733, + -0.010281566, + 0.020361533, + 0.022283446, + -0.034621324, + 0.005426382, + 0.013318996, + -0.017324103, + -0.008137893, + -0.029782942, + 0.017713862, + 0.021503929, + -0.016759625, + 0.016316107, + 0.0038203073, + -0.029137824, + 0.012143, + -0.01815738, + -0.017337542, + 0.0030122302, + 0.016894024, + 0.010778844, + -0.014031313, + -0.021436729, + -0.03026678, + 0.009959007, + 0.012687318, + 0.03018614, + -0.017754182, + 0.026436392, + 0.019568576, + -0.0058598206, + -0.031315096, + 0.0067770975, + -0.0019471135, + 0.037443716, + 0.024447279, + 0.010765404, + 0.014864591, + -0.013157717, + 0.022821045, + -0.03604596, + 0.0025317515, + -0.027417509, + -0.012808277, + 0.012895637, + 0.026960552, + 0.0029114303, + -0.0031382297, + 0.012613398, + 0.011087963, + -0.0022898323, + -0.0105167655, + 0.021490488, + -0.013124117, + -0.002716551, + 0.0041126264, + 0.0049727834, + -0.01495867, + -0.010563805, + 0.017203143, + 0.0052919826, + 0.008023653, + 0.0019823934, + -0.0299711, + 0.011007324, + 0.009300449, + 0.016894024, + -0.014649551, + 0.033949327, + 0.05112559, + -0.0037195077, + 0.0053491024, + -0.0059236605, + -0.0082790125, + -0.029567903, + 0.028546466, + -0.06413547, + 0.0126066785, + -0.041368183, + 0.0038471874, + 0.026181033, + 0.013345876, + -0.02076473, + -0.018990656, + -0.03994355, + 0.0023335123, + 0.0050534233, + 0.025186477, + -0.02720247, + -0.013964114, + 0.000013433393, + 0.0040723067, + 0.0007723775, + 0.00298199, + 0.016719304, + 0.022095287, + 0.009246689, + -0.0080438135, + -0.68941593, + -0.0038740672, + 0.020710971, + -0.026328873, + 0.025670316, + 0.03843827, + 0.00089207705, + 0.018560579, + -0.025589675, + 0.020670652, + -0.019125057, + -0.0024998318, + -0.010940124, + -0.01227068, + 0.0028946304, + -0.012673878, + 0.010335326, + -0.0065788585, + -0.014770512, + 0.008265573, + 0.005171023, + 0.032444052, + 0.0016900745, + 0.014273233, + 0.019044418, + -0.00006415479, + 0.009905247, + -0.018775618, + -0.001812714, + 0.031906456, + -0.029460382, + -0.003275989, + -0.0025703914, + 0.010610845, + 0.061017398, + -0.020549692, + -0.009488609, + -0.0049492638, + -0.005453262, + 0.0018479939, + -0.0181977, + -0.026127273, + 0.02106041, + -0.0044519855, + 0.005832941, + -0.0040555065, + 0.0049459036, + -0.02114105, + 0.005251663, + 0.005681741, + 0.0018849538, + -0.0018983937, + 0.010866204, + -0.0013549156, + 0.014757072, + 0.009730528, + 0.043303538, + -0.016544586, + 0.0012490759, + 0.015523149, + -0.0038875071, + 0.022135606, + -0.029057184, + -0.013661715, + 0.0028324707, + 0.009488609, + -0.0120086, + 0.006595658, + 0.009710368, + -0.005785901, + 0.015778508, + 0.013896914, + -0.020321213, + -0.0061185397, + 0.002054633, + 0.026637992, + 0.018654658, + -0.009488609, + -0.020603452, + 0.0181977, + 0.006676298, + -0.0036052682, + -0.023130164, + -0.016598346, + 0.025388077, + -0.00601102, + -0.022229686, + 0.009495328, + 0.0067636576, + 0.0046535847, + 0.013083797, + 0.010852764, + -0.008171493, + -0.0014019554, + 0.0041697463, + 0.005869901, + -0.00004504485, + 0.014259793, + -0.007801894, + -0.0038471874, + -0.014824271, + 0.015818827, + -0.028358307, + 0.005382702, + 0.0077548544, + -0.0015187149, + -0.0032373492, + 0.019219136, + 0.03311605, + -0.02376184, + -0.0061689396, + -0.008668771, + -0.0028677506, + -0.0133861955, + -0.0066998177, + -0.023896242, + 0.010180767, + 0.005517102, + 0.023721522, + -0.00026375914, + 0.020952892, + -0.002729991, + -0.00298199, + 0.0012877157, + 0.026785832, + 0.008144613, + 0.0076271747, + -0.02134265, + -0.022296887, + -0.003964787, + 0.007519655, + -0.000922317, + 0.05429742, + -0.016988104, + 0.025199916, + -0.002464552, + 0.01847994, + -0.00085049716, + 0.016020427, + -0.005443182, + -0.019985214, + 0.015254349, + -0.017579462, + 0.006558698, + 0.010557085, + -0.0183993, + -0.018762179, + -0.007163496, + 0.009468448, + -0.010375646, + 0.0019807136, + -0.012552919, + -0.024581678, + 0.026691752, + 0.012237079, + -0.01790202, + 0.0047879843, + -0.015791947, + -0.0076540546, + -0.02147705, + -0.0018748738, + 0.011397082, + -0.011047644, + 0.016208587, + -0.010120287, + -0.004559505, + -0.037820034, + 0.013406356, + -0.016517706, + -0.026476713, + -0.0031802296, + -0.02084537, + -0.005769101, + -0.00022112927, + -0.013977554, + -0.0043545454, + -0.019958334, + -0.0020227134, + 0.022995764, + -0.016369866, + 0.008655331, + 0.013755795, + -0.002741751, + 0.015281229, + 0.016463945, + 0.014273233, + -0.0018496739, + 0.015791947, + 0.0077078147, + -0.01798266, + 0.0037430276, + -0.013466836, + -0.013493716, + 0.0005195383, + -0.011491162, + 0.00039983867, + -0.007976614, + 0.03026678, + 0.017377863, + 0.008756131, + 0.03362677, + 0.0062697395, + 0.042873457, + -0.025670316, + -0.0045796647, + -0.02162489, + 0.002414152, + -0.022270007, + 0.01803642, + 0.012633558, + 0.003911027, + -0.02126201, + -0.01212956, + 0.010100126, + 0.015308109, + 0.025871914, + -0.007297896, + 0.007781734, + -0.0019504735, + 0.008198373, + 0.004942544, + -0.006723338, + 0.0041059065, + -0.0124588385, + -0.013379476, + 0.0057220613, + 0.026651433, + 0.03580404, + 0.0056649414, + -0.02370808, + -0.0031751895, + -0.003944627, + 0.0008546972, + 0.010933404, + 0.013829715, + 0.017686982, + 0.029137824, + 0.0008861971, + 0.029003425, + -0.0035246282, + -0.010745244, + 0.023103284, + 0.018775618, + -0.007371816, + 0.0244204, + 0.004495665, + 0.020186814, + 0.0014783951, + -0.019608894, + 0.009972447, + -0.011141723, + 0.012700758, + -0.031691417, + -0.006326859, + 0.021436729, + -0.013292116, + 0.00009911967, + 0.013345876, + 0.026140714, + 0.018842818, + 0.015751628, + -0.019017538, + -0.0044654254, + -0.00064973783, + 0.018977217, + -0.009932127, + -0.014111954, + -0.0045931046, + -0.016907465, + 0.014232913, + -0.0072306963, + -0.0070425365, + 0.035132043, + -0.008252133, + 0.02427256, + -0.00027656907, + 0.009528928, + -0.0009357569, + -0.016894024, + 0.004310866, + 0.0014599152, + -0.044298094, + 0.0073180557, + 0.007244136, + -0.002093273, + -0.019380417, + -0.03368053, + 0.037363075, + 0.003934547, + 0.0009962367, + 0.00033767888, + 0.00900477, + 0.02076473, + 0.002152073, + 0.00068081776, + 0.023425842, + 0.013359316, + -0.028707745, + -0.0020411932, + 0.0015716348, + 0.008238693, + 0.017337542, + -0.0038606273, + -0.027793828, + 0.030831259, + -0.0071030166, + 0.0055003017, + 0.021893688, + 0.006696458, + -0.009999327, + 0.0059942203, + 0.01847994, + -0.0038505474, + -0.02390968, + 0.02411128, + 0.0071231765, + -0.019461056, + -0.004542705, + 0.034701966, + 0.013775954, + -0.0035582283, + -0.029164704, + -0.019313216, + 0.0055137416, + 0.062576436, + 0.021356089, + -0.0045796647, + -0.0040958263, + 0.0072306963, + 0.005372622, + -0.010745244, + -0.03327733, + 0.00891069, + -0.021651769, + -0.0017421542, + 0.0044217454, + 0.015402189, + 0.0068778973, + 0.015845709, + -0.0034070287, + 0.010725085, + -0.0068039773, + -0.0013280356, + -0.023533363, + -0.009676768, + 0.027471269, + 0.012741078, + 0.0046300646, + 0.01770042, + 0.0001832244, + 0.0046502245, + 0.010718364, + 0.01212956, + -0.05150191, + -0.020173373, + 0.031449497, + 0.008050533, + 0.009952287, + -0.005120623, + 0.029110944, + -0.005459982, + -0.01494523, + 0.018748738, + -0.0020025533, + 0.021503929, + 0.019340096, + 0.017082183, + -0.015657548, + 0.009535649, + -0.0032591892, + 0.0020378332, + -0.00071609765, + -0.013883474, + -0.0036825477, + 0.0019991933, + -0.008077413, + -0.0074524553, + -0.023466162, + 0.008198373, + 0.009864927, + -0.009817887, + 0.0062260595, + -0.018883137, + -0.026530473, + 0.0077414145, + 0.008292452, + -0.0065788585, + -0.0037833476, + -0.018291779, + -0.013164436, + -0.00029378902, + 0.0037564675, + -0.02099321, + -0.00601438, + 0.0024964719, + 0.008144613, + 0.0014137153, + 0.013540755, + 0.013446676, + 0.0040219068, + 0.005144143, + -0.01537531, + -0.023291443, + -0.010731804, + -0.0013406356, + -0.0359922, + 0.0070022168, + -0.010167327, + -0.023587123, + 0.016611785, + 0.005419662, + 0.011551642, + 0.0052180625, + 0.011948121, + 0.02411128, + 0.003301189, + 0.006320139, + -0.016974663, + 0.0030945498, + -0.026785832, + 0.0019571935, + -0.034594446, + -0.010590685, + -0.019165376, + -0.0074121356, + -0.003329749, + 0.00598414, + -0.006545258, + 0.012431959, + 0.0025435116, + 0.008635172, + 0.031126937, + -0.014461393, + 0.019420736, + -0.00037064878, + 0.00056699815, + -0.010342046, + 0.00044351854, + -0.008265573, + 0.01186748, + 0.008796451, + -0.000047118596, + 0.008615011, + -0.022753844, + 0.025482155, + -0.059243325, + 0.01225724, + 0.029541023, + 0.000908877, + 0.014447953, + -0.011054363, + -0.012882197, + 0.0031382297, + -0.0062260595, + -0.009542368, + 0.005742221, + -0.01830522, + -0.014542032, + -0.029648542, + -0.0077481344, + -0.016074186, + 0.0037766276, + -0.018923458, + -0.0077682943, + -0.023869362, + 0.0023150323, + 0.008749411, + -0.000101219666, + -0.022310326, + -0.024702638, + 0.0037799876, + 0.01814394, + -0.0067938976, + 0.034379408, + 0.00091475697, + 0.0113702025, + -0.013910354, + -0.018291779, + 0.002113433, + -0.02720247, + -0.014085073, + -0.019756734, + 0.009858208, + 0.02417848, + 0.028600225, + -0.0043007857, + 0.012801558, + 0.004260466, + -0.015953228, + 0.0025031918, + 0.0025939115, + -0.011733081, + -0.018264899, + 0.011155163, + 0.005372622, + 0.023654321, + 0.01537531, + -0.009582688, + 0.004166386, + -0.01497211, + 0.012828438, + -0.016692424, + -0.013789395, + -0.024796719, + 0.0028996705, + 0.008359652, + -0.009320609, + 0.01220348, + -0.016652105, + 0.006746858, + 0.046206567, + 0.010570525, + 0.008675491, + 0.026960552, + 0.00031541896, + -0.0179961, + 0.012714198, + -0.0004481385, + 0.015496269, + -0.01838586, + -0.015079631, + -0.012378199, + 0.0017589541, + 0.030938778, + 0.016208587, + -0.0044116653, + -0.013023317, + 0.0073650954, + 0.001216316, + -0.017592901, + 0.0060043, + -0.0029651902, + 0.013500435, + -0.0049559837, + -0.031960215, + 0.0019739934, + -0.008373092, + -0.024742959, + -0.008366372, + 0.016060747, + -0.013520596, + 0.010886364, + -0.024124721, + -0.0068174177, + -0.002118473, + 0.0005031583, + 0.029836701, + 0.010711645, + 0.0010793965, + 0.0085881315, + -0.009938847, + -0.005480142, + 0.007580135, + -0.00899133, + -0.01198172, + 0.035105165, + 0.016988104, + 0.00296351, + -0.0017203143, + 0.015657548, + 0.022350647, + -0.016074186, + -0.019904574, + 0.015697869, + 0.013654995, + 0.0047006244, + -0.03935219, + -0.016302666, + -0.050480474, + 0.023385523, + 0.016477386, + -0.020254012, + -0.027874468, + 0.0005447382, + -0.040669307, + 0.025320876, + -0.01847994, + -0.0031197497, + 0.013124117, + -0.002430952, + -0.031207576, + 0.0066998177, + -0.0022360727, + 0.00016138447, + 0.006431019, + 0.034029968, + -0.013379476, + 0.014918351, + 0.0061386996, + 0.019622335, + -0.006306699, + -0.009663328, + 0.003339829, + 0.019918013, + -0.037443716, + -0.008843491, + -0.0043444657, + -0.0125327585, + 0.00902493, + -0.0062764594, + -0.017256903, + -0.003581748, + -0.015482829, + -0.011464282, + 0.011901081, + -0.003348229, + -0.021745848, + -0.0117532415, + 0.0043747057, + -0.022431286, + -0.013130836, + -0.011417243, + 0.013372756, + -0.026530473, + -0.024917677, + -0.0047107046, + 0.010812445, + 0.0052550226, + -0.0008769571, + -0.0065990184, + 0.019501375, + 0.037981313, + -0.0070290966, + 0.015294669, + 0.0018748738, + 0.0067569376, + -0.03346549, + 0.005826221, + 0.00024716917, + 0.00059765804, + 0.028600225, + -0.018560579, + -0.026409512, + 0.008890531, + -0.00300383, + 0.019971775, + 0.013198037, + -0.009031651, + -0.008608292, + 0.02136953, + -0.0013473555, + -0.0085881315, + -0.02416504, + 0.021665208, + 0.008655331, + -0.005372622, + 0.00610846, + -0.016463945, + 0.0014867951, + -0.0100598065, + -0.0034507087, + 0.009481888, + -0.02454136, + -0.034029968, + -0.0014506752, + 0.001232276, + 0.004425105, + -0.026154153, + -0.019098178, + -0.015966667, + -0.0013641554, + -0.0070358166, + -0.005863181, + 0.0013145957, + -0.00905181, + 0.005140783, + -0.011652442, + 0.028707745, + -0.015818827, + -0.01845306, + -0.021544248, + 0.00010090467, + -0.02709495, + -0.025509035, + -0.009145889, + 0.025509035, + 0.015066191, + -0.0090450905, + -0.012048921, + -0.013043477, + -0.028223908, + -0.011007324, + -0.004052147, + 0.001846314, + 0.020697532, + 0.0087359715, + -0.003338149, + 0.03290101, + 0.00040193868, + 0.027713189, + -0.0068778973, + 0.00045065852, + -0.0072172564, + -0.007996773, + 0.0037497475, + 0.008628451, + 0.0007370976, + -0.014461393, + 0.038626432, + 0.014609232, + 0.0051475028, + 0.017189704, + 0.0026073514, + -0.007882534, + -0.0133861955, + -0.0028862304, + -0.0062294193, + 0.010469725, + 0.0049828636, + -0.009381089, + -0.013332436, + 0.0031903095, + -0.006928297, + -0.00013670955, + 0.014488272, + 0.0093542095, + 0.0126066785, + 0.0098985275, + -0.010617565, + 0.0018496739, + -0.016853705, + -0.015751628, + 0.025414957, + -0.000895437, + -0.025173036, + 0.020240573, + 0.0008412572, + -0.0043982253, + -0.023318322, + 0.03040118, + -0.018977217, + -0.013164436, + -0.007600295, + -0.017028423, + -0.033546127, + 0.0012549559, + -0.007559975, + -0.010221086, + -0.0034507087, + -0.0052550226, + -0.025535915, + -0.025965994, + -0.0038807872, + 0.005402862, + -0.031879574, + -0.04518513, + -0.013648275, + 0.027740069, + -0.010006047, + -0.009293729, + -0.0068946974, + -0.012888918, + 0.012304279, + 0.013722194, + -0.0005459982, + -0.01215644, + 0.031073177, + 0.016087627, + -0.011101403, + 0.02710839, + 0.23052211, + -0.01537531, + 0.015402189, + 0.03959411, + 0.0055775815, + 0.026584232, + 0.0029047104, + 0.0020294334, + -0.014716751, + 0.003900947, + -0.008809891, + -0.0017203143, + 0.019017538, + -0.00605134, + 0.025535915, + 0.007889254, + -0.019192256, + -0.014058193, + -0.015738187, + -0.029514143, + 0.008695651, + 0.002162153, + -0.0018530339, + -0.021813048, + 0.0061487798, + -0.0058732606, + -0.0135340355, + -0.0122975595, + 0.027444389, + 0.018950338, + -0.0070358166, + -0.00921309, + 0.021517368, + 0.0049862233, + -0.017431622, + 0.011565082, + 0.0089711705, + -0.0044284654, + 0.028519586, + 0.02710839, + 0.011195483, + -0.0004489785, + -0.012828438, + -0.019595455, + -0.008467172, + 0.017431622, + -0.0023200724, + -0.008715811, + -0.01200188, + -0.0043377457, + 0.008776291, + 0.0042134263, + 0.0112962825, + 0.012774678, + 0.012747798, + -0.002694711, + 0.024890797, + -0.011249243, + -0.031879574, + 0.024326319, + -0.001216316, + 0.016517706, + -0.004764464, + 0.009938847, + -0.014165713, + -0.006407499, + 0.007271016, + -0.0047174245, + 0.0052819024, + 0.0011071163, + 0.0009676768, + -0.016880585, + -0.002743431, + -0.007506215, + -0.030858139, + -0.010489886, + -0.002110073, + 0.019797055, + 0.031825814, + 0.018412739, + -0.027551908, + -0.0128418775, + 0.010483165, + -0.025455276, + -0.025186477, + -0.029809821, + 0.0017404743, + -0.013668435, + -0.010819164, + -0.0084268525, + -0.011121564, + -0.016396746, + -0.009569248, + -0.0060815797, + 0.002141993, + -0.008023653, + -0.017230023, + 0.028815264, + 0.007291176, + 0.0073247757, + -0.029110944, + 0.020388413, + 0.01202204, + 0.013601235, + -0.0127679575, + -0.010819164, + -0.012431959, + 0.011289563, + 0.006935017, + -0.01503931, + -0.0034103887, + 0.011047644, + 0.012956117, + 0.004818224, + -0.013668435, + 0.0062260595, + 0.01538875, + -0.013896914, + 0.0038303873, + -0.00095171685, + -0.009643168, + -0.019528255, + -0.00607822, + -0.00082445727, + -0.0070156567, + -0.0129157975, + -0.013520596, + -0.018842818, + 0.012888918, + -0.024447279, + 0.0050399834, + 0.010785565, + 0.010725085, + -0.0030777499, + -0.007976614, + 0.005160943, + 0.0025283915, + -0.00900477, + -0.011887641, + 0.03316981, + -0.0012826758, + -0.008494052, + 0.0068274974, + 0.0001803894, + 0.011820441, + -0.034406286, + -0.00299879, + -0.010120287, + -0.0077682943, + -0.01835898, + -0.028600225, + -0.013258516, + -0.015899468, + -0.00076733745, + 0.020509372, + -0.016450506, + -0.031368855, + -0.025912235, + 0.013453395, + 0.00012536958, + -0.02116793, + 0.0050265435, + 0.029299103, + -0.014609232, + 0.004505745, + -0.0037732676, + -0.1762247, + 0.001505275, + 0.007055977, + -0.011309722, + 0.019004097, + -0.013271956, + 0.00303239, + 0.0011171963, + -0.002758551, + 0.015926348, + -0.00037295878, + -0.010839324, + -0.04319602, + -0.012868757, + -0.016423626, + 0.016786505, + -0.027874468, + 0.0041563064, + 0.011618841, + 0.030696858, + 0.017660102, + -0.0050769434, + 0.020052414, + -0.020227132, + 0.0014582352, + 0.001517875, + 0.009777567, + 0.031987093, + 0.005120623, + -0.0091324495, + -0.0063402993, + -0.0104428455, + -0.007855654, + 0.005036623, + 0.027525028, + -0.011665882, + 0.0047241445, + -0.026987432, + -0.014918351, + 0.025186477, + 0.033841807, + 0.032175254, + 0.0028963105, + -0.013036757, + 0.004179826, + 0.016786505, + 0.018439619, + -0.010180767, + 0.011659161, + -0.005806061, + 0.01220348, + -0.043222897, + 0.0015220749, + -0.017216584, + 0.00305255, + 0.023869362, + -0.011544921, + -0.012317719, + 0.009549089, + 0.02416504, + 0.0037060678, + -0.021033531, + 0.016450506, + 0.010590685, + 0.013251796, + -0.017203143, + -0.009643168, + 0.009777567, + -0.014689871, + 0.018600898, + -0.024286, + -0.017942341, + 0.0035044684, + -0.011524762, + 0.012814998, + -0.010637725, + -0.022740405, + 0.026637992, + -0.0027652709, + -0.02122169, + -0.021517368, + 0.03327733, + -0.01509307, + 0.01782138, + 0.012190039, + 0.022054967, + -0.004499025, + 0.0037396676, + 0.002740071, + 0.0006404979, + 0.03255157, + -0.0061219, + -0.010261406, + -0.014165713, + 0.022162486, + 0.016396746, + 0.015482829, + 0.002180633, + -0.00035258883, + -0.00059387804, + -0.013816275, + -0.034029968, + -0.011907801, + 0.0034910284, + 0.019313216, + 0.008413413, + 0.011269403, + 0.00068081776, + 0.0043444657, + -0.019676095, + -0.031180697, + 0.017404743, + 0.019797055, + 0.029030304, + -0.00061739795, + 0.010960284, + -0.026019754, + -0.021584569, + 0.00900477, + 0.016988104, + 0.037604995, + -0.005785901, + -0.005510382, + 0.014501712, + -0.00015875947, + -0.012143, + -0.06531818, + -0.021880249, + 0.010967004, + 0.028761504, + 0.003598548, + 0.017001543, + -0.00066359784, + 0.005869901, + -0.000609838, + -0.0028744705, + -0.0040319865, + -0.029433502, + -0.025616555, + -0.013480276, + 0.013708754, + -0.008803171, + 0.0024914318, + -0.002057993, + -0.000905517, + 0.022646325, + -0.014810831, + -0.019743295, + 0.0018513539, + -0.0181305, + -0.009461729, + -0.0002122043, + -0.034460045, + 0.035239562, + 0.016961224, + -0.010967004, + -0.0076204548, + -0.0044452655, + 0.02682615, + -0.019205697, + -0.022081846, + 0.0070290966, + -0.044486254, + -0.004519185, + 0.021786168, + -0.02718903, + -0.0071500563, + 0.008346212, + -0.001800954, + -0.023143604, + -0.015832268, + -0.0037900675, + -0.007922854, + 0.041153144, + 0.0058766208, + -0.020428732, + -0.030858139, + -0.009938847, + -0.029110944, + -0.020737851, + 0.023278004, + 0.0028610306, + 0.026248233, + 0.0019420736, + -0.02443384, + -0.00037757875, + 0.0071231765, + -0.016504265, + -0.005379342, + 0.017310662, + 0.012680599, + 0.009502049, + -0.011807001, + 0.0048887837, + 0.011766681, + 0.0053054225, + -0.008944291, + 0.008245413, + -0.014206033, + 0.025589675, + -0.01782138, + -0.0058967806, + -0.023022644, + -0.030508699, + 0.023224244, + 0.0014254752, + -0.017095624, + -0.02093945, + -0.0013943954, + -0.019474495, + 0.005782541, + 0.019487936, + -0.0054062223, + 0.008191653, + 0.0035716682, + -0.026396073, + 0.014138834, + 0.044190574, + 0.0065284586, + -0.02084537, + -0.008063973, + -0.0051844628, + 0.010328606, + 0.0070223766, + 0.011571802, + -0.0022192728, + -0.028976545, + -0.023479603, + -0.06392043, + 0.025845034, + 0.008373092, + -0.008500772, + -0.008225253, + -0.008883811, + -0.010967004, + -0.0053356625, + -0.014246353, + 0.005728781, + -0.00029336903, + -0.005345742, + 0.008957731, + -0.0034708686, + -0.018090181, + 0.0064746984, + 0.021436729, + -0.008675491, + 0.024729518, + 0.0047443043, + -0.010355486, + -0.0105167655, + 0.00013838954, + -0.0009374369, + -0.0061655794, + 0.015254349, + -0.03916403, + 0.018990656, + -0.010832604, + -0.01513339, + 0.010812445, + -0.03282037, + -0.0038807872, + 0.01498555, + -0.0052819024, + -0.0031365496, + -0.0077548544, + 0.044755053, + 0.0044486253, + -0.0012238759, + -0.00302231, + -0.022659766, + -0.003625428, + -0.019259457, + 0.00613534, + 0.020401852, + -0.019850815, + -0.029702302, + 0.02404408, + 0.0032776692, + 0.0061319796, + 0.012290839, + -0.029756062, + -0.026664872, + -0.016006988, + -0.028519586, + 0.02440696, + -0.01538875, + 0.001528795, + -0.017203143, + 0.04540017, + -0.008433572, + -0.010550365, + -0.023775281, + 0.012418519, + -0.00046955844, + -0.017068744, + 0.013856594, + 0.0010306766, + -0.011686041, + -0.013426515, + -0.0025871915, + -0.004015187, + 0.03623412, + 0.015818827, + 0.016719304, + -0.014447953, + 0.013641555, + -0.008386532, + 0.021920567, + 0.009979167, + 0.005137423, + -0.014138834, + 0.0029534302, + 0.03029366, + 0.022323767, + -0.009582688, + -0.00093995687, + -0.008010213, + 0.00302399, + -0.019555135, + 0.013164436, + -0.004851824, + 0.00014426952, + 0.010503326, + 0.006646058, + 0.001794234, + 0.0058497405, + 0.014878031, + 0.022659766, + 0.004525905, + -0.00895101, + 0.0016077547, + -0.0062193396, + -0.004858544, + -0.0001809144, + -0.037282437, + -0.031100057, + 0.012626838, + -0.0021907128, + -0.011027483, + -0.008272293, + 0.034943886, + 0.017149383, + -0.021853367, + 0.023802161, + 0.0018026341, + -0.009811168, + -0.025764395, + 0.026839592, + -0.001186916, + 0.0073314956, + 0.026920231, + -0.013144276, + 0.014192593, + 0.0034103887, + 0.008648612, + -0.024689198, + 0.0076271747, + 0.002691351, + -0.009468448, + 0.0027988707, + -0.0051038233, + -0.019178817, + 0.0005728781, + 0.008084133, + -0.010106847, + 0.035669643, + -0.006867817, + 0.082145005, + -0.0020025533, + -0.0023049524, + 0.0088972505, + -0.0040891063, + 0.023116723, + 0.00891069, + 0.020885691, + -0.014031313, + 0.0028324707, + 0.011538202, + 0.0031365496, + -0.008084133, + -0.0084268525, + -0.016544586, + -0.012633558, + -0.0057724607, + 0.016208587, + -0.016853705, + 0.010012767, + 0.018587459, + 0.012720918, + 0.02102009, + 0.01518715, + -0.012492439, + -0.023062963, + 0.023062963, + -0.014542032, + -0.014595792, + -0.029863581, + -0.011726362, + -0.0015632348, + -0.026691752, + -0.008097573, + 0.010711645, + 0.010772124, + -0.005093743, + -0.03287413, + -0.003890867, + 0.014676431, + 0.0032255894, + 0.026113834, + -0.0101337265, + -0.003301189, + -0.00038639872, + 0.010967004, + -0.017014984, + -0.00007502225, + -0.0240844, + }, + }, + }, + }, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + r := &EmbeddingResponseBase64{ + Object: tt.fields.Object, + Data: tt.fields.Data, + Model: tt.fields.Model, + Usage: tt.fields.Usage, + } + got, err := r.ToEmbeddingResponse() + if (err != nil) != tt.wantErr { + t.Errorf("EmbeddingResponseBase64.ToEmbeddingResponse() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("EmbeddingResponseBase64.ToEmbeddingResponse() = %v, want %v", got, tt.want) + } + }) + } +} From 3233e0ca641ec63c38c495508f09a85ac24d992d Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Sat, 2 Sep 2023 02:35:10 +0200 Subject: [PATCH 05/17] fix linting --- embeddings.go | 3 --- embeddings_test.go | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/embeddings.go b/embeddings.go index 0083da18d..c1d3147a7 100644 --- a/embeddings.go +++ b/embeddings.go @@ -4,7 +4,6 @@ import ( "context" "encoding/base64" "encoding/binary" - "fmt" "math" "net/http" ) @@ -136,8 +135,6 @@ type EmbeddingResponse struct { type base64String string func (b base64String) Decode() ([]float32, error) { - - fmt.Println(b) decodedData, err := base64.StdEncoding.DecodeString(string(b)) if err != nil { return nil, err diff --git a/embeddings_test.go b/embeddings_test.go index efca82871..69c82ec61 100644 --- a/embeddings_test.go +++ b/embeddings_test.go @@ -145,6 +145,7 @@ func TestEmbeddingResponseBase64_ToEmbeddingResponse(t *testing.T) { fields: fields{ Data: []Base64Embedding{ { + //nolint:lll Embedding: "/1jku0G/rLvA/EI8Fq3MvCUnybz9gSI9HiQmvOxZG7zgAVm8Z/Aj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8tQAdvHBndrpFPQO8Ii5GOxcyoLymr1c8Dfyeuw5HFzkkFiw8LcfZO4Es6zour787/MJzPPmguTwLTpQ7QqcSvEy70jqay8u7bDSfu9ezPbl4tRi9jMX+vMzgTjwQkg+7nqw0vIOIB7xSIQ893XyMPNUFs7zA/MI8XUbsOgW/ILzaD9O8tN7bPEuSm7oLPfA70YfcPBdbV7wNiGg81IBfO+iyDTwAQcq8Ye35O2FhMDuNIRu8Qm03O/k9p7vlHJ28My0WOlBzBDwwlyW8VRoSPW0L4bukO6g9RT0Du68OF7vGxRE86f2Fu0hfvTwl/hE8eBirPJjjZbz5oDk7ugo9PJKOTTtQcwS8yBAKvIOIh7z8/E686Sa9u9/HhDzIEIq8lwwkPLpEmDxma1A8UzKsPIbTeDwWrUy8iu68vIruvDy0QW68MCNvvHik9LztH0C8deXMuqmo2ryvqwS85X8vPJB9MDxq6aa7BqcGvev9frtqdXA8aWRTO67s1TzuBya8w1hYu4+VyrnzrjM8AmOLvERVnbimTMW8", }, }, From 071b654ebfe4dd3e019cab58a151abb6346a644a Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Sat, 2 Sep 2023 02:43:21 +0200 Subject: [PATCH 06/17] fix test --- embeddings_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/embeddings_test.go b/embeddings_test.go index 69c82ec61..1b44a6dcc 100644 --- a/embeddings_test.go +++ b/embeddings_test.go @@ -1697,6 +1697,18 @@ func TestEmbeddingResponseBase64_ToEmbeddingResponse(t *testing.T) { }, wantErr: false, }, + { + name: "Invalid embedding", + fields: fields{ + Data: []Base64Embedding{ + { + Embedding: "----", + }, + }, + }, + want: EmbeddingResponse{}, + wantErr: true, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { From 2a465a149c8f955f35844270f8bceb7ed3f8ae84 Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Sat, 2 Sep 2023 02:49:54 +0200 Subject: [PATCH 07/17] fix return error --- embeddings.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/embeddings.go b/embeddings.go index c1d3147a7..f5d6ab927 100644 --- a/embeddings.go +++ b/embeddings.go @@ -290,13 +290,9 @@ func (c *Client) CreateEmbeddings(ctx context.Context, conv EmbeddingRequestConv } err = c.sendRequest(req, embeddingResponse) - if err != nil { - return - } if baseReq.EncodingFormat == EmbeddingEncodingFormatBase64 { res, err = embeddingResponse.(*EmbeddingResponseBase64).ToEmbeddingResponse() - return } return From 18c19137bfdf5237f4a8b69a78d759afaead6739 Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Mon, 4 Sep 2023 18:17:30 +0200 Subject: [PATCH 08/17] fix: use smaller slice for tests --- embeddings_test.go | 1549 +------------------------------------------- 1 file changed, 4 insertions(+), 1545 deletions(-) diff --git a/embeddings_test.go b/embeddings_test.go index 1b44a6dcc..100e86f70 100644 --- a/embeddings_test.go +++ b/embeddings_test.go @@ -144,1555 +144,14 @@ func TestEmbeddingResponseBase64_ToEmbeddingResponse(t *testing.T) { name: "test embedding response base64 to embedding response", fields: fields{ Data: []Base64Embedding{ - { - //nolint:lll - Embedding: "/1jku0G/rLvA/EI8Fq3MvCUnybz9gSI9HiQmvOxZG7zgAVm8Z/AjvPyZPLyMxf47kaZnvLGr/TtNQCY89kSku9/wuzzwe9W69IV1PAN0KLxsNJ87h1hMPB9vnjvdQjE8gcnYuzD6t7nGi7Y7bahOvBkahjxVGpI7zo7ZOyox6bvIYni8EB7Zu/zTl7xtHIU7Nk9QO+xZm7zIYvg80J/2uz4ABTzsWRs8u4+QuvDe57lvyg+8BUvqvGYIPjtbDBg8Zd+GPEy70juuw5485lZxPC4S0rzOZSK84AFZu98ZczzfKhe9VlRmPHJPXDzOApA7fqeeu3vXUjv95DS8AsYdO5GmZ7y6RJi8MF3KvNpyZbsdwZM8RPIKPGGbCz2G03g8tYxmPKmo2rtvkLQ8jDm1PBScrzt4GKs8oDEIPA3CQ7zdzvo7M1bNvCcPLzzag4k8vT0bPJQTIbqolz272SftPG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8iu68vIruvDy0QW68MCNvvHik9LztH0C8deXMuqmo2ryvqwS85X8vPJB9MDxq6aa7BqcGvev9frtqdXA8aWRTO67s1TzuBya8w1hYu4+VyrnzrjM8AmOLvERVnbimTMW8", - }, + {Embedding: "pHCdP4XrkUDhevxA"}, + {Embedding: "/1jku0G/rLvA/EI8"}, }, }, want: EmbeddingResponse{ Data: []Embedding{ - { - Embedding: []float32{ - - -0.006968617, - -0.0052718227, - 0.011901081, - -0.024984878, - -0.024554798, - 0.039674748, - -0.010140447, - -0.009481888, - -0.013245076, - -0.010006047, - -0.011511322, - 0.0077750143, - -0.014138834, - 0.0077414145, - 0.010147166, - -0.0050131036, - 0.022942005, - -0.0016287547, - 0.01498555, - -0.010281566, - 0.004858544, - 0.012472278, - 0.004835024, - 0.010819164, - -0.006615818, - -0.00035090884, - 0.0055708615, - -0.012613398, - 0.016369866, - 0.0044587054, - 0.006639338, - -0.0071164565, - -0.01516027, - -0.006625898, - -0.0185337, - 0.0040622265, - 0.0031785495, - -0.018963777, - 0.03032054, - -0.0075263754, - 0.0081177335, - 0.009481888, - -0.0011029163, - -0.00044225855, - -0.008776291, - -0.028600225, - 0.0028996705, - 0.0092802895, - 0.016463945, - 0.006431019, - 0.019380417, - 0.014730191, - -0.025643434, - -0.009911967, - -0.003311269, - 0.014837711, - -0.03690612, - 0.014058193, - 0.013446676, - 0.0043948656, - -0.004841744, - 0.0032171893, - -0.011040923, - 0.002407432, - -0.014138834, - -0.018587459, - -0.024702638, - -0.0035011084, - 0.01803642, - 0.008480612, - 0.034083728, - 0.01518715, - 0.014071633, - -0.006672938, - 0.022041528, - 0.022122167, - 0.005359182, - 0.020885691, - 0.008312613, - -0.011948121, - 0.0076540546, - -0.025065517, - 0.010684765, - 0.016786505, - 0.009475169, - -0.000614458, - -0.0028929505, - 0.028949665, - -0.03292789, - -0.03045494, - 0.0076607745, - 0.020200253, - 0.009972447, - 0.018063301, - -0.005668301, - 0.008285733, - -0.010281566, - 0.020361533, - 0.022283446, - -0.034621324, - 0.005426382, - 0.013318996, - -0.017324103, - -0.008137893, - -0.029782942, - 0.017713862, - 0.021503929, - -0.016759625, - 0.016316107, - 0.0038203073, - -0.029137824, - 0.012143, - -0.01815738, - -0.017337542, - 0.0030122302, - 0.016894024, - 0.010778844, - -0.014031313, - -0.021436729, - -0.03026678, - 0.009959007, - 0.012687318, - 0.03018614, - -0.017754182, - 0.026436392, - 0.019568576, - -0.0058598206, - -0.031315096, - 0.0067770975, - -0.0019471135, - 0.037443716, - 0.024447279, - 0.010765404, - 0.014864591, - -0.013157717, - 0.022821045, - -0.03604596, - 0.0025317515, - -0.027417509, - -0.012808277, - 0.012895637, - 0.026960552, - 0.0029114303, - -0.0031382297, - 0.012613398, - 0.011087963, - -0.0022898323, - -0.0105167655, - 0.021490488, - -0.013124117, - -0.002716551, - 0.0041126264, - 0.0049727834, - -0.01495867, - -0.010563805, - 0.017203143, - 0.0052919826, - 0.008023653, - 0.0019823934, - -0.0299711, - 0.011007324, - 0.009300449, - 0.016894024, - -0.014649551, - 0.033949327, - 0.05112559, - -0.0037195077, - 0.0053491024, - -0.0059236605, - -0.0082790125, - -0.029567903, - 0.028546466, - -0.06413547, - 0.0126066785, - -0.041368183, - 0.0038471874, - 0.026181033, - 0.013345876, - -0.02076473, - -0.018990656, - -0.03994355, - 0.0023335123, - 0.0050534233, - 0.025186477, - -0.02720247, - -0.013964114, - 0.000013433393, - 0.0040723067, - 0.0007723775, - 0.00298199, - 0.016719304, - 0.022095287, - 0.009246689, - -0.0080438135, - -0.68941593, - -0.0038740672, - 0.020710971, - -0.026328873, - 0.025670316, - 0.03843827, - 0.00089207705, - 0.018560579, - -0.025589675, - 0.020670652, - -0.019125057, - -0.0024998318, - -0.010940124, - -0.01227068, - 0.0028946304, - -0.012673878, - 0.010335326, - -0.0065788585, - -0.014770512, - 0.008265573, - 0.005171023, - 0.032444052, - 0.0016900745, - 0.014273233, - 0.019044418, - -0.00006415479, - 0.009905247, - -0.018775618, - -0.001812714, - 0.031906456, - -0.029460382, - -0.003275989, - -0.0025703914, - 0.010610845, - 0.061017398, - -0.020549692, - -0.009488609, - -0.0049492638, - -0.005453262, - 0.0018479939, - -0.0181977, - -0.026127273, - 0.02106041, - -0.0044519855, - 0.005832941, - -0.0040555065, - 0.0049459036, - -0.02114105, - 0.005251663, - 0.005681741, - 0.0018849538, - -0.0018983937, - 0.010866204, - -0.0013549156, - 0.014757072, - 0.009730528, - 0.043303538, - -0.016544586, - 0.0012490759, - 0.015523149, - -0.0038875071, - 0.022135606, - -0.029057184, - -0.013661715, - 0.0028324707, - 0.009488609, - -0.0120086, - 0.006595658, - 0.009710368, - -0.005785901, - 0.015778508, - 0.013896914, - -0.020321213, - -0.0061185397, - 0.002054633, - 0.026637992, - 0.018654658, - -0.009488609, - -0.020603452, - 0.0181977, - 0.006676298, - -0.0036052682, - -0.023130164, - -0.016598346, - 0.025388077, - -0.00601102, - -0.022229686, - 0.009495328, - 0.0067636576, - 0.0046535847, - 0.013083797, - 0.010852764, - -0.008171493, - -0.0014019554, - 0.0041697463, - 0.005869901, - -0.00004504485, - 0.014259793, - -0.007801894, - -0.0038471874, - -0.014824271, - 0.015818827, - -0.028358307, - 0.005382702, - 0.0077548544, - -0.0015187149, - -0.0032373492, - 0.019219136, - 0.03311605, - -0.02376184, - -0.0061689396, - -0.008668771, - -0.0028677506, - -0.0133861955, - -0.0066998177, - -0.023896242, - 0.010180767, - 0.005517102, - 0.023721522, - -0.00026375914, - 0.020952892, - -0.002729991, - -0.00298199, - 0.0012877157, - 0.026785832, - 0.008144613, - 0.0076271747, - -0.02134265, - -0.022296887, - -0.003964787, - 0.007519655, - -0.000922317, - 0.05429742, - -0.016988104, - 0.025199916, - -0.002464552, - 0.01847994, - -0.00085049716, - 0.016020427, - -0.005443182, - -0.019985214, - 0.015254349, - -0.017579462, - 0.006558698, - 0.010557085, - -0.0183993, - -0.018762179, - -0.007163496, - 0.009468448, - -0.010375646, - 0.0019807136, - -0.012552919, - -0.024581678, - 0.026691752, - 0.012237079, - -0.01790202, - 0.0047879843, - -0.015791947, - -0.0076540546, - -0.02147705, - -0.0018748738, - 0.011397082, - -0.011047644, - 0.016208587, - -0.010120287, - -0.004559505, - -0.037820034, - 0.013406356, - -0.016517706, - -0.026476713, - -0.0031802296, - -0.02084537, - -0.005769101, - -0.00022112927, - -0.013977554, - -0.0043545454, - -0.019958334, - -0.0020227134, - 0.022995764, - -0.016369866, - 0.008655331, - 0.013755795, - -0.002741751, - 0.015281229, - 0.016463945, - 0.014273233, - -0.0018496739, - 0.015791947, - 0.0077078147, - -0.01798266, - 0.0037430276, - -0.013466836, - -0.013493716, - 0.0005195383, - -0.011491162, - 0.00039983867, - -0.007976614, - 0.03026678, - 0.017377863, - 0.008756131, - 0.03362677, - 0.0062697395, - 0.042873457, - -0.025670316, - -0.0045796647, - -0.02162489, - 0.002414152, - -0.022270007, - 0.01803642, - 0.012633558, - 0.003911027, - -0.02126201, - -0.01212956, - 0.010100126, - 0.015308109, - 0.025871914, - -0.007297896, - 0.007781734, - -0.0019504735, - 0.008198373, - 0.004942544, - -0.006723338, - 0.0041059065, - -0.0124588385, - -0.013379476, - 0.0057220613, - 0.026651433, - 0.03580404, - 0.0056649414, - -0.02370808, - -0.0031751895, - -0.003944627, - 0.0008546972, - 0.010933404, - 0.013829715, - 0.017686982, - 0.029137824, - 0.0008861971, - 0.029003425, - -0.0035246282, - -0.010745244, - 0.023103284, - 0.018775618, - -0.007371816, - 0.0244204, - 0.004495665, - 0.020186814, - 0.0014783951, - -0.019608894, - 0.009972447, - -0.011141723, - 0.012700758, - -0.031691417, - -0.006326859, - 0.021436729, - -0.013292116, - 0.00009911967, - 0.013345876, - 0.026140714, - 0.018842818, - 0.015751628, - -0.019017538, - -0.0044654254, - -0.00064973783, - 0.018977217, - -0.009932127, - -0.014111954, - -0.0045931046, - -0.016907465, - 0.014232913, - -0.0072306963, - -0.0070425365, - 0.035132043, - -0.008252133, - 0.02427256, - -0.00027656907, - 0.009528928, - -0.0009357569, - -0.016894024, - 0.004310866, - 0.0014599152, - -0.044298094, - 0.0073180557, - 0.007244136, - -0.002093273, - -0.019380417, - -0.03368053, - 0.037363075, - 0.003934547, - 0.0009962367, - 0.00033767888, - 0.00900477, - 0.02076473, - 0.002152073, - 0.00068081776, - 0.023425842, - 0.013359316, - -0.028707745, - -0.0020411932, - 0.0015716348, - 0.008238693, - 0.017337542, - -0.0038606273, - -0.027793828, - 0.030831259, - -0.0071030166, - 0.0055003017, - 0.021893688, - 0.006696458, - -0.009999327, - 0.0059942203, - 0.01847994, - -0.0038505474, - -0.02390968, - 0.02411128, - 0.0071231765, - -0.019461056, - -0.004542705, - 0.034701966, - 0.013775954, - -0.0035582283, - -0.029164704, - -0.019313216, - 0.0055137416, - 0.062576436, - 0.021356089, - -0.0045796647, - -0.0040958263, - 0.0072306963, - 0.005372622, - -0.010745244, - -0.03327733, - 0.00891069, - -0.021651769, - -0.0017421542, - 0.0044217454, - 0.015402189, - 0.0068778973, - 0.015845709, - -0.0034070287, - 0.010725085, - -0.0068039773, - -0.0013280356, - -0.023533363, - -0.009676768, - 0.027471269, - 0.012741078, - 0.0046300646, - 0.01770042, - 0.0001832244, - 0.0046502245, - 0.010718364, - 0.01212956, - -0.05150191, - -0.020173373, - 0.031449497, - 0.008050533, - 0.009952287, - -0.005120623, - 0.029110944, - -0.005459982, - -0.01494523, - 0.018748738, - -0.0020025533, - 0.021503929, - 0.019340096, - 0.017082183, - -0.015657548, - 0.009535649, - -0.0032591892, - 0.0020378332, - -0.00071609765, - -0.013883474, - -0.0036825477, - 0.0019991933, - -0.008077413, - -0.0074524553, - -0.023466162, - 0.008198373, - 0.009864927, - -0.009817887, - 0.0062260595, - -0.018883137, - -0.026530473, - 0.0077414145, - 0.008292452, - -0.0065788585, - -0.0037833476, - -0.018291779, - -0.013164436, - -0.00029378902, - 0.0037564675, - -0.02099321, - -0.00601438, - 0.0024964719, - 0.008144613, - 0.0014137153, - 0.013540755, - 0.013446676, - 0.0040219068, - 0.005144143, - -0.01537531, - -0.023291443, - -0.010731804, - -0.0013406356, - -0.0359922, - 0.0070022168, - -0.010167327, - -0.023587123, - 0.016611785, - 0.005419662, - 0.011551642, - 0.0052180625, - 0.011948121, - 0.02411128, - 0.003301189, - 0.006320139, - -0.016974663, - 0.0030945498, - -0.026785832, - 0.0019571935, - -0.034594446, - -0.010590685, - -0.019165376, - -0.0074121356, - -0.003329749, - 0.00598414, - -0.006545258, - 0.012431959, - 0.0025435116, - 0.008635172, - 0.031126937, - -0.014461393, - 0.019420736, - -0.00037064878, - 0.00056699815, - -0.010342046, - 0.00044351854, - -0.008265573, - 0.01186748, - 0.008796451, - -0.000047118596, - 0.008615011, - -0.022753844, - 0.025482155, - -0.059243325, - 0.01225724, - 0.029541023, - 0.000908877, - 0.014447953, - -0.011054363, - -0.012882197, - 0.0031382297, - -0.0062260595, - -0.009542368, - 0.005742221, - -0.01830522, - -0.014542032, - -0.029648542, - -0.0077481344, - -0.016074186, - 0.0037766276, - -0.018923458, - -0.0077682943, - -0.023869362, - 0.0023150323, - 0.008749411, - -0.000101219666, - -0.022310326, - -0.024702638, - 0.0037799876, - 0.01814394, - -0.0067938976, - 0.034379408, - 0.00091475697, - 0.0113702025, - -0.013910354, - -0.018291779, - 0.002113433, - -0.02720247, - -0.014085073, - -0.019756734, - 0.009858208, - 0.02417848, - 0.028600225, - -0.0043007857, - 0.012801558, - 0.004260466, - -0.015953228, - 0.0025031918, - 0.0025939115, - -0.011733081, - -0.018264899, - 0.011155163, - 0.005372622, - 0.023654321, - 0.01537531, - -0.009582688, - 0.004166386, - -0.01497211, - 0.012828438, - -0.016692424, - -0.013789395, - -0.024796719, - 0.0028996705, - 0.008359652, - -0.009320609, - 0.01220348, - -0.016652105, - 0.006746858, - 0.046206567, - 0.010570525, - 0.008675491, - 0.026960552, - 0.00031541896, - -0.0179961, - 0.012714198, - -0.0004481385, - 0.015496269, - -0.01838586, - -0.015079631, - -0.012378199, - 0.0017589541, - 0.030938778, - 0.016208587, - -0.0044116653, - -0.013023317, - 0.0073650954, - 0.001216316, - -0.017592901, - 0.0060043, - -0.0029651902, - 0.013500435, - -0.0049559837, - -0.031960215, - 0.0019739934, - -0.008373092, - -0.024742959, - -0.008366372, - 0.016060747, - -0.013520596, - 0.010886364, - -0.024124721, - -0.0068174177, - -0.002118473, - 0.0005031583, - 0.029836701, - 0.010711645, - 0.0010793965, - 0.0085881315, - -0.009938847, - -0.005480142, - 0.007580135, - -0.00899133, - -0.01198172, - 0.035105165, - 0.016988104, - 0.00296351, - -0.0017203143, - 0.015657548, - 0.022350647, - -0.016074186, - -0.019904574, - 0.015697869, - 0.013654995, - 0.0047006244, - -0.03935219, - -0.016302666, - -0.050480474, - 0.023385523, - 0.016477386, - -0.020254012, - -0.027874468, - 0.0005447382, - -0.040669307, - 0.025320876, - -0.01847994, - -0.0031197497, - 0.013124117, - -0.002430952, - -0.031207576, - 0.0066998177, - -0.0022360727, - 0.00016138447, - 0.006431019, - 0.034029968, - -0.013379476, - 0.014918351, - 0.0061386996, - 0.019622335, - -0.006306699, - -0.009663328, - 0.003339829, - 0.019918013, - -0.037443716, - -0.008843491, - -0.0043444657, - -0.0125327585, - 0.00902493, - -0.0062764594, - -0.017256903, - -0.003581748, - -0.015482829, - -0.011464282, - 0.011901081, - -0.003348229, - -0.021745848, - -0.0117532415, - 0.0043747057, - -0.022431286, - -0.013130836, - -0.011417243, - 0.013372756, - -0.026530473, - -0.024917677, - -0.0047107046, - 0.010812445, - 0.0052550226, - -0.0008769571, - -0.0065990184, - 0.019501375, - 0.037981313, - -0.0070290966, - 0.015294669, - 0.0018748738, - 0.0067569376, - -0.03346549, - 0.005826221, - 0.00024716917, - 0.00059765804, - 0.028600225, - -0.018560579, - -0.026409512, - 0.008890531, - -0.00300383, - 0.019971775, - 0.013198037, - -0.009031651, - -0.008608292, - 0.02136953, - -0.0013473555, - -0.0085881315, - -0.02416504, - 0.021665208, - 0.008655331, - -0.005372622, - 0.00610846, - -0.016463945, - 0.0014867951, - -0.0100598065, - -0.0034507087, - 0.009481888, - -0.02454136, - -0.034029968, - -0.0014506752, - 0.001232276, - 0.004425105, - -0.026154153, - -0.019098178, - -0.015966667, - -0.0013641554, - -0.0070358166, - -0.005863181, - 0.0013145957, - -0.00905181, - 0.005140783, - -0.011652442, - 0.028707745, - -0.015818827, - -0.01845306, - -0.021544248, - 0.00010090467, - -0.02709495, - -0.025509035, - -0.009145889, - 0.025509035, - 0.015066191, - -0.0090450905, - -0.012048921, - -0.013043477, - -0.028223908, - -0.011007324, - -0.004052147, - 0.001846314, - 0.020697532, - 0.0087359715, - -0.003338149, - 0.03290101, - 0.00040193868, - 0.027713189, - -0.0068778973, - 0.00045065852, - -0.0072172564, - -0.007996773, - 0.0037497475, - 0.008628451, - 0.0007370976, - -0.014461393, - 0.038626432, - 0.014609232, - 0.0051475028, - 0.017189704, - 0.0026073514, - -0.007882534, - -0.0133861955, - -0.0028862304, - -0.0062294193, - 0.010469725, - 0.0049828636, - -0.009381089, - -0.013332436, - 0.0031903095, - -0.006928297, - -0.00013670955, - 0.014488272, - 0.0093542095, - 0.0126066785, - 0.0098985275, - -0.010617565, - 0.0018496739, - -0.016853705, - -0.015751628, - 0.025414957, - -0.000895437, - -0.025173036, - 0.020240573, - 0.0008412572, - -0.0043982253, - -0.023318322, - 0.03040118, - -0.018977217, - -0.013164436, - -0.007600295, - -0.017028423, - -0.033546127, - 0.0012549559, - -0.007559975, - -0.010221086, - -0.0034507087, - -0.0052550226, - -0.025535915, - -0.025965994, - -0.0038807872, - 0.005402862, - -0.031879574, - -0.04518513, - -0.013648275, - 0.027740069, - -0.010006047, - -0.009293729, - -0.0068946974, - -0.012888918, - 0.012304279, - 0.013722194, - -0.0005459982, - -0.01215644, - 0.031073177, - 0.016087627, - -0.011101403, - 0.02710839, - 0.23052211, - -0.01537531, - 0.015402189, - 0.03959411, - 0.0055775815, - 0.026584232, - 0.0029047104, - 0.0020294334, - -0.014716751, - 0.003900947, - -0.008809891, - -0.0017203143, - 0.019017538, - -0.00605134, - 0.025535915, - 0.007889254, - -0.019192256, - -0.014058193, - -0.015738187, - -0.029514143, - 0.008695651, - 0.002162153, - -0.0018530339, - -0.021813048, - 0.0061487798, - -0.0058732606, - -0.0135340355, - -0.0122975595, - 0.027444389, - 0.018950338, - -0.0070358166, - -0.00921309, - 0.021517368, - 0.0049862233, - -0.017431622, - 0.011565082, - 0.0089711705, - -0.0044284654, - 0.028519586, - 0.02710839, - 0.011195483, - -0.0004489785, - -0.012828438, - -0.019595455, - -0.008467172, - 0.017431622, - -0.0023200724, - -0.008715811, - -0.01200188, - -0.0043377457, - 0.008776291, - 0.0042134263, - 0.0112962825, - 0.012774678, - 0.012747798, - -0.002694711, - 0.024890797, - -0.011249243, - -0.031879574, - 0.024326319, - -0.001216316, - 0.016517706, - -0.004764464, - 0.009938847, - -0.014165713, - -0.006407499, - 0.007271016, - -0.0047174245, - 0.0052819024, - 0.0011071163, - 0.0009676768, - -0.016880585, - -0.002743431, - -0.007506215, - -0.030858139, - -0.010489886, - -0.002110073, - 0.019797055, - 0.031825814, - 0.018412739, - -0.027551908, - -0.0128418775, - 0.010483165, - -0.025455276, - -0.025186477, - -0.029809821, - 0.0017404743, - -0.013668435, - -0.010819164, - -0.0084268525, - -0.011121564, - -0.016396746, - -0.009569248, - -0.0060815797, - 0.002141993, - -0.008023653, - -0.017230023, - 0.028815264, - 0.007291176, - 0.0073247757, - -0.029110944, - 0.020388413, - 0.01202204, - 0.013601235, - -0.0127679575, - -0.010819164, - -0.012431959, - 0.011289563, - 0.006935017, - -0.01503931, - -0.0034103887, - 0.011047644, - 0.012956117, - 0.004818224, - -0.013668435, - 0.0062260595, - 0.01538875, - -0.013896914, - 0.0038303873, - -0.00095171685, - -0.009643168, - -0.019528255, - -0.00607822, - -0.00082445727, - -0.0070156567, - -0.0129157975, - -0.013520596, - -0.018842818, - 0.012888918, - -0.024447279, - 0.0050399834, - 0.010785565, - 0.010725085, - -0.0030777499, - -0.007976614, - 0.005160943, - 0.0025283915, - -0.00900477, - -0.011887641, - 0.03316981, - -0.0012826758, - -0.008494052, - 0.0068274974, - 0.0001803894, - 0.011820441, - -0.034406286, - -0.00299879, - -0.010120287, - -0.0077682943, - -0.01835898, - -0.028600225, - -0.013258516, - -0.015899468, - -0.00076733745, - 0.020509372, - -0.016450506, - -0.031368855, - -0.025912235, - 0.013453395, - 0.00012536958, - -0.02116793, - 0.0050265435, - 0.029299103, - -0.014609232, - 0.004505745, - -0.0037732676, - -0.1762247, - 0.001505275, - 0.007055977, - -0.011309722, - 0.019004097, - -0.013271956, - 0.00303239, - 0.0011171963, - -0.002758551, - 0.015926348, - -0.00037295878, - -0.010839324, - -0.04319602, - -0.012868757, - -0.016423626, - 0.016786505, - -0.027874468, - 0.0041563064, - 0.011618841, - 0.030696858, - 0.017660102, - -0.0050769434, - 0.020052414, - -0.020227132, - 0.0014582352, - 0.001517875, - 0.009777567, - 0.031987093, - 0.005120623, - -0.0091324495, - -0.0063402993, - -0.0104428455, - -0.007855654, - 0.005036623, - 0.027525028, - -0.011665882, - 0.0047241445, - -0.026987432, - -0.014918351, - 0.025186477, - 0.033841807, - 0.032175254, - 0.0028963105, - -0.013036757, - 0.004179826, - 0.016786505, - 0.018439619, - -0.010180767, - 0.011659161, - -0.005806061, - 0.01220348, - -0.043222897, - 0.0015220749, - -0.017216584, - 0.00305255, - 0.023869362, - -0.011544921, - -0.012317719, - 0.009549089, - 0.02416504, - 0.0037060678, - -0.021033531, - 0.016450506, - 0.010590685, - 0.013251796, - -0.017203143, - -0.009643168, - 0.009777567, - -0.014689871, - 0.018600898, - -0.024286, - -0.017942341, - 0.0035044684, - -0.011524762, - 0.012814998, - -0.010637725, - -0.022740405, - 0.026637992, - -0.0027652709, - -0.02122169, - -0.021517368, - 0.03327733, - -0.01509307, - 0.01782138, - 0.012190039, - 0.022054967, - -0.004499025, - 0.0037396676, - 0.002740071, - 0.0006404979, - 0.03255157, - -0.0061219, - -0.010261406, - -0.014165713, - 0.022162486, - 0.016396746, - 0.015482829, - 0.002180633, - -0.00035258883, - -0.00059387804, - -0.013816275, - -0.034029968, - -0.011907801, - 0.0034910284, - 0.019313216, - 0.008413413, - 0.011269403, - 0.00068081776, - 0.0043444657, - -0.019676095, - -0.031180697, - 0.017404743, - 0.019797055, - 0.029030304, - -0.00061739795, - 0.010960284, - -0.026019754, - -0.021584569, - 0.00900477, - 0.016988104, - 0.037604995, - -0.005785901, - -0.005510382, - 0.014501712, - -0.00015875947, - -0.012143, - -0.06531818, - -0.021880249, - 0.010967004, - 0.028761504, - 0.003598548, - 0.017001543, - -0.00066359784, - 0.005869901, - -0.000609838, - -0.0028744705, - -0.0040319865, - -0.029433502, - -0.025616555, - -0.013480276, - 0.013708754, - -0.008803171, - 0.0024914318, - -0.002057993, - -0.000905517, - 0.022646325, - -0.014810831, - -0.019743295, - 0.0018513539, - -0.0181305, - -0.009461729, - -0.0002122043, - -0.034460045, - 0.035239562, - 0.016961224, - -0.010967004, - -0.0076204548, - -0.0044452655, - 0.02682615, - -0.019205697, - -0.022081846, - 0.0070290966, - -0.044486254, - -0.004519185, - 0.021786168, - -0.02718903, - -0.0071500563, - 0.008346212, - -0.001800954, - -0.023143604, - -0.015832268, - -0.0037900675, - -0.007922854, - 0.041153144, - 0.0058766208, - -0.020428732, - -0.030858139, - -0.009938847, - -0.029110944, - -0.020737851, - 0.023278004, - 0.0028610306, - 0.026248233, - 0.0019420736, - -0.02443384, - -0.00037757875, - 0.0071231765, - -0.016504265, - -0.005379342, - 0.017310662, - 0.012680599, - 0.009502049, - -0.011807001, - 0.0048887837, - 0.011766681, - 0.0053054225, - -0.008944291, - 0.008245413, - -0.014206033, - 0.025589675, - -0.01782138, - -0.0058967806, - -0.023022644, - -0.030508699, - 0.023224244, - 0.0014254752, - -0.017095624, - -0.02093945, - -0.0013943954, - -0.019474495, - 0.005782541, - 0.019487936, - -0.0054062223, - 0.008191653, - 0.0035716682, - -0.026396073, - 0.014138834, - 0.044190574, - 0.0065284586, - -0.02084537, - -0.008063973, - -0.0051844628, - 0.010328606, - 0.0070223766, - 0.011571802, - -0.0022192728, - -0.028976545, - -0.023479603, - -0.06392043, - 0.025845034, - 0.008373092, - -0.008500772, - -0.008225253, - -0.008883811, - -0.010967004, - -0.0053356625, - -0.014246353, - 0.005728781, - -0.00029336903, - -0.005345742, - 0.008957731, - -0.0034708686, - -0.018090181, - 0.0064746984, - 0.021436729, - -0.008675491, - 0.024729518, - 0.0047443043, - -0.010355486, - -0.0105167655, - 0.00013838954, - -0.0009374369, - -0.0061655794, - 0.015254349, - -0.03916403, - 0.018990656, - -0.010832604, - -0.01513339, - 0.010812445, - -0.03282037, - -0.0038807872, - 0.01498555, - -0.0052819024, - -0.0031365496, - -0.0077548544, - 0.044755053, - 0.0044486253, - -0.0012238759, - -0.00302231, - -0.022659766, - -0.003625428, - -0.019259457, - 0.00613534, - 0.020401852, - -0.019850815, - -0.029702302, - 0.02404408, - 0.0032776692, - 0.0061319796, - 0.012290839, - -0.029756062, - -0.026664872, - -0.016006988, - -0.028519586, - 0.02440696, - -0.01538875, - 0.001528795, - -0.017203143, - 0.04540017, - -0.008433572, - -0.010550365, - -0.023775281, - 0.012418519, - -0.00046955844, - -0.017068744, - 0.013856594, - 0.0010306766, - -0.011686041, - -0.013426515, - -0.0025871915, - -0.004015187, - 0.03623412, - 0.015818827, - 0.016719304, - -0.014447953, - 0.013641555, - -0.008386532, - 0.021920567, - 0.009979167, - 0.005137423, - -0.014138834, - 0.0029534302, - 0.03029366, - 0.022323767, - -0.009582688, - -0.00093995687, - -0.008010213, - 0.00302399, - -0.019555135, - 0.013164436, - -0.004851824, - 0.00014426952, - 0.010503326, - 0.006646058, - 0.001794234, - 0.0058497405, - 0.014878031, - 0.022659766, - 0.004525905, - -0.00895101, - 0.0016077547, - -0.0062193396, - -0.004858544, - -0.0001809144, - -0.037282437, - -0.031100057, - 0.012626838, - -0.0021907128, - -0.011027483, - -0.008272293, - 0.034943886, - 0.017149383, - -0.021853367, - 0.023802161, - 0.0018026341, - -0.009811168, - -0.025764395, - 0.026839592, - -0.001186916, - 0.0073314956, - 0.026920231, - -0.013144276, - 0.014192593, - 0.0034103887, - 0.008648612, - -0.024689198, - 0.0076271747, - 0.002691351, - -0.009468448, - 0.0027988707, - -0.0051038233, - -0.019178817, - 0.0005728781, - 0.008084133, - -0.010106847, - 0.035669643, - -0.006867817, - 0.082145005, - -0.0020025533, - -0.0023049524, - 0.0088972505, - -0.0040891063, - 0.023116723, - 0.00891069, - 0.020885691, - -0.014031313, - 0.0028324707, - 0.011538202, - 0.0031365496, - -0.008084133, - -0.0084268525, - -0.016544586, - -0.012633558, - -0.0057724607, - 0.016208587, - -0.016853705, - 0.010012767, - 0.018587459, - 0.012720918, - 0.02102009, - 0.01518715, - -0.012492439, - -0.023062963, - 0.023062963, - -0.014542032, - -0.014595792, - -0.029863581, - -0.011726362, - -0.0015632348, - -0.026691752, - -0.008097573, - 0.010711645, - 0.010772124, - -0.005093743, - -0.03287413, - -0.003890867, - 0.014676431, - 0.0032255894, - 0.026113834, - -0.0101337265, - -0.003301189, - -0.00038639872, - 0.010967004, - -0.017014984, - -0.00007502225, - -0.0240844, - }, - }, + {Embedding: []float32{1.23, 4.56, 7.89}}, + {Embedding: []float32{-0.006968617, -0.0052718227, 0.011901081}}, }, }, wantErr: false, From 7eed976b077086d59eec3b29d1c4e087a5027750 Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Tue, 5 Sep 2023 18:20:54 +0200 Subject: [PATCH 09/17] fix [skip ci] --- embeddings.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embeddings.go b/embeddings.go index f5d6ab927..aacb693c4 100644 --- a/embeddings.go +++ b/embeddings.go @@ -284,7 +284,7 @@ func (c *Client) CreateEmbeddings(ctx context.Context, conv EmbeddingRequestConv return } - var embeddingResponse any = &EmbeddingResponse{} + var embeddingResponse any = &res if baseReq.EncodingFormat == EmbeddingEncodingFormatBase64 { embeddingResponse = &EmbeddingResponseBase64{} } From 1e19595f562b1838759153dd3a3afd3af68df64f Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Tue, 5 Sep 2023 18:21:48 +0200 Subject: [PATCH 10/17] chore: refactor test to consider CreateEmbeddings response --- embeddings_test.go | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/embeddings_test.go b/embeddings_test.go index 100e86f70..052a31b05 100644 --- a/embeddings_test.go +++ b/embeddings_test.go @@ -98,33 +98,51 @@ func TestEmbeddingModel(t *testing.T) { func TestEmbeddingEndpoint(t *testing.T) { client, server, teardown := setupOpenAITestServer() defer teardown() + + sampleEmbeddings := []Embedding{ + {Embedding: []float32{1.23, 4.56, 7.89}}, + {Embedding: []float32{-0.006968617, -0.0052718227, 0.011901081}}, + } + server.RegisterHandler( "/v1/embeddings", func(w http.ResponseWriter, r *http.Request) { - resBytes, _ := json.Marshal(EmbeddingResponse{}) + resBytes, _ := json.Marshal(EmbeddingResponse{Data: sampleEmbeddings}) fmt.Fprintln(w, string(resBytes)) }, ) // test create embeddings with strings (simple embedding request) - _, err := client.CreateEmbeddings(context.Background(), EmbeddingRequest{}) + res, err := client.CreateEmbeddings(context.Background(), EmbeddingRequest{}) checks.NoError(t, err, "CreateEmbeddings error") + if len(res.Data) != len(sampleEmbeddings) { + t.Errorf("Expected %d embeddings, got %d", len(sampleEmbeddings), len(res.Data)) + } // test create embeddings with strings (simple embedding request) - _, err = client.CreateEmbeddings( + res, err = client.CreateEmbeddings( context.Background(), EmbeddingRequest{ EncodingFormat: EmbeddingEncodingFormatBase64, }, ) checks.NoError(t, err, "CreateEmbeddings error") + if len(res.Data) != len(sampleEmbeddings) { + t.Errorf("Expected %d embeddings, got %d", len(sampleEmbeddings), len(res.Data)) + } // test create embeddings with strings - _, err = client.CreateEmbeddings(context.Background(), EmbeddingRequestStrings{}) + res, err = client.CreateEmbeddings(context.Background(), EmbeddingRequestStrings{}) checks.NoError(t, err, "CreateEmbeddings strings error") + if len(res.Data) != len(sampleEmbeddings) { + t.Errorf("Expected %d embeddings, got %d", len(sampleEmbeddings), len(res.Data)) + } // test create embeddings with tokens - _, err = client.CreateEmbeddings(context.Background(), EmbeddingRequestTokens{}) + res, err = client.CreateEmbeddings(context.Background(), EmbeddingRequestTokens{}) checks.NoError(t, err, "CreateEmbeddings tokens error") + if len(res.Data) != len(sampleEmbeddings) { + t.Errorf("Expected %d embeddings, got %d", len(sampleEmbeddings), len(res.Data)) + } } func TestEmbeddingResponseBase64_ToEmbeddingResponse(t *testing.T) { From 8b469498240e61fdf49168e987da658145673c20 Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Tue, 5 Sep 2023 18:26:07 +0200 Subject: [PATCH 11/17] trigger build From 6089ca0844bf9e12587b0f8f7377f9e4d204f298 Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Thu, 7 Sep 2023 20:56:16 +0200 Subject: [PATCH 12/17] chore: remove named returns --- embeddings.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/embeddings.go b/embeddings.go index aacb693c4..ef708b05a 100644 --- a/embeddings.go +++ b/embeddings.go @@ -277,14 +277,16 @@ func (r EmbeddingRequestTokens) Convert() EmbeddingRequest { // // Body should be of type EmbeddingRequestStrings for embedding strings or EmbeddingRequestTokens // for embedding groups of text already converted to tokens. -func (c *Client) CreateEmbeddings(ctx context.Context, conv EmbeddingRequestConverter) (res EmbeddingResponse, err error) { //nolint:lll +func (c *Client) CreateEmbeddings(ctx context.Context, conv EmbeddingRequestConverter) (EmbeddingResponse, error) { //nolint:lll baseReq := conv.Convert() + response := EmbeddingResponse{} + req, err := c.newRequest(ctx, http.MethodPost, c.fullURL("/embeddings", baseReq.Model.String()), withBody(baseReq)) if err != nil { - return + return response, err } - var embeddingResponse any = &res + var embeddingResponse any = &response if baseReq.EncodingFormat == EmbeddingEncodingFormatBase64 { embeddingResponse = &EmbeddingResponseBase64{} } @@ -292,8 +294,8 @@ func (c *Client) CreateEmbeddings(ctx context.Context, conv EmbeddingRequestConv err = c.sendRequest(req, embeddingResponse) if baseReq.EncodingFormat == EmbeddingEncodingFormatBase64 { - res, err = embeddingResponse.(*EmbeddingResponseBase64).ToEmbeddingResponse() + response, err = embeddingResponse.(*EmbeddingResponseBase64).ToEmbeddingResponse() } - return + return response, err } From 250a43354debd9cfac065c1ceaa48374a1a4a248 Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Sat, 9 Sep 2023 19:05:10 +0200 Subject: [PATCH 13/17] chore: refactor code to simplify the understanding --- embeddings.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/embeddings.go b/embeddings.go index ef708b05a..5ba91f235 100644 --- a/embeddings.go +++ b/embeddings.go @@ -277,25 +277,27 @@ func (r EmbeddingRequestTokens) Convert() EmbeddingRequest { // // Body should be of type EmbeddingRequestStrings for embedding strings or EmbeddingRequestTokens // for embedding groups of text already converted to tokens. -func (c *Client) CreateEmbeddings(ctx context.Context, conv EmbeddingRequestConverter) (EmbeddingResponse, error) { //nolint:lll +func (c *Client) CreateEmbeddings( + ctx context.Context, + conv EmbeddingRequestConverter, +) (res EmbeddingResponse, err error) { baseReq := conv.Convert() - response := EmbeddingResponse{} - req, err := c.newRequest(ctx, http.MethodPost, c.fullURL("/embeddings", baseReq.Model.String()), withBody(baseReq)) if err != nil { - return response, err + return } - var embeddingResponse any = &response - if baseReq.EncodingFormat == EmbeddingEncodingFormatBase64 { - embeddingResponse = &EmbeddingResponseBase64{} + if baseReq.EncodingFormat != EmbeddingEncodingFormatBase64 { + err = c.sendRequest(req, &res) + return } - err = c.sendRequest(req, embeddingResponse) - - if baseReq.EncodingFormat == EmbeddingEncodingFormatBase64 { - response, err = embeddingResponse.(*EmbeddingResponseBase64).ToEmbeddingResponse() + base64Response := &EmbeddingResponseBase64{} + err = c.sendRequest(req, base64Response) + if err != nil { + return } - return response, err + res, err = base64Response.ToEmbeddingResponse() + return } From 94550a8cc14ab64c6db5daecac69156d0c282caf Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Sat, 9 Sep 2023 19:05:40 +0200 Subject: [PATCH 14/17] chore: tests have been refactored to match the encoding format passed by request --- embeddings_test.go | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/embeddings_test.go b/embeddings_test.go index 052a31b05..3a8976dde 100644 --- a/embeddings_test.go +++ b/embeddings_test.go @@ -104,18 +104,33 @@ func TestEmbeddingEndpoint(t *testing.T) { {Embedding: []float32{-0.006968617, -0.0052718227, 0.011901081}}, } + sampleBase64Embeddings := []Base64Embedding{ + {Embedding: "pHCdP4XrkUDhevxA"}, + {Embedding: "/1jku0G/rLvA/EI8"}, + } + server.RegisterHandler( "/v1/embeddings", func(w http.ResponseWriter, r *http.Request) { - resBytes, _ := json.Marshal(EmbeddingResponse{Data: sampleEmbeddings}) + var req struct { + EncodingFormat EmbeddingEncodingFormat `json:"encoding_format"` + } + _ = json.NewDecoder(r.Body).Decode(&req) + + var resBytes []byte + if req.EncodingFormat == EmbeddingEncodingFormatBase64 { + resBytes, _ = json.Marshal(EmbeddingResponseBase64{Data: sampleBase64Embeddings}) + } else { + resBytes, _ = json.Marshal(EmbeddingResponse{Data: sampleEmbeddings}) + } fmt.Fprintln(w, string(resBytes)) }, ) // test create embeddings with strings (simple embedding request) res, err := client.CreateEmbeddings(context.Background(), EmbeddingRequest{}) checks.NoError(t, err, "CreateEmbeddings error") - if len(res.Data) != len(sampleEmbeddings) { - t.Errorf("Expected %d embeddings, got %d", len(sampleEmbeddings), len(res.Data)) + if !reflect.DeepEqual(res.Data, sampleEmbeddings) { + t.Errorf("Expected %#v embeddings, got %#v", sampleEmbeddings, res.Data) } // test create embeddings with strings (simple embedding request) @@ -126,22 +141,22 @@ func TestEmbeddingEndpoint(t *testing.T) { }, ) checks.NoError(t, err, "CreateEmbeddings error") - if len(res.Data) != len(sampleEmbeddings) { - t.Errorf("Expected %d embeddings, got %d", len(sampleEmbeddings), len(res.Data)) + if !reflect.DeepEqual(res.Data, sampleEmbeddings) { + t.Errorf("Expected %#v embeddings, got %#v", sampleEmbeddings, res.Data) } // test create embeddings with strings res, err = client.CreateEmbeddings(context.Background(), EmbeddingRequestStrings{}) checks.NoError(t, err, "CreateEmbeddings strings error") - if len(res.Data) != len(sampleEmbeddings) { - t.Errorf("Expected %d embeddings, got %d", len(sampleEmbeddings), len(res.Data)) + if !reflect.DeepEqual(res.Data, sampleEmbeddings) { + t.Errorf("Expected %#v embeddings, got %#v", sampleEmbeddings, res.Data) } // test create embeddings with tokens res, err = client.CreateEmbeddings(context.Background(), EmbeddingRequestTokens{}) checks.NoError(t, err, "CreateEmbeddings tokens error") - if len(res.Data) != len(sampleEmbeddings) { - t.Errorf("Expected %d embeddings, got %d", len(sampleEmbeddings), len(res.Data)) + if !reflect.DeepEqual(res.Data, sampleEmbeddings) { + t.Errorf("Expected %#v embeddings, got %#v", sampleEmbeddings, res.Data) } } From 29f6a9b568aff86aed4f31318e440bf3627ea503 Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Sun, 10 Sep 2023 19:44:52 +0200 Subject: [PATCH 15/17] chore: fix tests --- embeddings_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/embeddings_test.go b/embeddings_test.go index 3a8976dde..953addf22 100644 --- a/embeddings_test.go +++ b/embeddings_test.go @@ -114,11 +114,15 @@ func TestEmbeddingEndpoint(t *testing.T) { func(w http.ResponseWriter, r *http.Request) { var req struct { EncodingFormat EmbeddingEncodingFormat `json:"encoding_format"` + User string `json:"user"` } _ = json.NewDecoder(r.Body).Decode(&req) var resBytes []byte - if req.EncodingFormat == EmbeddingEncodingFormatBase64 { + if req.User == "invalid" { + w.WriteHeader(http.StatusBadRequest) + return + } else if req.EncodingFormat == EmbeddingEncodingFormatBase64 { resBytes, _ = json.Marshal(EmbeddingResponseBase64{Data: sampleBase64Embeddings}) } else { resBytes, _ = json.Marshal(EmbeddingResponse{Data: sampleEmbeddings}) @@ -158,6 +162,13 @@ func TestEmbeddingEndpoint(t *testing.T) { if !reflect.DeepEqual(res.Data, sampleEmbeddings) { t.Errorf("Expected %#v embeddings, got %#v", sampleEmbeddings, res.Data) } + + // test failed sendRequest + res, err = client.CreateEmbeddings(context.Background(), EmbeddingRequest{ + User: "invalid", + EncodingFormat: EmbeddingEncodingFormatBase64, + }) + checks.HasError(t, err, "CreateEmbeddings error") } func TestEmbeddingResponseBase64_ToEmbeddingResponse(t *testing.T) { From a46764c1d13003d07b0cfea76b86dd5495f33231 Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Sun, 10 Sep 2023 19:47:24 +0200 Subject: [PATCH 16/17] fix --- embeddings_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/embeddings_test.go b/embeddings_test.go index 953addf22..f52cd314a 100644 --- a/embeddings_test.go +++ b/embeddings_test.go @@ -119,12 +119,14 @@ func TestEmbeddingEndpoint(t *testing.T) { _ = json.NewDecoder(r.Body).Decode(&req) var resBytes []byte - if req.User == "invalid" { + switch { + case req.User == "invalid": + w.WriteHeader(http.StatusBadRequest) return - } else if req.EncodingFormat == EmbeddingEncodingFormatBase64 { + case req.EncodingFormat == EmbeddingEncodingFormatBase64: resBytes, _ = json.Marshal(EmbeddingResponseBase64{Data: sampleBase64Embeddings}) - } else { + default: resBytes, _ = json.Marshal(EmbeddingResponse{Data: sampleEmbeddings}) } fmt.Fprintln(w, string(resBytes)) @@ -164,7 +166,7 @@ func TestEmbeddingEndpoint(t *testing.T) { } // test failed sendRequest - res, err = client.CreateEmbeddings(context.Background(), EmbeddingRequest{ + _, err = client.CreateEmbeddings(context.Background(), EmbeddingRequest{ User: "invalid", EncodingFormat: EmbeddingEncodingFormatBase64, }) From e36e11414dc2a312f1a8b3697b69f26162dc13c1 Mon Sep 17 00:00:00 2001 From: Simone Vellei Date: Sun, 10 Sep 2023 19:48:15 +0200 Subject: [PATCH 17/17] fix --- embeddings_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/embeddings_test.go b/embeddings_test.go index f52cd314a..9c48c5b8f 100644 --- a/embeddings_test.go +++ b/embeddings_test.go @@ -121,7 +121,6 @@ func TestEmbeddingEndpoint(t *testing.T) { var resBytes []byte switch { case req.User == "invalid": - w.WriteHeader(http.StatusBadRequest) return case req.EncodingFormat == EmbeddingEncodingFormatBase64: