diff --git a/openai/openai.go b/openai/openai.go index 8a45d7154..dc7adf8fa 100644 --- a/openai/openai.go +++ b/openai/openai.go @@ -584,7 +584,7 @@ func (w *BaseWriter) writeError(code int, data []byte) (int, error) { } w.ResponseWriter.Header().Set("Content-Type", "application/json") - err = json.NewEncoder(w.ResponseWriter).Encode(NewError(http.StatusInternalServerError, serr.Error())) + err = json.NewEncoder(w.ResponseWriter).Encode(NewError(code, serr.Error())) if err != nil { return 0, err } diff --git a/openai/openai_test.go b/openai/openai_test.go index 4aa4477be..702c16c57 100644 --- a/openai/openai_test.go +++ b/openai/openai_test.go @@ -20,7 +20,7 @@ import ( func capture(req any) gin.HandlerFunc { return func(c *gin.Context) { body, _ := io.ReadAll(c.Request.Body) - json.Unmarshal(body, req) + _ = json.Unmarshal(body, req) c.Next() } } @@ -200,7 +200,7 @@ func TestChatMiddleware(t *testing.T) { }) t.Run(tt.name, func(t *testing.T) { - r, _ := http.NewRequest("POST", "/api/chat", strings.NewReader(tt.body)) + r, _ := http.NewRequest(http.MethodPost, "/api/chat", strings.NewReader(tt.body)) r.Header.Set("Content-Type", "application/json") resp := httptest.NewRecorder() router.ServeHTTP(resp, r) @@ -408,7 +408,8 @@ func TestListMiddleware(t *testing.T) { Name: "test-model", ModifiedAt: time.Unix(int64(1686935002), 0).UTC(), }, - }}) + }, + }) }, body: `{ "object": "list",