-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoptions.go
More file actions
47 lines (40 loc) · 1.32 KB
/
options.go
File metadata and controls
47 lines (40 loc) · 1.32 KB
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
41
42
43
44
45
46
47
package llmberjack
import "net/http"
type llmOption func(*Llmberjack)
// WithDefaultProvider sets what LLM provider to use for communication.
func WithDefaultProvider(provider Llm) llmOption {
return func(llm *Llmberjack) {
llm.providers[defaultProvider] = provider
llm.defaultProvider = llm.providers[defaultProvider]
}
}
// WithProvider registers a provider.
//
// The first one to be registered will become the default, unless a default was
// already or is defined later with `SetDefaultProvider`.
func WithProvider(name string, provider Llm) llmOption {
return func(llm *Llmberjack) {
llm.providers[name] = provider
if llm.defaultProvider == nil {
llm.defaultProvider = llm.providers[name]
llm.providers[defaultProvider] = llm.providers[name]
}
}
}
// WithDefaultModel sets the model to use if not specified in a particular
// request. It is the caller's responsibility to ensure the requested model is
// available on the configured provider.
func WithDefaultModel(model string) llmOption {
return func(llm *Llmberjack) {
llm.defaultModel = model
}
}
// WithHttpClient sets a custom HTTP clients to be used.
//
// If a provider does not support overriding the HTTP client, this will be
// ignored.
func WithHttpClient(client *http.Client) llmOption {
return func(llm *Llmberjack) {
llm.httpClient = client
}
}