-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.go
64 lines (54 loc) · 1.5 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package gollama
import (
"os"
"time"
)
type Gollama struct {
ServerAddr string
ModelName string
SeedOrNegative int
TemperatureIfNegativeSeed float64
PullTimeout time.Duration
HTTPTimeout time.Duration
TrimSpace bool
Verbose bool
ContextLength int64
SystemPrompt string
}
const (
defaultModel = "llama3.2"
defaultHTTPTimeout = 10 * time.Minute // per HTTP request to Ollama
defaultFixedSeed = 256 // for when generated output should not be random, but have temperature 0 and a specific seed
defaultPullTimeout = 48 * time.Hour // pretty generous, in case someone has a poor connection
mimeJSON = "application/json"
)
func (c *Gollama) SetHTTPTimeout(timeout time.Duration) *Gollama {
c.HTTPTimeout = timeout
return c
}
func (c *Gollama) SetSeed(seed int) *Gollama {
c.SeedOrNegative = seed
return c
}
func (c *Gollama) SetRandomSeed() *Gollama {
c.SeedOrNegative = -1
return c
}
func (c *Gollama) SetTemperature(temperature float64) *Gollama {
c.TemperatureIfNegativeSeed = temperature
return c
}
func (c *Gollama) SetContextLength(contextLength int64) *Gollama {
c.ContextLength = contextLength
return c
}
func (c *Gollama) SetSystemPrompt(prompt string) *Gollama {
c.SystemPrompt = prompt
return c
}
func getEnv(key, defaultValue string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
return defaultValue
}