diff --git a/backend/src/embeddings/openai.go b/backend/src/embeddings/openai.go index cc5bfd5df..c5ec782ba 100644 --- a/backend/src/embeddings/openai.go +++ b/backend/src/embeddings/openai.go @@ -21,10 +21,18 @@ func CreateEmbeddingVector(infoForEmbedding string) ([]float32, *errors.Error) { requestInfoBody := bytes.NewBuffer(InfoBody) req, err := http.NewRequest("POST", fmt.Sprintf("https://api.openai.com/v1/embeddings"), requestInfoBody) + if err != nil { + return nil, &errors.FailedToVectorizeClub + } + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey)) req.Header.Set("content-type", "application/json") resp, err := http.DefaultClient.Do(req) + if err != nil { + return nil, &errors.FailedToVectorizeClub + } + defer resp.Body.Close() if err != nil { diff --git a/backend/src/embeddings/pinecone.go b/backend/src/embeddings/pinecone.go index c437216b8..1011ff762 100644 --- a/backend/src/embeddings/pinecone.go +++ b/backend/src/embeddings/pinecone.go @@ -111,6 +111,10 @@ func SearchPinecone(item types.Embeddable, topKResults int) ([]string, *errors.E req.Header.Set("content-type", "application/json") resp, err := http.DefaultClient.Do(req) + if err != nil { + return []string{}, &errors.FailedToSearchPinecone + } + defer resp.Body.Close() if err != nil { diff --git a/backend/src/errors/club.go b/backend/src/errors/club.go index 788d502ee..4d53473b4 100644 --- a/backend/src/errors/club.go +++ b/backend/src/errors/club.go @@ -50,6 +50,7 @@ var ( FailedToVectorizeClub = Error{ StatusCode: fiber.StatusInternalServerError, Message: "failed to vectorize club", + } FailedToGetClubFollowers = Error{ StatusCode: fiber.StatusInternalServerError, Message: "failed to get club followers", diff --git a/go.work.sum b/go.work.sum index b0d1362e6..aba04c49c 100644 --- a/go.work.sum +++ b/go.work.sum @@ -25,7 +25,6 @@ github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg= github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w= github.com/fatih/color v1.14.1/go.mod h1:2oHN61fhTpgcxD3TSWCgKDiH1+x4OiDVVGH8WlgGZGg= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -180,5 +179,7 @@ gorm.io/driver/postgres v1.5.4 h1:Iyrp9Meh3GmbSuyIAGyjkN+n9K+GHX9b9MqsTL4EJCo= gorm.io/driver/postgres v1.5.4/go.mod h1:Bgo89+h0CRcdA33Y6frlaHHVuTdOf87pmyzwW9C/BH0= gorm.io/gorm v1.25.6 h1:V92+vVda1wEISSOMtodHVRcUIOPYa2tgQtyF+DfFx+A= gorm.io/gorm v1.25.6/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= +lukechampine.com/frand v1.4.2 h1:RzFIpOvkMXuPMBb9maa4ND4wjBn71E1Jpf8BzJHMaVw= +lukechampine.com/frand v1.4.2/go.mod h1:4S/TM2ZgrKejMcKMbeLjISpJMO+/eZ1zu3vYX9dtj3s= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=