-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.go
37 lines (32 loc) · 884 Bytes
/
config.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
package openrouter
import (
"net/http"
)
const (
routerAPIURLv1 = "https://openrouter.ai/api/v1"
defaultEmptyMessagesLimit uint = 300
)
// ClientConfig is a configuration of a client.
// XTitle、HttpRefer your own site url
type ClientConfig struct {
authToken string
XTitle string
HttpReferer string
BaseURL string
HTTPClient *http.Client
EmptyMessagesLimit uint
}
func DefaultConfig(auth, xTitle, httpReferer string) (ClientConfig, error) {
return ClientConfig{
authToken: auth,
HTTPClient: &http.Client{},
XTitle: xTitle,
HttpReferer: httpReferer,
BaseURL: routerAPIURLv1,
EmptyMessagesLimit: defaultEmptyMessagesLimit,
}, nil
}
func (c ClientConfig) WithHttpClientConfig(client *http.Client) ClientConfig {
c.HTTPClient = client
return c
}