SendChat returns an ChatCompletionResponse
(request ChatCompletionRequest)
| 66 | |
| 67 | // SendChat returns an ChatCompletionResponse |
| 68 | func SendChat(request ChatCompletionRequest) (chatCompletionResponse ChatCompletionResponse, err error) { |
| 69 | var reqBytes []byte |
| 70 | reqBytes, err = json.Marshal(request) |
| 71 | if err != nil { |
| 72 | common.Logger.Error(err.Error()) |
| 73 | return |
| 74 | } |
| 75 | |
| 76 | body, err := Send(chatApi, reqBytes) |
| 77 | if err != nil { |
| 78 | common.Logger.Error(err.Error()) |
| 79 | return |
| 80 | } |
| 81 | |
| 82 | err = json.Unmarshal(body, &chatCompletionResponse) |
| 83 | return |
| 84 | } |