-
Notifications
You must be signed in to change notification settings - Fork 89
Expand file tree
/
Copy pathcompletion.go
More file actions
40 lines (33 loc) · 883 Bytes
/
completion.go
File metadata and controls
40 lines (33 loc) · 883 Bytes
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 cli
import (
"strings"
openai "github.com/sashabaranov/go-openai"
)
const maxRetries = 10
type oaiClients struct {
openAIClient openai.Client
}
func newOAIClients() oaiClients {
var config openai.ClientConfig
config = openai.DefaultConfig(*openAIAPIKey)
if openAIEndpoint != &openaiAPIURLv1 {
// Azure OpenAI
if strings.Contains(*openAIEndpoint, "openai.azure.com") {
config = openai.DefaultAzureConfig(*openAIAPIKey, *openAIEndpoint)
if len(*azureModelMap) != 0 {
config.AzureModelMapperFunc = func(model string) string {
return (*azureModelMap)[model]
}
}
} else {
// Local AI
config.BaseURL = *openAIEndpoint
}
// use at least 2023-07-01-preview api version for function calls
config.APIVersion = "2024-03-01-preview"
}
clients := oaiClients{
openAIClient: *openai.NewClientWithConfig(config),
}
return clients
}