-
Notifications
You must be signed in to change notification settings - Fork 0
/
chat.go
20 lines (17 loc) · 805 Bytes
/
chat.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package goai
func (goai Client) ChatCompletion(messages []Message) (ChatCompletionResponse, error) {
res := ChatCompletionResponse{}
req := ChatCompletionRequest{
N: IntPtr(1), // Convert to pointer using helper function
Messages: messages,
User: goai.User,
TopP: Float64Ptr(goai.TopP), // Convert to pointer
Model: goai.ChatModel,
MaxTokens: IntPtr(goai.MaxTokens), // Convert to pointer
Temperature: Float64Ptr(goai.Temperature), // Convert to pointer
PresencePenalty: Float64Ptr(goai.PresencePenalty), // Convert to pointer
FrequencyPenalty: Float64Ptr(goai.FrequencyPenalty), // Convert to pointer
}
_, err := goai.PostJson(req, &res, goai.Endpoint+"chat/completions")
return res, err
}