-
Notifications
You must be signed in to change notification settings - Fork 11
/
bloomz_7b1.go
40 lines (32 loc) · 819 Bytes
/
bloomz_7b1.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package go_ernie
import (
"context"
"net/http"
)
const bloomz7b1URL = "/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/bloomz_7b1"
type Bloomz7b1Request struct {
Messages []ChatCompletionMessage `json:"messages"`
Stream bool `json:"stream"`
UserId string `json:"user_id"`
}
type Bloomz7b1Response struct {
ErnieBotResponse
}
func (c *Client) CreateBloomz7b1ChatCompletion(
ctx context.Context,
request Bloomz7b1Request,
) (response Bloomz7b1Response, err error) {
if request.Stream {
err = ErrChatCompletionStreamNotSupported
return
}
req, err := c.newRequest(ctx, http.MethodPost, c.fullURL(bloomz7b1URL), withBody(request))
if err != nil {
return
}
err = c.sendRequest(req, &response)
if response.ErrorCode != 0 {
err = &response.APIError
}
return
}