add testable json marshaller (#161)

This commit is contained in:
sashabaranov
2023-03-15 12:16:47 +04:00
committed by GitHub
parent ba77a6476e
commit 53d195cf5a
10 changed files with 102 additions and 18 deletions

View File

@@ -3,7 +3,6 @@ package openai
import (
"bytes"
"context"
"encoding/json"
"net/http"
)
@@ -53,7 +52,7 @@ type ModerationResponse struct {
// Input can be an array or slice but a string will reduce the complexity.
func (c *Client) Moderations(ctx context.Context, request ModerationRequest) (response ModerationResponse, err error) {
var reqBytes []byte
reqBytes, err = json.Marshal(request)
reqBytes, err = c.marshaller.marshal(request)
if err != nil {
return
}